:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #FFFFFF;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.2);
    --text-main: #000000;
    --text-muted: #333333;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(168, 85, 247, 0.15) 0%, transparent 50%);
}

.container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
}

.main-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.upload-section {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-section:hover,
.upload-section.dragover {
    border-color: var(--primary);
    background: var(--glass-bg);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

input[type="number"] {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.preview-section {
    margin-top: 3rem;
    display: none;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.preview-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.sticker-item {
    background: var(--glass-bg);
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1/1;
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Checkerboard pattern for transparency preview */
    background-color: #e5e5f7;
    background-image: repeating-linear-gradient(45deg, #c5c5d0 25%, transparent 25%, transparent 75%, #c5c5d0 75%, #c5c5d0), repeating-linear-gradient(45deg, #c5c5d0 25%, #e5e5f7 25%, #e5e5f7 75%, #c5c5d0 75%, #c5c5d0);
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
    transition: background-color 0.3s, background-image 0.3s, border 0.3s, transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.sticker-item.preview-dark-bg {
    background-image: none !important;
    background-color: #1e293b !important;
    /* 暗いスレートブルー */
}

.sticker-item.selected-main {
    border: 3px solid var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    transform: scale(1.02);
    z-index: 10;
}

.sticker-item.selected-main::after {
    content: "MAIN";
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sticker-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.hidden {
    display: none;
}

#imageInput {
    display: none;
}

/* LINE Simulator Styles */
.line-simulator {
    width: 100%;
    max-width: 400px;
    background-color: #8EABC0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 750px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

.line-header {
    background-color: #8EABC0;
    color: #111;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.line-header-left,
.line-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-back,
.icon-info,
.icon-menu {
    font-weight: normal;
    font-size: 1.5rem;
    cursor: pointer;
}

.line-chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    width: 100%;
}

.chat-row.received {
    justify-content: flex-start;
}

.chat-row.sent {
    justify-content: flex-end;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #E2E8F0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 10px;
    color: white;
    flex-shrink: 0;
}

.avatar-icon {
    font-size: 1.2rem;
}

.sticker-message {
    position: relative;
    max-width: 60%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.sticker-message img {
    width: 100%;
    max-width: 150px;
    height: auto;
    object-fit: contain;
}

.chat-row.received .sticker-message {
    flex-direction: row;
}

.chat-row.sent .sticker-message {
    flex-direction: row-reverse;
}

.time-stamp {
    font-size: 0.7rem;
    color: #ffffff;
    white-space: nowrap;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
}

.line-footer {
    background-color: #F8F9FA;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #E2E8F0;
}

.input-box {
    flex: 1;
    background-color: white;
    border: 1px solid #E2E8F0;
    border-radius: 20px;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: #94A3B8;
}

.btn-group {
    display: flex;
    gap: 5px;
}

.footer-btn {
    background-color: #E2E8F0;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: bold;
}


.chat-row.received .sticker-message {
    align-items: flex-end;
}

.chat-row.sent .sticker-message {
    align-items: flex-end;
}

.chat-row.received .time-stamp {
    margin-bottom: 5px;
    margin-left: 5px;
}

.chat-row.sent .time-stamp {
    margin-bottom: 5px;
    margin-right: 5px;
}