/* ═══════════════════════════════════════════════════════════════════════════
   CONSPIRACY MAHJONG — STYLESHEET
   Area 589 — Conspiracy Series 2 NFT Mahjong Solitaire
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-dark:       #050510;
    --bg-medium:     #0a0a1a;
    --bg-light:      #111128;
    --bg-card:       #16162e;
    --green:         #00ff41;
    --green-dim:     #00cc33;
    --green-glow:    rgba(0, 255, 65, 0.3);
    --orange:        #ff6600;
    --orange-glow:   rgba(255, 102, 0, 0.3);
    --purple:        #8b00ff;
    --cyan:          #00e5ff;
    --cyan-glow:     rgba(0, 229, 255, 0.25);
    --red:           #ff0044;
    --text:          #c0c0d0;
    --text-dim:      #505070;
    --tile-bg:       #1e1e38;
    --tile-face:     #2a2a52;
    --tile-border:   #4a4a7a;
    --tile-hover:    #353568;
    --tile-width:    110px;
    --tile-height:   135px;
    --font-display:  'Orbitron', sans-serif;
    --font-mono:     'Share Tech Mono', monospace;
}

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

/* Inline SVG icons */
.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    display: inline-block;
    flex-shrink: 0;
}
.icon-lg {
    width: 1.3em;
    height: 1.3em;
    vertical-align: -0.2em;
}

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: var(--font-mono);
    overflow: visible;
    height: 100vh;
    height: 100dvh;  /* dynamic viewport height for mobile browsers */
    width: 100vw;
    touch-action: auto;  /* allow pinch-zoom and scrolling */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

/* ── Scanline overlay ─────────────────────────────────────────────────── */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 255, 65, 0.008) 3px,
        rgba(0, 255, 65, 0.008) 6px
    );
    pointer-events: none;
    z-index: 9999;
}

/* ═══════════ LOADING SCREEN ═══════════ */

#loading-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.6s ease;
}

.loading-content {
    text-align: center;
}

.loading-icon {
    width: 140px;
    height: 140px;
    margin: 0 auto 10px;
    animation: rabbit-float 2.5s infinite ease-in-out;
    filter: drop-shadow(0 0 24px var(--green)) drop-shadow(0 0 60px rgba(0,255,65,0.25));
}

.loading-icon svg {
    width: 100%;
    height: 100%;
}

@keyframes rabbit-float {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-12px) scale(1.04); }
}

.loading-content h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    color: var(--green);
    text-shadow: 0 0 20px var(--green-glow);
    margin: 20px 0 5px;
    letter-spacing: 4px;
}

.loading-subtitle {
    color: var(--text-dim);
    font-size: 0.85rem;
    letter-spacing: 6px;
    text-transform: uppercase;
}

.loading-bar-wrapper {
    width: 320px;
    height: 4px;
    background: var(--bg-light);
    border-radius: 2px;
    margin: 30px auto 15px;
    overflow: hidden;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    border-radius: 2px;
    transition: width 0.2s ease;
}

.loading-text {
    color: var(--text-dim);
    font-size: 0.75rem;
}

/* ═══════════ GAME CONTAINER ═══════════ */

#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ═══════════ HEADER ═══════════ */

#game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--tile-border);
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
}

.header-left h1 {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--green);
    text-shadow: 0 0 10px var(--green-glow);
    letter-spacing: 2px;
}

.header-subtitle {
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 3px;
}

.header-center {
    display: flex;
    gap: 24px;
}

.stat-box {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.55rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 0.95rem;
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan-glow);
}

#match-trait {
    color: var(--orange);
    font-size: 0.75rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    gap: 8px;
}

/* ═══════════ BUTTONS ═══════════ */

