* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: #0a0a0f;
    color: #e0e0e0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}

.arena-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* ─── Header ─── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #111118;
    border-bottom: 1px solid #222;
}

.header h1 {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Buttons ─── */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #1a1a24;
    color: #ccc;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover, .btn:active { background: #252530; border-color: #555; color: #fff; }

.btn-primary {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

.btn-primary:hover, .btn-primary:active { background: #5558e6; }

.btn-icon {
    padding: 8px;
    min-height: 40px;
    min-width: 40px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #1a1a24;
    color: #888;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.btn-icon:hover { color: #fff; border-color: #555; }

.btn-play {
    font-size: 18px;
    padding: 16px 48px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.btn-close:hover { color: #fff; }

/* ─── Game info bar ─── */
.game-info {
    padding: 8px 16px;
    background: #0f0f16;
    border-bottom: 1px solid #1a1a24;
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-info .game-name {
    font-size: 15px;
    font-weight: 600;
    color: #f0f0f0;
}

.game-info .game-desc {
    font-size: 12px;
    color: #888;
}

.game-info .game-level {
    margin-left: auto;
    font-size: 11px;
    color: #6366f1;
    background: #6366f120;
    padding: 3px 8px;
    border-radius: 4px;
}

/* ─── Game frame ─── */
.game-frame-wrapper {
    flex: 1;
    position: relative;
    background: #000;
}

.game-frame-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ─── Overlays ─── */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.94);
    z-index: 10;
    transition: opacity 0.3s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.overlay .score-text {
    font-size: 20px;
    color: #a855f7;
    margin-bottom: 4px;
    font-weight: 600;
}

.overlay .best-score-text {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
    font-weight: 600;
}

.overlay .actions {
    display: flex;
    gap: 12px;
}

.overlay .actions .btn { font-size: 15px; padding: 12px 24px; }

/* Game over emoji */
.game-over-emoji {
    font-size: 48px;
    margin-bottom: 8px;
    animation: bounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ─── Splash ─── */
.splash h2 {
    font-size: 40px;
    font-weight: 800;
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.splash .tagline {
    color: #ccc;
    margin-bottom: 32px;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.splash .splash-sub {
    margin-top: 16px;
    color: #555;
    font-size: 13px;
}

/* ─── Confetti canvas ─── */
#confettiCanvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

/* ─── Stats panel ─── */
.stats-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    background: #111118;
    border-left: 1px solid #222;
    padding: 16px;
    overflow-y: auto;
    z-index: 20;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    -webkit-overflow-scrolling: touch;
}

.stats-panel.open { transform: translateX(0); }

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stats-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

/* Summary cards */
.summary-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.summary-item {
    flex: 1;
    background: #1a1a28;
    border: 1px solid #252530;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.summary-value {
    font-size: 24px;
    font-weight: 800;
    color: #a855f7;
}

.summary-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Stat cards */
.stat-card {
    background: #1a1a24;
    border: 1px solid #252530;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.stat-card-name {
    font-size: 14px;
    font-weight: 700;
    color: #e0e0e0;
}

.stat-card-best {
    font-size: 12px;
    color: #a855f7;
    font-weight: 600;
}

.stat-card-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.stat-bar {
    height: 4px;
    background: #252530;
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    border-radius: 2px;
    transition: width 0.3s;
}

/* ─── Loading ─── */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #333;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Mobile ─── */
@media (max-width: 600px) {
    .header {
        padding: 10px 12px;
    }

    .header h1 {
        font-size: 16px;
    }

    .game-info {
        padding: 6px 12px;
    }

    .game-info .game-name {
        font-size: 14px;
    }

    .game-info .game-desc {
        font-size: 11px;
    }

    .overlay h2 {
        font-size: 22px;
    }

    .overlay .score-text {
        font-size: 18px;
    }

    .overlay .actions {
        flex-direction: column;
        gap: 10px;
        width: 80%;
        max-width: 280px;
    }

    .overlay .actions .btn {
        width: 100%;
        font-size: 16px;
        padding: 14px 24px;
    }

    .splash h2 {
        font-size: 32px;
    }

    .splash .tagline {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .btn-play {
        font-size: 16px;
        padding: 14px 40px;
    }

    /* Stats panel becomes bottom sheet on mobile */
    .stats-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 70vh;
        border-left: none;
        border-top: 1px solid #333;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }

    .stats-panel.open {
        transform: translateY(0);
    }
}
