/* ============================================
   FOUC PREVENTION (Flash of Unstyled Content)
   ============================================ */

/* Prevent white flash on page load */
html {
    background-color: #0a0a0a;
}

body {
    opacity: 0;
    transition: opacity 0.4s ease-in;
    background-color: #0a0a0a;
}

body.loaded {
    opacity: 1;
}

/* Ensure lanes start dark before rendering */
.train-lane {
    background-color: #14142e;
    visibility: hidden;
}

body.loaded .train-lane {
    visibility: visible;
}

/* ============================================
   BASE STYLES & RESET
   ============================================ */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 100%);
    color: #00ff9d;
    overflow-x: hidden; 
    min-height: 100vh;
}

/* Grid background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 255, 157, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 157, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   DEALING ANIMATION OVERRIDES
   ============================================ */

html.dealing,
body.dealing {
    overflow: hidden !important;
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

html.dealing::-webkit-scrollbar,
body.dealing::-webkit-scrollbar,
.dealing *::-webkit-scrollbar {
    display: none !important;
}

.domino.deal-animation {
    position: absolute !important;
    z-index: 9999 !important;
    animation: dealCard 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    will-change: transform, opacity;
}

@keyframes dealCard {
    0% {
        transform: translateY(-50vh) translateX(-30px) rotate(180deg) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translateY(10px) translateX(0) rotate(-5deg) scale(1.1);
        opacity: 1;
    }
    80% {
        transform: translateY(-5px) rotate(3deg) scale(0.95);
    }
    100% {
        transform: translateY(0) rotate(0) scale(1);
        opacity: 1;
        position: relative !important;
    }
}

.dealing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 20%, rgba(0, 255, 157, 0.1), transparent 50%);
    pointer-events: none;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.dealing-overlay.active {
    opacity: 1;
    display: block;
    background: radial-gradient(circle, rgba(0, 255, 157, 0.15) 0%, transparent 70%);
}

.player-hand.dealing {
    overflow: hidden !important;
    position: relative !important;
    min-height: 150px;
}

.player-area.dealing {
    min-height: 300px;
}

.player-hand.dealing {
    min-height: 140px !important;
    max-height: 140px !important;
}

.player-area .player-hand.dealing {
    overflow: hidden !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    max-height: none !important;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ============================================
   HEADER
   ============================================ */

.game-header {
    padding: 0 20px 0 0;
    background: rgba(26, 26, 46, 0.9);
    border-bottom: 2px solid #00ff9d;
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap; /* Prevent wrapping */
    gap: 15px;
    position: relative;
    z-index: 10;
    height: 80px;
}

.game-title {
    font-size: 1.8em;
    font-weight: bold;
    text-shadow: 0 0 10px #00ff9d, 0 0 20px #00ff9d;
    letter-spacing: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0;
    margin: 0;
}

/* On desktop the row1 wrapper is invisible to layout —
   logo + buttons behave as direct children of .game-header */
.game-header-row1 {
    display: contents;
}

.header-logo {
    height: 60px;      /* cap logo on desktop so it doesn't fill full 80px header */
    max-height: 60px;
    width: auto;
    object-fit: contain;
    display: block;
}

.header-buttons {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 5;
    max-width: 400px;
}

.game-info {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    flex-shrink: 0;
    margin-left: auto;   /* push right */
    padding-right: 20px; /* match the header's right padding so stats don't get clipped */
    z-index: 6;
}

.info-item {
    font-size: 0.95em;
    color: #00ffff;
    text-shadow: none;
    transition: all 0.3s ease;
    display: inline-block;
    white-space: nowrap; /* Prevent text wrapping */
}

.info-label {
    color: #888;
    margin-right: 5px;
}

/* ============================================
   TRAINS AREA
   ============================================ */

.trains-area {
    flex: 6;
    padding: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.train-lane {
    flex: 1;
    background: rgba(20, 20, 35, 0.6);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 8px;
    padding: 5px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.train-lane.playable {
    border-color: #00ff9d;
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.4);
    background: rgba(0, 255, 157, 0.05);
}

.train-lane.mexican-train {
    border-color: #ff00ff;
}

.train-lane.mexican-train.playable {
    border-color: #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
    background: rgba(255, 0, 255, 0.05);
}

.train-lane.drop-target {
    background: rgba(0, 255, 157, 0.15);
    border-color: #00ff9d;
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.6);
}

.train-info {
    min-width: 170px;
    max-width: 170px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-left: 8px;
}

.train-name {
    font-size: 0.95em;
    font-weight: bold;
    color: #00ffff;
    text-shadow: none;
    white-space: nowrap;
    margin-left: 0;
}

.mexican-train .train-name {
    color: #ff00ff;
    text-shadow: none;
    margin-left: 0;
}

.train-status {
    font-size: 0.8em;
    color: #888;
    margin-top: 0; 
    margin-left: 40px; 
}

.train-public {
    color: #ff00ff;
    text-shadow: 0 0 5px #ff00ff;
}

/* Desktop: restore content via CSS since HTML text node is empty */
.mexican-train-status::before {
    content: '🔐 Always Playable';
}

.train-tile-count {
    font-size: 0.8em;
    color: #888;
}

.train-info-row2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
}

.train-tile-count {
    font-size: 1em;
    color: #888;
}

.train-status-inline {
    color: #888;
    white-space: nowrap;
}

.train-status-inline.public {
    color: #ff00ff;
    text-shadow: 0 0 5px #ff00ff;
}

/* ============================================
   ENGINE & TILES
   ============================================ */

.engine-start {
    min-width: 40px;
    max-width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, #ff00ff 0%, #8b00ff 100%);
    box-shadow: 0 0 15px #ff00ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.engine-start.hidden {
    opacity: 0;
    width: 0;
    min-width: 0;
    max-width: 0;
    margin: 0;
    overflow: hidden;
}

.train-tiles {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    padding-right: 80px; /* Physical space for next tile (70px + 8px gap) */
    min-height: 70px;
    scroll-behavior: smooth; /* Smooth scrolling animation */
    scroll-snap-type: x proximity; /* Better scroll UX */
}

.train-tiles::-webkit-scrollbar {
    height: 6px;
}

.train-tiles::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.train-tiles::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 157, 0.5);
    border-radius: 3px;
}

.train-tiles::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 157, 0.7);
}

.train-tiles.auto-scrolling {
    scroll-behavior: smooth;
}

/* ============================================
   DOMINO TILES
   ============================================ */

.domino {
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 6px;
    display: flex;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8);
    overflow: visible;
}

.domino:hover {
    transform: translateY(-3px);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.domino.selected {
    border: 3px solid #ffd700 !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8) !important;
    transform: scale(1.05) translateY(-5px) !important;
    z-index: 10;
    cursor: pointer;
}

.domino.selected:hover {
    transform: scale(1.08) translateY(-8px) !important;
    box-shadow: 0 0 25px rgba(255, 215, 0, 1) !important;
}

.domino.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.domino.help-highlight {
    animation: helpPulse 1s ease-in-out 5;
    border-color: #00ff9d;
}

@keyframes helpPulse {
    0%, 100% {
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 255, 157, 0.8);
        border-color: #00ff9d;
    }
    50% {
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 255, 157, 1);
        border-color: #00ff9d;
    }
}

.domino.double-glow {
    animation: doubleGlow 1s ease-in-out infinite;
}

