/* ====================================
   Space Samurai 
   Pixel Art Styled Game
   ==================================== */

:root {
    /* Player Colors */
    --player1-primary: #00f0ff;
    --player1-secondary: #0088aa;
    --player1-glow: rgba(0, 240, 255, 0.6);
    
    --player2-primary: #D9291C;
    --player2-secondary: #8B1A12;
    --player2-glow: rgba(217, 41, 28, 0.6);
    
    /* Board Colors */
    --board-dark: #0a0e1a;
    --board-light: #121828;
    --board-accent: #1e2a40;
    --board-edge: #060810;
    --board-frame: #1a2035;
    --board-frame-light: #222c45;
    
    /* wormhole Colors */
    --wormhole-glow: #E0E0E0;
    
    /* UI Colors */
    --bg-dark: #020205;
    --bg-gradient: linear-gradient(135deg, #020205 0%, #05060f 50%, #111105 100%);
    --text-primary: #ffffff;
    --text-secondary: #aaaacc;
    --card-bg: #1a1a2e;
    --card-border: #333366;
    
    /* Sizing */
    --square-size: 70px;
    --piece-size: 65px;
    --card-width: 120px;
    --card-height: 120px;

    /* Subscription modal — X CTA */
    --subscribe-x-magenta: #e010b8;
    --subscribe-x-magenta-dark: #9a0b7a;
    --subscribe-x-glow: rgba(224, 16, 184, 0.45);
}

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

body {
    font-family: 'Press Start 2P', cursive;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    overflow: hidden;
}

body.modal-open {
    overflow: hidden;
    touch-action: none;
}

.bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2;
    pointer-events: none;
}

/* Starfield Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, white, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 380px 60px, white, transparent),
        radial-gradient(2px 2px at 420px 180px, rgba(255,255,255,0.8), transparent);
    background-size: 500px 200px;
    animation: stars 60s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes stars {
    from { background-position: 0 0; }
    to { background-position: 500px 200px; }
}

/* ====================================
   GAME CONTAINER
   ==================================== */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    max-width: 100vw;
    position: relative;
}

/* Turn Indicator Gradient Overlay */
.game-container::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.5s ease, background 0.5s ease;
}

/* Player 1's turn - gradient goes from center downward */
.game-container.player1-turn::after {
    opacity: 1;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 40%,
        rgba(0, 240, 255, 0.03) 50%,
        rgba(0, 240, 255, 0.08) 70%,
        rgba(0, 240, 255, 0.15) 85%,
        rgba(0, 240, 255, 0.25) 100%
    );
}

/* Player 2's turn - gradient goes from center upward */
.game-container.player2-turn::after {
    opacity: 1;
    background: linear-gradient(
        to top,
        transparent 0%,
        transparent 40%,
        rgba(217, 41, 28, 0.03) 50%,
        rgba(217, 41, 28, 0.08) 70%,
        rgba(217, 41, 28, 0.15) 85%,
        rgba(217, 41, 28, 0.25) 100%
    );
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
    width: 100vw;
}

