/* ═══════════════════════════════════════════════════════
   BEAKS NFT PUZZLE — Production CSS
   Author: ExpatQ3
═══════════════════════════════════════════════════════ */

:root {
    --bg:         #07070a;
    --bg2:        #0f0f15;
    --card:       rgba(255,255,255,0.04);
    --border:     rgba(255,255,255,0.09);
    --gold:       #e8c16a;
    --gold-glow:  rgba(232,193,106,0.25);
    --white:      #f2f2f5;
    --muted:      #888;
    --danger:     #e05555;
    --radius:     16px;
    --tile:       90px;            /* puzzle tile size */
    --tile-sm:    70px;
    --trans:      all 0.35s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--white);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    overflow: hidden;          /* screens manage their own scroll */
}

img { display:block; max-width:100%; }
button { cursor:pointer; font-family:inherit; }

/* ─── Screen Layer ────────────────────────────────── */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.55s ease;
}

.screen.scrollable {
    overflow-y: auto;
    overflow-x: hidden;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
}

/* Tap-to-start overlay */
.tap-start {
    position: absolute;
    inset: 0;
    background: rgba(7,7,10,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    cursor: pointer;
    transition: opacity 0.4s;
}

.tap-hint {
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    animation: tapPulse 1.6s ease-in-out infinite;
}

@keyframes tapPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.97); }
}

.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    display: none !important;
}

/* ─── Footer ──────────────────────────────────────── */
.site-footer {
    width: 100%;
    text-align: center;
    padding: 1.2rem;
    color: var(--muted);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   PHASE 0 — Book Flip
═══════════════════════════════════════════════════ */
#book-flip-screen {
    background: #000;
    perspective: 1200px;
}

.flip-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
}

.flip-book {
    width: clamp(220px, 38vw, 380px);
    height: clamp(280px, 50vw, 500px);
    position: relative;
    transform-style: preserve-3d;
}

.flip-page {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    overflow: hidden;
    transform-origin: left center;
    backface-visibility: hidden;
    transition: transform 0.35s cubic-bezier(.645,.045,.355,1);
    border: 1px solid #222;
    box-shadow: 6px 0 20px rgba(0,0,0,0.6);
}

.flip-page img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flip-page.flipped {
    transform: rotateY(-170deg);
}

.flip-cover {
    background: linear-gradient(145deg, #111 0%, #1a1a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-text { text-align: center; }
.cover-text h2 {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    color: var(--gold);
    letter-spacing: 0.08em;
}
.cover-text p {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.4rem;
}

.btn-skip {
    position: absolute;
    bottom: 28px;
    right: 28px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.45rem 1.2rem;
    border-radius: 40px;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    transition: var(--trans);
    z-index: 100;
}
.btn-skip:hover { color: var(--white); border-color: var(--white); }

/* ═══════════════════════════════════════════════════
   PHASE 1 — Video (fills screen, no wrapper needed)
═══════════════════════════════════════════════════ */
#video-screen {
    background: #000;
    padding: 0;
}

#intro-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* ═══════════════════════════════════════════════════
   PHASE 2 — Landing
═══════════════════════════════════════════════════ */
#intro-screen {
    background: radial-gradient(ellipse at 50% 30%, rgba(232,193,106,0.06) 0%, transparent 65%), var(--bg);
}

.landing-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    padding: 2rem;
    flex: 1;
    flex-wrap: wrap;
}

.hero-ring {
    width: clamp(220px, 35vw, 420px);
    height: clamp(220px, 35vw, 420px);
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--gold);
    box-shadow: 0 0 60px var(--gold-glow);
    animation: heroGlow 4s ease-in-out infinite alternate;
    flex-shrink: 0;
    position: relative;
}

.hero-ring img { width:100%; height:100%; object-fit:cover; }

/* Hero Carousel */
.hero-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1.2s ease-in-out;
}

.hero-slide.active {
    opacity: 1;
}

@keyframes heroGlow {
    from { box-shadow: 0 0 40px var(--gold-glow); }
    to   { box-shadow: 0 0 80px var(--gold-glow), 0 0 120px rgba(232,193,106,0.1); }
}

.landing-copy { max-width: 480px; }

.brand-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    font-weight: 900;
    letter-spacing: 0.05em;
    line-height: 1;
    color: var(--white);
}

.brand-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    color: var(--muted);
    margin: 0.5rem 0 1.5rem;
    font-weight: 400;
}

.brand-founder { color: var(--gold); font-weight: 600; }

.brand-desc {
    color: #aaa;
    font-size: 0.95rem;
    margin-bottom: 2.5rem;
    max-width: 380px;
}

