:root {
    --bg: #0b1020;
    --panel: #111831;
    --panel-2: #192244;
    --text: #e8eeff;
    --muted: #9ea9d3;
    --brand: #6fa3ff;
    --danger: #f37f7f;
    --ok: #71d49b;
    --occupied: #5f698f;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    background: radial-gradient(circle at top, #172246 0%, var(--bg) 60%);
    color: var(--text);
}

.app-header {
    margin-bottom: 20px;
}

.app-header h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.app-header p {
    margin: 0;
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.panel {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid #2a376d;
    border-radius: var(--radius);
    padding: 16px;
}

h2 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
}

.field-group,
.ticket-count {
    margin-top: 14px;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--muted);
}

.help-text {
    color: var(--muted);
    font-size: 12px;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #2f3e7a;
    background: #0d1430;
    color: var(--text);
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.stepper {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    background: #0d1430;
    border: 1px solid #2f3e7a;
    border-radius: 10px;
}

.stepper button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #253772;
    color: var(--text);
    cursor: pointer;
}

.stepper output {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
}

.screen {
    margin: 4px auto 16px;
    width: 85%;
    text-align: center;
    font-size: 12px;
    color: #bed1ff;
    padding: 8px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #39529b, #5f80e3);
}

.seat-map {
    display: grid;
    grid-template-columns: repeat(8, minmax(24px, 1fr));
    gap: 8px;
}

.seat {
    height: 28px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: #1b2a59;
    color: #d4ddff;
    cursor: pointer;
}

.seat.available:hover {
    border-color: var(--brand);
}

.seat.selected {
    background: var(--ok);
    color: #072611;
}

.seat.occupied {
    background: var(--occupied);
    color: #c4cbeb;
    cursor: not-allowed;
}

.legend {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    color: var(--muted);
    font-size: 13px;
}

.seat-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: -1px;
}

.seat-dot.available {
    background: #1b2a59;
}

.seat-dot.selected {
    background: var(--ok);
}

.seat-dot.occupied {
    background: var(--occupied);
}

.checkout {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px dashed #415297;
}

.checkout p {
    margin: 8px 0;
}

#buyBtn {
    margin-top: 6px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #4b7cf8, #6aa8ff);
    color: #04102b;
    font-weight: 700;
    cursor: pointer;
}

#buyBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.order-panel {
    margin-top: 4px;
}

.order-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.order-item {
    border: 1px solid #324382;
    border-radius: 10px;
    padding: 12px;
    background: #10183a;
}

.order-item p {
    margin: 4px 0;
    font-size: 14px;
}

.empty-text {
    color: var(--muted);
    margin: 12px 0 0;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #0d1534;
    border: 1px solid #2f3e7a;
    color: var(--text);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: var(--danger);
}

/* ── Tablet (≤900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* ── Mobile (≤600px) ─────────────────────────────────────── */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .app-header {
        margin-bottom: 14px;
    }

    .app-header h1 {
        font-size: 22px;
    }

    .app-header p {
        font-size: 13px;
    }

    h2 {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .panel {
        padding: 14px 12px;
        border-radius: 10px;
    }

    .layout {
        gap: 12px;
        margin-bottom: 12px;
    }

    /* Touch-friendly inputs & selects */
    input,
    select {
        padding: 11px 12px;
        font-size: 16px; /* prevents iOS auto-zoom */
        border-radius: 8px;
    }

    /* Stepper: larger touch targets */
    .stepper button {
        width: 40px;
        height: 40px;
        border-radius: 8px;
        font-size: 18px;
    }

    .stepper output {
        min-width: 32px;
        font-size: 16px;
    }

    /* Seat map: tighter grid for small screens */
    .seat-map {
        grid-template-columns: repeat(8, minmax(0, 1fr));
        gap: 5px;
    }

    .seat {
        height: 32px;
        font-size: 11px;
        border-radius: 5px;
    }

    .screen {
        font-size: 11px;
        padding: 6px 10px;
        margin-bottom: 12px;
    }

    .legend {
        margin-top: 10px;
        gap: 8px 12px;
        font-size: 12px;
    }

    /* Buy button: full-width comfortable tap area */
    #buyBtn {
        padding: 14px;
        font-size: 16px;
        border-radius: 10px;
    }

    .checkout {
        margin-top: 12px;
        padding-top: 10px;
    }

    .checkout p {
        font-size: 14px;
    }

    .order-panel {
        margin-top: 8px;
    }

    .order-item p {
        font-size: 13px;
    }

    /* Toast: center-bottom on mobile */
    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        text-align: center;
        font-size: 14px;
    }
}

/* ── Small mobile (≤380px) ───────────────────────────────── */
@media (max-width: 380px) {
    body {
        padding: 8px;
    }

    .app-header h1 {
        font-size: 20px;
    }

    .seat-map {
        grid-template-columns: repeat(8, minmax(0, 1fr));
        gap: 4px;
    }

    .seat {
        height: 28px;
    }
}