body.game-active .game-header {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    pointer-events: none;
    z-index: 0;
    animation: headerMoveDown 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes headerMoveDown {
    0% {
        top: 10%;
        transform: translate(-50%, 0);
        z-index: 1000;
    }
    20% {
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 1000;
        filter: brightness(2) drop-shadow(0 0 50px white);
    }
    40% {
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 1000;
        filter: brightness(1) drop-shadow(0 0 30px var(--player1-glow));
    }
    100% {
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 0;
    }
}

.game-header h1 {
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    gap: 20px;
    font-size: 2.5rem;
    background: linear-gradient(180deg, var(--player1-primary) 0%, var(--player2-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px var(--player1-glow);
    letter-spacing: 4px;
    margin: 0;
    padding: 0;
}

body:not(.game-active) .game-header h1 {
    animation: titlePulse 3s ease-in-out infinite;
}

body.game-active .game-header h1 {
    animation: h1FadeOut 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes h1FadeOut {
    0%, 40% {
        opacity: 1;
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 30px var(--player1-glow));
    }
    100% {
        opacity: 0;
        transform: scale(1.5);
        filter: brightness(0);
    }
}

@keyframes titlePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

.subtitle {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 8px;
    letter-spacing: 4px;
}

/* ====================================
   BACKGROUND SCROLLING TEXT
   ==================================== */
.bg-scroller {
    position: absolute;
    font-size: 6rem;
    white-space: nowrap;
    opacity: 0;
    z-index: 0;
    pointer-events: none;
    background: linear-gradient(180deg, var(--player1-primary) 0%, var(--player2-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
    transition: opacity 1s ease;
}

body.game-active .bg-scroller {
    animation-play-state: running;
}

/* Base plane styling for rotation */
.bg-space {
    top: 65%;
    left: -25vw;
    animation: bgScroll 40s linear infinite both;
    animation-delay: 2.5s; /* Wait for intro */
    transform-origin: center;
}

.bg-samurai {
    top: 80%;
    left: 25vw;
    animation: bgScroll 40s linear infinite both;
    animation-delay: 12.5s; /* 10 seconds behind space */
    transform-origin: center;
}

@keyframes bgScroll {
    0% {
        opacity: 0;
        transform: rotate(-45deg) translateX(-30vw);
    }
    10% {
        opacity: 0.08;
    }
    90% {
        opacity: 0.08;
    }
    100% {
        opacity: 0;
        transform: rotate(-45deg) translateX(120vw);
    }
}

@media (max-width: 768px) {
    .bg-scroller {
        font-size: 3.5rem;
    }
}

@media (max-width: 480px) {
    .bg-scroller {
        font-size: 2.5rem;
    }
}

/* ====================================
   GAME LAYOUT
   ==================================== */

.game-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
        ". p2 ."
        "rl board rr"
        ". p1 .";
    gap: 20px 30px;
    align-items: center;
    justify-items: center;
    position: relative;
    width: 100%;
}

.player2-cards { grid-area: p2; }
.river-left { grid-area: rl; justify-self: end; }
.board-frame { grid-area: board; position: relative; } /* adding position relative so it stacks correctly */
.river-right { grid-area: rr; justify-self: start; }
.player1-cards { grid-area: p1; }

/* ====================================
   PLAYER CARDS
   ==================================== */

.player-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.player-label {
    font-size: 0.7rem;
    letter-spacing: 2px;
    padding: 5px 15px;
    border-radius: 4px;
}

.player-label.centered {
    margin: 0 auto;
}

.player1-cards .player-label {
    color: var(--player1-primary);
    background: rgba(0, 240, 255, 0.1);
    border: 2px solid var(--player1-secondary);
}

.player2-cards .player-label {
    color: var(--player2-primary);
    background: rgba(255, 0, 255, 0.1);
    border: 2px solid var(--player2-secondary);
}

.cards-container {
    display: flex;
    gap: 15px;
}

/* ====================================
   CARDS
   ==================================== */

.card {
    width: var(--card-width);
    min-height: var(--card-height);
    height: auto;
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease, border-color 0.2s ease;
    position: relative;
    image-rendering: pixelated;
}

/* Player-specific card border colors */
.card[data-player="1"] {
    border-color: var(--player1-primary);
}

.card[data-player="2"] {
    border-color: var(--player2-primary);
}

/* River/neutral card border color */
.card[data-player="0"],
.river-card {
    border-color: #E0E0E0;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    border-radius: 5px;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.card.selected {
    border-color: #E0E0E0;
    box-shadow: 0 0 20px rgba(224, 224, 224, 0.4);
    transform: translateY(-8px) scale(1.05);
}

.card[data-player="1"].selected {
    border-color: var(--player1-primary);
    box-shadow: 0 0 20px var(--player1-glow);
}

.card[data-player="2"].selected {
    border-color: var(--player2-primary);
    box-shadow: 0 0 20px var(--player2-glow);
}

.card-name {
    font-size: 0.45rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 4px;
}

.card-cell {
    width: 16px;
    height: 16px;
    background: rgba(50, 50, 80, 0.5);
    border: 1px solid rgba(100, 100, 150, 0.3);
}

.card-cell.center {
    background: rgba(100, 100, 100, 0.8);
    border-color: rgba(150, 150, 150, 0.5);
}

.card-cell.move {
    background: var(--player1-primary);
    box-shadow: 0 0 8px var(--player1-glow);
    /* Smooth transition for color changes during animation */
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.card[data-player="2"] .card-cell.move {
    background: var(--player2-primary);
    box-shadow: 0 0 8px var(--player2-glow);
}

/* River cards use neutral silver color */
.card[data-player="0"] .card-cell.move,
.river-card .card-cell.move {
    background: #E0E0E0;
    box-shadow: 0 0 8px rgba(224, 224, 224, 0.4);
}

/* Only pulse the move cells when card is selected */
.card.selected .card-cell.move {
    animation: movePulse 1.5s ease-in-out infinite;
}

@keyframes movePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 12px currentColor; }
    50% { opacity: 0.6; box-shadow: 0 0 6px currentColor; }
}

.card-stamp {
    font-size: 0.4rem;
    margin-top: auto;
    padding: 2px 6px;
    border-radius: 2px;
}

.card[data-player="1"] .card-stamp {
    background: var(--player1-secondary);
    color: var(--player1-primary);
}

.card[data-player="2"] .card-stamp {
    background: var(--player2-secondary);
    color: var(--player2-primary);
}

/* River Card Container & Turn Text */
.river-card-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: var(--card-width);
    gap: 15px; /* Add space between card and turn text */
}

.river-turn-text {
    font-size: 0.6rem;
    letter-spacing: 2px;
    text-align: center;
    transition: all 0.3s ease;
    opacity: 0.5;
    white-space: nowrap;
    color: #1a1a2e; /* dark text to look "unlit" */
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.2);
}

#p1-turn-text.active {
    color: var(--player1-primary);
    -webkit-text-stroke: 0;
    opacity: 1;
    text-shadow: 0 0 10px currentColor;
    transform: scale(1.1);
}