.game-btn {
    background: var(--bg-light);
    border: 1px solid var(--tile-border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.game-btn:hover {
    border-color: var(--green);
    color: var(--green);
    box-shadow: 0 0 10px var(--green-glow);
}

.game-btn:active {
    transform: scale(0.95);
}

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

.game-btn:disabled:hover {
    border-color: var(--tile-border);
    color: var(--text);
    box-shadow: none;
}

.big-btn {
    padding: 14px 36px;
    font-size: 1.1rem;
    font-family: var(--font-display);
    letter-spacing: 2px;
    margin-top: 10px;
}

/* ═══════════ GAME BOARD ═══════════ */

#board-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    padding: 20px;
    touch-action: auto;  /* allow pinch-zoom */
    -webkit-overflow-scrolling: touch;
    background: radial-gradient(ellipse at center, #0d0d20 0%, #050510 70%);
}

#board {
    position: relative;
    transform-origin: center center;
}

/* ═══════════ TILES ═══════════ */

.tile {
    position: absolute;
    width: var(--tile-width);
    height: var(--tile-height);
    cursor: pointer;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        filter 0.15s ease;
    user-select: none;
    transform-style: preserve-3d;
}

/* ── Top face — NFT image fills the entire surface ── */
.tile-face {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    border: 2px solid #2a5a3a;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 2;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* Playable tiles glow — free tiles pulse green */
.tile.free .tile-face {
    border-color: rgba(0, 255, 65, 0.7) !important;
    box-shadow:
        0 0 12px rgba(0, 255, 65, 0.5),
        0 0 30px rgba(0, 255, 65, 0.25),
        0 0 50px rgba(0, 255, 65, 0.1),
        inset 0 0 8px rgba(0, 255, 65, 0.1) !important;
    animation: playable-pulse 1.8s ease-in-out infinite;
}

@keyframes playable-pulse {
    0%, 100% {
        box-shadow: 0 0 12px rgba(0,255,65,0.5), 0 0 30px rgba(0,255,65,0.25), 0 0 50px rgba(0,255,65,0.1), inset 0 0 8px rgba(0,255,65,0.1);
        border-color: rgba(0, 255, 65, 0.7);
    }
    50% {
        box-shadow: 0 0 20px rgba(0,255,65,0.7), 0 0 45px rgba(0,255,65,0.35), 0 0 70px rgba(0,255,65,0.15), inset 0 0 12px rgba(0,255,65,0.15);
        border-color: rgba(0, 255, 65, 0.9);
    }
}

/* ── Inset wrapper — edge-to-edge ── */
.tile-face .tile-inset {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

/* ── Right edge (3D side — bamboo green) ── */
.tile-side-right {
    position: absolute;
    top: 7px;
    right: -9px;
    width: 9px;
    height: 100%;
    background: linear-gradient(180deg, #2a5a3a 0%, #1a3a28 40%, #0e2818 100%);
    border-radius: 0 5px 5px 0;
    border: 1px solid #3a6a4a;
    border-left: none;
    z-index: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ── Bottom edge (3D base — bamboo green) ── */
.tile-side-bottom {
    position: absolute;
    bottom: -7px;
    left: 7px;
    width: 100%;
    height: 9px;
    background: linear-gradient(90deg, #1e4a30 0%, #143822 40%, #0c2818 100%);
    border-radius: 0 0 5px 5px;
    border: 1px solid #2a5a3a;
    border-top: none;
    z-index: 1;
}

/* ── Corner fill ── */
.tile-side-corner {
    position: absolute;
    bottom: -7px;
    right: -9px;
    width: 9px;
    height: 9px;
    background: #0c2818;
    border-radius: 0 0 5px 0;
    border: 1px solid #2a5a3a;
    border-top: none;
    border-left: none;
    z-index: 1;
}

/* ── Trait color bar — hidden (full-image tiles) ── */
.tile-face .tile-group-bar {
    display: none;
}

/* ── NFT image (inside the recessed inset) ── */
.tile-face .tile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    image-rendering: auto;
    display: block;
}

/* ── Tile label — small overlay at bottom of image ── */
.tile-face .tile-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #fff;
    background: linear-gradient(0deg, rgba(0,0,0,0.75) 0%, transparent 100%);
    letter-spacing: 1px;
    font-weight: bold;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* ── Tile states ─────────────────────────────────────────────────── */

/* Hover only on devices that support it (not touch) */
@media (hover: hover) and (pointer: fine) {
    .tile:hover {
        z-index: 5000 !important;
        transform: translateY(-16px) scale(2);
        filter: brightness(1.15) contrast(1.1) saturate(1.15) drop-shadow(0 12px 30px rgba(0,0,0,0.7)) !important;
    }
    .tile:hover .tile-face {
        border-color: var(--cyan);
        box-shadow:
            0 0 20px var(--cyan-glow),
            0 0 40px rgba(0, 229, 255, 0.15);
    }
    .tile:hover .tile-image {
        filter: brightness(1.2) contrast(1.1) saturate(1.2);
    }
    .tile:hover .tile-side-right {
        background: linear-gradient(180deg, #306844 0%, #1e4a30 100%);
        box-shadow: 0 0 8px rgba(0, 229, 255, 0.15);
    }
    .tile:hover .tile-side-bottom {
        background: linear-gradient(90deg, #285c3c 0%, #1a4a2e 100%);
        box-shadow: 0 0 8px rgba(0, 229, 255, 0.15);
    }
    .tile:hover .tile-label {
        opacity: 1;
    }
}

/* Touch devices: no hover, just active press feedback */
@media (hover: none) {
    .tile:active {
        transform: scale(1.05);
        filter: brightness(1.1) !important;
        z-index: 5000 !important;
    }
    .tile:active .tile-face {
        border-color: var(--cyan);
        box-shadow: 0 0 12px var(--cyan-glow);
    }
}

/* Covered: tile under another — no interaction */
.tile.covered {
    cursor: not-allowed;
    filter: brightness(0.35) saturate(0.2) blur(1px);
    pointer-events: none;
    opacity: 0.55;
}

/* Blocked: side-locked (hover ok, can't play) */
.tile.blocked {
    cursor: not-allowed;
    filter: brightness(0.4) saturate(0.15) grayscale(0.8);
    opacity: 0.5;
}

@media (hover: hover) and (pointer: fine) {
    .tile.blocked:hover {
        box-shadow: none;
        transform: none;
        filter: brightness(0.5) saturate(0.2) grayscale(0.7);
        opacity: 0.6;
    }
    .tile.blocked:hover .tile-face {
        border-color: #333;
        box-shadow: none;
    }
}

.tile.selected {
    transform: translateY(-6px) scale(1.1) !important;
    z-index: 5001 !important;
}
.tile.selected .tile-face {
    border-color: var(--green) !important;
    box-shadow:
        0 0 12px var(--green-glow),
        0 0 28px var(--green-glow),
        inset 0 0 6px rgba(0, 255, 65, 0.08) !important;
}

/* On touch devices, make selected tile even more obvious */
@media (hover: none) {
    .tile.selected {
        transform: translateY(-8px) scale(1.2) !important;
    }
    .tile.selected .tile-face {
        box-shadow:
            0 0 16px var(--green-glow),
            0 0 36px var(--green-glow),
            0 0 60px rgba(0, 255, 65, 0.15) !important;
    }
}

.tile.hint {
    z-index: 4999 !important;
    animation: hint-glow 1s ease-in-out infinite !important;
    transform: translateY(-8px) scale(1.15) !important;
    filter: brightness(1.3) saturate(1.3) !important;
}

.tile.hint .tile-face {
    border-color: var(--orange) !important;
    box-shadow:
        0 0 20px rgba(255, 102, 0, 0.7),
        0 0 40px rgba(255, 102, 0, 0.4),
        0 0 60px rgba(255, 102, 0, 0.2),
        inset 0 0 10px rgba(255, 102, 0, 0.15) !important;
}

.tile.matched {
    animation: match-pop 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
}

.tile.wrong {
    animation: wrong-shake 0.4s ease;
}

.tile.entering {
    animation: tile-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}

/* ── Tile animations ─────────────────────────────────────────────── */

@keyframes hint-glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 102, 0, 0.7), 0 0 40px rgba(255, 102, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 102, 0, 0.9), 0 0 60px rgba(255, 102, 0, 0.5), 0 0 80px rgba(255, 102, 0, 0.2);
    }
}

@keyframes match-pop {
    0%   { transform: scale(1); opacity: 1; }
    30%  { transform: scale(1.15); opacity: 0.9; }
    100% { transform: scale(0) rotate(15deg); opacity: 0; }
}

@keyframes wrong-shake {
    0%, 100% { transform: translateX(0); }
    15%, 55%, 85% { transform: translateX(-5px); }
    35%, 75% { transform: translateX(5px); }
}

@keyframes tile-enter {
    0%   { transform: scale(0) rotate(90deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

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

/* ═══════════ MATCH FLASH ═══════════ */

#match-flash {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 7000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.flash-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at center, rgba(0,255,65,0.25) 0%, rgba(0,0,0,0.6) 70%);
    animation: flash-bg-pulse 0.6s ease-out;
}

@keyframes flash-bg-pulse {
    0%   { opacity: 0; transform: scale(0.5); }
    50%  { opacity: 1; }
    100% { opacity: 1; transform: scale(1); }
}

.flash-inner {
    position: relative;
    text-align: center;
    animation: flash-slam 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flash-slam {
    0%   { opacity: 0; transform: scale(2.5) rotate(-2deg); }
    40%  { opacity: 1; transform: scale(0.95) rotate(0.5deg); }
    60%  { transform: scale(1.05) rotate(-0.3deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.flash-header {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--green);
    letter-spacing: 12px;
    text-shadow:
        0 0 30px var(--green-glow),
        0 0 80px rgba(0, 255, 65, 0.4),
        0 0 120px rgba(0, 255, 65, 0.2);
    margin-bottom: 16px;
    animation: flash-glitch 0.15s ease 0.3s 2;
}

@keyframes flash-glitch {
    0%   { transform: translate(0); }
    25%  { transform: translate(-3px, 1px); color: var(--cyan); }
    50%  { transform: translate(2px, -1px); color: var(--red); }
    75%  { transform: translate(-1px, 2px); color: var(--green); }
    100% { transform: translate(0); }
}

.flash-traits {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.flash-trait-row {
    display: flex;
    align-items: center;
    gap: 14px;
    animation: flash-trait-slide 0.4s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    background: rgba(0, 255, 65, 0.12);
    border: 1px solid rgba(0, 255, 65, 0.35);
    border-radius: 10px;
    padding: 10px 28px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@keyframes flash-trait-slide {
    0% { opacity: 0; transform: translateX(-30px); }
    100% { opacity: 1; transform: translateX(0); }
}

.flash-trait-type {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--cyan);
    letter-spacing: 3px;
    text-transform: uppercase;
    min-width: 120px;
    text-align: right;
    text-shadow: 0 0 12px var(--cyan-glow);
}

.flash-trait-divider {
    width: 4px;
    height: 24px;
    background: var(--green);
    border-radius: 2px;
    box-shadow: 0 0 12px var(--green-glow);
}

.flash-trait-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.4);
}

.flash-points {
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--orange);
    letter-spacing: 5px;
    text-shadow:
        0 0 30px var(--orange-glow),
        0 0 60px rgba(255, 102, 0, 0.3);
    animation: flash-points-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
}

@keyframes flash-points-pop {
    0% { opacity: 0; transform: scale(0.3); }
    100% { opacity: 1; transform: scale(1); }
}

.flash-combo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--red);
    letter-spacing: 6px;
    margin-top: 8px;
    text-shadow:
        0 0 20px rgba(255, 0, 68, 0.6),
        0 0 50px rgba(255, 0, 68, 0.3);
    animation: flash-combo-shake 0.3s ease 0.5s 3;
}

@keyframes flash-combo-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25%  { transform: translateX(-4px) rotate(-1deg); }
    75%  { transform: translateX(4px) rotate(1deg); }
}

/* Particles */
.flash-particles {
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    pointer-events: none;
}

.flash-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: particle-fly 1.2s ease-out forwards;
}

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

/* Fadeout for the entire flash */
#match-flash.fading-out {
    animation: flash-fade-out 0.6s ease forwards;
}

@keyframes flash-fade-out {
    0%   { opacity: 1; }
    100% { opacity: 0; transform: scale(1.05); }
}

/* ═══════════ NFT DETAIL PANEL ═══════════ */

#nft-detail {
    position: fixed;
    left: 16px;
    top: 70px;
    width: 220px;
    display: flex;
    flex-direction: column;
    gap: 0;
    z-index: 5000;
    pointer-events: none;
}

.preview-slot {
    background: var(--bg-medium);
    border: 1px solid var(--tile-border);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow:
        0 6px 32px rgba(0, 0, 0, 0.7),
        0 0 20px rgba(0, 229, 255, 0.08);
}

.preview-slot img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--tile-border);
}