/* ═══════════════════════════════════════════════════
   PHASE 3 — Setup / Gallery  (true scrollable page)
═══════════════════════════════════════════════════ */
#setup-screen {
    background: var(--bg);
    align-items: stretch;
}

.setup-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem 2rem;
    /* no flex:1 / no min-height:0 — let content determine height */
}

.page-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.8rem;
    letter-spacing: 0.04em;
}

.setup-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;   /* panels take their natural height */
}

.setup-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.panel-head h3 {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.3rem;
}
.panel-head p { color: var(--muted); font-size: 0.85rem; }

/* ─── Gallery: Full-height scrollable bordered section ── */
.panel-gallery {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.2rem;
    padding: 0.5rem;
    max-height: 65vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.gallery-grid::-webkit-scrollbar { width: 5px; }
.gallery-grid::-webkit-scrollbar-track { background: rgba(255,255,255,0.02); border-radius: 4px; }
.gallery-grid::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }
.gallery-grid::-webkit-scrollbar-thumb:hover { background: rgba(232,193,106,0.7); }

.gallery-item {
    display: flex;
    flex-direction: column;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--trans);
    background: #111;
    /* NO positioning that could cause overlap */
}

.gallery-item:hover { border-color: rgba(232,193,106,0.5); transform: translateY(-2px); }
.gallery-item.selected { border-color: var(--gold); }

.gallery-item-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.gallery-item-name {
    padding: 0.4rem 0.5rem;
    font-size: 0.65rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #0e0e12;
    text-align: center;
}

.gallery-item.selected .gallery-item-name { color: var(--gold); }

/* ─── Sidebar ────────────────────────────────────── */
.panel-sidebar {
    gap: 1rem;
    position: relative;
}

.btn-back-mobile {
    display: none; /* hidden on desktop */
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: var(--trans);
}
.btn-back-mobile:hover { background: var(--gold); color: #000; }

.selected-preview-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #0e0e12;
    border: 1px dashed var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.preview-placeholder {
    color: var(--muted);
    font-size: 0.8rem;
}

#setup-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.artist-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gold);
    background: rgba(232,193,106,0.08);
    border: 1px solid var(--gold-glow);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    text-align: center;
}

/* ═══════════════════════════════════════════════════
   PHASE 2 — Map Screen
═══════════════════════════════════════════════════ */
#map-screen {
    background: url('../assets/beaks_map.png') center/cover no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
}

#map-screen::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 10, 14, 0.6); /* Darken the map background slightly */
    z-index: 1;
    pointer-events: none; /* Let clicks pass through to the nodes */
}

.map-container {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1000px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.map-title {
    color: var(--gold);
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(232, 193, 106, 0.4);
}

.map-subtitle {
    color: var(--muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.map-nodes-container {
    flex: 1;
    width: 100%;
    position: relative;
}

/* Map Nodes */
.map-node {
    position: absolute;
    z-index: 5;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(10, 10, 14, 0.8);
    border: 2px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--white);
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--trans);
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    overflow: visible;
    padding: 0;
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.map-node-label {
    position: absolute;
    bottom: -30px;
    font-size: 0.8rem;
    color: var(--gold);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'Playfair Display', serif;
    text-shadow: 0 0 5px #000;
    pointer-events: none;
}

.map-node:hover:not(.locked):not(:disabled) {
    transform: translate(-50%, -50%) scale(1.1);
    border-color: var(--gold);
    box-shadow: 0 0 30px rgba(232, 193, 106, 0.4);
}

.map-node.unlocked {
    border-color: var(--gold);
    color: var(--gold);
}

.map-node.active-glow {
    animation: nodePulse 2s infinite;
}

@keyframes nodePulse {
    0% { box-shadow: 0 0 0 0 rgba(232, 193, 106, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(232, 193, 106, 0); }
    100% { box-shadow: 0 0 0 0 rgba(232, 193, 106, 0); }
}

.map-node.locked,
.map-node:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(30, 30, 30, 0.8);
    border-color: #333;
    color: #666;
}

/* SVG Path connecting nodes */
.map-path {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.map-path path {
    fill: none;
    stroke: rgba(232, 193, 106, 0.2);
    stroke-width: 4px;
    stroke-dasharray: 10;
    animation: dash 30s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -1000;
    }
}

/* X Handle Input */
.x-handle-wrap {
    margin-bottom: 1.5rem;
}

.x-handle-label {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.x-handle-input-group {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.6rem 1rem;
    transition: var(--trans);
    max-width: 300px;
    margin: 0 auto;
}

.x-handle-input-group:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(232, 193, 106, 0.2);
}

.x-handle-prefix {
    color: var(--gold);
    font-weight: 700;
    font-size: 1rem;
    margin-right: 0.3rem;
}

.x-handle-field {
    background: none;
    border: none;
    outline: none;
    color: var(--white);
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
}

.x-handle-field::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* Map Header Row */
.map-header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    width: 100%;
    flex-wrap: wrap;
}

.map-leaderboard-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    font-size: 0.8rem !important;
    padding: 0.5rem 1.2rem !important;
    white-space: nowrap;
}