#p2-turn-text.active {
    color: var(--player2-primary);
    -webkit-text-stroke: 0;
    opacity: 1;
    text-shadow: 0 0 10px currentColor;
    transform: scale(1.1);
}

.river-left {
    /* Left side river - for P2 to pick up (P1's discards) */
    order: -1;
}

.river-right {
    /* Right side river - for P1 to pick up (P2's discards) */
    order: 1;
}



.river-card {
    cursor: default;
    opacity: 0.7;
    border-color: #E0E0E0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Empty river slot styling */
.river-card.empty {
    opacity: 0.2;
    border-style: dashed;
}

/* River card on left faces Player 2 (rotated) */
.river-left .river-card {
    transform: rotate(180deg);
}

/* River card on right faces Player 1 (normal) */
.river-right .river-card {
    transform: rotate(0deg);
}


/* Player 2 cards face Player 2 (rotated 180deg) */
.player2-cards .card {
    transform: rotate(180deg);
}

/* For P2, negative translateY moves the card toward the board (down on screen) */
.player2-cards .card:hover {
    transform: rotate(180deg) translateY(-5px);
}

.player2-cards .card.selected {
    transform: rotate(180deg) translateY(-8px) scale(1.05);
}

/* Card slide animation classes */
.card.animating-out {
    position: fixed !important;
    z-index: 100;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.card.animating-in {
    animation: cardSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* ====================================
   GAME BOARD
   ==================================== */

.board-frame {
    background: var(--board-frame);
    padding: 20px;
    border-radius: 4px;
    box-shadow: 
        inset 0 2px 8px rgba(0, 0, 0, 0.7),
        0 8px 30px rgba(0, 0, 0, 0.9),
        0 0 40px rgba(0, 100, 180, 0.1);
    border: 3px solid var(--board-edge);
    image-rendering: pixelated;
}

.board {
    display: grid;
    grid-template-columns: repeat(5, var(--square-size));
    grid-template-rows: repeat(5, var(--square-size));
    gap: 2px;
    background: var(--board-edge);
    padding: 2px;
    border-radius: 2px;
    image-rendering: pixelated;
}

.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
}

.square.dark {
    background: var(--board-dark);
}

.square.light {
    background: var(--board-light);
}

/* wormhole Squares */
.square.wormhole {
    position: relative;
}

.square.wormhole .wormhole-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.4;
    image-rendering: pixelated;
    z-index: 0;
}

.square.wormhole.player1-wormhole .wormhole-canvas {
    filter: hue-rotate(0deg) drop-shadow(0 0 6px var(--player1-glow));
}

.square.wormhole.player2-wormhole .wormhole-canvas {
    filter: hue-rotate(0deg) drop-shadow(0 0 6px var(--player2-glow));
}

/* Valid Move Highlights */
.square.valid-capture {
    background: transparent !important;
}

.glow-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.9;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.square.valid-move {
    background: transparent !important;
}

.square:hover {
    filter: brightness(1.2);
}

/* ====================================
   PIECES - Pixel Art Space Samurai
   ==================================== */

.piece {
    --p-scale: 1;
    --p-rotate: 0deg;
    width: var(--piece-size);
    height: var(--piece-size);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1;
    position: relative;
    image-rendering: pixelated;
    transform: scaleX(var(--p-scale)) rotate(var(--p-rotate));
}

.piece:hover {
    transform: scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(1.15);
}

.piece.selected {
    animation: selectedBounce 0.5s ease-in-out infinite;
}

.piece.player1.selected {
    filter: drop-shadow(0 0 15px var(--player1-primary)) drop-shadow(0 0 30px var(--player1-glow));
}

.piece.player2.selected {
    filter: drop-shadow(0 0 15px var(--player2-primary)) drop-shadow(0 0 30px var(--player2-glow));
}

@keyframes selectedBounce {
    0%, 100% { transform: translateY(0) scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(1.1); }
    50% { transform: translateY(-5px) scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(1.15); }
}

/* Player 1 Pieces - Cyan Space Samurai */
.piece.player1 {
    filter: drop-shadow(0 0 8px var(--player1-glow));
    background-image: url('robot_samauri_blue.png');
    background-size: 500% 100%;
    animation: play-sprite 1s steps(5) infinite;
}

.piece.player1::before {
    content: '';
    color: var(--player1-primary);
    text-shadow: 
        0 0 10px var(--player1-primary),
        0 0 20px var(--player1-glow);
}


/* Player 2 Pieces - Red Space Samurai */
.piece.player2 {
    filter: drop-shadow(0 0 8px var(--player2-glow));
    background-image: url('red_stationary.png');
    background-size: 500% 100%;
    animation: play-sprite 1s steps(5) infinite;
    transform: scaleX(var(--p-scale)) rotate(var(--p-rotate));
}

.piece.player2::before {
    content: '';
}


/* Sprite Animation States */
@keyframes play-sprite {
    0% { background-position-x: 0px; }
    100% { background-position-x: calc(var(--piece-size) * -5); }
}

.piece.player1.is-moving {
    background-image: url('blue_moving.png');
}
.piece.player2.is-moving {
    background-image: url('red_moving.png');
}

.piece.player1.is-attacking {
    background-image: url('blue_attacking.png');
}
.piece.player2.is-attacking {
    background-image: url('red_attacking.png');
}

.piece.player1.is-defeated {
    animation: play-sprite 1s steps(5) infinite;
}
.piece.player2.is-defeated {
    animation: play-sprite 1s steps(5) infinite;
}

@keyframes play-sprite-once {
    0% { background-position-x: 0px; }
    100% { background-position-x: calc(var(--piece-size) * -5); }
}

/* Capture Animation */
.piece.captured {
    animation: captureExplosion 0.3s ease-out forwards;
}

@keyframes captureExplosion {
    0% { transform: scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(1); opacity: 1; }
    50% { transform: scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(1.5); opacity: 0.5; }
    100% { transform: scaleX(var(--p-scale)) rotate(var(--p-rotate)) scale(0); opacity: 0; }
}

/* Sliding Animation */
.piece.sliding {
    animation: slideMove 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    z-index: 10;
}

@keyframes slideMove {
    0% {
        transform: translate(0, 0) scaleX(var(--p-scale)) rotate(var(--p-rotate));
    }
    100% {
        transform: translate(var(--slide-x), var(--slide-y)) scaleX(var(--p-scale)) rotate(var(--p-rotate));
    }
}

/* ====================================
   TURN INDICATOR
   ==================================== */

.turn-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.6rem;
    letter-spacing: 2px;
    transition: all 0.3s ease;
}