.slot-info {
    text-align: center;
    margin-top: 8px;
}

.slot-info h3 {
    font-family: var(--font-display);
    color: var(--green);
    font-size: 0.95rem;
    text-shadow: 0 0 8px var(--green-glow);
}

.slot-info p {
    color: var(--orange);
    font-size: 0.65rem;
    margin-top: 3px;
    white-space: pre-line;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    text-align: left;
}

.preview-vs {
    text-align: center;
    font-family: var(--font-display);
    color: var(--cyan);
    font-size: 0.75rem;
    letter-spacing: 2px;
    padding: 8px 0;
    text-shadow: 0 0 10px var(--cyan-glow);
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.preview-vs.has-match {
    color: var(--green);
    text-shadow: 0 0 12px var(--green-glow);
}

.shared-trait {
    display: block;
    font-size: 0.7rem;
    color: var(--green);
    text-shadow: 0 0 8px var(--green-glow);
    letter-spacing: 1px;
}

/* ═══════════ MODALS ═══════════ */

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 8000;
    animation: modal-fade 0.3s ease;
}

@keyframes modal-fade {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

.modal-content {
    background: var(--bg-medium);
    border: 1px solid var(--tile-border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    max-width: 440px;
    animation: modal-scale 0.3s ease;
}

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

.modal-content h2 {
    font-family: var(--font-display);
    color: var(--green);
    font-size: 1.4rem;
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-dim);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Win modal */
.win-content {
    border-color: var(--green);
    box-shadow: 0 0 60px var(--green-glow);
}

.win-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 8px;
    filter: drop-shadow(0 0 20px var(--green));
    animation: rabbit-float 2.5s infinite ease-in-out;
}
.win-icon svg {
    width: 100%;
    height: 100%;
}

.win-subtitle {
    color: var(--text) !important;
    font-style: italic;
    font-size: 0.85rem !important;
}

.win-stats {
    display: flex;
    justify-content: center;
    gap: 36px;
    margin: 20px 0;
}

.win-stat { text-align: center; }

.win-stat-label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.win-stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 1.4rem;
    color: var(--cyan);
    text-shadow: 0 0 10px var(--cyan-glow);
}