/* Leaderboard Rows */
.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--trans);
}

.leaderboard-item:hover {
    background: rgba(232, 193, 106, 0.05);
}

.leaderboard-item .lb-rank {
    font-weight: 800;
    color: var(--gold);
    width: 30px;
}

.leaderboard-item .lb-pfp {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-item .lb-user {
    flex: 1;
    font-weight: 600;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.leaderboard-item .lb-level {
    color: var(--gold);
    font-size: 0.8rem;
    border: 1px solid var(--gold);
    padding: 2px 6px;
    border-radius: 4px;
}

.leaderboard-item .lb-time {
    color: var(--muted);
    font-family: monospace;
    font-size: 1.1rem;
}

.launch-btn { width: 100%; margin-top: 1rem; }

/* ═══════════════════════════════════════════════════
   PHASE 4 — Game (side-by-side desktop, stacked mobile)
═══════════════════════════════════════════════════ */
#game-screen {
    background: var(--bg);
    align-items: stretch;
}

.game-inner {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.game-header { text-align: center; width: 100%; }

.game-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    letter-spacing: 0.05em;
}

.game-artist { color: var(--gold); font-size: 0.85rem; margin: 0.3rem 0; }

.timer-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 0.5rem 1.5rem;
    margin-top: 0.5rem;
}

.timer-label { font-size: 0.65rem; letter-spacing: 0.15em; color: var(--muted); }

#timer {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
    transition: color 0.3s;
}

#timer.danger { color: var(--danger); }

/* Game Body: side-by-side on desktop */
.game-body {
    display: flex;
    gap: 1rem;
    width: 100%;
    max-width: 820px;
    align-items: flex-start;
    justify-content: center;
    margin: 0 auto;
}

/* Puzzle area fills remaining space next to target */
.puzzle-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Target card sits to the right on desktop */
.target-side {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    position: sticky;
    top: 1rem;
}

.target-side h4 {
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    color: var(--gold);
    margin-bottom: 0.8rem;
    text-align: center;
}

.target-side img {
    width: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Puzzle Board */
.puzzle-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 4px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    width: 100%;
    max-width: min(480px, calc(100vh - 240px));
    aspect-ratio: 1 / 1;
}

.tile {
    width: 100%;
    height: 100%;
    border-radius: 5px;
    cursor: pointer;
    transition: filter 0.18s, transform 0.12s;
    position: relative;
    user-select: none;
}

.tile:hover { filter: brightness(1.25); transform: scale(1.02); z-index: 2; }
.tile.movable {
    box-shadow: inset 0 0 0 1px rgba(232, 193, 106, 0.3);
}
.tile.movable:hover {
    box-shadow: inset 0 0 0 2px var(--gold);
    filter: brightness(1.3);
    transform: scale(1.03);
    z-index: 3;
}

.empty-slot {
    background: rgba(255,255,255,0.03) !important;
    border: 1px dashed var(--border);
    cursor: default;
}
.empty-slot:hover { filter: none !important; transform: none !important; }

.tile-number {
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(0,0,0,0.65);
    color: var(--gold);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* Controls row below puzzle */
.game-controls-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    padding-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════
   PHASE 5 — Completion Overlay
═══════════════════════════════════════════════════ */
.overlay-screen {
    position: fixed;
    inset: 0;
    background: rgba(5,5,8,0.93);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.overlay-content {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 480px;
}

.overlay-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: rgba(232,193,106,0.12);
    border: 2px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--gold);
    margin: 0 auto 1.5rem;
}

.overlay-icon.fail { border-color: var(--danger); color: var(--danger); background: rgba(224,85,85,0.12); }

#status-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    margin-bottom: 0.8rem;
}

#status-text {
    color: var(--muted);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.overlay-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Art preview in completion overlay */
.overlay-art-preview {
    margin: 1.2rem auto 1.5rem;
    max-width: 220px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px var(--gold-glow);
}

.overlay-art-preview img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