.turn-indicator.player1-turn {
    background: rgba(0, 240, 255, 0.1);
    border: 2px solid var(--player1-primary);
    color: var(--player1-primary);
    box-shadow: 0 0 20px var(--player1-glow);
}

.turn-indicator.player2-turn {
    background: rgba(255, 0, 255, 0.1);
    border: 2px solid var(--player2-primary);
    color: var(--player2-primary);
    box-shadow: 0 0 20px var(--player2-glow);
}

/* ====================================
   VICTORY MODAL
   ==================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: modalFadeIn 0.3s ease;
}

.modal.show, .modal.active {
    display: flex;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, var(--board-dark) 0%, var(--card-bg) 100%);
    padding: 40px 60px;
    border-radius: 16px;
    text-align: center;
    border: 4px solid var(--wormhole-glow);
    box-shadow: 
        0 0 60px rgba(255, 215, 0, 0.4),
        inset 0 0 30px rgba(255, 215, 0, 0.1);
    animation: victoryPopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes victoryPopIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    font-size: 2rem;
    color: var(--wormhole-glow);
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    animation: victoryPulse 1s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.modal-content p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
    line-height: 1.8;
}

.victory-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.play-again-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    padding: 15px 30px;
    background: linear-gradient(180deg, var(--player1-primary) 0%, var(--player2-primary) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.play-again-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.4);
}

.play-again-btn:active {
    transform: translateY(0);
}

#victory-menu-btn {
    background: var(--card-bg);
    border: 2px solid var(--board-edge);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

#victory-menu-btn:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

/* ====================================
   MENU SCREEN
   ==================================== */

.menu-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px;
}

.menu-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    animation: fadeIn 0.3s ease;
}

.menu-stage.hidden {
    display: none;
}

.menu-title {
    font-size: 1.2rem;
    color: var(--wormhole-glow);
    text-shadow: 0 0 20px #E0E0E0;
    letter-spacing: 3px;
}

.mode-buttons {
    display: flex;
    gap: 30px;
}

.mode-btn {
    font-family: 'Press Start 2P', cursive;
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 280px;
    height: 180px;
}