@keyframes doubleGlow {
    0%, 100% {
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 15px rgba(255, 255, 0, 0.8);
        border-color: #ffff00;
    }
    50% {
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 255, 0, 1);
        border-color: #ffff00;
    }
}

.domino.horizontal {
    flex-direction: row;
    width: 70px;
    height: 50px;
    min-width: 70px;
}

.domino.vertical {
    flex-direction: column;
    width: 50px;
    height: 100px;
    min-width: 50px;
}

.domino-half {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    font-weight: bold;
}

.domino.horizontal .domino-half {
    font-size: 1.3em;
}

/* Neon colors */
.domino-half[data-value="0"] { color: #00ffff; text-shadow: 0 0 8px #00ffff; }
.domino-half[data-value="1"] { color: #00ff9d; text-shadow: 0 0 8px #00ff9d; }
.domino-half[data-value="2"] { color: #ff00ff; text-shadow: 0 0 8px #ff00ff; }
.domino-half[data-value="3"] { color: #ffff00; text-shadow: 0 0 8px #ffff00; }
.domino-half[data-value="4"] { color: #ff6600; text-shadow: 0 0 8px #ff6600; }
.domino-half[data-value="5"] { color: #00ccff; text-shadow: 0 0 8px #00ccff; }
.domino-half[data-value="6"] { color: #ff0066; text-shadow: 0 0 8px #ff0066; }
.domino-half[data-value="7"] { color: #66ff00; text-shadow: 0 0 8px #66ff00; }
.domino-half[data-value="8"] { color: #9900ff; text-shadow: 0 0 8px #9900ff; }
.domino-half[data-value="9"] { color: #ff3300; text-shadow: 0 0 8px #ff3300; }
.domino-half[data-value="10"] { color: #00ff66; text-shadow: 0 0 8px #00ff66; }
.domino-half[data-value="11"] { color: #ff9900; text-shadow: 0 0 8px #ff9900; }
.domino-half[data-value="12"] { color: #cc00ff; text-shadow: 0 0 8px #cc00ff; }

.domino-divider {
    background: linear-gradient(to bottom, transparent, #00ff9d, transparent);
    box-shadow: 0 0 3px #00ff9d;
}

.domino.horizontal .domino-divider {
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, #00ff9d, transparent);
}

.domino.vertical .domino-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, #00ff9d, transparent);
}

/* ============================================
   TILE ANIMATIONS
   ============================================ */

.domino.tile-slide-in {
    animation: dominoLand 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes dominoLand {
    0% {
        transform: translateX(50px) scale(0.8) rotateY(-15deg);
        opacity: 0;
        filter: brightness(1.8);
    }
    60% {
        transform: translateX(0) scale(1.15) rotateY(5deg);
    }
    80% {
        transform: scale(0.95) rotateY(-2deg);
    }
    100% {
        transform: scale(1) rotateY(0);
        opacity: 1;
        filter: brightness(1);
    }
}

.domino-place-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, #00ff9d, transparent);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--px), var(--py)) scale(0);
        opacity: 0;
    }
}

.flying-deal {
    animation: flyFromCenter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.flying-from-boneyard {
    animation: flyFromBoneyard 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes flyFromCenter {
    0% {
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes flyFromBoneyard {
    0% {
        transform: translate(var(--startX), var(--startY)) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes flipReveal {
    0% {
        transform: rotateY(0deg) scale(0.8);
        background: #1a1a2e;
    }
    50% {
        transform: rotateY(90deg) scale(1);
        background: #1a1a2e;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        background: #0a0a0a;
    }
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   PLAYER AREA
   ============================================ */

.player-area {
    flex: 4;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(0, 255, 157, 0.3);
    border-top: 3px solid #00ffff;              /* always 3px — prevents layout bump when your-turn adds 1px */
    box-shadow: 0 -5px 20px rgba(0, 255, 255, 0.3);
    border-radius: 15px;
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: border-top-color 0.3s ease, box-shadow 0.3s ease;  /* only color+shadow, never geometry */
    gap: 5px;
}

.player-area.your-turn {
    border-top: 3px solid #00ff9d;              /* same width, different color — no layout shift */
    box-shadow: 0 -5px 40px rgba(0, 255, 157, 0.5);
}

.player-header {
    width: 100%;
    margin-bottom: 0;
    padding-bottom: 10px;
    border-bottom: 0px solid rgba(0, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    padding-left: 0px;
}

.status-message-container {
    position: absolute;
    left: 20px;
    text-align: left;
    width: 300px;
}

.status-message-inline {
    font-size: 0.9em;
    color: #00ff9d;
    text-shadow: 0 0 5px #00ff9d;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.status-message-inline.visible {
    opacity: 1;
}

.hand-title-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.player-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff;
    white-space: nowrap;
}

.btn-help {
    padding: 5px 12px;
    background: rgba(255, 255, 0, 0.1);
    border: 1px solid rgba(255, 255, 0, 0.5);
    border-radius: 5px;
    color: #ffff00;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85em;
    flex-shrink: 0;
}

.btn-help:hover {
    background: rgba(255, 255, 0, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
}

/* ====================================
   PLAYER DASHBOARD - Grey Wrapper Container
   ==================================== */
.player-dashboard {
    background: rgba(39, 39, 57, 0.6);
    border: 1px solid rgba(0, 255, 157, 0.3);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 140px;
    position: relative;
    overflow: visible;
}

/* ====================================
   POWER-UP GRID - Fixed 2x2 on Left
   ==================================== */
.powerup-grid {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 10px;
    margin-right: 15px;
    padding-right: 15px;
    border-right: 2px solid rgba(0, 255, 157, 0.2);
    flex-shrink: 0;
}

/* Power-up Button Styling */
.powerup-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, rgba(0, 255, 157, 0.1), rgba(255, 0, 255, 0.1));
    border: 2px solid rgba(0, 255, 157, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: relative;
}

.powerup-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(0, 255, 157, 0.2), rgba(255, 0, 255, 0.2));
    border-color: var(--neon-cyan);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 157, 0.5);
}

.powerup-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
}

.powerup-btn .powerup-icon {
    font-size: 2.2em;
    line-height: 1;
}

.powerup-btn.targeting {
    animation: powerup-pulse 0.8s ease-in-out infinite;
    border-color: var(--neon-pink);
}

.powerup-btn.targeting[data-targeting-type="sabotage"] {
    border-color: #ff0066;
    box-shadow: 0 0 20px rgba(255, 0, 102, 0.8);
}

.powerup-btn.targeting[data-targeting-type="freeze"] {
    border-color: #00d4ff;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
}

@keyframes powerup-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px currentColor;
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 25px currentColor;
    }
}

/* ====================================
   PLAYER HAND - Transparent, JS-Managed
   ==================================== */
.player-hand {
    background: transparent; /* No background - parent has it */
    border: none; /* No border - parent has it */
    padding: 30px 22px; /* Add vertical padding for selection effects */
    min-height: 120px;
    flex: 1;
    overflow-x: auto;
    overflow-y: visible;
    display: flex;
    gap: 10px;
    align-items: center;
    
    /* Hide scrollbar for all browsers */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.player-hand::-webkit-scrollbar {
    display: none;
}


/* During animations, prevent container collapse */
.player-hand.dealing {
    min-width: 100%;
}

/* Hide old powerups panel if it exists */
.powerups-panel {
    display: none;
}



.player-hand .domino.vertical {
    width: 50px;
    height: 100px;
    min-width: 50px;
    flex-shrink: 1;
}

.player-hand .domino {
    cursor: grab;
}

.player-hand .domino:active {
    cursor: grabbing;
}

@media (max-height: 800px) {
    .player-hand .domino.vertical {
        width: 45px;
        height: 90px;
        min-width: 45px;
    }
    
    .player-hand {
        gap: 10px;
    }
}

.player-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 0;
    margin-left: 0px;
}

.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    min-height: 50px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #00ff9d 0%, #00cc7a 100%);
    border: none;
    border-radius: 5px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 255, 157, 0.5);
    font-size: 0.9em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(0, 255, 157, 0.8);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-start-game {
    animation: startGamePulse 2s ease-in-out infinite;
}

@keyframes startGamePulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(0, 255, 157, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 25px rgba(0, 255, 157, 1), 0 0 40px rgba(0, 255, 157, 0.6);
        transform: scale(1.02);
    }
}

.btn-start-game:hover:not(:disabled) {
    animation: none;
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 157, 1);
}

.btn-light-blue {
    background: linear-gradient(135deg, #00ccff 0%, #0099cc 100%);
    box-shadow: 0 0 10px rgba(0, 204, 255, 0.5);
}

.btn-light-blue:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(0, 204, 255, 0.8);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff00ff 0%, #cc00cc 100%);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.8);
}

.btn-draw-highlight {
    animation: drawGlow 1s ease-in-out 5;
}

.btn-pass-highlight {
    animation: passGlow 1s ease-in-out 5;
}

@keyframes drawGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 255, 0, 1);
    }
}

@keyframes passGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 0, 0.5);
        border: 2px solid rgba(255, 255, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 255, 0, 1);
        border: 2px solid rgba(255, 255, 0, 1);
    }
}

/* ============================================
   POWER-UPS PANEL
   ============================================ */

.powerups-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 15px;
    box-shadow: none;
    z-index: 100;
    min-width: 180px;
}

.powerups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.powerup-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(0, 255, 157, 0.1);
    border: 2px solid #00ff9d;
    border-radius: 10px;
    padding: 10px 8px;
    margin-bottom: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.powerup-btn:hover:not(:disabled) {
    background: rgba(0, 255, 157, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 157, 0.6);
    transform: scale(1.05);
}

.powerup-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #666;
}

.powerup-btn.used {
    background: rgba(100, 100, 100, 0.1);
    border-color: #555;
}

.powerup-btn.used .powerup-icon {
    filter: grayscale(100%);
    opacity: 0.5;
}

.powerup-btn.used .powerup-name {
    color: #666;
}

.powerup-btn.targeting {
    animation: targetingButtonPulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 20px currentColor !important;
}

@keyframes targetingButtonPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px currentColor;
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 35px currentColor;
    }
}