/* ═══════════ MOBILE SELECTION CHIP (hidden on desktop) ═══════════ */

#mobile-selection {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--green-dim);
    padding: 6px 12px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
}

.mobile-sel-tile {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 1;
    min-width: 0;
}

.mobile-sel-tile img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid var(--green-dim);
    object-fit: cover;
    flex-shrink: 0;
}

.mobile-sel-tile span {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mobile-sel-vs {
    font-family: var(--font-display);
    font-size: 0.6rem;
    color: var(--text-dim);
    letter-spacing: 1px;
    flex-shrink: 0;
}

#mobile-sel-result {
    font-family: var(--font-display);
    font-size: 0.55rem;
    letter-spacing: 1px;
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 4px;
}

#mobile-sel-result.match {
    color: var(--green);
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--green-dim);
}

#mobile-sel-result.no-match {
    color: var(--red);
    background: rgba(255, 0, 68, 0.1);
    border: 1px solid var(--red);
}

/* ═══════════ FOOTER ═══════════ */

#game-footer {
    padding: 6px 20px;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-dim);
    background: var(--bg-medium);
    border-top: 1px solid var(--tile-border);
    letter-spacing: 2px;
    flex-shrink: 0;
}

/* ═══════════ SCROLLBAR ═══════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--tile-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green); }

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 1400px) {
    :root {
        --tile-width: 90px;
        --tile-height: 112px;
    }
    .header-center { gap: 14px; }
    .stat-value { font-size: 0.8rem; }
    #match-trait { max-width: 120px; font-size: 0.65rem; }
}

@media (max-width: 1000px) {
    :root {
        --tile-width: 74px;
        --tile-height: 92px;
    }
    .header-left h1 { font-size: 0.8rem; }
    .header-center { gap: 10px; }
    .stat-label { font-size: 0.5rem; }
    .stat-value { font-size: 0.7rem; }
    .tile-side-right { width: 7px; right: -7px; top: 5px; }
    .tile-side-bottom { height: 7px; bottom: -5px; left: 5px; }
    .tile-side-corner { width: 7px; height: 7px; right: -7px; bottom: -5px; }
}

/* ═══════════ TABLET (iPad portrait / landscape) ═══════════ */