.mode-btn:hover {
    border-color: var(--player1-primary);
    box-shadow: 0 0 30px var(--player1-glow);
    transform: translateY(-5px);
}

.mode-btn.selected {
    border-color: var(--wormhole-glow);
    box-shadow: 0 0 20px #E0E0E0;
    background: rgba(233, 232, 225, 0.1);
}

.mode-icon {
    font-size: 2.5rem;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mode-icon.animated-icon {
    display: grid;
    place-items: center;
}

.icon-frame {
    grid-area: 1 / 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    animation: fadeCycle 4s ease-in-out infinite;
}

.mode-icon-x {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 1.8rem;
}

.icon-frame-1 {
    animation-delay: 0s;
}

.icon-frame-2 {
    animation-delay: 2s;
    opacity: 0;
    font-size: 3.5rem; /* Larger to match the 3-character sequence */
}

@keyframes fadeCycle {
    0%, 35% { opacity: 1; }
    50%, 85% { opacity: 0; }
    100% { opacity: 1; }
}

.mode-text {
    font-size: 0.7rem;
    color: var(--text-primary);
}

.mode-sub {
    font-size: 0.5rem;
    color: var(--text-secondary);
}

/* Local play mode buttons: align content consistently between 1P (has sub) and 2P (no sub) */
#local-mode-stage .mode-btn {
    justify-content: center;
    gap: 12px;
}

#local-mode-stage #mode-2p .mode-text {
    margin-bottom: calc(0.5rem + 4px);
}

.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.start-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    padding: 20px 50px;
    background: var(--player1-secondary);
    border: 3px solid var(--player1-primary);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 15px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 4px 6px 0px rgba(0, 0, 0, 0.5), 0 0 20px var(--player1-glow);
    background: var(--player1-primary);
}

.start-btn:active {
    transform: translateY(2px);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.5);
}

.back-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    padding: 12px 30px;
    background: transparent;
    border: 2px solid var(--text-secondary);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.4);
}

.back-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

/* ====================================
   GAME SCREEN
   ==================================== */

.game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeIn 0.5s ease;
}

.game-screen.hidden {
    display: none;
}

.game-screen.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

/* ====================================
   GAME CONTROLS
   ==================================== */

.game-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.control-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    padding: 10px 15px;
    background: rgba(26, 26, 46, 0.9);
    border: 2px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(5px);
}

.control-btn:hover {
    border-color: var(--player1-primary);
    color: var(--text-primary);
    box-shadow: 0 0 15px var(--player1-glow);
}

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

.control-btn:disabled:hover {
    border-color: var(--card-border);
    color: var(--text-secondary);
    box-shadow: none;
}

.control-btn .btn-icon {
    font-size: 0.7rem;
}

#quit-btn:hover {
    border-color: #ff4444;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

/* ====================================
   CARD DEAL ANIMATION
   ==================================== */

.deal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
}

.deal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.deal-card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    transition: all 0.5s ease;
}

