:root {
    --zoom-compensation: 1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    background: radial-gradient(circle at 15% 10%, #4c1d95 0%, rgba(17, 12, 35, 0.9) 40%), #07030f;
    color: #f5f2ff;
    min-height: 100vh;
    position: relative;
    padding: 24px 16px 32px;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

body.modal-open {
    overflow: hidden;
}

body::before {
    content: "";
    position: absolute;
    inset: -30%;
    background: conic-gradient(from 120deg, rgba(103, 232, 249, 0.18), rgba(79, 70, 229, 0.12), rgba(14, 165, 233, 0.18));
    filter: blur(180px);
    opacity: 0.8;
    animation: auroraDrift 18s linear infinite;
    z-index: -2;
}

.app {
    width: min(680px, 100%);
    margin: 0 auto;
    padding: 24px 26px 28px;
    background: linear-gradient(160deg, rgba(20, 10, 35, 0.88), rgba(6, 5, 22, 0.92));
    border-radius: 22px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 0 0 auto;
}

.app::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(140deg, rgba(236, 72, 153, 0.08), rgba(59, 130, 246, 0.1));
    opacity: 0.9;
    pointer-events: none;
    z-index: -1;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1 0 auto;
}

body.viewport--compact {
    align-items: stretch;
    padding-top: 16px;
    padding-bottom: 40px;
}

body.viewport--compact .app {
    margin-left: auto;
    margin-right: auto;
    width: min(680px, 100%);
}

body.viewport--compact main {
    gap: 16px;
}

body.zoom-compensated {
    min-height: calc(100vh * var(--zoom-compensation));
}
.combo-banner {
    display: inline-flex;
    align-items: baseline;
    gap: 12px;
    margin: 0 auto 16px;
    padding: 10px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.85), rgba(236, 72, 153, 0.9));
    box-shadow: 0 12px 24px rgba(14, 116, 233, 0.35);
    transform: translateY(-18px) scale(0.85);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    position: relative;
    overflow: hidden;
}

.combo-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 120% 50%, rgba(255, 255, 255, 0.45), transparent 60%);
    mix-blend-mode: screen;
}

.combo-banner__badge {
    font-size: 14px;
    letter-spacing: 0.32em;
    font-weight: 700;
    text-transform: uppercase;
}

.combo-banner__count {
    font-size: clamp(22px, 6vw, 32px);
    font-weight: 800;
}

.combo-banner--show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.combo-banner--mega {
    animation: comboPulse 0.9s ease-in-out infinite;
}

.flash-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(253, 224, 71, 0.6), rgba(253, 224, 71, 0));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    z-index: 20;
}

.flash-overlay--active {
    opacity: 0.9;
}

.app__header {
    text-align: center;
    margin-bottom: 24px;
}

.app__title {
    margin: 0;
    font-size: clamp(28px, 6vw, 44px);
    letter-spacing: 0.08em;
}

.app__subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    opacity: 0.85;
}

.app__actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.app__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app__user-label {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.04em;
}

.app__audio {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.volume-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.25);
}

.volume-control__label {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #cbd5f5;
}

.volume-control__slider {
    width: 140px;
    accent-color: #6366f1;
}

.btn--ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn--ghost:hover {
    box-shadow: 0 0 18px rgba(148, 163, 184, 0.35);
}

.status-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
}

.status-bar__item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.status-bar__label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #b8a3f0;
}

.status-bar__value {
    font-size: 24px;
    font-weight: 700;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, minmax(96px, 1fr));
    grid-auto-rows: minmax(96px, 1fr);
    gap: 16px;
    padding: 20px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(60, 30, 100, 0.8), rgba(20, 10, 35, 0.95));
    border: 4px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    min-height: 320px;
}

.board__cell {
    border-radius: 14px;
    background: rgba(10, 5, 25, 0.9);
    border: 3px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.board__cell--fall {
    animation: cellFall 0.4s ease-out;
}

.board__cell--clear {
    animation: cellClear 0.35s ease forwards;
}

.board__cell--highlight {
    border-color: #facc15;
    box-shadow: 0 0 16px rgba(253, 224, 71, 0.85), inset 0 0 16px rgba(254, 243, 199, 0.35);
}

.board__cell--streak {
    border-color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.65), inset 0 0 16px rgba(191, 219, 254, 0.35);
}