@media (max-width: 820px) {
    :root {
        --tile-width: 62px;
        --tile-height: 78px;
    }

    #game-header {
        padding: 6px 12px;
        height: auto;
        flex-wrap: wrap;
        gap: 4px;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        justify-content: space-between;
    }

    .header-left h1 { font-size: 0.75rem; letter-spacing: 1px; }
    .header-subtitle { display: none; }

    .header-center {
        width: 100%;
        justify-content: center;
        gap: 10px;
        order: 3;
    }

    .header-right {
        position: absolute;
        right: 12px;
        top: 6px;
    }

    .stat-box { min-width: auto; }
    .stat-label { font-size: 0.45rem; }
    .stat-value { font-size: 0.65rem; }

    .game-btn { padding: 5px 8px; font-size: 0.75rem; }

    #board-wrapper { padding: 10px; }

    /* Preview panel — side panel too big, shrink it */
    #nft-detail {
        width: 160px;
        left: 8px;
        top: auto;
        bottom: 50px;
    }
    .preview-slot img { width: 140px; height: 140px; }
    .slot-info h3 { font-size: 0.75rem; }
    .slot-info p { font-size: 0.55rem; max-height: 60px; }

    .tile-side-right { width: 5px; right: -5px; top: 4px; }
    .tile-side-bottom { height: 5px; bottom: -4px; left: 4px; }
    .tile-side-corner { width: 5px; height: 5px; right: -5px; bottom: -4px; }

    .modal-content { padding: 28px 20px; max-width: 360px; }
    .big-btn { padding: 12px 28px; font-size: 0.95rem; }
}