.powerup-icon {
    font-size: 2.7em;
    margin-bottom: 0;
}

.powerup-name {
    font-size: 1em;
    color: #00ffff;
    font-weight: bold;
    text-transform: none;
}

/* Sabotage button targeting - RED pulse */
.powerup-btn.targeting[data-targeting-type="sabotage"] {
    animation: sabotagePulse 0.8s ease-in-out infinite !important;
    background: rgba(255, 0, 0, 0.2) !important;
    border-color: #ff0000 !important;
}

@keyframes sabotagePulse {
    0%, 100% {
        background: rgba(255, 0, 0, 0.2);
        border-color: #ff0000;
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
        transform: scale(1);
    }
    50% {
        background: rgba(255, 0, 0, 0.4);
        border-color: #ff3333;
        box-shadow: 0 0 35px rgba(255, 0, 0, 1), 0 0 50px rgba(255, 0, 0, 0.6);
        transform: scale(1.1);
    }
}

/* Freeze button targeting - TEAL pulse */
.powerup-btn.targeting[data-targeting-type="freeze"] {
    animation: freezeButtonPulse 0.8s ease-in-out infinite !important;
    background: rgba(0, 255, 255, 0.2) !important;
    border-color: #00ffff !important;
}

@keyframes freezeButtonPulse {
    0%, 100% {
        background: rgba(0, 255, 255, 0.2);
        border-color: #00ffff;
        box-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
        transform: scale(1);
    }
    50% {
        background: rgba(0, 255, 255, 0.4);
        border-color: #33ffff;
        box-shadow: 0 0 35px rgba(0, 255, 255, 1), 0 0 50px rgba(0, 255, 255, 0.6);
        transform: scale(1.1);
    }
}

/* ============================================
   POWER-UP EFFECTS - SABOTAGE
   ============================================ */

.train-lane.sabotage-target {
    animation: sabotageTargetGlow 2s ease-in-out infinite !important;
    cursor: crosshair !important;
    border: 2px solid #ff0000 !important;
}

@keyframes sabotageTargetGlow {
    0%, 100% { 
        border-color: rgba(255, 0, 0, 0.35);
        box-shadow: 0 0 15px rgba(255, 0, 0, 0.4), inset 0 0 10px rgba(255, 0, 0, 0.2);
        background: rgba(255, 0, 0, 0.04);
    }
    50% { 
        border-color: rgba(255, 0, 0, 0.65);
        box-shadow: 0 0 25px rgba(255, 0, 0, 0.6), inset 0 0 15px rgba(255, 0, 0, 0.3);
        background: rgba(255, 0, 0, 0.08);
    }
}

/* ============================================
   POWER-UP EFFECTS - FREEZE
   ============================================ */

.train-lane.freeze-target {
    animation: freezeTargetGlow 2s ease-in-out infinite !important;
    cursor: crosshair !important;
    border: 2px solid #00bfff !important;
}

@keyframes freezeTargetGlow {
    0%, 100% { 
        border-color: rgba(0, 255, 255, 0.35);
        box-shadow: 0 0 15px rgba(0, 191, 255, 0.4), inset 0 0 10px rgba(0, 191, 255, 0.2);
        background: rgba(0, 255, 255, 0.04);
    }
    50% { 
        border-color: rgba(0, 255, 255, 0.65);
        box-shadow: 0 0 25px rgba(0, 191, 255, 0.6), inset 0 0 15px rgba(0, 191, 255, 0.3);
        background: rgba(0, 255, 255, 0.08);
    }
}

.train-lane.frozen {
    position: relative;
    background: rgba(0, 255, 255, 0.15) !important;
    border: 3px solid #00ffff !important;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.6) !important;
}

.train-lane.frozen::before {
    content: '❄️ FROZEN';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.95), rgba(0, 200, 255, 0.95));
    color: #000;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.2em;
    pointer-events: none;
    z-index: 100;
    box-shadow: 0 0 20px rgba(0, 255, 255, 1);
    animation: frozenFloat 2s ease-in-out infinite;
    letter-spacing: 1px;
}

.player-area.frozen {
    position: relative;
    border-top: 4px solid #00ffff !important;
    box-shadow: 0 -5px 50px rgba(0, 255, 255, 0.7) !important;
    background: rgba(0, 255, 255, 0.1) !important;
}

.player-area.frozen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, 
        rgba(0, 255, 255, 0.15) 0%, 
        rgba(0, 255, 255, 0.05) 50%,
        rgba(0, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 1;
    animation: frozenPulse 2s ease-in-out infinite;
}