.board__cell--blank {
    border-color: rgba(255, 255, 255, 0.05);
    background: rgba(15, 10, 40, 0.35);
}

.symbol-image {
    width: 100%;
    height: 100%;
    padding: 8px;
    object-fit: contain;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.45));
}

.board__cell--blank .symbol-image {
    opacity: 0.2;
    filter: none;
}

@keyframes cellFall {
    0% { transform: translateY(-120%); opacity: 0; }
    70% { opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes cellClear {
    0% { transform: scale(1); opacity: 1; }
    70% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0.4); opacity: 0; }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 0;
    flex-wrap: wrap;
}

.btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    color: #201030;
    background: linear-gradient(135deg, #fcd34d, #f97316);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.35);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
    box-shadow: none;
}

.btn--primary {
    background: linear-gradient(135deg, #f97316, #dc2626);
    color: #fff;
}

.btn--secondary {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: #f8fafc;
}

.message {
    text-align: center;
    min-height: 24px;
    font-size: 16px;
    margin: 0;
}

.paytable {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 18px;
}

.paytable__title {
    margin: 0 0 12px;
    font-size: 20px;
}

.paytable__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.paytable__table th,
.paytable__table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.paytable__symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    padding: 6px;
    min-width: 76px;
}

.paytable__symbol img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.paytable__note {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 12px;
}