/* ═══════════ PHONE (iPhone / small Android) ═══════════ */

@media (max-width: 480px) {
    :root {
        --tile-width: 62px;
        --tile-height: 78px;
    }

    /* Ultra-compact single-line header */
    #game-header {
        padding: 2px 8px;
        padding-top: max(2px, env(safe-area-inset-top));
        height: auto;
        min-height: 36px;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .header-left { flex-shrink: 1; min-width: 0; }
    .header-left h1 { font-size: 0.55rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .header-subtitle { display: none; }

    .header-center {
        gap: 6px;
        flex-shrink: 0;
    }

    .stat-box { min-width: auto; }
    .stat-label { display: none; }
    .stat-value { font-size: 0.6rem; }
    #match-trait { max-width: 55px; font-size: 0.5rem; }

    .game-btn {
        padding: 4px 6px;
        font-size: 0.7rem;
        min-width: 32px;
    }

    .header-right {
        position: static;
        gap: 3px;
        flex-shrink: 0;
    }

    /* Scrollable board — no shrink-to-fit */
    #board-wrapper {
        padding: 8px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        align-items: flex-start;
        justify-content: flex-start;
    }

    /* Hide the desktop preview panel entirely on mobile */
    #nft-detail { display: none !important; }

    /* Mobile floating selection chip */
    #mobile-selection {
        display: flex !important;
    }

    .tile-side-right { width: 4px; right: -4px; top: 3px; }
    .tile-side-bottom { height: 4px; bottom: -3px; left: 3px; }
    .tile-side-corner { width: 4px; height: 4px; right: -4px; bottom: -3px; }

    /* Loading screen on phone */
    .loading-icon { width: 90px; height: 90px; }
    .loading-content h1 { font-size: 1.3rem; letter-spacing: 2px; }
    .loading-subtitle { font-size: 0.65rem; letter-spacing: 3px; }
    .loading-bar-wrapper { width: 240px; }

    /* Modals on phone */
    .modal-content { padding: 24px 16px; max-width: 320px; }
    .modal-content h2 { font-size: 1.1rem; }
    .big-btn { padding: 12px 24px; font-size: 0.9rem; }
    .win-icon { width: 70px; height: 70px; }
    .win-stat-value { font-size: 1.1rem; }

    /* Hide footer on phones */
    #game-footer { display: none; }

    /* Match flash on phones */
    .flash-header { font-size: 1.6rem; letter-spacing: 6px; }
    .flash-trait-type { font-size: 0.75rem; min-width: 70px; }
    .flash-trait-value { font-size: 1rem; }
    .flash-trait-row { padding: 8px 16px; }
    .flash-points { font-size: 2rem; }
    .flash-combo { font-size: 1rem; }
}

