/* ==========================================================================
   DOBBLE TABLET GAME STYLES
   Designed for tablets/iPads with true multi-touch and 60fps animations
   ========================================================================== */

:root {
    --bg-gradient: radial-gradient(circle at center, #1e2640 0%, #0f1423 100%);
    --felt-color: #172033;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 14px 35px rgba(0, 0, 0, 0.45), 0 4px 10px rgba(0, 0, 0, 0.25);
    --gold: #f59e0b;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html {
    background-color: #0f1423;
}

body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    overflow: hidden;
    background-color: #0f1423;
    background: var(--bg-gradient);
    font-family: var(--font-family);
    color: #ffffff;
    touch-action: none;
    position: fixed;
    inset: 0;
}

#app {
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
    overflow: hidden;
    background-color: #0f1423;
}

/* Standalone / iPad Home Screen app mode */
@media all and (display-mode: standalone) {
    #btn-fullscreen {
        display: none !important;
    }

    /* iPad Home Screen standalone: ensure generous clearance above iOS Home Indicator bar */
    .layout-2p .player-zone-0 {
        bottom: max(calc(1.5vh + env(safe-area-inset-bottom, 0px)), 42px) !important;
    }
}

/* ==========================================================================
   PLAYFIELD & BOARD LAYOUTS
   ========================================================================== */

.playfield {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(30, 41, 67, 0.8) 0%, rgba(15, 23, 42, 0.95) 75%),
                repeating-radial-gradient(circle at center, rgba(255, 255, 255, 0.015) 0, rgba(255, 255, 255, 0.015) 30px, transparent 30px, transparent 60px);
}