.ranking {
    padding: 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.ranking__title {
    margin: 0 0 16px;
    font-size: 20px;
    letter-spacing: 0.08em;
}

.ranking__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.ranking__block {
    background: rgba(15, 23, 42, 0.35);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ranking__heading {
    margin: 0 0 10px;
    font-size: 16px;
    letter-spacing: 0.06em;
    color: #d8b4fe;
}

.ranking__list {
    margin: 0;
    padding: 0;
    list-style: decimal;
    list-style-position: inside;
    display: grid;
    gap: 6px;
}

.ranking__item {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 14px;
}

.ranking__name {
    font-weight: 600;
}

.ranking__value {
    font-variant-numeric: tabular-nums;
}

.ranking__empty {
    list-style: none;
    padding: 4px 0;
    opacity: 0.65;
    font-size: 13px;
}

.double-up {
    margin: 0;
    padding: 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.double-up__title {
    margin: 0 0 12px;
    font-size: 20px;
    letter-spacing: 0.08em;
}

.double-up__info {
    margin: 0 0 12px;
    font-weight: 600;
}

.double-up__choices {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.auth-panel,
.bgm-panel {
    background: linear-gradient(160deg, rgba(27, 22, 48, 0.95), rgba(9, 13, 35, 0.96));
    border-radius: 18px;
    padding: 24px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.auth-panel__title,
.bgm-panel__title {
    margin: 0 0 12px;
    font-size: 22px;
    letter-spacing: 0.08em;
}

.auth-panel__note {
    margin: 0 0 18px;
    font-size: 14px;
    opacity: 0.8;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
}

.auth-form__field input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(10, 18, 40, 0.8);
    color: #f8fafc;
}

.auth-form__field input:focus {
    outline: none;
    border-color: rgba(94, 234, 212, 0.7);
    box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.2);
}

.auth-form__submit {
    margin-top: 6px;
}

.auth-panel__switch {
    text-align: center;
    margin: 18px 0 0;
}

.auth-panel__message {
    min-height: 20px;
    margin: 12px 0 0;
    font-size: 13px;
    color: #fca5a5;
    text-align: center;
}

.auth-panel__message--success {
    color: #bbf7d0;
}

.bgm-panel__steps {
    margin: 0 0 16px 18px;
    padding: 0;
    display: grid;
    gap: 6px;
}

.bgm-panel__note {
    margin: 0;
    font-size: 13px;
    opacity: 0.75;
}

code {
    font-family: "Cascadia Code", "Fira Mono", monospace;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 4px;
    border-radius: 4px;
}

.highlow[hidden] {
    display: none;
}

.highlow__cards {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.card {
    width: clamp(96px, 15vw, 140px);
    height: clamp(132px, 22vw, 180px);
    border-radius: 16px;
    border: 3px solid rgba(248, 250, 252, 0.2);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(32px, 6vw, 48px);
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
    position: relative;
}

.card--hidden {
    filter: grayscale(0.7);
    opacity: 0.6;
}

.card__value {
    position: relative;
    z-index: 1;
    font-size: clamp(32px, 6vw, 48px);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.05em;
}

.highlow__controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.double-up--ready {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 12px 28px rgba(56, 189, 248, 0.2);
    transform: translateY(-4px);
}

.double-up--success {
    border-color: rgba(253, 224, 71, 0.7);
    box-shadow: 0 12px 30px rgba(253, 224, 71, 0.25);
    animation: panelGlow 1.1s ease-in-out 2;
}

.double-up--fail {
    border-color: rgba(248, 113, 113, 0.6);
    box-shadow: 0 12px 28px rgba(248, 113, 113, 0.18);
}

.card {
    position: relative;
    overflow: hidden;
}

.card::before,
.card::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: 12px;
    opacity: 0.18;
}

.card::before {
    background: radial-gradient(circle at top left, rgba(248, 250, 252, 0.8), transparent 60%);
}

.card::after {
    background: radial-gradient(circle at bottom right, rgba(56, 189, 248, 0.45), transparent 70%);
}

.card__suit {
    position: absolute;
    inset: 14px;
    pointer-events: none;
    font-size: 18px;
    opacity: 0.3;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card__suit span:last-child {
    transform: rotate(180deg);
    align-self: flex-end;
}

.card--success {
    box-shadow: 0 0 18px rgba(253, 224, 71, 0.65), 0 0 36px rgba(251, 191, 36, 0.4);
}

.card--fail {
    box-shadow: 0 0 18px rgba(248, 113, 113, 0.6), 0 0 36px rgba(239, 68, 68, 0.35);
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: rgba(5, 8, 20, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 40;
}

.modal--show {
    opacity: 1;
    pointer-events: auto;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 26, 0.65);
}

.modal__overlay--locked {
    pointer-events: auto;
}

.modal__content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: min(440px, 92vw);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal__close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    color: #f8fafc;
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

.modal__close:hover {
    color: #fcd34d;
}

@media (max-width: 640px) {
    body {
        padding: 16px 12px 24px;
    }

    .app {
        padding: 20px;
        border-radius: 18px;
        gap: 20px;
    }

    main {
        gap: 16px;
    }

    .app__actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .app__audio {
        width: 100%;
        justify-content: flex-start;
    }

    .status-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .ranking__grid {
        grid-template-columns: 1fr;
    }

    .board {
        grid-template-columns: repeat(3, minmax(78px, 1fr));
        grid-auto-rows: minmax(78px, 1fr);
        gap: 12px;
        padding: 16px;
        min-height: 260px;
    }

    .controls {
        gap: 10px;
    }

    .controls .btn {
        flex: 1 1 calc(50% - 10px);
        padding: 12px 16px;
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls .btn {
        width: 100%;
        min-width: 0;
    }

    .highlow__cards {
        flex-direction: column;
        align-items: center;
    }

    .card {
        width: clamp(96px, 50vw, 140px);
        height: clamp(132px, 65vw, 180px);
    }

    .app__audio {
        flex-direction: column;
        align-items: stretch;
    }

    .app__audio .btn {
        width: 100%;
    }

    main {
        gap: 14px;
    }
}

@keyframes auroraDrift {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}

@keyframes comboPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes panelGlow {
    0%, 100% { box-shadow: 0 12px 30px rgba(253, 224, 71, 0.25); }
    50% { box-shadow: 0 0 50px rgba(253, 224, 71, 0.55); }
}