.card-back {
    background: linear-gradient(135deg, #1a1a3e 0%, #2a2a5e 50%, #1a1a3e 100%);
    border: 3px solid #E0E0E0;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-back::before {
    content: 'SS';
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem;
    background: linear-gradient(180deg, var(--player1-primary) 0%, var(--player2-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px var(--player1-glow);
    letter-spacing: 4px;
    animation: titlePulse 3s ease-in-out infinite;
}

.card-back::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 2px solid rgba(224, 224, 224, 0.3);
    border-radius: 5px;
}

/* Card Flip Animation */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
}

.flip-card-front {
    transform: rotateY(180deg);
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes dealToP1 {
    from {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes dealToP2 {
    from {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    to {
        transform: rotate(180deg);
        opacity: 0;
    }
}

@keyframes pieceFadeIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.piece.animating {
    animation: pieceFadeIn 0.3s ease forwards;
}

/* Utility class */
.hidden {
    display: none !important;
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (max-width: 768px) {
    :root {
        --square-size: 55px;
        --piece-size: 40px;
        --card-width: 100px;
        --card-height: 130px;
    }
    
    .game-header h1 {
        font-size: 1.5rem;
        letter-spacing: 4px;
    }
    
    .game-area {
        flex-direction: column;
    }
    
    .river-card-container {
        flex-direction: row;
    }
    
    .board-frame {
        padding: 12px;
    }
    
    .mode-buttons {
        flex-direction: column;
        gap: 20px;
    }
    
    .mode-btn {
        min-width: 200px;
    }
    
    .game-controls {
        bottom: 10px;
        right: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 200px;
        justify-content: flex-end;
    }
    
    .control-btn {
        padding: 8px 12px;
        font-size: 0.4rem;
    }
    
    .control-btn .btn-text {
        display: none;
    }
}

@media (max-width: 480px) {
    :root {
        --square-size: 45px;
        --piece-size: 32px;
        --card-width: 80px;
        --card-height: 100px;
    }
    
    .cards-container {
        gap: 8px;
    }
    
    .card-cell {
        width: 12px;
        height: 12px;
    }
    
    .menu-title {
        font-size: 0.9rem;
    }
    
    .mode-btn {
        padding: 20px 30px;
        min-width: 150px;
    }
    
    .mode-icon {
        font-size: 2rem;
    }
    
    .start-btn {
        font-size: 0.6rem;
        padding: 15px 30px;
    }
}

/* ====================================
   START PLAYER FLASH ANIMATION
   ==================================== */
.start-flash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
    pointer-events: none;
    z-index: 2000;
    opacity: 0;
    width: 100%;
    color: white;
    text-shadow: 0 0 20px currentColor, 0 0 40px currentColor;
    letter-spacing: 10px;
}

.start-flash.animate {
    animation: flashText 2s ease-out forwards;
}

@keyframes flashText {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    40% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* Empty Card Placeholder */
.card.placeholder {
    background: rgba(26, 26, 46, 0.4);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    box-shadow: none;
    cursor: default;
}

.card.placeholder::before {
    display: none;
}

.card.placeholder * {
    display: none;
}

/* Ensure animating cards are fully visible */
.card.animating-out {
    opacity: 1 !important;
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    z-index: 1000 !important;
    display: flex !important;
    flex-direction: column;
}

.card.animating-out .card-name,
.card.animating-out .card-grid {
    opacity: 1 !important;
    visibility: visible !important;
    display: block;
}

.card.animating-out .card-grid {
    display: grid;
}

/* ====================================
   MOBILE RESPONSIVE
   ==================================== */
@media (max-width: 768px) {
    :root {
        --square-size: 45px;
        --piece-size: 35px;
        --card-width: 75px;
        --card-height: 95px;
    }

    .game-layout {
        grid-template-areas:
            ". ind ."
            "rl p2 ."
            ". board ."
            ". p1 rr";
        gap: 15px 5px;
    }

    .player2-cards { align-self: end; }
    .river-left { justify-self: center; align-self: end; }
    .player1-cards { align-self: start; }
    .river-right { justify-self: center; align-self: start; }

    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .board-frame {
        padding: 5px;
        border-width: 3px;
    }
    
    .turn-indicator {
        grid-area: ind;
        position: static;
        transform: none;
        padding: 6px 12px;
        font-size: 0.5rem;
        width: max-content;
        margin: 0;
    }

    .card-grid {
        gap: 1px;
        padding: 2px;
    }
    .card-cell {
        width: 10px;
        height: 10px;
    }
    .card-name {
        font-size: 0.35rem;
        margin-bottom: 2px;
    }
    .card-stamp {
        font-size: 0.3rem;
        padding: 1px 4px;
        margin-top: 2px;
    }
    .player-label {
        font-size: 0.5rem;
        padding: 4px 10px;
    }
    .player-cards {
        gap: 5px;
    }
    .cards-container {
        gap: 8px;
    }
}
/* ====================================
   AUTH MODAL & SSO
   ==================================== */

.modal.active {
    display: flex !important;
    animation: fadeIn 0.3s ease forwards;
}

.auth-forms {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.auth-forms input {
    background: rgba(26, 26, 46, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 12px;
    color: white;
    font-family: inherit;
    font-size: 0.8rem;
}

.auth-divider {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin: 10px 0;
}

.sso-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sso-btn {
    padding: 12px;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sso-btn.google {
    background: #fff;
    color: #000;
}

.sso-btn.twitter {
    background: #000;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sso-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.auth-btn {
    background: var(--wormhole-glow);
    color: black;
    border: none;
    padding: 12px;
    border-radius: 4px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
}

.close-modal-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 15px;
    font-family: inherit;
    font-size: 0.6rem;
    cursor: pointer;
}

.auth-btn-row {
    display: flex;
    gap: 10px;
}

.auth-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* =========================================
   DASHBOARD / LOBBY CSS
   ========================================= */

#dashboard-stage {
    width: 600px;
    max-width: 95vw;
}

.dashboard-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    gap: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--player1-primary);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    flex: 1;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.stat-value {
    color: var(--player2-primary);
    font-size: 1.5rem;
    margin-bottom: 8px;
    text-shadow: 0 0 10px var(--player2-glow);
}

.stat-label {
    font-size: 0.6rem;
    color: var(--text-color);
    letter-spacing: 1px;
}

.dashboard-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.friend-match-box {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.half-width {
    flex: 1;
}

.join-friend-col {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.friend-input {
    width: 100%;
    padding: 15px 10px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--card-border);
    color: white;
    font-family: 'Press Start 2P', cursive;
    text-align: center;
    font-size: 1rem;
    border-radius: 8px;
    box-sizing: border-box;
    text-transform: uppercase;
}

.friend-input:focus {
    outline: none;
    border-color: var(--player2-primary);
    box-shadow: 0 0 15px var(--player2-glow);
}

.friend-match-bubble {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--card-border);
    border-radius: 12px;
    padding: 15px;
}

.code-input-animated {
    border-width: 3px !important;
    caret-color: var(--player1-primary);
}

.code-input-animated::placeholder {
    color: rgba(170, 170, 204, 0.4);
}

.mode-btn.small-btn {
    padding: 10px;
    height: auto;
    font-size: 0.8rem;
    min-width: 0;
    width: 100%;
}

#btn-ranked-match {
    width: 100%;
    height: 180px;
}

/* Waiting Screen */
.waiting-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--player2-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.waiting-text {
    text-align: center;
    color: var(--text-color);
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 30px;
}

/* =========================================
   BOARD PERSPECTIVE FIX (PLAYER 2)
   ========================================= */
.game-layout.perspective-p2 {
    grid-template-areas:
        ". p1 ."
        "rr board rl"
        ". p2 .";
}

.game-layout.perspective-p2 .board-frame {
    transform: rotate(180deg);
}

.game-layout.perspective-p2 .piece,
.game-layout.perspective-p2 .deal-card {
    --p-rotate: 180deg;
    transform: scaleX(var(--p-scale, 1)) rotate(var(--p-rotate));
}

.game-layout.perspective-p2 .player2-cards .card {
    transform: rotate(0deg); /* Counter the default 180deg */
}

.game-layout.perspective-p2 .player2-cards .card:hover {
    transform: rotate(0deg) translateY(-5px); /* Matches normal card hover up */
}

.game-layout.perspective-p2 .player2-cards .card.selected {
    transform: rotate(0deg) translateY(-8px) scale(1.05); /* Normal selected */
}

.game-layout.perspective-p2 .player1-cards .card {
    transform: rotate(180deg); /* Make opponent cards face them */
}

/* Also invert cards coming out of the deck during dealing */
.game-layout.perspective-p2 .deal-card.flipped {
    transform: rotateX(180deg) rotateZ(180deg);
}

/* =========================================
   TIMERS & MULTIPLAYER UI
   ========================================= */

.player-timer {
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.your-turn-badge {
    position: absolute;
    background: var(--wormhole-glow);
    color: black;
    padding: 4px 10px;
    font-size: 0.6rem;
    border-radius: 10px;
    font-weight: bold;
    animation: turnPulse 1.5s infinite;
    z-index: 10;
    white-space: nowrap;
}

#p1-turn-badge {
    top: -20px;
}

#p2-turn-badge {
    bottom: -20px;
    top: auto;
}

@keyframes turnPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px var(--wormhole-glow); }
    50% { transform: scale(1.1); box-shadow: 0 0 20px var(--wormhole-glow); }
}

.disconnect-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    backdrop-filter: blur(4px);
}

.disconnect-text {
    font-size: 1.2rem;
    line-height: 1.8;
}

.active-match-card {
    background: rgba(30, 30, 50, 0.8);
    border: 2px solid var(--wormhole-glow);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.active-match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
}

.match-info {
    font-size: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.match-vs {
    color: white;
}

.match-time {
    color: var(--text-secondary);
    font-size: 0.6rem;
}


/* Pixel Art Style Slider */
/* ====================================
   SETTING ROWS (Fuel, Difficulty, etc.)
   ==================================== */

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 350px;
    margin-top: 15px;
    height: 30px;
}

.setting-row + .setting-row {
    margin-top: 8px;
}

.setting-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
    white-space: nowrap;
    text-align: left;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-value {
    font-size: 0.75rem;
    color: var(--text-primary);
    width: 80px;
    text-align: left;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    height: 24px;
    flex-shrink: 0;
}

.infinity-symbol {
    display: inline-block;
    transform: scale(2.2);
    transform-origin: center;
    margin: 0 10px 0 6px;
}

/* 2P mode button head gap */
#mode-2p .mode-icon {
    gap: 6px;
}