/* Center Card Deck / Target */
.center-deck-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(36.75vmin, 30vh, 326px);
    height: min(36.75vmin, 30vh, 326px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.center-card-slot {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Center card stack visual layers */
.center-card-slot::before {
    content: '';
    position: absolute;
    inset: -5px -5px -8px -5px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 3px solid #cbd5e1;
    z-index: -1;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.center-card-slot::after {
    content: '';
    position: absolute;
    inset: -10px -10px -15px -10px;
    border-radius: 50%;
    background: #cbd5e1;
    border: 3px solid #94a3b8;
    z-index: -2;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.center-badge {
    position: absolute;
    bottom: -22px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 10px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    pointer-events: none;
}

/* ==========================================================================
   PLAYER ZONES & CARD SLOTS
   ========================================================================== */

.player-zone {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 20;
    touch-action: manipulation;
}

.player-card-container {
    width: min(35.7vmin, 28.9vh, 310px);
    height: min(35.7vmin, 28.9vh, 310px);
    position: relative;
}

.player-hud {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 5px 14px;
    border-radius: 24px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.player-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.player-cards-pill {
    background: #3b82f6;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 28px;
    text-align: center;
}

.player-status-tag {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fbbf24;
}

/* In-Game Streak Badge in HUD */
.player-streak-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    display: none;
    animation: streakPulse 0.7s infinite alternate ease-in-out;
}

.player-streak-badge.active {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

@keyframes streakPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.12); filter: brightness(1.25); }
}

/* ==========================================================================
   LAYOUTS: 1/2 PLAYERS, 3 PLAYERS, 4 PLAYERS
   Corner-oriented positioning maximizes screen center room for large cards
   ========================================================================== */

/* 1 or 2 Players: Bottom Center (P1) + Top Center (P2 / AI) */
.layout-2p .player-zone-0 {
    bottom: max(calc(1.5vh + env(safe-area-inset-bottom, 0px)), 38px);
    left: 50%;
    transform: translateX(-50%);
    transform-origin: center center;
}

.layout-2p .player-zone-1 {
    top: max(calc(1.5vh + env(safe-area-inset-top, 0px)), 24px);
    left: 50%;
    transform: translateX(-50%) rotate(180deg);
    transform-origin: center center;
}

.layout-2p .center-deck-container {
    width: min(33vmin, 25.5vh, 300px);
    height: min(33vmin, 25.5vh, 300px);
}

.layout-2p .player-card-container {
    width: min(31vmin, 24vh, 280px);
    height: min(31vmin, 24vh, 280px);
}

.layout-2p .player-hud {
    margin-top: 5px;
    padding: 4px 14px;
}

/* 3 Players: 3 Corners: SW Corner (P1), NW Corner (P2), NE Corner (P3) */
.layout-3p .player-zone-0 {
    bottom: calc(2.5vh + env(safe-area-inset-bottom, 10px));
    left: calc(2.5vw + env(safe-area-inset-left, 10px));
    transform: rotate(45deg);
    transform-origin: center center;
}

.layout-3p .player-zone-1 {
    top: calc(2.5vh + env(safe-area-inset-top, 10px));
    left: calc(2.5vw + env(safe-area-inset-left, 10px));
    transform: rotate(135deg);
    transform-origin: center center;
}

.layout-3p .player-zone-2 {
    top: calc(2.5vh + env(safe-area-inset-top, 10px));
    right: calc(2.5vw + env(safe-area-inset-right, 10px));
    transform: rotate(-135deg);
    transform-origin: center center;
}

.layout-3p .center-deck-container {
    width: min(40.95vmin, 33.1vh, 373px);
    height: min(40.95vmin, 33.1vh, 373px);
}

.layout-3p .player-card-container {
    width: min(38.85vmin, 31vh, 352px);
    height: min(38.85vmin, 31vh, 352px);
}

/* 4 Players: All 4 corners facing outward diagonally */
.layout-4p .player-zone-0 {
    bottom: calc(2.5vh + env(safe-area-inset-bottom, 10px));
    left: calc(2.5vw + env(safe-area-inset-left, 10px));
    transform: rotate(45deg);
    transform-origin: center center;
}

.layout-4p .player-zone-1 {
    top: calc(2.5vh + env(safe-area-inset-top, 10px));
    left: calc(2.5vw + env(safe-area-inset-left, 10px));
    transform: rotate(135deg);
    transform-origin: center center;
}

.layout-4p .player-zone-2 {
    top: calc(2.5vh + env(safe-area-inset-top, 10px));
    right: calc(2.5vw + env(safe-area-inset-right, 10px));
    transform: rotate(-135deg);
    transform-origin: center center;
}

.layout-4p .player-zone-3 {
    bottom: calc(2.5vh + env(safe-area-inset-bottom, 10px));
    right: calc(2.5vw + env(safe-area-inset-right, 10px));
    transform: rotate(-45deg);
    transform-origin: center center;
}

.layout-4p .center-deck-container {
    width: min(38.85vmin, 31vh, 352px);
    height: min(38.85vmin, 31vh, 352px);
}

.layout-4p .player-card-container {
    width: min(36.75vmin, 29.4vh, 331px);
    height: min(36.75vmin, 29.4vh, 331px);
}

/* ==========================================================================
   CIRCULAR DOBBLE CARD & 3D FLIP STYLES
   ========================================================================== */

.dobble-card {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    touch-action: manipulation;
    perspective: 1000px;
    -webkit-perspective: 1000px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* 3D Flipper Container */
.card-inner-flip {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dobble-card.face-down .card-inner-flip {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

.card-face-front {
    background: var(--card-bg);
    border: 4px solid #ffffff;
    box-shadow: var(--card-shadow);
    transform: rotateY(0deg);
}

.card-face-back {
    background: #ffd100;
    border: 4px solid #ffffff;
    box-shadow: var(--card-shadow);
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* Flat Card Inner (for center card and flying card) */
.dobble-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    background: var(--card-bg);
    border: 4px solid #ffffff;
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.dobble-card-symbols {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
}

.dobble-card-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-weight: 700;
    font-size: 1.1rem;
    background: #f1f5f9;
}

/* Symbols inside cards */
.symbol-item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transform-origin: center center;
    transition: transform 0.12s ease;
    touch-action: manipulation;
}

.symbol-item.clickable {
    pointer-events: auto;
    cursor: pointer;
    touch-action: manipulation;
}

.symbol-item svg,
.symbol-item img,
.dobble-real-img {
    width: 100%;
    height: 100%;
    pointer-events: none;
    object-fit: contain;
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    image-rendering: -webkit-optimize-contrast;
}

/* Active tap feedback */
.symbol-item.active-tap {
    transform: translate(-50%, -50%) scale(1.3) !important;
    filter: brightness(1.25);
}

/* ==========================================================================
   TIMEOUT & NEAR-MISS OVERLAYS
   ========================================================================== */

.timeout-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    z-index: 50;
    animation: timeoutPulse 1s ease infinite alternate;
    backdrop-filter: blur(2px);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.8);
    pointer-events: all;
}

.timeout-lock-icon {
    font-size: 2rem;
    margin-bottom: 2px;
}

.timeout-seconds {
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1;
}

.timeout-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

@keyframes timeoutPulse {
    from { transform: scale(1); opacity: 0.92; }
    to { transform: scale(1.02); opacity: 1; }
}

.shake-animation {
    animation: shakeCard 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeCard {
    10%, 90% { transform: translate3d(-3px, 0, 0); }
    20%, 80% { transform: translate3d(5px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Near miss banner */
.near-miss-pill {
    position: absolute;
    top: -24px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
    animation: nearMissPop 0.85s ease forwards;
    pointer-events: none;
    white-space: nowrap;
    z-index: 60;
}

@keyframes nearMissPop {
    0% { transform: scale(0.6) translateY(10px); opacity: 0; }
    20% { transform: scale(1.1) translateY(-5px); opacity: 1; }
    70% { transform: scale(1) translateY(-5px); opacity: 1; }
    100% { transform: scale(0.9) translateY(-15px); opacity: 0; }
}

/* ==========================================================================
   FAST FLYING CARD ANIMATION (Hardware-accelerated)
   ========================================================================== */

.flying-card {
    position: fixed;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 25px rgba(59, 130, 246, 0.5);
    z-index: 1000;
    pointer-events: none;
    will-change: transform, opacity;
}

/* ==========================================================================
   HEADER CONTROLS & HUD
   ========================================================================== */

.game-header {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s, transform 0.1s;
}

.icon-btn:active {
    transform: scale(0.92);
    background: rgba(30, 41, 67, 0.95);
}

/* ==========================================================================
   MODALS: START MENU, SOUND SETTINGS, GAME OVER
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 19, 0.85);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    display: none; /* Crucial: completely removed from hit-testing when inactive */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    border-radius: 28px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transform: scale(0.94);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.active .modal-card {
    transform: scale(1);
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 900;
    text-align: center;
    background: linear-gradient(135deg, #60a5fa, #c084fc, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: #94a3b8;
    text-align: center;
    margin-top: -12px;
}

/* Setting Groups */
.setting-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #cbd5e1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-hint {
    font-size: 0.8rem;
    font-weight: 500;
    color: #60a5fa;
}

/* Player Names Grid in Settings */
.player-names-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.player-name-field {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 4px 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-name-field:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.pname-badge {
    font-size: 0.75rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 8px;
    margin-right: 8px;
    flex-shrink: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.pname-badge:hover {
    transform: scale(1.08);
    filter: brightness(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

.pname-badge::after {
    content: '🎨';
    font-size: 0.65rem;
    opacity: 0.8;
}

.pcolor-0 { background: #3b82f6; color: #fff; }
.pcolor-1 { background: #ef4444; color: #fff; }
.pcolor-2 { background: #10b981; color: #fff; }
.pcolor-3 { background: #8b5cf6; color: #fff; }

.player-name-input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    outline: none;
    padding: 6px 0;
}

.player-name-input::placeholder {
    color: #64748b;
    font-weight: 400;
}

/* Segmented Buttons */
.segment-group {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    padding: 4px;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.segment-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.segment-btn.active {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

#theme-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 3px;
}

#theme-group .segment-btn {
    font-size: 0.80rem;
    padding: 9px 2px;
    white-space: nowrap;
    text-align: center;
}

@media (max-width: 480px) {
    #theme-group {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
    }
}

/* Sliders */
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #334155;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #60a5fa;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 2px solid #ffffff;
}

/* Sound Toggles Grid */
.toggle-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.toggle-row-label {
    font-size: 0.9rem;
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 26px;
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .switch-slider {
    background-color: #10b981;
}

input:checked + .switch-slider:before {
    transform: translateX(22px);
}

/* Primary Action Buttons */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 800;
    padding: 14px 24px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 12px 20px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   WINNER CELEBRATION & CONFETTI
   ========================================================================== */

#confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1999;
    display: none;
}

#confetti-canvas.active {
    display: block;
}

.winner-crown {
    font-size: 3.5rem;
    text-align: center;
    animation: bounceCrown 1s ease infinite alternate;
}

@keyframes bounceCrown {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

/* Modal Card Wide Variant */
.modal-card.modal-card-wide {
    max-width: 620px;
}

/* Winner & Rankings Cards */
.winner-rankings-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 14px 0;
    max-height: 52vh;
    overflow-y: auto;
    padding-right: 4px;
}

.ranking-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s ease;
}

.ranking-card.rank-gold {
    border-color: rgba(245, 158, 11, 0.6);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(15, 23, 42, 0.88));
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.18);
}

.ranking-card.rank-silver {
    border-color: rgba(203, 213, 225, 0.55);
    background: linear-gradient(135deg, rgba(203, 213, 225, 0.12), rgba(15, 23, 42, 0.88));
}

.ranking-card.rank-bronze {
    border-color: rgba(217, 119, 6, 0.5);
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.12), rgba(15, 23, 42, 0.88));
}

.ranking-card.rank-medal {
    border-color: rgba(139, 92, 246, 0.5);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(15, 23, 42, 0.88));
}

.ranking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ranking-cup-badge {
    font-size: 0.82rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.ranking-cup-badge.cup-gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.ranking-cup-badge.cup-silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: #ffffff;
}

.ranking-cup-badge.cup-bronze {
    background: linear-gradient(135deg, #b45309, #78350f);
    color: #ffffff;
}

.ranking-cup-badge.cup-medal {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #ffffff;
}

.ranking-player-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    flex: 1;
    margin-left: 6px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-cards-left {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    flex-shrink: 0;
}

.ranking-cards-left.winner {
    background: rgba(16, 185, 129, 0.22);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.45);
}

.ranking-times-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.28);
    border-radius: 10px;
    padding: 8px 10px;
    margin-top: 4px;
}

@media (max-width: 460px) {
    .ranking-times-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.time-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.time-stat-lbl {
    font-size: 0.68rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.time-stat-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: #f8fafc;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

/* ==========================================================================
   3-SECOND COUNTDOWN OVERLAY
   ========================================================================== */

.countdown-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    pointer-events: none;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.4) 0%, transparent 70%);
}

.countdown-number {
    font-size: min(28vmin, 200px);
    font-weight: 900;
    color: #fed01b;
    text-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 35px rgba(254, 208, 27, 0.7);
    transform: scale(0.3);
    opacity: 0;
    user-select: none;
    letter-spacing: -0.02em;
}

.countdown-number.pop {
    animation: countdownPop 0.85s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.countdown-number.go {
    color: #10b981;
    text-shadow: 0 10px 40px rgba(0, 0, 0, 0.9), 0 0 45px rgba(16, 185, 129, 0.9);
}

@keyframes countdownPop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    30% {
        transform: scale(1.22);
        opacity: 1;
    }
    75% {
        transform: scale(1.0);
        opacity: 1;
    }
    100% {
        transform: scale(0.85);
        opacity: 0;
    }
}

/* ==========================================================================
   COLOR PICKER MODAL (12 Primary, Secondary & Tertiary Colors)
   ========================================================================== */
.color-picker-card {
    max-width: 380px !important;
    text-align: center;
    padding: 24px;
}

.color-palette-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 18px 0 14px;
}