.player-area.frozen::after {
    content: '❄️ FROZEN - TURN SKIPPED';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.95), rgba(0, 200, 255, 0.95));
    color: #000;
    padding: 10px 24px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.1em;
    z-index: 1000;
    box-shadow: 0 0 25px rgba(0, 255, 255, 1);
    animation: frozenFloat 2s ease-in-out infinite;
    letter-spacing: 1px;
}

@keyframes frozenFloat {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: translate(-50%, -55%) scale(1.05);
        filter: brightness(1.2);
    }
}

@keyframes frozenPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* ============================================
   POWER-UP PARTICLE EFFECTS
   ============================================ */

@keyframes shuffleFly {
    0% {
        transform: translate(-50%, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--endX)), var(--endY)) rotate(720deg) scale(0.3);
        opacity: 0;
    }
}

@keyframes explosionBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--endX), var(--endY)) scale(0.3);
        opacity: 0;
    }
}

@keyframes tileCountFly {
    0% {
        transform: translate(0, 0) scale(2);
        opacity: 1;
    }
    100% {
        transform: translate(var(--endX), var(--endY)) scale(0.5);
        opacity: 0;
    }
}

@keyframes iceFall {
    0% {
        transform: translateY(-30px) rotate(0deg) scale(0);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translateY(100px) rotate(360deg) scale(1.5);
        opacity: 0;
    }
}

.shuffle-vortex {
    pointer-events: none;
    animation: vortexSpin 1s ease-in-out forwards;
}

@keyframes vortexSpin {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5) rotate(360deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1) rotate(720deg);
        opacity: 1;
    }
}

.boneyard-pulse {
    animation: boneyardPulse 0.4s ease-out;
}

@keyframes boneyardPulse {
    0% { 
        transform: scale(1);
        color: #00ff9d;
        text-shadow: 0 0 10px #00ff9d;
    }
    50% { 
        transform: scale(1.3);
        color: #00ff9d;
        text-shadow: 0 0 20px #00ff9d, 0 0 30px #00ff9d;
    }
    100% { 
        transform: scale(1);
        color: #00ff9d;
        text-shadow: 0 0 10px #00ff9d;
    }
}

/* ============================================
   TURN INDICATORS & AI
   ============================================ */

.turn-indicator {
    font-size: 1.5em;
    color: #00ff9d;
    text-shadow: 0 0 20px #00ff9d;
    opacity: 0;
    transition: opacity 0.3s ease;
    margin-right: 5px;
    display: inline-block;
}

.train-lane.current-turn .turn-indicator {
    opacity: 1;
    animation: arrowBounce 1s ease-in-out infinite;
}

@keyframes arrowBounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

.train-lane.current-turn .train-name {
    color: #00ff9d !important;
    text-shadow: 0 0 20px #00ff9d, 0 0 40px #00ff9d;
    animation: nameGlow 1.5s ease-in-out infinite;
}

@keyframes nameGlow {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1);
    }
    50% { 
        transform: scale(1.08);
        filter: brightness(1.3);
    }
}

.ai-thinking {
    font-size: 1.1em;
    color: #00ff9d;
    text-shadow: 0 0 8px #00ff9d;
    letter-spacing: 2px;
    font-family: monospace;
    font-weight: bold;
    min-width: 25px;
    text-align: left;
}

.ai-thinking.active {
    opacity: 1;
}

.ai-thinking::after {
    content: '';
    animation: dotsAppear 1.2s ease-in-out infinite;
}

.ai-thinking.active::after {
    display: inline-block;
}

@keyframes dotsAppear {
    0%, 33% { content: '.'; }
    34%, 66% { content: '..'; }
    67%, 100% { content: '...'; }
}

.ai-reaction {
    font-size: 1.3em;
    min-width: 25px;
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-reaction.active {
    opacity: 1;
    animation: reactionPop 1.5s ease-out forwards;
}

@keyframes reactionPop {
    0% {
        opacity: 0;
        transform: scale(0) translateY(0);
    }
    30% {
        opacity: 1;
        transform: scale(1.4) translateY(-4px);
    }
    60% {
        transform: scale(1) translateY(0);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(2px);
    }
}

/* ============================================
   SCREEN SHAKE
   ============================================ */

@keyframes shake-light {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, 1px); }
    20% { transform: translate(2px, -1px); }
    30% { transform: translate(-2px, -1px); }
    40% { transform: translate(2px, 1px); }
    50% { transform: translate(-1px, 1px); }
    60% { transform: translate(1px, -1px); }
    70% { transform: translate(-1px, -1px); }
    80% { transform: translate(1px, 1px); }
    90% { transform: translate(-1px, 0); }
}

@keyframes shake-medium {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-4px, 2px); }
    20% { transform: translate(4px, -2px); }
    30% { transform: translate(-3px, -3px); }
    40% { transform: translate(3px, 3px); }
    50% { transform: translate(-2px, 1px); }
    60% { transform: translate(2px, -1px); }
    70% { transform: translate(-1px, -2px); }
    80% { transform: translate(1px, 2px); }
    90% { transform: translate(-1px, 1px); }
}

@keyframes shake-heavy {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-6px, 3px) rotate(-1deg); }
    20% { transform: translate(6px, -3px) rotate(1deg); }
    30% { transform: translate(-5px, -4px) rotate(-1deg); }
    40% { transform: translate(5px, 4px) rotate(1deg); }
    50% { transform: translate(-4px, 2px) rotate(-0.5deg); }
    60% { transform: translate(4px, -2px) rotate(0.5deg); }
    70% { transform: translate(-2px, -3px) rotate(-0.5deg); }
    80% { transform: translate(2px, 3px) rotate(0.5deg); }
    90% { transform: translate(-1px, 1px) rotate(0deg); }
}

/* ============================================
   CELEBRATION & PARTICLES
   ============================================ */

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.celebration-overlay.hidden {
    display: none;
}

.particle {
    position: absolute;
    font-size: 2em;
    animation: particle-fall 3s ease-out forwards;
    opacity: 0;
}

@keyframes particle-fall {
    0% {
        opacity: 1;
        transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) translateX(var(--drift)) rotate(720deg) scale(0.5);
    }
}

.particle.intense {
    animation: particle-fall-intense 4s ease-out forwards;
    font-size: 2.5em;
}

@keyframes particle-fall-intense {
    0% {
        opacity: 1;
        transform: translateY(0) translateX(0) rotate(0deg) scale(1.2);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) translateX(var(--drift)) rotate(1080deg) scale(0.3);
    }
}

.particle.color-cycle {
    animation: particle-fall-intense 4s ease-out forwards, color-cycle 2s linear infinite;
}

@keyframes color-cycle {
    0% { filter: hue-rotate(0deg); }
    33% { filter: hue-rotate(120deg); }
    66% { filter: hue-rotate(240deg); }
    100% { filter: hue-rotate(360deg); }
}

/* ============================================
   MODALS & OVERLAYS
   ============================================ */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.overlay.hidden {
    display: none;
}

/* Modal wrapper containing logo and modal container */
.modal-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 700px;
    width: 90%;
}

/* Logo positioned above the modal */
.modal-logo-top {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-logo-above {
    max-width: 250px;                                    /* reduced from 350px */
    width: 100%;
    height: auto;
    object-fit: contain;
}

.modal {
    background: rgba(26, 26, 46, 0.95);
    background-image: url('NeonNigthsBlurred.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid #00ff9d;
    border-radius: 15px;
    padding: 40px;
    width: 100%;                                         /* fill wrapper width */
    box-shadow: 0 0 40px rgba(0, 255, 157, 0.5);
    text-align: center;
    max-height: 70vh;                                    /* reduced from 80vh to accommodate logo */
    overflow-y: auto;
    position: relative;
}

/* Semi-transparent overlay for text readability */
.modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.75);
    border-radius: 15px;
    z-index: 0;
}