input[type="range"].pixel-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    background: transparent;
    outline: none;
}

input[type="range"].pixel-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: var(--card-bg, #1a1a2e);
    border: 2px solid var(--neon-cyan, #333366);
    border-radius: 0;
}

input[type="range"].pixel-slider::-moz-range-track {
    width: 100%;
    height: 8px;
    background: var(--card-bg, #1a1a2e);
    border: 2px solid var(--neon-cyan, #333366);
    border-radius: 0;
}

input[type="range"].pixel-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--neon-cyan, #333366);
    border: 2px solid #444475;
    border-radius: 0;
    cursor: pointer;
    margin-top: -5px;
}

input[type="range"].pixel-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--neon-cyan, #333366);
    border: 2px solid #444475;
    border-radius: 0;
    cursor: pointer;
}

input[type="range"].pixel-slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
input[type="range"].pixel-slider:disabled::-webkit-slider-thumb {
    background: #666;
    border-color: #999;
}
input[type="range"].pixel-slider:disabled::-moz-range-thumb {
    background: #666;
    border-color: #999;
}
input[type="range"].pixel-slider:disabled::-webkit-slider-runnable-track {
    border-color: #666;
}
input[type="range"].pixel-slider:disabled::-moz-range-track {
    border-color: #666;
}

/* ====================================
   SUBSCRIPTION MODAL — compact Polar + X CTAs
   ==================================== */

.subscription-pay-options {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.subscription-close-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 22px;
}

/* Smaller hit box than default .back-btn; keep font size */
#subscription-modal .subscription-close-row .back-btn {
    padding: 6px 14px;
    gap: 6px;
    width: auto;
    max-width: min(130px, 100%);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.sub-polar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    min-height: 64px;
    padding: 8px 0 10px;
    box-sizing: content-box;
}