.color-swatch-btn {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    outline: none;
}

.color-swatch-btn:hover {
    transform: scale(1.15);
    border-color: #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

.color-swatch-btn.active {
    transform: scale(1.15);
    border-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5), 0 8px 20px rgba(0, 0, 0, 0.6);
}

.color-swatch-btn .swatch-check {
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 900;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    display: none;
}

.color-swatch-btn.active .swatch-check {
    display: block;
}

.color-swatch-btn .swatch-name {
    position: absolute;
    bottom: -16px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #94a3b8;
    white-space: nowrap;
    pointer-events: none;
}

/* ==========================================================================
   PAUSE MODAL & 6x10 / 10x6 THEME SYMBOLS OVERVIEW GRID
   ========================================================================== */
.modal-card-pause {
    max-width: min(940px, 95vw) !important;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
}

.pause-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-continue-header {
    padding: 10px 20px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
    flex-shrink: 0;
}

.pause-symbols-container {
    flex: 1;
    overflow-y: auto;
    margin: 12px 0;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
}

.pause-symbols-grid {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
}

/* Landscape Mode: 10 columns x 6 rows */
@media (orientation: landscape) {
    .pause-symbols-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
    }
}

/* Portrait Mode: 6 columns x 10 rows */
@media (orientation: portrait) {
    .pause-symbols-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.pause-symbol-cell {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.pause-symbol-cell:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: #60a5fa;
    transform: scale(1.05);
    z-index: 2;
}

.pause-symbol-img-wrap {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.pause-symbol-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.pause-symbol-name {
    font-size: 0.64rem;
    font-weight: 600;
    color: #cbd5e1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
}

.pause-actions {
    display: flex;
    gap: 12px;
    margin-top: 4px;
}