/* ═══════════════════════════════════════════════════
   BUTTONS — Unified System
═══════════════════════════════════════════════════ */
.btn-primary {
    background: var(--gold);
    color: #07070a;
    border: none;
    padding: 0.85rem 2rem;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    transition: var(--trans);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px var(--gold-glow); }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--border);
    padding: 0.7rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: var(--trans);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn-secondary:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-secondary.active { background: var(--gold); color: #000; border-color: var(--gold); }

/* Back Button & Header System */
.btn-back-link {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: var(--trans);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-back-link:hover {
    color: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(232, 193, 106, 0.15);
}

.btn-back-top {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 100;
}

.setup-header-row {
    position: relative;
    width: 100%;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.setup-header-row .btn-back-link {
    position: absolute;
    left: 0;
}

.header-actions {
    position: absolute;
    right: 0;
    display: flex;
    gap: 0.8rem;
    align-items: center;
}

.setup-header-row .page-title {
    margin: 0;
}

@media (max-width: 900px) {
    .setup-header-row {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    .setup-header-row .btn-back-link,
    .header-actions {
        position: static;
        width: 100%;
        justify-content: center;
    }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .setup-layout { grid-template-columns: 1fr; }
    .panel-sidebar { flex-direction: column; }
    .selected-preview-box { width: 100%; aspect-ratio: 16/9; }

    /* Tablet: stack game vertically and center */
    .game-body {
        flex-direction: column;
        align-items: center;
    }

    .puzzle-area {
        width: 100%;
    }

    .target-side {
        width: 100%;
        max-width: 480px;
        position: static;
    }

    .puzzle-grid {
        max-width: min(480px, calc(100vh - 280px));
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .landing-wrap { flex-direction: column; text-align: center; gap: 1.5rem; padding: 1.5rem; }
    .hero-ring { width: 200px; height: 200px; }
    .brand-desc { margin: 0 auto 1.5rem; }

    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 0.7rem; max-height: 55vh; }

    .setup-inner { padding: 1.2rem 1rem 1.5rem; }
    .setup-layout { grid-template-columns: 1fr; gap: 1rem; }

    /* Map Screen Mobile Fixes */
    .map-header-row {
        flex-direction: column;
        gap: 0.5rem;
        padding-top: 3.5rem;
    }
    .map-leaderboard-btn {
        position: static;
        width: auto;
    }
    .map-title {
        font-size: 1.4rem;
        margin-bottom: 0;
    }
    .map-subtitle {
        font-size: 0.85rem;
        margin-top: 0;
    }
    .map-node-label {
        font-size: 0.65rem;
        bottom: -22px;
    }

    /* Mobile: hide sidebar by default, show when .mobile-active */
    .panel-sidebar {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 800;
        background: var(--bg);
        border: none;
        border-radius: 0;
        padding: 1.5rem;
        overflow-y: auto;
        flex-direction: column;
        animation: slideUp 0.35s ease;
    }

    .panel-sidebar.mobile-active {
        display: flex;
    }

    .btn-back-mobile {
        display: inline-flex;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0); opacity: 1; }
    }

    /* Game: stack vertically on mobile */
    .game-inner { max-width: 100%; padding: 1rem 0.6rem 1.5rem; }

    .game-body {
        flex-direction: column-reverse;
        gap: 1rem;
    }

    .target-side {
        width: 100%;
        position: static;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 1rem;
    }

    .target-side h4 {
        margin-bottom: 0.3rem;
        writing-mode: horizontal-tb;
        text-orientation: mixed;
    }

    .target-side img {
        max-height: 200px;
        width: auto;
        max-width: 100%;
    }

    .puzzle-grid {
        max-width: min(100%, calc(100vh - 340px));
    }
}

@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .page-title { font-size: 1.3rem; }
    .brand-title { font-size: 2.4rem; }
    .game-title { font-size: 1.2rem; }

    .target-side img { max-height: 160px; }
    
    .puzzle-grid {
        max-width: min(100%, calc(100vh - 380px));
    }
}

/* ──────────────────────────────────────────────────────
   DIFFICULTY OPTIONS
   ────────────────────────────────────────────────────── */
.difficulty-section {
    width: 100%;
    margin: 1.2rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-section h4 {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--muted);
    text-transform: uppercase;
}

.difficulty-options {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.diff-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 0.6rem 0.5rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.05em;
}

.diff-btn:hover {
    border-color: rgba(232, 193, 106, 0.4);
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.diff-btn.active {
    background: rgba(232, 193, 106, 0.1);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 0 15px rgba(232, 193, 106, 0.15);
}