/* Override global .mode-btn (280×180) — plan chips */
#subscription-modal #polar-plan-buttons .sub-plan-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 102px;
    max-width: 118px;
    height: auto;
    min-height: 0;
    padding: 10px 8px 12px;
    gap: 4px;
    font-size: 0.48rem;
    line-height: 1.25;
    transform: none;
}

/* Light yellow / soft glow like “PLEASE SUBSCRIBE TO PLAY” title — not cyan */
#subscription-modal #polar-plan-buttons .sub-plan-btn:hover {
    border-color: #f0e68c;
    box-shadow:
        0 0 14px rgba(255, 215, 0, 0.5),
        0 0 22px rgba(224, 224, 224, 0.65);
    transform: translateY(-2px);
}

#polar-plan-buttons .sub-plan-btn .btn-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

#polar-plan-buttons .sub-plan-btn .sub-plan-line {
    display: block;
    width: 100%;
    white-space: nowrap;
}

#polar-plan-buttons .sub-plan-btn .sub-plan-price-row {
    color: #fff;
    font-size: 0.5rem;
}

#polar-plan-buttons .sub-plan-btn .sub-price-with-x {
    display: none;
    color: #7df9ff;
    margin-left: 6px;
    text-shadow: 0 0 8px rgba(125, 249, 255, 0.45);
}

#polar-plan-buttons.x-subscriber-active .sub-price-original {
    text-decoration: line-through;
    opacity: 0.55;
}

#polar-plan-buttons.x-subscriber-active .sub-price-with-x {
    display: inline;
}

#polar-plan-buttons .sub-plan-btn .sub-plan-period {
    color: rgba(170, 170, 204, 1);
    font-size: 0.44rem;
}

.section-top-narrow {
    margin-top: 10px;
}

.label-micro {
    font-size: 0.5rem;
    line-height: 1.5;
}

.sub-x-free-prompt {
    margin-top: 12px;
    margin-bottom: 6px;
    cursor: pointer;
}

#subscription-modal #x-sub-prompt p.label-micro {
    color: rgba(170, 170, 204, 1);
    text-decoration: underline;
    margin: 0;
}

/* Magenta CTA: short bar, not full .mode-btn height */
#subscription-modal .btn-subscribe-x-magenta {
    display: block;
    width: 100%;
    max-width: 320px;
    margin: 10px auto 0;
    height: auto;
    min-height: 0;
    padding: 10px 20px;
    gap: 0;
    font-size: 0.48rem;
    line-height: 1.25;
    border-radius: 6px;
    background: linear-gradient(180deg, var(--subscribe-x-magenta) 0%, var(--subscribe-x-magenta-dark) 100%);
    border: 2px solid #ff5fdb;
    color: #fff;
    box-shadow: 0 0 14px var(--subscribe-x-glow);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    transform: none;
}

#subscription-modal .btn-subscribe-x-magenta .btn-text {
    color: #fff;
}

#subscription-modal .btn-subscribe-x-magenta:hover {
    border-color: #ffb8f0;
    box-shadow:
        0 0 18px var(--subscribe-x-glow),
        0 0 36px rgba(224, 16, 184, 0.65);
    filter: brightness(1.07);
    transform: translateY(-2px);
}

#subscription-modal .btn-subscribe-x-magenta:active {
    filter: brightness(0.95);
}