/* Ensure modal content is above the overlay */
.modal > * {
    position: relative;
    z-index: 1;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    color: #00ff9d;
    cursor: pointer;
    line-height: 1;
    padding: 5px 10px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    color: #ff00ff;
    transform: scale(1.2);
    text-shadow: 0 0 10px #ff00ff;
}

.btn-back {
    position: absolute;
    top: 15px;
    left: 15px;
    padding: 8px 16px;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid #00ffff;
    color: #00ffff;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    transform: translateX(-2px);
}

.current-game-status {
    margin: 15px 0;
    padding: 12px;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 8px;
    color: #00ffff;
}

.current-game-status strong {
    color: #00ff9d;
}

.status-divider {
    border: none;
    border-top: 1px solid rgba(0, 255, 157, 0.3);
    margin: 15px 0;
}

.modal h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #00ff9d;
    text-shadow: 0 0 15px #00ff9d;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.modal-logo {
    display: none;                                       /* hidden - using background image instead */
}

.modal h3 {
    font-size: 1.3em;
    margin-top: 20px;
    margin-bottom: 10px;
    color: #00ffff;
    text-align: left;
}

.modal p {
    margin: 15px 0;
    font-size: 1.1em;
    color: #00ffff;
}

.modal ul {
    text-align: left;
    margin: 10px 0 10px 20px;
    color: #00ffff;
    line-height: 1.6;
}

.modal li {
    margin: 8px 0;
}

.difficulty-select {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
}

.difficulty-btn {
    padding: 15px 25px;
    font-size: 1.1em;
    background: rgba(0, 255, 157, 0.1);
    border: 2px solid #00ff9d;
    color: #00ff9d;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    background: rgba(0, 255, 157, 0.3);
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.6);
    transform: scale(1.05);
}

.difficulty-btn.selected {
    background: #00ff9d;
    color: #000;
    box-shadow: 0 0 25px rgba(0, 255, 157, 0.8);
}

.leaderboard {
    margin: 25px 0;
    text-align: left;
}

.leaderboard-entry {
    padding: 10px;
    margin: 8px 0;
    background: rgba(0, 255, 157, 0.05);
    border-left: 3px solid #00ff9d;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    color: #00ffff;
}

.scores-table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
}

.scores-table th,
.scores-table td {
    padding: 10px;
    border: 1px solid rgba(0, 255, 157, 0.3);
    text-align: center;
}

.scores-table th {
    background: rgba(0, 255, 157, 0.2);
    color: #00ff9d;
}

.scores-table td {
    color: #00ffff;
}

.detailed-scores-table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    font-size: 0.9em;
}

.detailed-scores-table th,
.detailed-scores-table td {
    padding: 8px;
    border: 1px solid rgba(0, 255, 157, 0.3);
    text-align: center;
}

.detailed-scores-table th {
    background: rgba(0, 255, 157, 0.2);
    color: #00ff9d;
    font-weight: bold;
}

.detailed-scores-table td {
    color: #00ffff;
}

.detailed-scores-table .round-label {
    font-weight: bold;
    background: rgba(0, 255, 157, 0.05);
}

.detailed-scores-table .totals-row {
    background: rgba(0, 255, 157, 0.15);
    font-weight: bold;
    border-top: 2px solid #00ff9d;
}

.detailed-scores-table .current-round {
    background: rgba(255, 255, 0, 0.1);
}

.detailed-scores-table .winner-col {
    background: rgba(0, 255, 157, 0.2);
}

.detailed-scores-table .player-col {
    font-weight: bold;
}

/* ============================================
   SCORE COUNT-UP ANIMATION
   ============================================ */

@keyframes scoreCountUp {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.score-counting {
    display: inline-block;
    animation: scoreCountUp 0.6s ease-out;
    color: #00ff9d !important;
    text-shadow: 0 0 10px #00ff9d;
    font-weight: bold;
}

.score-final {
    color: #00ffff !important;
}

.total-counting {
    animation: scoreCountUp 0.8s ease-out;
    color: #ffd700 !important;
    text-shadow: 0 0 15px #ffd700;
    font-weight: bold;
    font-size: 1.2em;
}

/* ============================================
   ORACLE VISION
   ============================================ */

.oracle-vision-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

@keyframes oraclePulse {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(138, 43, 226, 1),
                     0 0 40px rgba(138, 43, 226, 0.8),
                     0 0 60px rgba(138, 43, 226, 0.6);
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 30px rgba(138, 43, 226, 1),
                     0 0 60px rgba(138, 43, 226, 1),
                     0 0 90px rgba(138, 43, 226, 0.8);
    }
}

@keyframes oracleFloat {
    0%, 100% {
        transform: scale(3) translateY(0px);
    }
    50% {
        transform: scale(3) translateY(-20px);
    }
}

@keyframes oracleParticle {
    0% {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateX(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) rotate(var(--angle)) translateX(var(--distance)) scale(0);
        opacity: 0;
    }
}

/* ============================================
   TARGETING MODES
   ============================================ */

body.targeting-cursor,
body.targeting-cursor * {
    cursor: crosshair !important;
}

.train-lane.clickable-train {
    background: rgba(0, 255, 157, 0.1) !important;
    border: 2px solid rgba(0, 255, 157, 0.5) !important;
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.3) !important;
}

.train-lane.clickable-train:hover {
    background: rgba(0, 255, 157, 0.2) !important;
    border-color: rgba(0, 255, 157, 0.8) !important;
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.5) !important;
}