/* ═══════════ VERY SMALL PHONES (iPhone SE etc.) ═══════════ */

@media (max-width: 375px) {
    :root {
        --tile-width: 52px;
        --tile-height: 66px;
    }

    .header-left h1 { font-size: 0.5rem; }
    .stat-value { font-size: 0.55rem; }
    .game-btn { padding: 3px 5px; font-size: 0.65rem; }

    .tile-side-right { width: 3px; right: -3px; top: 2px; }
    .tile-side-bottom { height: 3px; bottom: -2px; left: 2px; }
    .tile-side-corner { width: 3px; height: 3px; right: -3px; bottom: -2px; }
}

/* ═══════════ LANDSCAPE PHONE ═══════════ */

@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --tile-width: 40px;
        --tile-height: 50px;
    }

    #game-header {
        height: 36px;
        padding: 2px 10px;
        flex-wrap: nowrap;
    }

    .header-left h1 { font-size: 0.6rem; }
    .header-subtitle, #game-footer { display: none; }
    .header-center { gap: 8px; order: 0; width: auto; }
    .header-right { position: static; }

    .stat-label { font-size: 0.4rem; }
    .stat-value { font-size: 0.55rem; }

    #board-wrapper { padding: 4px; }

    /* Hide desktop preview, show mobile chip in landscape too */
    #nft-detail { display: none !important; }
    #mobile-selection { display: flex !important; }

    .tile-side-right { width: 3px; right: -3px; top: 2px; }
    .tile-side-bottom { height: 3px; bottom: -2px; left: 2px; }
    .tile-side-corner { width: 3px; height: 3px; right: -3px; bottom: -2px; }

    .modal-content { padding: 16px; max-width: 300px; }
    .big-btn { padding: 10px 20px; font-size: 0.85rem; }
}