/* ============================================
   MOBILE RESPONSIVE // Narrow desktop 
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
    
    .game-header {
        flex-wrap: wrap !important;
        height: auto !important;
        padding: 10px 20px !important;
        gap: 10px;
        position: relative;
    }

    /* Logo stays left */
    .game-title {
        order: 1;
        flex: 0 0 auto;
        position: static !important;
        height: 50px !important;
        left: auto !important;
        top: auto !important;
    }

    .header-logo {
        height: 100% !important;
        max-height: 50px !important;
    }

    /* Buttons on the RIGHT side of row 1 */
    .header-buttons {
        position: static !important;
        transform: none !important;
        order: 2;
        margin-left: auto; /* Push to the right */
    }

    .header-buttons .btn {
        padding: 8px 14px !important;
        font-size: 0.95em !important;
        min-height: auto !important;
    }

    .btn-text {
        display: inline !important;
    }

    /* Stats on second row, full width, centered */
    .game-info {
        order: 3;
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0 !important;
        justify-content: center !important;
        gap: 55px !important;
        background: rgba(0, 0, 0, 0.3) !important;
        position: static !important;
    }

    /* ========================================
       LAYOUT - Natural page scrolling (narrow desktop)
       ======================================== */
    .game-container {
        height: auto !important;
        min-height: 100vh !important;
    }

    /* ========================================
       TRAIN LANES - Compact sizing (narrow desktop)
       ======================================== */
    .trains-area {
        padding: 5px 10px !important;
        gap: 3px !important;
    }

    .train-lane {
        padding: 4px 6px;                               /* reduced from 4px 8px */
        gap: 6px;                                        /* reduced from 8px */
        min-height: 0;
    }

    .train-info {
        min-width: 120px;
        max-width: 120px;
    }

    .train-name {
        font-size: 0.9em;
    }

    /* Mexican train: show "MEX TRAIN" instead of full name */
    .mexican-train .train-name {
        display: flex !important;
        align-items: center;
        gap: 4px;
    }

    .mexican-train .train-name::before {
        content: '🚂 MEX TRAIN';
        font-size: 0.8rem;
    }

    .mexican-train .train-name::after {
        content: 'MEX TRAIN';
        font-size: 0.85em;
        font-weight: bold;
        color: #ff00ff;
    }

    /* Hide original text node - target text directly */
    .mexican-train .train-name {
        font-size: 0;
    }

    /* Mexican train second row: tight spacing */
    .mexican-train .train-status {
        font-size: 0.65em;
        margin-left: 0;
    }

    .mexican-train-status::before {
        content: '🔐 Always Playable';
        font-size: 1em;
        white-space: nowrap;
    }

    /* Reduce second row font sizes */
    .train-status {
        font-size: 0.7em;
        margin-left: 0px;                              /* reduced from base */
    }

    .mexican-train-status {
        font-size: 0.7em;
    }

    .train-info-row2 {
        font-size: 0.75em;
        gap: 8px;
    }

    .train-tile-count {
        font-size: 1em;
    }

    .train-status-inline {
        font-size: 1em;
    }

    .ai-thinking {
        font-size: 0.85em;
        min-width: unset;
    }

    .ai-reaction {
        font-size: 1em;
        min-width: unset;
    }

    .engine-start {
        min-width: 36px;
        max-width: 36px;
        height: 36px;
        font-size: 0.95em;
    }

    .domino.horizontal {
        width: 62px;
        height: 44px;
        min-width: 62px;
    }

    .domino.horizontal .domino-half {
        font-size: 1.2em;
    }

    .train-tiles {
        padding: 4px 60px 4px 8px;
        min-height: 0;
    }

    /* ========================================
       PLAYER AREA - Expand naturally, no internal scroll
       ======================================== */
    .player-area {
        overflow-y: visible !important;                            /* no internal scroll */
    }

    /* ========================================
       PLAYER AREA - Fix status message overlap + wrapping dashboard
       ======================================== */
    .player-header {
        display: flex;
        justify-content: center;                       /* title centered */
        align-items: center;
        gap: 15px;
        position: relative;                             /* for absolute positioned status */
    }

    .status-message-container {
        position: absolute;
        left: 0;                                        /* status on left edge */
        text-align: left;
        width: 220px;                                      /* fixed width to prevent overlap */
    }

    /* Dashboard: powerup grid on left, hand wraps on right */
    .player-dashboard {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start;
        gap: 0 !important;
        padding: 15px !important;
        min-height: auto !important;                    /* let content dictate height, expands as hand wraps */
        overflow: visible !important;
        height: auto !important;                         /* ensure it grows with content */
    }

    .powerup-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 60px) !important;
        grid-template-rows: repeat(2, 60px) !important;
        gap: 10px !important;
        margin-right: 0 !important;
        padding-right: 15px !important;
        border-right: 2px solid rgba(0, 255, 157, 0.2) !important;  /* vertical separator */
        border-top: none !important;
        border-bottom: none !important;
        flex-shrink: 0;
    }

    .powerup-btn {
        width: 60px !important;
        height: 60px !important;
    }

    .player-hand {
        flex: 1 !important;
        padding: 0 0 0 15px !important;                /* space after separator */
        overflow-x: visible !important;                 /* was hidden — allow selected domino lift to not be clipped */
        overflow-y: visible !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px !important;
        min-height: 130px !important;                   /* enough for one row of 88px tiles + gaps, expands with wrapping */
    }

    .player-hand.dealing {
        min-height: 186px !important;                   /* enough for 2 rows: 88*2 + 10 gap + padding */
        max-height: none !important;                     /* no max height constraint — tiles can wrap */
        overflow: hidden !important;                     /* hide tiles during animation */
    }

    .player-dashboard.dealing {
        min-height: 216px !important;                    /* accommodate wrapped tiles + padding during dealing */
    }

    .player-hand .domino.vertical {
        width: 44px;                                    /* was 50px — smaller to fit more per row */
        height: 88px;                                   /* was 100px */
        min-width: 44px;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    
    /* Header adjustments for TABLET */
    .game-header {
        height: auto !important;
        padding: 5px 15px !important;   /* was 10px — tighter top/bottom */
        gap: 0 !important;
        position: relative;
        display: flex !important;
        flex-direction: column !important;
    }

    /* Logo stays left - absolute positioning */
    .game-title {
        order: 1;
        position: absolute !important;
        left: 15px;
        top: 5px;                        /* match new padding */
        height: 40px !important;         /* was 45px */
    }

    .header-logo {
        height: 100% !important;
        max-height: 45px !important;
    }

    /* Buttons on the RIGHT side of row 1 - absolute positioning with safe margins */
    .header-buttons {
        order: 2;
        position: absolute !important;
        right: 20px !important;
        top: 5px;                        /* match new header padding */
        transform: none !important;
        display: flex !important;
        gap: 4px !important;
        justify-content: flex-end !important; /* Align to right */
    }

    .header-buttons .btn {
        padding: 8px 14px !important;
        font-size: 0.9em !important;
        min-height: 40px !important;
        white-space: nowrap;
        flex-shrink: 1 !important;
        min-width: 0 !important;
        transition: all 0.2s ease;
    }

    .btn-text {
        display: inline !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Stats on second row, full width, centered with dark band */
    .game-info {
        order: 3;
        width: 100% !important;
        margin-left: -15px !important;
        margin-right: -15px !important;
        margin-top: 50px !important;     /* was 55px — matches reduced header padding */
        padding: 5px 15px !important;    /* was 10px top/bottom — tighter */
        justify-content: center !important;
        gap: 35px !important;
        position: static !important;
        background: rgba(0, 0, 0, 0.3) !important;
        border-radius: 5px;
    }

    .info-item {
        font-size: 0.8rem !important;
    }

    /* Reduce gap between stats bar and trains */
    .trains-area {
        padding: 8px 15px !important;
        gap: 6px !important;
        flex: none !important;          /* don't stretch to fill viewport — height driven by lanes */
        overflow-y: auto;
    }

    /* ========================================
       TRAIN LANES (tablet)
       ======================================== */
    .train-lane {
        padding: 3px 8px;
        gap: 8px;
        min-height: 0;
        flex: 0 0 auto !important;      /* size to content, not equal share of viewport height */
    }

    .train-info {
        min-width: 85px;
        max-width: 85px;
        display: grid;
        grid-template-rows: 20px 18px;   /* keep fixed — prevents jumping */
        gap: 2px;
        align-content: center;
    }

    .train-info > div:first-child {
        align-items: center;             /* no overflow:hidden — was causing visual box artifact */
    }

    .train-name {
        font-size: 0.75em;
        line-height: 1.2;
    }

    /* Shrink ai-thinking so its expanding dots stay contained */
    .ai-thinking {
        font-size: 0.65em;
        min-width: unset;
        letter-spacing: 1px;
    }

    .ai-reaction {
        font-size: 0.8em;
        min-width: unset;
    }

    /* Mexican train: two-line label (MEX / TRAIN) + lock icon, no 'Always Playable' text */
    .mexican-train .train-info {
        display: flex;               /* override the grid — mexican train has different layout */
        flex-direction: column;
        gap: 2px;
    }

    .mexican-train .train-name {
        font-size: 0;              /* hide original text */
        display: flex !important;
        align-items: center;
        gap: 3px;
    }

    .mexican-train .train-name::before {
        content: '🚂';
        font-size: 0.9rem;         /* was 1.1rem */
        line-height: 1;
    }

    .mexican-train .train-name::after {
        content: 'MEX\A TRAIN';
        white-space: pre;          /* \A becomes a newline */
        font-size: 0.62rem;        /* was 0.72rem */
        line-height: 1.2;          /* was 1.25 */
        font-weight: bold;
        color: #ff00ff;
    }

    /* Hide "Always Playable" text, show only 🔐 icon */
    .mexican-train-status {
        font-size: 0;
        margin-left: 0;
    }

    .mexican-train-status::before {
        content: '🔐';
        font-size: 0.7rem;         /* was 0.95rem */
    }

    .train-status {
        font-size: 0.65em;
        margin-left: 15px;
    }

    .train-info-row2 {
        font-size: 0.78em;             /* was 0.65em */
        gap: 6px;
    }

    /* Show lock/public icon but keep it compact */
    .train-status-inline {
        display: inline !important;
        font-size: 0.9em;              /* was 0.7em */
    }

    /* Name glow: text-shadow only — filter:brightness bleeds to parent container */
    .train-lane.current-turn .train-name {
        animation: nameGlowTablet 1.5s ease-in-out infinite;
    }

    @keyframes nameGlowTablet {
        0%, 100% { text-shadow: 0 0 8px #00ff9d; }
        50%       { text-shadow: 0 0 16px #00ff9d, 0 0 28px #00ff9d; }
    }

    .engine-start {
        min-width: 30px;
        max-width: 30px;
        height: 30px;
        font-size: 0.8em;
    }

    .domino.horizontal {
        width: 52px;
        height: 36px;
        min-width: 52px;
    }

    .domino.horizontal .domino-half {
        font-size: 1.05em;
    }

    .train-tiles {
        padding: 3px 60px 3px 8px;     /* override base 8px top/bottom — 8+36+8=52px → 3+36+3=42px */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .train-tiles::-webkit-scrollbar {
        display: none;
    }

    /* Hide ▶ arrow — glowing train name is sufficient on tablet */
    .turn-indicator {
        display: none !important;
    }

    /* ========================================
       LAYOUT - Natural page scrolling (tablet)
       ======================================== */
    .game-container {
        height: auto !important;
        min-height: 100vh !important;
    }

    /* ========================================
       PLAYER AREA (tablet) - Expand naturally, no internal scroll
       ======================================== */
    .player-area {
        padding: 10px !important;
        gap: 8px !important;
        padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
        overflow-y: visible !important;                            /* no internal scroll — page scrolls instead */
    }

    .player-header {
        margin-bottom: 6px !important;
        flex-direction: column;
        gap: 6px;
    }

    .hand-title-container {
        width: 100%;
        justify-content: center;
    }

    .player-name {
        font-size: 1.1em;
    }

    .btn-help {
        padding: 5px 10px;
        font-size: 0.85em;
    }

    .status-message-container {
        position: static;
        width: 100%;
        text-align: center;
        min-height: 30px;                                /* fixed height to prevent layout shift */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .status-message-inline {
        font-size: 0.85em;                               /* slightly smaller on tablet */
    }

    /* ========================================
       PLAYER DASHBOARD (tablet)
       ======================================== */
    .player-dashboard {
        flex-direction: column !important;
        padding: 10px !important;
        min-height: auto !important;
        gap: 0 !important;                                         /* separator line handles spacing */
        overflow: visible !important;                              /* allow selected domino lift to escape upward */
    }

    /* ========================================
       POWER-UPS — 4×1 row (tablet, TOP above dominoes)
       ======================================== */
    .powerup-grid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        width: 100% !important;
        border-right: none !important;
        border-top: none !important;                               /* remove top line */
        border-bottom: 1px solid rgba(0, 255, 157, 0.2);          /* separator below powerups */
        padding: 0 0 8px 0 !important;                            /* space above separator */
        margin: 0 !important;
        gap: 15px;                                                 /* was 8px */
        order: 1;                                                  /* powerups on top */
    }

    .powerup-btn {
        flex: 0 0 56px !important;
        width: 56px !important;
        height: 56px !important;
    }

    .powerup-btn .powerup-icon {
        font-size: 2em;
    }

    /* ========================================
       PLAYER HAND — wrapping (tablet, BELOW separator)
       ======================================== */
    .player-hand {
        width: 100% !important;
        margin: 0 !important;
        padding: 8px 10px 10px 10px !important;                    /* breathing room below separator */
        overflow-x: visible !important;                            /* was hidden — allows selected domino lift above separator */
        overflow-y: visible !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px;
        min-height: 88px;
        order: 2;                                                  /* dominoes below powerups */
    }

    .player-hand .domino.vertical {
        width: 44px;
        height: 88px;
        min-width: 44px;
    }

    /* ========================================
       ACTIONS (tablet)
       ======================================== */
    .player-actions {
        display: flex !important;
        width: 100% !important;
        gap: 10px !important;
        margin: 8px 0 0 0 !important;
    }

    .player-actions .btn {
        flex: 1 !important;
        min-height: 48px !important;
        font-size: 1em;
    }

    /* ========================================
       TOUCH OPTIMISATION (tablet)
       ======================================== */
    button,
    .domino {
        -webkit-tap-highlight-color: rgba(0, 255, 157, 0.2);
    }

    * {
        touch-action: manipulation;
    }
}


/* ========================================
   MOBILE (≤ 480px)
   ======================================== */
@media (max-width: 480px) {

    /* ========================================
       HEADER - Flexbox Row 1 (Logo + Buttons)
       ======================================== */
    .game-header {
        height: auto !important;
        padding: 0 !important;
        gap: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative;
    }

    /* ---- Row 1: logo left, buttons right, flex, no absolute ---- */
    .game-header-row1 {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 4px 10px;              /* was 6px — tighter top/bottom */
        gap: 8px;
        min-height: 44px;               /* was 52px */
    }

    /* Logo: shrinks proportionally, never overflows */
    .game-title {
        position: static !important;    /* override any inherited absolute */
        height: auto !important;
        flex: 0 1 auto;                 /* can shrink */
        display: flex !important;
        align-items: center !important;
        min-width: 0;
        order: unset;
    }

    .header-logo {
        height: 38px !important;        /* base size */
        max-height: 38px !important;
        width: auto !important;
        object-fit: contain;
    }

    /* Buttons: sit right of logo, shrink when tight */
    .header-buttons {
        position: static !important;    /* override any inherited absolute */
        transform: none !important;
        flex: 0 1 auto;                 /* can shrink */
        display: flex !important;
        flex-direction: row !important;
        gap: 4px !important;
        align-items: center !important;
        justify-content: flex-end !important;
        min-width: 0;
        order: unset;
    }

    .header-buttons .btn {
        padding: 6px 10px !important;
        font-size: 0.8em !important;    /* shrinks text so labels stay visible */
        min-height: 36px !important;
        white-space: nowrap;
        flex-shrink: 1 !important;
    }

    .btn-text {
        display: inline !important;
    }

    /* ---- Row 2: Stats bar ---- */
    .game-info {
        display: flex !important;
        width: 100% !important;
        justify-content: space-between !important;
        background: rgba(0, 0, 0, 0.3);
        padding: 4px 10px !important;   /* was 6px — tighter top/bottom */
        border-radius: 0;
        gap: 10px !important;
        margin-top: 0 !important;
        font-size: 0.75rem !important;
        position: static !important;
    }

    .info-label {
        color: #888;
    }

    /* ========================================
       TRAINS AREA
       ======================================== */
    .trains-area {
        padding: 5px 8px;
        gap: 4px;
        flex: none !important;          /* don't stretch to fill viewport — height driven by lanes */
        overflow-y: auto;
    }

    .train-lane {
        padding: 3px 4px;               /* less left/right */
        gap: 5px;                        /* less space between info/engine/tiles */
        min-height: 0;
        flex: 0 0 auto !important;      /* size to content, not equal share of viewport height */
    }

    .train-info {
        min-width: 68px;                 /* was 75px */
        max-width: 68px;
        display: grid;
        grid-template-rows: 20px 18px;
        gap: 2px;
        align-content: center;
        padding-left: 0;                 /* override base 8px */
    }

    .train-name {
        font-size: 0.75em;
        margin-left: 0;
        line-height: 1.2;
    }

    /* Mexican train: two-line label (MEX / TRAIN) + lock icon, no 'Always Playable' text */
    .mexican-train .train-info {
        gap: 2px;                  /* tighter than default 5px between name row and status */
    }

    .mexican-train .train-name {
        font-size: 0;              /* hide original text */
        display: flex !important;
        align-items: center;
        gap: 3px;
    }

    .mexican-train .train-name::before {
        content: '🚂';
        font-size: 0.85rem;        /* was 1.1rem */
        line-height: 1;
    }

    .mexican-train .train-name::after {
        content: 'MEX\A TRAIN';
        white-space: pre;          /* \A becomes a newline */
        font-size: 0.6rem;         /* was 0.72rem */
        line-height: 1.2;          /* was 1.25 */
        font-weight: bold;
        color: #ff00ff;
    }

    /* Hide "Always Playable" text, show only 🔐 icon */
    .mexican-train-status {
        font-size: 0;
        margin-left: 0;
    }

    .mexican-train-status::before {
        content: '🔐';
        font-size: 0.65rem;        /* was 0.95rem */
    }

    .train-status {
        font-size: 0.65em;
        margin-left: 15px;
    }
    .train-info-row2 {
        font-size: 0.75em;             /* was 0.65em */
        gap: 6px;
    }

    .train-status-inline {
        display: inline !important;    /* was none — show lock on mobile */
        font-size: 0.85em;
    }

    .engine-start {
        min-width: 30px;
        max-width: 30px;
        height: 30px;
        font-size: 0.8em;
    }

    /* Hide ▶ arrow — glowing train name is sufficient on mobile */
    .turn-indicator {
        display: none !important;
    }

    .ai-thinking {
        font-size: 0.8em;
        min-width: 18px;
    }

    .ai-reaction {
        font-size: 0.95em;
        min-width: 16px;
    }

    .domino.horizontal {
        width: 52px;
        height: 36px;
        min-width: 52px;
    }

    .domino.horizontal .domino-half {
        font-size: 1.05em;
    }

    .train-tiles {
        padding: 3px 60px 3px 8px;     /* override base 8px top/bottom — 8+36+8=52px → 3+36+3=42px */
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .train-tiles::-webkit-scrollbar {
        display: none;
    }

    /* ========================================
       PLAYER AREA
       ======================================== */
    .player-area {
        padding: 8px 10px !important;                              /* was 10px all sides */
        gap: 6px !important;                                       /* was 8px */
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }

    .player-header {
        margin-bottom: 6px !important;
        flex-direction: column;
        gap: 6px;
    }

    .hand-title-container {
        width: 100%;
        justify-content: center;
    }

    .player-name {
        font-size: 1.1em;
    }

    .btn-help {
        padding: 5px 10px;
        font-size: 0.85em;
    }

    .status-message-container {
        position: static;
        width: 100%;
        text-align: center;
        min-height: 30px;                                /* fixed height to prevent layout shift */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .status-message-inline {
        font-size: 0.85em;                               /* slightly smaller on mobile */
    }

    /* ========================================
       PLAYER DASHBOARD
       ======================================== */
    .player-dashboard {
        flex-direction: column !important;
        padding: 6px !important;
        min-height: auto !important;
        gap: 0 !important;
        overflow: visible !important;                              /* ensure selected domino lift is not clipped */
    }

    /* ========================================
       POWER-UPS - 4x1 Row (TOP, above dominoes)
       ======================================== */
    .powerup-grid {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        width: 100% !important;
        border-right: none !important;
        border-top: none !important;                               /* remove top line */
        border-bottom: 1px solid rgba(0, 255, 157, 0.2);          /* separator below powerups */
        padding: 0 0 6px 0 !important;                            /* space above separator */
        margin: 0 !important;
        gap: 15px;                                                 /* was 8px */
        order: 1;                                                  /* powerups on top */
    }

    .powerup-btn {
        flex: 0 0 44px !important;                                /* was 52px */
        width: 44px !important;
        height: 44px !important;
    }

    /* ========================================
       PLAYER HAND - Wrapping (BELOW separator)
       ======================================== */
    .player-hand {
        width: 100% !important;
        margin: 0 !important;
        padding: 6px !important;                                   /* was 10px */
        overflow-x: visible !important;                            /* was hidden — selected domino lift must not be clipped at separator */
        overflow-y: visible !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px;                                                  /* was 10px */
        min-height: 80px;                                          /* matches new domino height */
        order: 2;                                                  /* dominoes below powerups */
    }

    .player-hand .domino.vertical {
        width: 40px;                                               /* was 46px */
        height: 80px;                                              /* was 92px */
        min-width: 40px;
    }

    /* ========================================
       ACTIONS
       ======================================== */
    .player-actions {
        display: flex !important;
        width: 100% !important;
        gap: 10px !important;
        margin: 6px 0 0 0 !important;                             /* was 8px */
    }

    .player-actions .btn {
        flex: 1 !important;
        min-height: 40px !important;                               /* was 48px */
        font-size: 1em;
    }

    /* ========================================
       MODALS
       ======================================== */
    .modal-wrapper {
        width: 95%;
        max-width: 95%;
    }

    .modal-logo-above {
        max-width: 150px;                                /* reduced to match desktop proportion */
    }

    .modal {
        padding: 30px 15px;
        max-height: 60vh;                                /* more room for logo on mobile */
    }

    .modal h2 {
        font-size: 1.5em;
    }

    .modal-logo {
        display: none;                                   /* hidden - using background image instead */
    }

    .difficulty-select {
        flex-direction: column;
        gap: 10px;
    }

    .difficulty-btn {
        width: 100%;
    }

    /* ========================================
       TOUCH OPTIMIZATION
       ======================================== */
    button,
    .domino {
        -webkit-tap-highlight-color: rgba(0, 255, 157, 0.2);
    }

    * {
        touch-action: manipulation;
    }
}

/* ========================================
   LANDSCAPE MOBILE
   ======================================== */
@media (max-width: 900px) and (max-height: 500px) {
    .player-hand .domino.vertical {
        width: 44px;
        height: 88px;
        min-width: 44px;
    }
    
    .powerup-btn {
        flex: 0 0 50px !important;
        width: 50px !important;
        height: 50px !important;
    }
}