:root {
    --bg-dark: #000000;
    --panel-bg: #2a221b;
    --panel-bg-gradient: linear-gradient(135deg, #3d3024 0%, #1a140f 100%);
    --panel-border: #8b5a2b;
    --panel-border-hover: #a06b3a;
    --panel-border-inner: #d7b586;
    --gold: #dfb256;
    --gold-bright: #ffdf80;
    --wood-color: #5c4033;
    --stone-color: #555555;
    --text-light: #f4e8d3;
    --text-muted: #bdae93;
    --text-dim: #8b7d6b;
    --warning: #d9784a;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Outfit', sans-serif;
    --font-numbers: 'Roboto Mono', monospace;
    --ui-scale: 1;
}

/* UI scale (Settings → +/-): zoom instead of transform:scale on purpose — zoom resizes an
   element from its own box (no transform-origin bookkeeping needed per panel, which matters
   here since every panel below is anchored to a different corner/edge, and several are
   independently draggable), and it never touches #gameCanvas, so none of the click/touch
   world-coordinate math is affected. Cascades naturally to descendants (e.g. #topBar's mobile
   children that escape it via position:fixed still zoom with it).
   #minimapContainer is deliberately NOT here: its own resize handle (#minimapResizeHandle, see
   initMinimapResize() in main.js) keeps it square by writing width/height directly in screen
   px — mixing that with an inherited zoom is the same rect-vs-style mismatch that made the old
   draggable HUD elements drift, except here it would fight its own square-enforcement instead. */
.game-ui,
#btnSettings {
    zoom: var(--ui-scale);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-body);
    font-size: 14px;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
    /* NOTE: touch-action is NOT simple override/inheritance — the browser computes the allowed
       gestures as the INTERSECTION of the value on the touched element AND every ancestor. So
       touch-action:none here would make it impossible for ANY descendant (build bar's h-scroll,
       selection panel's v-scroll, etc.) to ever re-enable native scrolling, no matter what they
       declare themselves. Scoped instead to only the elements that truly need it: the canvas and
       the draggable HUD panels (see below and #gameCanvas). */
}

/* Canvas styling */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: grab;
    touch-action: none;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#gameCanvas:active {
    cursor: grabbing;
}

/* UI Elements */
.game-ui {
    position: absolute;
    z-index: 10;
    pointer-events: auto;
}

.ui-panel {
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 3px;
    padding: 6px 16px;
    /* Softer, more centered shadow than before (was a hard 4/4 offset at 0.8 opacity) — reads as
       a calm ambient elevation instead of a heavy drop-shadow slapped on top. */
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 0 10px rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ui-panel:hover {
    border-color: var(--panel-border-hover);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.6), inset 0 0 14px rgba(0, 0, 0, 0.4);
}

/* Top UI Bar */
#topBar {
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    pointer-events: none; /* Let clicks pass through the container to the game */
    /* #btnSettings is a real DOM child now but deliberately position:absolute, not a flex item
       (see its own rule) — pinned to this bar's own top-right corner instead of flowing with the
       rest of the content, so it can never get pushed around or wrapped onto a 2nd row. Without
       this reservation the other children (stats panel etc.) would flow straight into that corner
       and end up underneath it. */
    padding-right: 56px;
    /* Locked to the same 44px as .settings-gear-btn (#btnSettings) — without this the bar's
       height instead followed its tallest child (which shrinks when #nextChestInfo is hidden),
       so the gear button and the bar edge only lined up by coincidence some of the time.
       min- not height: content is allowed to grow past 44px rather than get clipped, it just
       never shrinks below it. */
    min-height: 44px;
}

/* Hueco del banner de CrazyGames dentro de la cabecera (ver CG_BANNER_W/H, _cgRequestBanner en
   main.js). Tamaño fijo — nunca se encoge, es _updateTopBarFit quien aparta todo lo demás a su
   alrededor. display:none por defecto — main.js lo pone en flex cuando toca. */
#cgBannerHeaderSlot {
    display: none;
    flex: 0 0 auto;
    align-self: center;
    width: 320px;
    height: 50px;
    min-width: 320px;
    min-height: 50px;
    box-sizing: border-box;
}

/* Stats Panel (Aldeanos, Territorio) */
.stats-panel {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 0 24px;
    pointer-events: auto;
    flex-shrink: 0;
}

/* Resources Column — hidden, elements moved to top bar */
.resources-column { display: none !important; }

/* Tabs UI */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 5px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: 'Outfit', sans-serif;
}

.tab-btn:hover {
    color: var(--text-light);
    background: rgba(255,255,255,0.05);
}

.tab-btn.active {
    color: var(--accent-gold);
    background: rgba(197, 160, 89, 0.1);
    border-bottom: 2px solid var(--accent-gold);
}

#topBar .ui-panel {
    pointer-events: auto; /* Re-enable clicks for actual panels */
}

.logo-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
}

.logo-panel h1 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--gold-bright);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.logo-panel .sub-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 2px;
}

/* Offline boost panel tier buttons (×2/×3/×5/×10) — same warm gold theme as the rest of the UI */
.offline-boost-btn {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 700;
    color: #2a1e10;
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border: 1px solid #6a4a1a;
    border-radius: 4px;
    padding: 7px 16px;
    cursor: pointer;
    letter-spacing: .3px;
}
.offline-boost-btn:hover { filter: brightness(1.12); }
.offline-boost-btn.active {
    background: linear-gradient(160deg, #6aaa5a, #3a7a3a);
    border-color: #2a5a2a;
    color: #eaffea;
}

/* Offline boost strip: top-right, just under the main bar (not center — see the request to move
   it there, and out from under #btnSettings/#btnAdTimeBonus's old fixed corner spot). top-20-44
   (bar's own top + its now-fixed 44px height) leaves a 24px gap below the bar; halved to 12px. */
.offline-boost-strip {
    top: 76px;
    left: auto;
    right: 20px;
    transform: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    /* "cuando arrastro se ve grande y pequeño en frames... no deberia verse grande y luego
       ajustado" — _updateTutoBoostScale() (main.js) recomputes this scale on every resize event
       during a live window drag, snapping the strip to each new value instantly; without a
       transition each snap reads as a jarring flicker. Eases it into a smooth resize instead. */
    transition: transform 0.12s ease-out;
}

/* Desktop default position — moved here from an inline style so leaving mobile has something to
   fall back TO (see _positionMobileOfflineStripsNow's own comment for why that matters: it sets
   plain JS inline styles while on mobile, and a removeProperty() on the way back out only works
   if a real stylesheet rule is left underneath to take back over). */
.offline-ad-offer-strip {
    position: fixed;
    top: 150px;
    right: 20px;
    left: auto;
    transform: none;
    /* "el div de recurso extra puede tb escalarse como el de tiempo?" — same reasoning as
       .offline-boost-strip's own transition above: _updateTutoBoostScale() (main.js) now scales
       this one too when it would otherwise overlap the tutorial dialog. */
    transition: transform 0.12s ease-out;
}

/* "eso da problemas en pantallas más pequeñas... no dije de quitarlo durante el tutorial?" —
   #offlineBoostStrip's own top-right desktop spot (.offline-boost-strip above) collides with
   #tutorialPanel's top-right corner on a narrower browser window (the dialog is centered but not
   full-width, so it doesn't claim that whole corner the way the mobile layout does). Tried
   force-hiding the strip, repositioning the tutorial dialog around it, and a flat 25% shrink —
   landed on "calcula la distancia... que se haga mas pequeño si es necesario automaticamente":
   #offlineBoostStrip's scale is now computed live and applied as an inline style by
   _updateTutoBoostScale() in main.js (only ever shrinks by exactly the overlap, anchored top-right
   so that corner never moves) rather than a fixed class here. */
.offline-boost-time {
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    color: #e8d5a0;
    letter-spacing: 1px;
    margin: 0 4px;
    white-space: nowrap;
}
.offline-boost-info-btn {
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--gold);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}
.offline-boost-info-btn:hover { color: var(--gold-bright); border-color: var(--panel-border-hover); }

/* Main menu + custom match config screen */
.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    font-weight: 700;
    color: #2a1e10;
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border: 1px solid #6a4a1a;
    border-radius: 6px;
    padding: 12px 20px;
    cursor: pointer;
    letter-spacing: .5px;
    text-align: center;
}
.menu-btn:hover { filter: brightness(1.12); }
.menu-btn-secondary {
    background: var(--panel-bg-gradient);
    color: var(--text-light);
    border: 1px solid var(--panel-border);
}
.menu-btn-secondary:hover { border-color: var(--panel-border-hover); }

.slot-card-wrap { position: relative; width: 100%; }
.slot-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    width: 100%;
}
/* ── Tarjetas de partida (menú): ver _slotCardHTML ─────────────────────────────────────────── */
#menuSlotPicker .sc-pick-title { font-family: 'Cinzel', serif; color: var(--gold-bright); font-size: 16px; letter-spacing: 2px; text-transform: uppercase; text-align: center; }
/* Volver: arriba a la derecha, a la altura del título, sin fila propia */
#menuSlotPicker #btnBackToMainOptions { position: absolute; top: 14px; right: 16px; width: auto; padding: 5px 12px; font-size: 12px; z-index: 3; }
.slot-card.sc-full, .slot-card.sc-empty {
    flex-direction: column; align-items: stretch; gap: 0; padding: 0; overflow: hidden; height: 100%;
    border-radius: 12px; border: 1px solid #6a5226; background: linear-gradient(170deg, #2e2418, #1b140d);
    box-shadow: 0 6px 18px rgba(0,0,0,0.45); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.slot-card.sc-full:hover, .slot-card.sc-empty:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 10px 26px rgba(0,0,0,0.55), 0 0 0 1px rgba(224,185,90,0.25); }
.slot-card.sc-last { border-color: var(--gold-bright); box-shadow: 0 6px 18px rgba(0,0,0,0.45), 0 0 18px rgba(224,185,90,0.25); }
.slot-card.sc-full, .slot-card.sc-empty { font-family: var(--font-body); font-weight: 400; letter-spacing: normal; }   /* solo el título en Cinzel */
.sc-thumb { position: relative; display: block; aspect-ratio: 1 / 1;   /* cuadrada: el minimapa entero */ background: radial-gradient(ellipse at center, #13200f 0%, #070a06 75%); border-bottom: 1px solid #4a3a1c; }
.sc-thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block; }
.sc-thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, transparent 35%, transparent 70%, rgba(27,20,13,0.85) 100%); pointer-events: none; }
.sc-world { position: absolute; top: 8px; left: 8px; z-index: 1; font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 2px 8px; border-radius: 9px; }
.sc-world.w1 { color: #b8e0a0; background: rgba(40,70,30,0.85); border: 1px solid rgba(150,200,110,0.6); }
.sc-world.w2 { color: #a8d4f0; background: rgba(25,55,80,0.85); border: 1px solid rgba(120,180,230,0.6); }
.sc-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; }
.sc-head { display: flex; align-items: center; gap: 8px; }
.sc-title { font-family: 'Cinzel', serif; font-size: 17px; font-weight: 700; color: var(--gold-bright); }
.sc-badge { font-size: 9px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: #1b1208; background: linear-gradient(180deg, #e0b95a, #b8862f); padding: 2px 7px; border-radius: 8px; }
.sc-sub { font-size: 11px; color: var(--text-muted); margin-top: -4px; }
.sc-legacy { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.sc-legacy-l i { color: var(--gold); }
.sc-pips { display: flex; gap: 3px; flex: 1; }
.sc-pips .legacy-pip { width: 7px; height: 7px; }
.sc-legacy-n { font-family: var(--font-numbers, monospace); color: #e8d5a0; }
.sc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sc-stat { display: grid; grid-template-columns: 18px 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center; padding: 6px 8px; border-radius: 6px; background: rgba(0,0,0,0.25); border: 1px solid #3c3220; }
.sc-stat i { grid-row: 1 / 3; color: var(--gold); font-size: 13px; text-align: center; }
.sc-stat b { font-family: var(--font-numbers, monospace); font-size: 14px; color: #f2e6cf; font-weight: 700; line-height: 1.1; }
.sc-stat small { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.sc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.sc-time { font-size: 11px; color: var(--text-muted); }
.sc-time i { color: var(--gold); margin-right: 3px; }
.sc-play { font-size: 12px; font-weight: 700; color: #1b1208; background: linear-gradient(180deg, #e0b95a, #b8862f); padding: 6px 12px; border-radius: 6px; letter-spacing: .3px; }
.sc-play i { font-size: 10px; margin-left: 3px; }
.slot-card.sc-empty { border: 2px dashed #5a4a2a; background: rgba(20,15,10,0.55); min-height: 260px; justify-content: center; box-shadow: none; }
.sc-empty-in { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px; text-align: center; }
.sc-plus { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--gold-bright); border: 2px solid #6a5226; background: rgba(0,0,0,0.3); }
.slot-card.sc-empty:hover .sc-plus { border-color: var(--gold-bright); background: rgba(224,185,90,0.12); }
.slot-card-wrap .slot-actions { z-index: 2; }
.slot-card-wrap .slot-action-btn { background: rgba(10,8,5,0.75); }
.slot-card-thumb {
    width: 84px;
    height: 84px;
    border-radius: 4px;
    border: 1px solid var(--panel-border);
    object-fit: cover;
    image-rendering: pixelated;
    flex-shrink: 0;
    background: #000;
}
.slot-card-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.slot-card-title { font-size: 14px; font-weight: 700; }
.slot-card:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.slot-card-info { font-size: 11px; color: var(--text-muted); font-weight: 400; line-height: 1.7; }
.slot-card-pips { display: flex; gap: 4px; }

/* City browser ("Visitar una ciudad") — grid of shared cities across 3 tabs (Populares recientes
   / Popular / Recientes). No internal scrollbar on the grid itself — the full-screen overlay
   (see _promptVisitCity) scrolls as a whole as "Cargar más" appends rows, instead of a cramped
   nested scrollbox. */
.city-sort-btn.city-sort-active {
    border-color: #c8a030;
    color: var(--gold-bright);
    box-shadow: inset 0 0 8px rgba(200,160,48,0.25);
}
.city-browser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    align-content: start;
}
.city-browser-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 30px 10px;
}
.city-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.city-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: #000;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.12s, transform 0.12s;
}
.city-card-version-badge {
    position: absolute; bottom: 4px; right: 4px; z-index: 1;
    background: rgba(0,0,0,0.7); color: #f0d9a0;
    font-size: 9px; font-weight: 600;
    padding: 2px 6px; border-radius: 999px;
    display: flex; align-items: center; gap: 3px;
    pointer-events: none;
}
.city-card-thumb:hover { border-color: var(--panel-border-hover); transform: scale(1.03); }
.city-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    display: block;
}
.city-card-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 26px;
}
.city-card-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-top: -4px;
}
.city-card-name:hover { color: var(--gold-bright); }
.city-card-byline {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.city-card-meta {
    display: flex;
    gap: 10px;
    font-size: 10px;
    color: var(--text-muted);
}
.city-card-meta span { display: flex; align-items: center; gap: 3px; }
.city-card-meta i { font-size: 9px; color: var(--text-dim); }
.city-card-vote {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 2px 4px;
}
.city-vote-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 13px;
    line-height: 1;
}
.city-vote-btn:hover { color: var(--gold-bright); }
.city-vote-btn:disabled { cursor: default; opacity: 0.6; }
.city-vote-btn.city-vote-active-up { color: #5aaa5a; }
.city-vote-btn.city-vote-active-down { color: #e05050; }
.city-vote-score {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    min-width: 18px;
    text-align: center;
}

/* "Mis ciudades" tab — your own shares, hidden or not, with a way to hide/unhide each one */
.city-card-hidden-entry { opacity: 0.5; }
.city-card-hidden-badge {
    font-size: 9px;
    color: #e0a050;
    display: flex;
    align-items: center;
    gap: 4px;
}
.city-card-mine-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
}
.city-card-mine-score {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}
.city-card-hide-btn {
    background: none;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 10px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}
.city-card-hide-btn:hover { border-color: var(--panel-border-hover); color: var(--gold-bright); }
.city-card-hide-btn:disabled { cursor: default; opacity: 0.6; }

.legacy-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 1px solid var(--panel-border);
    display: inline-block;
}
.legacy-pip.filled { background: var(--gold-bright); border-color: var(--gold); }
.slot-card-info i { width: 14px; color: var(--gold); margin-right: 5px; text-align: center; }
.slot-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
}
.slot-action-btn {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 1px solid var(--panel-border);
    background: rgba(0,0,0,0.4);
    color: var(--gold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.slot-action-btn:hover { border-color: var(--panel-border-hover); color: var(--gold-bright); }
.slot-action-danger { border-color: #8b1a1a; background: rgba(60,20,20,0.5); color: #ff9090; }
.slot-action-danger:hover { background: #6b1a1a; color: #ffb0b0; }

/* Desktop is the default (unconditional) layout everywhere in this file now — see the single
   canonical MOBILE PORTRAIT breakpoint near the end for the one and only override condition. */
#menuSlotGrid {
    display: grid;
    grid-template-columns: repeat(3, 290px);
    justify-content: center;
    gap: 18px;
    width: auto;
    max-width: 1400px;
    margin: 0 auto;
}
#menuSlotGrid .slot-card-wrap { width: 290px; }
@media (max-width: 960px) { #menuSlotGrid { grid-template-columns: repeat(2, 290px); } }

.stats-tab-btn {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    padding: 5px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-body);
}
.stats-tab-btn:hover { border-color: var(--panel-border-hover); color: var(--text-light); }
.stats-tab-btn.active { background: var(--panel-bg-gradient); border-color: var(--gold); color: var(--gold-bright); }

/* ─── Achievements panel (#achievementsPanel) ────────────────────────────── */
.ach-tier-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-family: 'Cinzel', serif;
    color: var(--gold);
    font-size: 12.5px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 18px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #4a3e28;
}
.ach-tier-header:first-child { margin-top: 0; }
/* Per-tier decoCoin payout (see DECO_COIN_REWARD) — its own un-uppercased, un-spaced run so the
   number reads normally instead of inheriting the header's all-caps letter-spacing. */
.ach-tier-coin {
    font-family: var(--font-body);
    text-transform: none;
    letter-spacing: normal;
    font-size: 11px;
    font-weight: 700;
    color: #e8c040;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
/* Rarity color convention (common → legendary), same idea as loot tiers in most games. */
.ach-tier-trivial { color: #9a9086; border-bottom-color: #4a463e; }
.ach-tier-easy    { color: #6ed07a; border-bottom-color: #2e5a34; }
.ach-tier-medium  { color: #5aa8e0; border-bottom-color: #2a4a68; }
.ach-tier-hard    { color: #b87ae8; border-bottom-color: #4a2e5e; }
.ach-tier-extreme { color: #e8b840; border-bottom-color: #5e4a1a; }
/* Its own tier, one step past Legendario — see ACHIEVEMENT_TIER_ORDER/sinDescanso's own comment
   for why it earns a separate rung instead of just being another "extreme" entry. */
.ach-tier-inhuman { color: #ff3838; border-bottom-color: #6e1414; }
/* Tarjetas de #retosPanel — "más vistoso y en 1 columna": una fila ancha por reto en vez de la
   rejilla de 2 columnas compacta que comparten los logros, con más aire, icono grande con brillo
   y las cifras clave (duración, Legado exigido, mejor marca) como chips en vez de solo texto. */
.reto-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 4px;
}
/* "céntrame los textos y botones, hazlo más bonito" — de fila (icono a la izquierda, texto a la
   derecha) a columna centrada: cada tarjeta ahora se lee como un cartel propio (icono grande
   arriba, título, descripción de ancho legible, chips, marca y botón, todo apilado en el medio)
   en vez de un bloque de texto pegado a la izquierda del icono. */
.reto-card-big {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(216, 184, 96, 0.09), rgba(0, 0, 0, 0.3));
    border: 1px solid #4a3a1e;
    border-radius: 12px;
    padding: 26px 24px 24px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}
/* "quita quizás el icono y el fondo ese, con el icono se vea en una esquina" — se quita el
   círculo grande del icono (y su placa de fondo) del centro de la tarjeta; el mismo icono del
   reto pasa a vivir SOLO aquí, como marca de agua recortada en la esquina superior derecha:
   enorme, muy tenue y puramente ambiental, nunca protagonista del layout centrado. */
.reto-card-watermark {
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 104px;
    color: rgba(216, 184, 96, 0.10);
    pointer-events: none;
    line-height: 1;
}
.reto-card-big:hover { border-color: #8b6914; }
.reto-card-big.locked { opacity: 0.6; }
.reto-card-big.locked .reto-card-watermark { color: rgba(120, 108, 80, 0.10); }
/* Columna propia: todo lo que cuelga del icono se centra por sí solo (align-items) sin tener que
   repetir justify-content:center en cada fila hija — mismo truco que antes vivía solo en el
   @media de móvil, ahora es el layout de base. */
.reto-card-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.reto-card-name {
    font-family: 'Cinzel', serif;
    font-size: 18px;
    color: #f4e2ac;
    margin-bottom: 7px;
}
.reto-card-big.locked .reto-card-name { color: #cbb98e; }
.reto-card-desc {
    max-width: 380px;
    font-size: 12.5px;
    color: #a89878;
    line-height: 1.55;
    margin-bottom: 14px;
}
.reto-info-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 14px;
}
.reto-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid #4a3a1e;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 10.5px;
    color: #c8b898;
}
.reto-chip i { color: #d8b860; font-size: 10px; }
.reto-best-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(216, 184, 96, 0.12);
    border: 1px solid rgba(216, 184, 96, 0.35);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    color: #f0d888;
    margin-bottom: 12px;
}
.reto-best-pill i { color: #f0d080; }
/* "encima bien grande su mejor puntuación con la fecha y número de intentos" — reemplaza la
   pildorita discreta de arriba: número protagonista, fecha del récord y nº de intentos como
   metadatos pequeños debajo. */
.reto-best-block {
    max-width: 280px;
    background: rgba(216, 184, 96, 0.10);
    border: 1px solid rgba(216, 184, 96, 0.3);
    border-radius: 8px;
    padding: 10px 20px 12px;
    margin-bottom: 14px;
}
.reto-best-label {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #a89878;
}
.reto-best-number {
    font-family: 'Cinzel', serif;
    font-size: 26px;
    font-weight: 900;
    color: #f0d080;
    line-height: 1.2;
}
.reto-best-unit {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    color: #a89878;
    margin-left: 6px;
}
.reto-best-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 12px;
    margin-top: 3px;
    font-size: 10.5px;
    color: #c8b898;
}
.reto-best-meta i { color: #d8b860; font-size: 10px; }

/* Global ranking (top 3 + this player's own rank) — filled async by _retoRenderGlobalRank once
   the panel's single ?summary=1 fetch resolves, see openRetosPanel. */
.reto-global-rank {
    max-width: 280px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(216, 184, 96, 0.18);
    border-radius: 8px;
    padding: 8px 14px 10px;
    margin-bottom: 14px;
}
.reto-global-rank-loading, .reto-global-rank-empty {
    font-size: 10.5px; color: #a89878; font-style: italic; text-align: center; padding: 4px 0;
}
.reto-global-rank-title {
    font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #a89878;
    margin-bottom: 4px; text-align: center;
}
.reto-global-rank-row {
    display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 2px 0; color: #e8dcc8;
}
.reto-global-rank-pos { font-weight: 800; width: 22px; flex-shrink: 0; color: #a89878; }
.reto-global-rank-pos-1 { color: #f0d080; }
.reto-global-rank-pos-2 { color: #cbd0d8; }
.reto-global-rank-pos-3 { color: #d8a468; }
.reto-global-rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.reto-global-rank-score { font-weight: 700; color: #f0d080; }
.reto-global-rank-mine {
    margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(216, 184, 96, 0.18);
    font-size: 11px; color: #c8b898; text-align: center;
}
.reto-locked-hint {
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
}
.reto-start-btn-big {
    padding: 11px 36px;
    /* "el start que sea amarillo, vamos a intentar quitar el verde neon del juego" — mismo
       dorado sólido que ya usan ¡Empezar!/Aceptar (los botones de "acción principal" del propio
       reto) en vez de un tercer color de acento — el verde, incluso ya apagado, seguía leyendo
       demasiado vivo contra el resto del panel. */
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border: 2px ridge #6a4a1a;
    border-radius: 6px;
    color: #2a1e10;
    font-family: var(--font-heading);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
}
.reto-start-btn-big:hover {
    background: linear-gradient(160deg, #ffdf80, #c69140);
}
/* La tarjeta ya es de columna centrada por defecto (ver .reto-card-big más arriba) — en móvil
   solo hace falta recortar el padding lateral y dejar el botón a ancho completo. */
@media (max-width: 520px) {
    .reto-card-big { padding: 22px 16px; }
    .reto-start-btn-big { width: 100%; }
}
.ach-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 4px;
}
.ach-card {
    position: relative; /* ancla para .ach-pin-btn */
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid #3a2e1e;
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ach-card.unlocked {
    border-color: rgba(110, 208, 122, 0.45);
    background: rgba(110, 208, 122, 0.06);
}
.ach-card:hover { border-color: #5a4a2a; background: rgba(0, 0, 0, 0.32); }
.ach-card-icon {
    position: relative;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(80, 70, 50, 0.25);
    color: #6a5c44;
    font-size: 15px;
}
.ach-card.unlocked .ach-card-icon,
/* Same gold "unlocked" treatment, standalone — used by the end-of-game achievement icon strip
   (see showEndGameStats), which isn't nested inside a .ach-card at all. */
.ach-card-icon.unlocked-inline {
    background: linear-gradient(160deg, rgba(216, 184, 96, 0.35), rgba(140, 100, 30, 0.25));
    color: #f0d080;
    box-shadow: 0 0 10px rgba(216, 184, 96, 0.35);
}
.ach-card-icon.unlocked-inline { width: 34px; height: 34px; font-size: 13px; }
.ach-lock {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1a140f;
    border: 1px solid #4a3e28;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #6a5c44;
}
/* flex:1 so this fills the row's remaining width (not just as wide as its own text) — the bar
   track below is a plain block div, so it naturally stretches to match once this does.
   min-width:0 still lets ach-card-desc's text wrap instead of overflowing the grid cell. */
.ach-card-body { flex: 1; min-width: 0; }
.ach-card-name {
    font-family: 'Cinzel', serif;
    font-size: 12.5px;
    color: #cbb98e;
    margin-bottom: 2px;
}
.ach-card.unlocked .ach-card-name { color: #f4e2ac; }
.ach-card-desc {
    font-size: 11px;
    color: #8a7c66;
    line-height: 1.4;
}
.ach-bar-track {
    margin-top: 6px;
    height: 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.4);
    overflow: hidden;
}
.ach-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #7a9a4a, #a8c060);
    border-radius: 3px;
    transition: width 0.2s ease;
}
.ach-card.unlocked .ach-bar-fill { background: linear-gradient(90deg, #d8b860, #f0d888); }
.ach-bar-label {
    margin-top: 3px;
    font-family: 'Roboto Mono', monospace;
    font-size: 10px;
    color: #7a6c56;
    text-align: right;
}
/* Segunda barra opcional (ver bar2Display en ACHIEVEMENTS, p.ej. Talador Relámpago) — mismo
   tamaño y comportamiento que la barra normal, pero en azul para distinguirla de un vistazo de
   la barra de progreso "verde" de siempre. .expired cuando se acaba el tiempo: no desaparece
   (igual que .ach-req nunca desaparece al fallar), se queda en rojo a 0% como aviso permanente
   de que este intento ya no puede desbloquear el logro.  */
.ach-bar-fill.time { background: linear-gradient(90deg, #4a7a9a, #60a8c0); }
.ach-bar-fill.time.expired { background: linear-gradient(90deg, #9a4a4a, #c06060); }
.ach-req {
    margin-top: 5px;
    font-size: 10.5px;
    color: #e07070;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ach-req.met { color: #6ed07a; }
/* Chincheta para fijar el logro en el panel de selección (ver _togglePinAchievement en main.js).
   Esquina superior derecha de la tarjeta — .ach-card ya tiene position:relative para esto.
   Apagada (gris, opacity baja) hasta que se fija, entonces se pone dorada y opaca — el mismo
   lenguaje de "activo = color del oro" que ya usa el resto del HUD. */
.ach-pin-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #3a2e1e;
    border-radius: 50%;
    color: #7a6c56;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ach-pin-btn:hover { opacity: 1; }
.ach-pin-btn.pinned {
    opacity: 1;
    color: #1a1400;
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border-color: #6a4a1a;
}
/* When/at what Legado an unlocked achievement was actually earned — see _achUnlockInfo */
.ach-card-meta {
    margin-top: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 9.5px;
    color: #8a7c5e;
}

/* La tarjeta fijada vive en el panel de selección, mucho más estrecho (260px) que la rejilla de
   dos columnas del panel de Logros — la fila normal (icono a la izquierda, todo lo demás
   apretado a la derecha) dejaba muy poco ancho para las barras. Aquí icono+nombre van en una
   cabecera y descripción/barras ocupan el ancho completo debajo, con el mismo HTML que la lista
   de Logros (_achCardHTML no cambia) — solo una reestructuración por CSS Grid.
   display:contents en .ach-card-body "desenvuelve" sus hijos: pasan a comportarse como si fueran
   hijos DIRECTOS de la rejilla de .ach-card, así cada uno (desc, barras, req, meta) puede pedir
   su propia fila entera con grid-column:1/-1 en vez de quedarse encajonado dentro de la columna
   del cuerpo. */
#pinnedAchContent .ach-card {
    display: grid;
    grid-template-columns: 38px 1fr;
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
    /* Sin borde/fondo propios aquí — #selectionPanel (.ui-panel) ya pone su propio borde dorado
       alrededor de todo el panel. Con los dos, una tarjeta suelta dentro de un panel ya
       enmarcado se veía como marco dentro de marco; en la rejilla de Logros SÍ hace falta,
       porque ahí separa varias tarjetas entre sí — aquí solo hay una. */
    border: none;
    background: none;
    padding: 0;
}
#pinnedAchContent .ach-card-icon { grid-column: 1; grid-row: 1; }
#pinnedAchContent .ach-card-body { display: contents; }
/* padding-right: la chincheta es position:absolute (top:8px;right:8px;width:22px) y no reserva
   su propio hueco en la rejilla — un título de dos líneas se metía debajo de ella en la segunda
   línea. 34px = 8px de margen + 22px de ancho + un poco de aire. */
#pinnedAchContent .ach-card-name { grid-column: 2; grid-row: 1; margin-bottom: 0; padding-right: 34px; }
#pinnedAchContent .ach-card-desc,
#pinnedAchContent .ach-bar-track,
#pinnedAchContent .ach-bar-label,
#pinnedAchContent .ach-req,
#pinnedAchContent .ach-card-meta {
    grid-column: 1 / -1;
}

/* Achievement-unlocked toast — celebratory, gold-themed, distinct from the red build-error
   toast (#buildToast): slides down from the top-center instead of sitting near the bottom, and
   auto-hides via the .show class toggle in _showAchievementToast() rather than display:none. */
.ach-toast {
    position: fixed;
    /* Hidden state animates via transform, not top. It used to be top:-80px, which fully hid a
       short single-line desktop toast but wasn't enough once the unlock-meta line (Legado X/7 ·
       time) made it taller, wrapped across more lines on a narrow mobile width — a sliver stayed
       visible at the top of the screen even while "hidden". A percentage translateY (relative to
       the toast's OWN height) was tried next and made THAT case worse instead: on page load,
       before any achievement has ever unlocked, #achievementToast sits empty in the DOM (no
       innerHTML yet — see _showAchievementToast, which only fills it in once one actually
       fires) — an empty box is barely taller than its own padding/border, so a fraction of ITS
       height wasn't enough clearance either, and the very first F5 always showed a sliver.
       -200px is a plain fixed offset instead: comfortably clears both the empty box on load and
       the tallest realistic populated/wrapped one, with real margin either way. */
    top: 20px;
    left: 50%;
    transform: translate(-50%, -200px);
    z-index: 9600;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(160deg, #3a2e12, #1a1408);
    border: 2px ridge var(--gold);
    border-radius: 8px;
    padding: 10px 22px 10px 14px;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6), 0 0 20px rgba(216, 184, 96, 0.25);
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(.22, 1.1, .36, 1);
}
.ach-toast.show { transform: translate(-50%, 0); }
.ach-toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, rgba(216, 184, 96, 0.35), rgba(140, 100, 30, 0.25));
    color: #f0d080;
    font-size: 18px;
    box-shadow: 0 0 12px rgba(216, 184, 96, 0.4);
    flex-shrink: 0;
}
.ach-toast-label {
    font-family: 'Cinzel', serif;
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #d8b860;
}
.ach-toast-name {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 700;
    color: #f4e2ac;
}
.ach-toast-meta {
    font-family: 'Roboto Mono', monospace;
    font-size: 10px;
    color: #b8a878;
    margin-top: 2px;
}
.ach-progress {
    color: #a8987c;
    font-size: 12px;
    margin-bottom: 4px;
}
/* One-line reminder that unlocking ANY achievement also pays out decoCoins — nothing else in
   the UI ever states this outright (see DECO_COIN_REWARD/_checkAchievements), so this plus the
   per-tier badge below (.ach-tier-coin) are the only two places it's actually spelled out. */
.ach-coin-hint {
    color: #d8b860;
    font-size: 11px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ach-coin-hint .fa-coins { color: #e8c040; }
@media (max-width: 720px) {
    .ach-grid { grid-template-columns: 1fr; }
    #achievementsPanel > div { min-width: 0 !important; width: 92vw; padding: 20px !important; }
    /* "el modal de retos es más grande en móviles que los otros modal, por ejemplo logros" —
       #retosPanel se creó calcado a #achievementsPanel pero esta regla solo apuntaba al segundo
       por id, así que en móvil se quedaba con su min-width/padding de escritorio sin encoger.
       Mismos valores exactos que Logros aquí arriba. */
    #retosPanel > div { min-width: 0 !important; width: 92vw; padding: 20px !important; }
}

/* Compact top-bar resources */
.top-resources-panel {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 20px;
    flex-grow: 1;
    flex-shrink: 0;
    flex-basis: auto;
    justify-content: center;
}

.top-res {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 12px;
}

.top-res-icon {
    font-size: 18px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* Resource icons — shared across HUD, cost displays and villager indicator */
.res-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    display: inline-block;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
    image-rendering: -webkit-optimize-contrast;
}

.res-icon-hud {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55));
    image-rendering: pixelated;
}
/* Almas: el único recurso sin PNG propio en assets/, así que su "icono" es un glifo de Font
   Awesome. Hereda .res-icon-hud para ocupar exactamente lo mismo que los <img> de los demás y no
   descuadrar la fila, pero necesita centrar el glifo dentro de esa caja de 22px. */
.souls-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: #b9a7d8;   /* violeta pálido: se distingue del oro sin competir con él */
    image-rendering: auto;
}

/* Settings gear button in top bar — same ridge-border/gradient/shadow "system" as every other
   #topBar panel (.ui-panel), just sized down to an icon-only square instead of text content. */
.settings-gear-btn {
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 3px;
    color: var(--gold);
    font-size: 18px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 0 10px rgba(0, 0, 0, 0.35);
}
.settings-gear-btn:hover {
    border-color: var(--panel-border-hover);
    color: var(--gold-bright);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.6), inset 0 0 14px rgba(0, 0, 0, 0.4);
}

/* "parte del header, el botón de la derecha inamovible, nunca puede ocultarse" — a real #topBar
   child now (see index.html), but position:absolute against IT instead of a flex item: #topBar is
   always itself a positioned element (.game-ui on desktop, position:fixed on mobile — see its own
   rules), so this pins to the bar's own right edge and tracks it automatically whatever the bar's
   actual size ends up being, instead of the old raw viewport top:20px/right:20px that only lined
   up with a single-line bar by luck.
   Taken out of the flex flow on purpose — that's what makes it immune to wrapping/being squeezed
   by the rest of the bar's content; #topBar's own padding-right (see its rule) reserves the corner
   so nothing else renders underneath it. Not part of any drag/positioning system either (see the
   "must never move or get lost" decision for the HUD drag feature) — this is the one HUD element
   that's never draggable.
   top:50% + translateY(-50%) rather than a fixed top offset: "no está centrado... que se quede
   fijo a la derecha sin que los saltos de línea le afecten" — the header's height is NOT constant
   (its min-height is only a floor; it grows when content wraps to a 2nd row on a narrow phone, or
   via #topBar.topbar-2line on a narrow desktop), so any fixed top value can only ever be centered
   at ONE particular header height and drifts to the top at every other. Centering off the bar's
   own live height instead is correct at every one of them. */
#btnSettings {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0;
    z-index: 2;
}

/* Zoom +/- plus the screensaver-mode trigger — bottom-right on desktop, tucked right against
   #commandCard's left edge (that panel is a fixed 280px wide regardless of collapsed/expanded
   state — see its own comment — so this 10px-gap offset never drifts out of place). Same
   ridge/gold chrome as .settings-gear-btn above but a notch smaller (36px vs 44px) and round,
   since these are secondary controls, not primary nav. Side by side (reads as one small bar, not
   several unrelated buttons). The MOBILE PORTRAIT block below moves it to the right edge — and
   back to stacked — there, since #commandCard itself becomes a full-width bottom bar with no
   "left edge" to sit next to. */
#zoomControls {
    position: fixed;
    bottom: 20px;
    right: 310px; /* 280 (commandCard width) + 20 (its own right offset) + 10 (gap) */
    display: flex;
    flex-direction: row;
    gap: 6px;
    z-index: 10;
}
/* Los controles de zoom NO se mueven por el banner: si no caben los dos, el que desaparece es
   el banner (ver _cgBannerHasRoom en main.js). La UI del juego manda sobre el anuncio. */
/* Borde liso + brillo interior con box-shadow: el "2px ridge" de antes, en un círculo, se dibujaba dentado ("se ven pixelados") */
#zoomControls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #3a2e22, #1c150f 75%);
    border: 1.5px solid var(--panel-border);
    color: var(--gold);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 0 rgba(255,220,150,0.18), inset 0 -2px 4px rgba(0,0,0,0.45), 0 2px 6px rgba(0, 0, 0, 0.55);
}
/* Opciones → "Botones de zoom (+ / −)" apagado: fuera el + y el −, el del salvapantallas se queda */
body.fn-no-zoom-btns #btnZoomIn, body.fn-no-zoom-btns #btnZoomOut { display: none !important; }
body.fn-no-ss-btn #btnScreensaver { display: none !important; }   /* Opciones: sin el botón de pantalla completa (settingShowScreensaverBtn) */
#zoomControls button:hover {
    border-color: var(--panel-border-hover);
    color: var(--gold-bright);
}

/* Screensaver mode's only visible control — hidden by default, shown only via
   body.fn-screensaver-mode below. Sits exactly where #commandCard normally does (bottom-right,
   20px) since that panel — like everything else — is hidden for the whole time this button is
   showing, so there's nothing there to collide with. */
#btnExitScreensaver {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #3a2e22, #1c150f 75%);   /* liso: el "2px ridge" en un círculo se veía dentado */
    border: 1.5px solid var(--panel-border);
    color: var(--gold);
    font-size: 16px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 0 rgba(255,220,150,0.18), inset 0 -2px 4px rgba(0,0,0,0.45), 0 2px 6px rgba(0, 0, 0, 0.55);
}
#btnExitScreensaver:hover {
    border-color: var(--panel-border-hover);
    color: var(--gold-bright);
}
body.fn-screensaver-mode #btnExitScreensaver {
    display: flex;
}

/* Watch-an-ad time bonus — lives inline inside #offlineBoostStrip instead of floating as its own
   fixed corner icon, so it scales/positions with the rest of the bar automatically (no separate
   zoom rule needed, unlike #btnSettings above). Cooldown label + the jackpot-ready glow below are
   updated by _updateAdTimeBonusButton(). Can show at the same time as the spend-bank tiers (see
   .offline-boost-ad-sep, the divider between them). */
.ad-time-inline-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--gold);
    font-size: 16px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 3px;
    transition: color 0.15s ease, background 0.15s ease;
}
.ad-time-inline-btn:hover {
    color: var(--gold-bright);
    background: rgba(223, 178, 86, 0.12);
}
.ad-time-inline-btn #adTimeBonusCooldown {
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
/* Divider between the spend-bank tiers and the ad button — only shown when both are visible at
   once (see _updateOfflineBoostUI). */
.offline-boost-ad-sep {
    width: 1px;
    height: 22px;
    background: var(--panel-border);
    opacity: 0.6;
}
/* Ready state: just a brighter gold, no glow/pulse — was an animated box-shadow "halo" before. */
.ad-time-inline-btn.jackpot-ready {
    color: var(--gold-bright);
    background: rgba(223, 178, 86, 0.14);
}
.ad-time-inline-btn.jackpot-ready #adTimeBonusCooldown {
    color: var(--gold-bright);
}

/* Screenshot mode (toggled only via the F6 key — no on-screen button, so it can never be
   triggered by an accidental tap; see _toggleScreenshotMode() in main.js): hide every UI
   panel/number, leaving only the canvas (game world) visible. #btnSettings is deliberately
   spared — otherwise there'd be no way to reach Settings while it's active.
   Screensaver mode (the #btnScreensaver button next to the zoom controls, see
   _toggleScreensaverMode()) shares every one of these rules — same "just the world, nothing else"
   look — except it does NOT spare #btnSettings (see the block below): safe to hide there, unlike
   screenshot mode, since it has its own dedicated exit button + Esc instead of relying on
   Settings being reachable.
   :not(#topBar) on the .game-ui selector: #topBar can't just be display:none'd wholesale anymore
   now that #btnSettings lives inside it (see its own comment in index.html) — a display:none
   ancestor hides every descendant unconditionally, no override possible, which would take
   #btnSettings down with it. #topBar itself is handled by its own block right below instead. */
body.fn-screenshot-mode .game-ui:not(#topBar),
body.fn-screenshot-mode #minimapContainer,
body.fn-screenshot-mode #btnShowMinimap,
body.fn-screenshot-mode #offlineBoostPanel,
body.fn-screenshot-mode #fpsCounter,
body.fn-screenshot-mode #buildToast,
body.fn-screenshot-mode #zoomControls,
body.fn-screensaver-mode .game-ui:not(#topBar),
body.fn-screensaver-mode #minimapContainer,
body.fn-screensaver-mode #btnShowMinimap,
body.fn-screensaver-mode #offlineBoostPanel,
body.fn-screensaver-mode #fpsCounter,
body.fn-screensaver-mode #buildToast,
body.fn-screensaver-mode #zoomControls {
    display: none !important;
}
/* #topBar itself stays "displayed" in both modes (see the :not(#topBar) exclusion above) so its
   #btnSettings child CAN be selectively kept visible below — but its own painted background/
   border/shadow are stripped here so an empty bar-shaped box doesn't linger across the top of the
   screen with nothing in it, and every OTHER child is hidden individually instead of relying on
   the bar itself being display:none. #btnSettings is the one exception, screenshot-mode only —
   screensaver mode hides it too, no exception, same as always. */
body.fn-screenshot-mode #topBar,
body.fn-screensaver-mode #topBar {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}
body.fn-screenshot-mode #topBar > *,
body.fn-screensaver-mode #topBar > * {
    display: none !important;
}
/* :not(.fn-screensaver-mode) matters here — _toggleScreensaverMode() sets BOTH classes on body at
   once (screensaver piggybacks on screenshot mode's plumbing, see its own comment in main.js), so
   a bare .fn-screenshot-mode selector would also re-show #btnSettings during screensaver mode,
   undoing the "hide it there" rule above. Only the pure F6 case (screenshot, not screensaver)
   gets the exception. */
body.fn-screenshot-mode:not(.fn-screensaver-mode) #btnSettings {
    display: flex !important;
}
/* #btnToggleCommandCard needs its own (higher-specificity) rule: the mobile media query gives
   it #btnToggleCommandCard { display:flex !important; } (an ID selector) so it survives the
   command card's title bar being hidden there — an ID always beats the .game-ui class rule
   above regardless of !important, so without this it kept showing in screenshot mode. */
body.fn-screenshot-mode #btnToggleCommandCard,
body.fn-screensaver-mode #btnToggleCommandCard {
    display: none !important;
}

/* Spectator mode (set once, at boot, only when the page loaded as ?view=SLUG — see
   initSpectatorMode() in main.js): a shared city, read-only. Unlike screenshot mode this KEEPS
   the resource/villager/territory HUD and the minimap visible — the whole point is watching the
   numbers and the map move — it only hides the surfaces that would let a visitor build, buy,
   pause/demolish/move a building, or spend a relic. #btnSettings is hidden by initSpectatorMode
   (its "Volver al menú" would reload straight back into the visited city). */
body.fn-spectator-mode #commandCard,
body.fn-spectator-mode #btnToggleCommandCard,
body.fn-spectator-mode #treeCountdown,
body.fn-spectator-mode #nextChestInfo,
body.fn-spectator-mode #selectionPanel,
body.fn-spectator-mode #topResourcesPanel,
body.fn-spectator-mode #gameTimerPanel,
body.fn-spectator-mode #topbarSepTimer,
body.fn-spectator-mode #offlineBoostPanel,
body.fn-spectator-mode #offlineBoostStrip,
body.fn-spectator-mode #offlineAdOfferStrip,
body.fn-spectator-mode #btnAdTimeBonus,
body.fn-spectator-mode #achievementToast,
body.fn-spectator-mode #btnShareCity,
body.fn-spectator-mode #btnRetos,
body.fn-spectator-mode #buildToast,
body.fn-spectator-mode #minimapDownloadBtn,
body.fn-spectator-mode #minimapCloseBtn {
    display: none !important;
}
/* Zoom +/- and the screensaver button stay reachable here (spectating is exactly when someone
   might want either) — but #commandCard, the panel they normally sit beside, is hidden above, so
   the 310px offset that tucks them against its left edge would leave them stranded over empty
   space instead. Go to the actual bottom-right corner — except #spectatorBanner (measured 37px
   tall) now OWNS that corner's bottom edge, so both this and the screensaver-exit button (which
   can only ever show while spectating together with screensaver mode, same corner) need to sit
   above it instead of at the usual 20px. */
body.fn-spectator-mode #zoomControls,
body.fn-spectator-mode #btnExitScreensaver {
    right: 20px;
    bottom: 49px; /* 37px banner + 12px gap */
}
/* LOGROS/STATS stay reachable — they show the SHARED player's own unlocked achievements and
   lifetime stats (see _applySnapshotState), not the visitor's, so they're worth keeping. */
body.fn-spectator-mode .logo-panel h1 {
    font-size: 28px; /* "Forest Nothing" reads as the header's title here, not just a corner logo */
}

/* Settings / Debug panel */
.settings-panel .panel-title-bar {
    cursor: default;
    padding: 10px 14px 8px;
    border-bottom: 1px solid rgba(139,90,43,0.4);
}
.settings-panel {
    position: fixed;
    top: 70px;
    right: 20px; /* matches #commandCard's right:20px, so both sit on the same X */
    width: 280px;
    background: var(--panel-bg-gradient);
    /* El mismo marco que el menú de construir (.ui-panel), pedido de JC: era uno más fino y redondeado */
    border: 3px ridge var(--panel-border);
    border-radius: 3px;
    z-index: 900;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 0 10px rgba(0, 0, 0, 0.35);
    /* Was unbounded — fine in a normal browser tab, but a shorter embed (e.g. the CrazyGames
       iframe, which doesn't get the full page height) could cut the panel off with no way to
       reach whatever option landed below the fold. Caps the whole panel and hands the overflow
       to .settings-body below (flex:1 1 auto + its own scroll) so the title bar/close button
       stay pinned and reachable regardless of how much of the body scrolls past view.
       100vh-90px still wasn't enough on CrazyGames specifically — their own player chrome (the
       row of icons along the very bottom of the embed) floats on top of the iframe rather than
       shrinking it, so 100vh there reports taller than what's actually free to use.
       100vh-150px still wasn't quite enough even in a plain browser tab: #commandCard sits in
       this same right-hand column, and toggleSettingsPanel() only auto-collapses it down to its
       title bar (+ #buildTabBar's tab flap, ~90-100px total from the very bottom once
       decorations are unlocked) rather than hiding it outright — 150px only left ~80px of
       reserved margin, just short of that. Padding the reserved margin out further (190px total,
       only 70 of which is the top offset itself) costs nothing on a plain browser tab — it's
       just some unused space at the bottom there — but is what keeps the last button clear of
       both the CrazyGames overlay AND the collapsed build panel underneath it. */
    max-height: calc(100vh - 190px);
    display: flex;
    flex-direction: column;
}
.settings-body {
    /* Shrinks the panel's content so more fits without scrolling — zoom (not transform:scale) so
       it actually affects layout/flow, not just paint: this block has no explicit width of its
       own (a flex child stretching to fill .settings-panel), so it keeps spanning the panel's
       real 280px on screen while every px value INSIDE it (padding, gaps, font-size, button
       height...) is computed at 1/0.8x then shown at 0.8x — i.e. genuinely smaller content in
       the same real width, not a narrower panel. Was 0.5, user found it too small — 0.8 reads
       more comfortably while still fitting noticeably more per screen than unscaled. */
    zoom: 0.8;
    padding: 12px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* flex:1 1 auto is what actually makes this the piece that shrinks to fit under
       .settings-panel's own max-height — without it this stays sized to its own content and the
       overflow-y below never gets a chance to kick in (same flex-item-shrink pattern as
       #commandCardBody/#commandCard elsewhere in this file). */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    gap: 10px;
}
.settings-label {
    font-size: 13px;
    color: var(--text-light);
    flex: 1;
}
.settings-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--gold);
    flex-shrink: 0;
}
.settings-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gold);
    opacity: 0.85;
    margin: 14px 0 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-group-title:first-child {
    margin-top: 0;
}

/* Custom range slider (music volume, etc.) — browsers don't let you style the default one with
   a couple of properties, track and thumb need separate -webkit-/-moz- rules each. */
.game-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 70px;
    height: 4px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    cursor: pointer;
    flex-shrink: 0;
}
.game-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: linear-gradient(90deg, var(--gold) 0%, var(--gold) var(--fill, 50%), transparent var(--fill, 50%));
    border-radius: 2px;
}
.game-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: var(--gold-bright);
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 3px rgba(0,0,0,0.6);
    cursor: pointer;
}
.game-slider::-moz-range-track {
    height: 4px;
    background: var(--panel-bg);
    border-radius: 2px;
}
.game-slider::-moz-range-progress {
    height: 4px;
    background: var(--gold);
    border-radius: 2px;
}
.game-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--gold-bright);
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 3px rgba(0,0,0,0.6);
    cursor: pointer;
}

.top-res-value {
    font-family: var(--font-numbers);
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
    letter-spacing: 0.5px;
    display: inline-block;
    /* Hueco reservado para que el número no empuje al resto de la barra al crecer. En ch, no
       en px: con tabular-nums (arriba) un 'ch' es exactamente el ancho de un dígito, así que 7ch
       da para el peor caso real de formatCompact — "999,99M" — y además se reescala solo si algún
       día cambia el font-size. Con text-align:right el número crece hacia la izquierda, que es lo
       que mantiene el icono quieto. En móvil se anula a 0 (ver el bloque portrait). */
    min-width: 7ch;
    text-align: right;
}

/* Wraps the value + the rate line below it so the icon centers against the pair as one block —
   "añadimos en pc un 23k/s debajo de cada recurso". Desktop-only by construction: hidden outright
   in the mobile portrait block below (see the file's one responsive breakpoint), where there's no
   room to spare for it. */
.top-res-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.top-res-rate {
    font-family: var(--font-numbers);
    font-size: 10px;
    font-weight: 600;
    color: #7fae6b;
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
    letter-spacing: 0.3px;
    line-height: 1;
    /* Altura de línea SIEMPRE reservada, incluso vacío (recurso sin movimiento neto ahora mismo,
       ver _updateResRateEl) — así que un recurso quieto no hace que la barra cambie de alto cada
       vez que otro empieza/deja de moverse. visibility en vez de un texto placeholder: oculta el
       contenido sin dejar de ocupar el hueco. */
    min-height: 12px;
    visibility: hidden;
}
.top-res-rate:not(:empty) { visibility: visible; }
.top-res-rate.rate-negative { color: #d07070; }

.top-res-sep {
    display: none;
    width: 1px;
    height: 24px;
    background: var(--panel-border);
    opacity: 0.5;
}

/* ── Recursos apretados: el peldaño que evita partir la barra en dos líneas ──
   Es la pieza más ancha de la cabecera con diferencia (cinco contadores con valores en millones),
   así que es la única que puede dar los ~325 px que hacían falta para que en escritorio no se
   llegue nunca al recurso de las dos filas.
   No baja a los 11 px del móvil a propósito: eso es legible a treinta centímetros de la cara, no
   en un monitor. 14 px con 5ch reservados cubre hasta "9,99M" sin que el número empuje, y sigue
   leyéndose de un vistazo. Lo pone _updateTopBarFit, justo antes del peldaño de las dos filas. */
.top-resources-panel.compact { padding: 0 10px; }
.top-resources-panel.compact .top-res      { padding: 0 7px; gap: 5px; }
.top-resources-panel.compact .top-res-value { font-size: 14px; min-width: 5ch; }
.top-resources-panel.compact .res-icon-hud  { width: 15px; height: 15px; }
.top-resources-panel.compact .top-res-sep   { display: none; }
/* En compacto la producción por minuto se queda ("no veo mis recursos ganados por minuto en verde,
   se quitan si hay muchos elementos"): solo baja un punto de tamaño. Con el valor a 14 px la
   segunda línea sigue cabiendo de sobra en el alto normal de la barra. */
.top-resources-panel.compact .top-res-rate  { font-size: 9px; min-height: 10px; letter-spacing: 0; }

/* Stats panel (aldeanos / territorio) */
.top-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
}

.top-stat-icon {
    font-size: 20px;
}

.top-stat-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.top-stat-label {
    font-family: var(--font-body);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.top-stat-value {
    font-family: var(--font-numbers);
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
}

/* Mismo problema y misma solución que en .top-res-value, pero SOLO en los dos contadores del
   juego: .top-stat-value la comparten los campos del panel de espectador (nombre de ciudad,
   jugador...), que son texto libre y no deben ir alineados a la derecha ni con hueco fijo.
   Población llega a "123 / 250" y territorio a "10.000" — de ahí los dos anchos. Al ir en ch,
   .stats-panel.compact los encoge solo al bajar el font-size, sin necesitar su propia regla. */
#villagerValue { min-width: 9ch;  text-align: right; display: inline-block; }
#tilesValue    { min-width: 6ch;  text-align: right; display: inline-block; }

/* Last narrow-desktop tier (see _updateTopBarFit): villagers/territory never disappear, but
   once even the icon-only SKILLS/STATS buttons aren't enough, shrink this block's own width
   and text down to a minimum instead. */
.stats-panel.compact {
    gap: 8px;
    padding: 0 8px;
}
.stats-panel.compact .top-stat {
    gap: 3px;
    padding: 0 4px;
}
.stats-panel.compact .top-stat-label {
    font-size: 7px;
    letter-spacing: 0.5px;
}
.stats-panel.compact .top-stat-value {
    font-size: 12px;
}

/* Legacy — keep for any remaining refs */
.resource-item { display: flex; align-items: center; gap: 12px; }
.res-icon { font-size: 20px; }
.res-details { display: flex; flex-direction: column; }
.res-label { font-size: 11px; color: var(--text-muted); }
.res-value { font-family: var(--font-numbers); font-size: 18px; font-weight: 700; color: var(--gold); }

/* Controls modal (#controlsModal) — replaces the old permanently-docked #leftSide/
   #instructionsPanel sidebar; now opened on demand from Ajustes (see openControlsModal()). */
.controls-modal-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.controls-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.controls-row-text { min-width: 0; }
.controls-row-title {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    color: var(--gold-bright);
    margin-bottom: 3px;
}
.controls-row-desc {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}
/* Panel "Cómo Jugar" + Controles: caja con cabecera y pestañas fijas y el cuerpo con su propio scroll */
.howto-box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(980px, 96vw);    /* más ancho en escritorio: ahora lleva imágenes (figuras y miniaturas de edificios) */
    height: min(760px, 90vh);
    box-sizing: border-box;
    padding: 22px 26px 18px;
    background: linear-gradient(160deg, #2a221b, #1a140f);
    border: 2px ridge #8b6914;
    border-radius: 10px;
}
.howto-close { position: absolute; top: 10px; right: 14px; background: none; border: none; color: #bdae93; font-size: 20px; cursor: pointer; }
.howto-title { font-family: 'Cinzel', serif; color: #c8a050; margin: 0 0 12px; font-size: 18px; border-bottom: 1px solid #5a4a2a; padding-bottom: 10px; flex-shrink: 0; }
.howto-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; flex-shrink: 0; }
.howto-tab {
    cursor: pointer; padding: 5px 10px; font-size: 12px; color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3); border: 1px solid #5a4a2a; border-radius: 5px;
}
.howto-tab:hover { color: var(--gold-bright); border-color: var(--gold); }
.howto-tab.active { color: #1b1208; background: linear-gradient(180deg, #e0b95a, #b8862f); border-color: #e0b95a; font-weight: 700; }
#howtoBody { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 8px; }
#howtoBody .key { min-width: 112px; text-align: center; box-sizing: border-box; }   /* las etiquetas de tecla del mismo ancho: los títulos quedan alineados */
/* Figuras del Cómo Jugar: captura del juego (assets/howto, ver tools/howto_scenes.mjs) con números de colores y su leyenda al lado
   (debajo en pantallas estrechas). Verde = funciona, rojo = no funciona. */
.howto-fig { display: flex; gap: 16px; align-items: center; padding: 12px; background: rgba(0,0,0,0.25); border: 1px solid #4a3c22; border-radius: 8px; }
.howto-fig img { flex: 0 1 58%; min-width: 0; max-width: 58%; height: auto; border-radius: 6px; border: 1px solid #5a4a2a; image-rendering: pixelated; }
.howto-fig-text { flex: 1 1 0; min-width: 0; }
.howto-fig.wide { flex-direction: column; align-items: stretch; }   /* escenas alargadas (ruta, núcleo): imagen a todo el ancho y la leyenda debajo */
.howto-fig.wide img { max-width: 100%; flex-basis: auto; }
.howto-fig-title { font-family: 'Cinzel', serif; font-size: 13px; color: var(--gold-bright); margin-bottom: 8px; }
.howto-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.howto-legend li { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.howto-num { flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font: bold 11px sans-serif; color: #fff; border: 2px solid #fff; }
.howto-num.ok { background: #2f9e44; }
.howto-num.no { background: #c92a2a; }
/* Bloque Urbano / Rural: dos columnas con la regla y las miniaturas de sus edificios (sprites del juego) */
.howto-kinds-intro { font-size: 12px; line-height: 1.5; color: var(--text-muted); margin-bottom: 10px; }
.howto-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.howto-kind { padding: 12px; border-radius: 8px; }
.howto-kind.urban { background: rgba(90,130,190,0.12); border: 1px solid rgba(130,170,230,0.45); }
.howto-kind.rural { background: rgba(120,160,70,0.12); border: 1px solid rgba(150,190,100,0.45); }
.howto-kind-h { display: inline-block; padding: 1px 10px; border-radius: 9px; font-size: 11px; font-weight: bold; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 8px; }
.howto-kind.urban .howto-kind-h { color: #9fc0e8; background: rgba(90,130,190,0.22); border: 1px solid rgba(130,170,230,0.55); }
.howto-kind.rural .howto-kind-h { color: #a9c97c; background: rgba(120,160,70,0.22); border: 1px solid rgba(150,190,100,0.55); }
.howto-kind-rule { font-size: 12px; line-height: 1.5; color: #e8d5a0; margin-bottom: 10px; }
.howto-kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.howto-kind-item { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 10px; line-height: 1.25; color: var(--text-muted); min-width: 0; overflow-wrap: anywhere; hyphens: auto; }   /* nombres largos de una palabra (Schapenboerderij) se partían fuera de su hueco */
.howto-kind-item img { width: 52px; height: 52px; object-fit: contain; image-rendering: pixelated; }
.howto-kind-world { font-size: 9px; line-height: 1; padding: 2px 5px; border-radius: 6px; color: #8fc4e8; background: rgba(90,130,190,0.18); border: 1px solid rgba(130,170,230,0.4); }   /* edificio de un solo mundo */
.howto-num.info { background: #c8952c; }
.howto-kind-ico { font-size: 28px; height: 44px; display: flex; align-items: center; color: #c8a050; }
/* Bloques con tarjetas (carteles, oficios, progreso) y la de recursos */
.howto-pics { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 8px; }
.howto-pic { image-rendering: pixelated; visibility: hidden; }   /* tamaño en _howtoPicFit (escala entera de la tira) */
.howto-pic-arrow { color: var(--gold); font-size: 14px; align-self: center; }
.howto-pic-wx { color: var(--gold); font-size: 22px; width: 30px; text-align: center; align-self: center; }   /* el dorado de los iconos de clima */
.howto-block { padding: 12px; background: rgba(0,0,0,0.25); border: 1px solid #4a3c22; border-radius: 8px; }
.howto-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.howto-cards.jobs { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.howto-cards.flow { grid-template-columns: repeat(4, 1fr); }
.howto-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; padding: 8px 6px; background: rgba(255,255,255,0.03); border: 1px solid #3c3220; border-radius: 6px; }
.howto-card-img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; }
.howto-card-img.pose { width: 56px; height: 56px; }
.howto-card-ico { font-size: 30px; height: 40px; display: flex; align-items: center; color: #c8a050; }
.howto-card-name { font-family: 'Cinzel', serif; font-size: 12px; color: var(--gold-bright); max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
.howto-card-d { font-size: 11px; line-height: 1.4; color: var(--text-muted); }
.howto-cards.flow .howto-card { position: relative; }
.howto-cards.flow .howto-card:not(:last-child)::after { content: '➜'; position: absolute; right: -10px; top: 22px; color: #c8a050; font-size: 14px; }
.howto-chain-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid #3c3220; }
.howto-chain-row:first-of-type { border-top: none; }
.howto-chain-src { display: flex; gap: 8px; flex: 1 1 auto; flex-wrap: wrap; }
.howto-chain-src .howto-kind-item { width: 84px; }
.howto-chain-arrow { color: #c8a050; font-size: 16px; flex-shrink: 0; }
.howto-chain-res { display: flex; align-items: center; gap: 6px; flex: 0 0 120px; font-family: 'Cinzel', serif; font-size: 13px; color: var(--gold-bright); }
.howto-chain-res img { width: 28px; height: 28px; image-rendering: pixelated; }
/* Ruta comercial: fórmula y tabla a la izquierda, lo que la multiplica a la derecha */
.howto-route { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.howto-route-formula { font-family: var(--font-numbers, monospace); font-size: 14px; color: var(--gold-bright); background: rgba(0,0,0,0.3); border: 1px solid #5a4a2a; border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; display: inline-block; }
.howto-route-sub { font-family: 'Cinzel', serif; font-size: 12px; color: var(--gold-bright); margin-bottom: 6px; }
.howto-route-mods { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.howto-route-mods b { color: #e8d5a0; font-weight: 600; }
.howto-table { border-collapse: collapse; font-size: 12px; color: var(--text-muted); }
.howto-table th { font-weight: 600; color: #e8d5a0; text-align: left; padding: 3px 14px 3px 0; border-bottom: 1px solid #5a4a2a; }
.howto-table td { padding: 3px 14px 3px 0; border-bottom: 1px solid #3c3220; }
.howto-table td img { width: 14px; height: 14px; vertical-align: -2px; image-rendering: pixelated; }
@media (max-width: 700px) {
    .howto-route { grid-template-columns: 1fr; }
    .howto-cards.flow { grid-template-columns: 1fr 1fr; }
    .howto-cards.flow .howto-card::after { display: none; }
    .howto-chain-res { flex-basis: 70px; font-size: 11px; }   /* en móvil, miniaturas más pequeñas: caben 3 por fila */
    .howto-chain-src { gap: 4px; }
    .howto-chain-src .howto-kind-item { width: 62px; font-size: 9px; }
    .howto-chain-src .howto-kind-item img { width: 40px; height: 40px; }
    .howto-fig { flex-direction: column; align-items: stretch; }
    .howto-fig img { max-width: 100%; flex-basis: auto; }
    .howto-kinds { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .howto-box { padding: 16px 14px 12px; }
    .howto-tab { padding: 5px 8px; font-size: 11px; }
    #howtoBody .key { min-width: 84px; font-size: 10px; }
}
.howto-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    margin-top: 2px;
    color: var(--gold);
    font-size: 14px;
}

.key {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gold-bright);
    flex-shrink: 0;
    white-space: nowrap;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--panel-border), transparent);
    margin: 12px 0;
}

.mission p {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

.mission strong {
    color: var(--text-light);
}

/* Command Card at bottom-right */
#commandCard {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 280px;
    /* Caps the WHOLE card (title bar + #decoCoinDisplay + scrollable body), not just the body —
       so Cosméticos (which also shows the pinned coin balance/eraser row above the scroll) ends
       up the same total height as Construcciones instead of taller by however much that row
       adds. #commandCardBody is the flex item that actually shrinks to make room for it (see its
       own rule, flex:1 1 auto) — same calc() budget that used to live there directly. Neutralized
       on mobile (see its own #commandCard rule) — there #commandCardBody owns its own separate
       cap instead, by design. */
    max-height: calc(100vh - 280px);
    display: flex;
    flex-direction: column;
}
#commandCard > .panel-title-bar, #commandCard > #decoCoinDisplay { flex-shrink: 0; }

#commandCard h3 {
    font-family: var(--font-heading);
    font-size: 14px;
    color: var(--gold-bright);
    margin-bottom: 0;
    letter-spacing: 1px;
}

/* Construcciones / Cosméticos — folder-style tab flaps sitting above #commandCard's own top
   edge (#commandCard is position:fixed, which is enough of a containing block on its own — no
   extra positioning context needed here). Icon-only: the panel's own title (see
   #buildPanelTitle/_switchBuildTab) already names whichever one is active, so repeating that as
   text on the tab itself was pure redundancy (see the request that prompted this). */
.build-tab-bar {
    position: absolute;
    /* Was -26px — with the 28px tall buttons below (see .build-tab-btn), that let the bottom ~2px
       of each tab overlap INTO #commandCard's own top border/background, which is what actually
       looked wrong (a stacking-context root's own background/border always paints behind its
       children regardless of z-index, so this was never really a winnable z-index fight either
       way). -28px sits the tab flush against the panel's top edge — touching, seam still reads as
       one folder-tab piece with the panel below (see .build-tab-btn's open bottom border) — with
       zero pixels actually inside its box, so nothing is left to render across the icons. */
    /* -31: encima del marco de 3px del panel, no metidas en él (pedido de JC: "las de arriba, hacia arriba") */
    top: -31px;
    left: 14px;
    display: flex;
    gap: 3px;
    z-index: 5;
}
.build-tab-btn {
    width: 32px;
    height: 28px;
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.build-tab-btn:hover { color: var(--text-light); border-color: var(--panel-border-hover); }
.build-tab-btn.active {
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border-color: #6a4a1a;
    color: #2a1e10;
}

.commands-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

/* Categorías de decoración: pestañas de carpeta que salen del lateral izquierdo del panel, con el mismo aspecto que .build-tab-btn. */
.deco-cat-bar {
    position: absolute;
    top: 88px;
    right: calc(100% + 3px);   /* fuera del marco de 3px del panel, apoyadas en él como las de arriba (pedido de JC); en móvil van en fila, ver #decoCatBar */
    display: flex;
    flex-direction: column;
    flex-wrap: wrap-reverse;          /* si no caben en el alto del panel, otra columna hacia fuera (la primera sigue pegada al panel) */
    align-content: flex-start;
    max-height: calc(100% - 96px);
    gap: 3px;
    z-index: 5;
}
.deco-cat-btn {
    width: 34px;
    height: 34px;
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.deco-cat-btn:hover { color: var(--text-light); border-color: var(--panel-border-hover); }
.deco-cat-btn.active {
    background: linear-gradient(160deg, #dfb256, #a97d2f);
    border-color: #6a4a1a;
    color: #2a1e10;
}
/* Con la ventana baja, más compactas: si no, llegarían a los controles de zoom, que están a la misma altura */
@media (max-height: 760px) {
    .deco-cat-bar { top: 60px; max-height: calc(100% - 66px); }
    .deco-cat-btn { height: 28px; }
}
@media (max-height: 620px) {
    .deco-cat-bar { gap: 2px; }
    .deco-cat-btn { height: 24px; }
}
/* El PNG de valla es alto (18×24) y el dibujo ocupa solo la franja de abajo: se amplía esa franja para que se distinga en el botón */
.btn-icon-img.fence-icon {
    object-fit: cover;
    object-position: 50% 100%;
    transform: translateY(-22%) scale(1.45);
}
/* El filtro va en una clase aparte porque updateUI ya usa style.display en algunos de estos botones (Plaza Discord, ancla, nasa) */
.deco-cat-hidden { display: none !important; }
/* Decoración infinita: sin precios ni anuncio para ganar monedas */
body.deco-infinite #decorationsGrid .btn-cost, body.deco-infinite #btnDecoAd { display: none !important; }
/* Clima: rejilla propia, para no heredar las reglas de los botones de construir */
.wx-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; grid-column: 1 / -1; padding: 2px; }
.wx-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 58px; padding: 6px 3px;
    cursor: pointer; font-size: 11px; font-weight: 700; color: var(--text-light); text-align: center;
    background: rgba(0, 0, 0, 0.28); border: 1px solid var(--panel-border-hover); border-radius: 4px;
}
.wx-btn i { font-size: 18px; }
.wx-btn > i { color: var(--gold); }   /* el dorado de siempre (--gold), no un color por clima */
.wx-btn:hover { background: rgba(255, 255, 255, 0.07); }
.wx-price { display: none; font-size: 10px; color: #e8c040; }
.wx-btn.locked .wx-price { display: block; }
.wx-price i { font-size: 10px !important; }
.wx-btn.locked { opacity: 0.85; }
.wx-btn.preview { border-color: #80c8ff; box-shadow: inset 0 0 0 1px #80c8ff; opacity: 1; }
.wx-buy-bar { grid-column: 1 / -1; position: sticky; bottom: 0; justify-content: center; padding: 6px; background: var(--panel-bg, #2a1e10); }
body.wx-tab #decoCoinDisplay .command-btn-danger { display: none; }
.wx-btn.active { border-color: #e8c040; background: rgba(232, 192, 64, 0.2); box-shadow: inset 0 0 0 1px #e8c040; }
@media (max-width: 1024px) and (orientation: portrait) { .wx-grid { grid-template-columns: repeat(4, 1fr); } .wx-btn { min-height: 52px; font-size: 10px; } }
/* Goma: qué se borra */
.deco-erase-opts { flex-basis: 100%; flex-wrap: wrap; gap: 4px; }
.deco-erase-opt {
    flex: 1 1 0; min-width: 0; padding: 4px 2px; cursor: pointer;
    font-size: 11px; font-weight: 700; color: var(--text-light);
    background: rgba(0, 0, 0, 0.3); border: 1px solid var(--panel-border-hover); border-radius: 3px;
}
.deco-erase-opt.active { background: #e8c040; border-color: #e8c040; color: #2a1e10; }
.deco-erase-hint { flex-basis: 100%; font-size: 11px; font-weight: 400; color: var(--text-light); opacity: 0.8; }
/* Las pestañas cuelgan del lateral del panel, que está anclado por abajo: con una lista corta (Favoritas vacía, una categoría con poco)
   el panel se encogía y las últimas pestañas se salían de la pantalla. Lo mínimo es lo que miden ellas en cada tamaño de ventana (ver
   .deco-cat-bar: su top + las pestañas que se ven, --deco-cats, que pone _applyDecoCat). Solo abierto y en Cosméticos; en móvil vertical las
   pestañas son una fila, y no hace falta. Con la ventana baja manda el max-height del panel y las que sobran se van a otra columna. */
@media not all and (max-width: 1024px) and (orientation: portrait) {
    #commandCard:has(#commandCardBody.deco-tab-active:not([style*="display: none"])) { min-height: calc(100px + var(--deco-cats, 10) * 37px); }
}
@media (max-height: 760px) {
    @media not all and (max-width: 1024px) and (orientation: portrait) {
        #commandCard:has(#commandCardBody.deco-tab-active:not([style*="display: none"])) { min-height: calc(72px + var(--deco-cats, 10) * 31px); }
    }
}
@media (max-height: 620px) {
    @media not all and (max-width: 1024px) and (orientation: portrait) {
        #commandCard:has(#commandCardBody.deco-tab-active:not([style*="display: none"])) { min-height: calc(72px + var(--deco-cats, 10) * 26px); }
    }
}
/* Favoritas: la estrella es hermana del botón (ver _initDecoFavStars). El envoltorio ocupa la celda de la rejilla, así que se oculta con su botón */
.deco-btn-wrap { position: relative; display: flex; min-width: 0; }
.deco-btn-wrap > .command-btn { flex: 1 1 auto; min-width: 0; width: 100%; }
.deco-btn-wrap:has(> .deco-cat-hidden), .deco-btn-wrap:has(> .command-btn[style*="display: none"]) { display: none; }
.deco-fav {
    position: absolute; top: 1px; right: 1px; z-index: 2;
    width: 22px; height: 22px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 0; cursor: pointer;
    font-size: 11px; color: rgba(255, 255, 255, 0.45);
    text-shadow: 0 1px 1px #000;
    opacity: 0;
}
.deco-btn-wrap:hover .deco-fav, .deco-fav:focus-visible { opacity: 1; }
.deco-fav:hover { color: #e8c040; }
.deco-fav.is-fav { opacity: 1; color: #e8c040; }
/* Sin ratón no hay "pasar por encima": la estrella se ve siempre */
@media (hover: none) { .deco-fav { opacity: 0.8; } }
.deco-fav-empty { grid-column: 1 / -1; padding: 16px 10px; text-align: center; font-size: 13px; color: var(--text-light); }

/* Subcategory heading inside #decorationsGrid (Cosméticos) — separates the floor tiles
   (GROUND_DECO_TYPES) from the object decorations above them. grid-column:1/-1 so it always
   spans the full row regardless of column count — 1 on this desktop rule above, 4 on the mobile
   #commandCardBody grid (see its own rule; #decorationsGrid becomes display:contents there, so
   this ends up a direct grid item of that 4-column layout instead). */
.deco-section-label {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0;
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.deco-section-label::before, .deco-section-label::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--panel-border), transparent);
}

/* Cantidad libre del mercado: el boton se ilumina cuando TIENES la cantidad escrita entera
   (stock al vender, oro al comprar). Sin esto, "habilitado" solo decia que algo se podia hacer,
   no que fuera lo que has pedido — ver previewMarketCustom. */
.command-btn.mkt-ready {
    border-color: #d8b878;
    color: #f4e4b8;
    box-shadow: inset 0 0 0 1px rgba(216,184,120,.45), 0 0 6px rgba(216,184,120,.25);
}
.command-btn {
    background: linear-gradient(160deg, #3b2f22 0%, #1e160f 100%);
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-light);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
    font-family: var(--font-body);
    width: 100%;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.45);
}

.command-btn:hover:not(:disabled) {
    background: linear-gradient(160deg, #4a3b28 0%, #241a10 100%);
    border-color: var(--panel-border-hover);
    box-shadow: inset 0 0 10px rgba(223, 178, 86, 0.14), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.command-btn:active:not(:disabled) {
    transform: scale(0.98);
    background: linear-gradient(160deg, #241a10 0%, #3b2f22 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.command-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #4a3a28;
    background: linear-gradient(160deg, #221a12, #16110c);
    color: var(--text-dim);
    text-shadow: none;
    box-shadow: none;
}
/* "que los recursos que ya tengo se vean en blanco, así sé a simple vista cuál me falta": en los
   botones cuyo coste viene de renderCostHTML (.cost-part), el botón no se atenúa entero — la
   opacidad de un padre no se puede deshacer en un hijo — sino pieza a pieza: icono, nombre y los
   recursos que FALTAN a media luz, y los que ya tienes en blanco y a plena luz. Cualquier otro
   botón desactivado sigue exactamente igual (regla de arriba). */
/* El botón tiene que verse IGUAL que cualquier desactivado ("el botón no cambia, mismo tono"):
   el fondo y el borde llevan el 50% en el propio color (rgba) en vez de en la opacidad del botón,
   que es lo que da el mismo resultado sin atenuar a los hijos; luego cada pieza se atenúa por su
   cuenta, menos los recursos que ya tienes. */
.command-btn:disabled:has(.cost-part) {
    opacity: 1;
    background: linear-gradient(160deg, rgba(34, 26, 18, 0.5), rgba(22, 17, 12, 0.5));
    border-color: rgba(74, 58, 40, 0.5);
}
.command-btn:disabled:has(.cost-part) > :not(.btn-info),
.command-btn:disabled:has(.cost-part) .btn-info > :not(.btn-cost),
.command-btn:disabled:has(.cost-part) .btn-cost > :not(.cost-part):not(.cost-grid),
.command-btn:disabled:has(.cost-part) .btn-cost .cost-miss { opacity: 0.5; }
/* Su color NORMAL (el de un botón activo, que .btn-cost ya fija en --text-muted), solo sin atenuar. */
.command-btn:disabled .cost-part.cost-ok { opacity: 1; }

/* Building gifted for free by a skill (dona*/canteras) — green frame is now the ONLY signal
   (besides the already-green cost label), replacing the old separate "free building!"
   notification card that used to nag about it on top. */
.command-btn.free-gift {
    border-color: #44cc44;
    box-shadow: inset 0 0 10px rgba(68, 204, 68, 0.18), 0 2px 4px rgba(0, 0, 0, 0.45);
}
.command-btn.free-gift:hover:not(:disabled) {
    border-color: #5eda5e;
}

/* "hay dos colores en algunos botones, rojo y verde... un poco fuera de estética" — Mover/
   Demoler (y, a mano, Cancelar/Acabar/Empezar Reto/Descargar Imagen, que no son .command-btn de
   verdad pero comparten la misma idea) usaban un rojo y un verde bastante saturados/fríos, tipo
   alerta de app web. Primer intento (degradado tintado + texto en color) seguía leyendo "neón
   semitransparente"; el siguiente (gris neutro, Demolish más oscuro que Move) quedaba "raro" —
   deslucido/como deshabilitado en una interfaz que por lo demás es toda marrón cálido. Ahora dos
   marrones en vez de gris: Move usa un marrón más claro/cálido que el marrón por defecto de
   .command-btn (para notarse distinto de un botón de "Construir X" cualquiera) con el mismo borde
   dorado-marrón de siempre (--panel-border); Demoler reutiliza el marrón rojizo oscuro que YA usa
   el botón Cancelar del Reto (#362119/#6e3f30) — así "demoler" se lee como su propio "cuidado,
   esto no se deshace" sin salir nunca del marrón. Reutilizados a mano (mismos valores hex) en
   .mob-act-move/.mob-act-demolish para móvil. */
.command-btn-danger {
    background: linear-gradient(160deg, #362119 0%, #1a100c 100%);
    border-color: #6e3f30;
    color: var(--text-light);
}
.command-btn-danger:hover:not(:disabled) {
    background: linear-gradient(160deg, #452a1f 0%, #221410 100%);
    border-color: #8a5040;
}
.command-btn-positive {
    background: linear-gradient(160deg, #4a3826 0%, #241c12 100%);
    border-color: var(--panel-border);
    color: var(--text-light);
}
.command-btn-positive:hover:not(:disabled) {
    background: linear-gradient(160deg, #5a4530 0%, #2c2216 100%);
    border-color: var(--panel-border-hover);
}

/* Tutorial guidance — a strong, animated marker on whatever button the current step wants the
   player to press next (see TUTORIAL_HIGHLIGHT_TARGETS/_tutoApplyHighlight in main.js). Reuses
   .free-gift's same green ("this one, right here") but pulses and glows much harder — that one is
   a quiet, permanent badge meant to blend in once you know to look for it; this one has to catch
   a brand-new player's eye immediately; it can't read as the same easy-to-miss signal. */
@keyframes tutoHighlightPulse {
    0%, 100% { box-shadow: inset 0 0 12px rgba(80, 230, 80, 0.35), 0 0 2px rgba(80, 230, 80, 0.5), 0 2px 4px rgba(0, 0, 0, 0.45); }
    50%      { box-shadow: inset 0 0 20px rgba(80, 230, 80, 0.6), 0 0 22px rgba(80, 230, 80, 0.9), 0 2px 4px rgba(0, 0, 0, 0.45); }
}
.command-btn.tuto-highlight {
    border-color: #5eff5e;
    border-width: 2px;
    animation: tutoHighlightPulse 1.1s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

.mres-btn {
    flex: 1;
    background: linear-gradient(160deg, #3b2f22 0%, #1e160f 100%);
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 10px;
    font-family: var(--font-body);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.mres-btn:hover { background: linear-gradient(160deg, #4a3b28, #241a10); border-color: var(--panel-border-hover); }
.mres-btn:active { transform: scale(0.97); }
.mres-btn.selected { background: linear-gradient(160deg, #5a4720, #352708); border-color: var(--gold); color: var(--gold-bright); }
.mres-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-icon-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 32px;
    gap: 2px;
}
.btn-icon {
    font-size: 24px;
    color: var(--gold);
    text-align: center;
}
/* Decoration buttons show the real sprite instead of a Font Awesome glyph — grayscale at rest
   (matches the muted look of every other unselected button here), full color on hover so the
   preview still reads as "this one" without a second dedicated selected state. */
.btn-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    image-rendering: pixelated;
    filter: grayscale(1);
    transition: filter 0.15s ease;
}
.command-btn:hover:not(:disabled) .btn-icon-img {
    filter: grayscale(0);
}
.btn-size {
    font-size: 9px;
    color: var(--text-dim);
    font-family: var(--font-numbers);
    letter-spacing: 0.5px;
    line-height: 1;
}

.btn-info {
    display: flex;
    flex-direction: column;
}

.btn-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
}

.btn-desc {
    font-size: 10px;
    color: var(--text-dim);
    font-style: italic;
    margin-top: 1px;
    line-height: 1.3;
}

.btn-cost {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    white-space: nowrap;
    font-family: var(--font-numbers);
}

/* "el cancelar del edificio que sea el único texto del botón" — mientras ese botón está en modo
   "Cancelar" (ver _updateBuildButtonToggleLabels en main.js), se oculta el icono/tamaño y el coste
   y el label que queda se centra solo, en vez de quedarse pegado a la izquierda con un hueco vacío
   donde iba el icono. */
.command-btn.btn-cancel-mode {
    justify-content: center;
}
.command-btn.btn-cancel-mode .btn-icon-wrap,
.command-btn.btn-cancel-mode .btn-cost {
    display: none;
}
.command-btn.btn-cancel-mode .btn-label {
    text-align: center;
}

/* Precio + crédito de diseño en la misma fila (ver deco.designer_jc) — así el botón no crece
   una línea más por decoración. */
.btn-cost-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.btn-cost-row .btn-cost,
.btn-cost-row .btn-desc {
    margin-top: 0;
}

.wipe-btn {
    background: linear-gradient(to bottom, #6b2e2e, #4a1f1f);
    border: 3px outset #8a3f3f;
    border-radius: 0;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #ffb3b3;
    cursor: pointer;
    width: 100%;
    text-align: center;
    transition: all 0.1s ease;
    margin-top: 8px;
    font-family: var(--font-body);
    text-shadow: 1px 1px 2px #000;
}

.wipe-btn:hover {
    background: linear-gradient(to bottom, #8a3f3f, #5a2626);
    border-color: #aa4f4f;
    box-shadow: inset 0 0 5px rgba(255,255,255,0.2);
}

.wipe-btn:active {
    border-style: inset;
    background: linear-gradient(to bottom, #4a1f1f, #6b2e2e);
}

/* Selection Panel Styling */
/* Skins: pestaña de carpeta pegada a la derecha de la ficha del edificio (en móvil, encima) y su panel */
.skin-flap {
    position: fixed;
    width: 34px;
    height: 42px;
    z-index: 51;
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    border-left: none;
    border-radius: 0 6px 6px 0;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.skin-flap.on-top { width: 44px; height: 36px; border: 2px ridge var(--panel-border); border-bottom: none; border-radius: 6px 6px 0 0; }
.skin-flap:hover { color: var(--text-light); border-color: var(--panel-border-hover); }
.skin-flap.active { background: linear-gradient(160deg, #dfb256, #a97d2f); border-color: #6a4a1a; color: #2a1e10; }
#skinPanel { position: fixed; z-index: 51; flex-direction: column; gap: 8px; overflow-y: auto; padding: 12px; box-sizing: border-box; }
.skin-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; color: var(--gold-bright); font-family: var(--font-heading); }
.skin-coins { font-family: var(--font-numbers); color: var(--text-light); font-size: 13px; }
.skin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.skin-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 2px; background: rgba(0, 0, 0, 0.25); border: 1px solid #5d4630; border-radius: 4px; color: var(--text-muted); font-size: 10.5px; line-height: 1.15; cursor: pointer; min-width: 0; }
.skin-cell img { width: 48px; height: 72px; object-fit: contain; image-rendering: pixelated; }
/* Las mulas: un 16×16 cuadrado no necesita el alto de un edificio */
.skin-cell img[src*="mule"] { height: 48px; transform: scaleX(-1); }
.skin-cell:hover { border-color: var(--panel-border-hover); color: var(--text-light); }
.skin-cell.current { border-color: var(--panel-border-inner); }
.skin-cell.selected { border-color: var(--gold-bright); background: rgba(223, 178, 86, 0.18); color: var(--text-light); }
.skin-apply { flex-shrink: 0; padding: 8px; background: linear-gradient(160deg, #dfb256, #a97d2f); border: 1px solid #6a4a1a; border-radius: 4px; color: #2a1e10; font-weight: 700; cursor: pointer; font-family: var(--font-body); }
.skin-hint { flex-shrink: 0; text-align: center; font-size: 12px; color: var(--text-muted); padding: 6px; }
.skin-short { color: #e08a7a; }

#selectionPanel {
    position: fixed;
    bottom: 20px;
    left: 20px; /* used to slide over from 316px when the old #leftSide controls panel was open
                   and not collapsed — that panel is gone now (see #controlsModal), so this is
                   just its permanent resting position. */
    width: 260px;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.18s ease,
                transform 0.18s ease;
    z-index: 50;
}
#selectionPanel.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.selection-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.selection-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
/* Decoraciones: el sprite real en vez del glifo (ver el caso DECO_TYPES de
   _getBuildingDescriptorInner). A color, no en gris como en la tienda — aquí ya está elegida y
   puesta, no es una opción entre otras. 28px para ocupar lo mismo que el icono al que sustituye. */
/* Animal elegido en un edificio de mulas: 16×16 y mirando al mismo lado que en el mapa */
.mule-skin-icon { image-rendering: pixelated; transform: scaleX(-1); }
.worker-stepper .ws-icon .mule-skin-icon { width: 24px; height: 24px; }
.selection-icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    image-rendering: pixelated;
    vertical-align: middle;
}

.selection-info {
    display: flex;
    flex-direction: column;
}

.selection-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 14px;
    color: var(--gold-bright);
}

.selection-workers {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.selection-status {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    width: 100%;
    margin-top: 6px;
}

/* Tutorial Panel Styling */
/* var(--tuto-scale, 1) — set live by _updateTutoBoostScale() (main.js) right before either
   animation can start. Without it, these keyframes (which fully own `transform` while playing,
   overriding any inline value) always played the sign-in/out motion at full size and only snapped
   to the correct #offlineBoostStrip-avoiding scale once the animation ended — "calcula bien el
   escalado del tutorial antes de la animacion para que no haga escalado raro despues". */
@keyframes tuto-sign-out {
    0%   { transform: translateX(-50%) rotate(0deg)  scale(var(--tuto-scale, 1)); opacity: 1; }
    100% { transform: translateX(70%)  rotate(10deg) scale(var(--tuto-scale, 1)); opacity: 0; }
}
@keyframes tuto-sign-in {
    0%   { transform: translateX(-160%) rotate(-10deg) scale(var(--tuto-scale, 1)); opacity: 0; }
    65%  { transform: translateX(-46%)  rotate(2deg)   scale(var(--tuto-scale, 1)); opacity: 1; }
    82%  { transform: translateX(-52%)  rotate(-1deg)  scale(var(--tuto-scale, 1)); opacity: 1; }
    100% { transform: translateX(-50%)  rotate(0deg)   scale(var(--tuto-scale, 1)); opacity: 1; }
}
/* Loading screen: villager takes a chop, tree shakes right as the axe lands. Same total
   duration on both so they stay phase-locked across every loop; the tree's animation-delay
   just shifts where in ITS OWN cycle that loop starts, lining its shake up with the chop's
   downswing (~78% through the villager's cycle) instead of its own 0%. */
@keyframes lv-chop {
    0%   { transform: rotate(0deg); }
    60%  { transform: rotate(-26deg); }
    78%  { transform: rotate(20deg); }
    100% { transform: rotate(0deg); }
}
#lv-char {
    transform-origin: 50% 82%;
    animation: lv-chop 1.2s ease-in-out infinite;
}
@keyframes lv-tree-shake {
    0%        { transform: rotate(0deg); }
    3%        { transform: rotate(7deg); }
    10%       { transform: rotate(-5deg); }
    17%       { transform: rotate(3deg); }
    23%       { transform: rotate(-1deg); }
    25%, 100% { transform: rotate(0deg); }
}
#lv-tree {
    transform-origin: 50% 85%;
    animation: lv-tree-shake 1.2s ease-in-out infinite;
    animation-delay: 0.94s;
}

@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

#tutorialPanel {
    /* "pegado al header de arriba" — top is overwritten live by _positionTutorialPanel() in
       main.js, which pins this to #topBar's actual rendered bottom edge (handles the two-line
       header wrap, mobile's whole different layout, etc.). This 74px is just the pre-JS fallback
       so it doesn't flash at some other spot for a frame before that runs. */
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    /* "no deberia verse grande y luego ajustado" — same reasoning as #offlineBoostStrip's own
       transition above: _updateTutoBoostScale() can now shrink this panel too (once the strip
       itself has already hit its own floor and there's still not enough room) via inline transform
       changes on resize, and this smooths those into a resize instead of a snap. Coexists fine
       with the .tuto-in/.tuto-out step-change animations below — those drive transform via
       `animation`, which takes priority over a `transition` on the same property while active. */
    transition: transform 0.12s ease-out;
    width: 380px; /* "hazlo mas pequeño en general" — was 448px ("20% mas pequeño" from an even earlier 560px) */
    max-width: calc(100% - 40px);
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 2px;
    /* "menos aire tb en la descripcion por los lados y el titulo menos padding tb" — tightened all
       three sides (was 13px 21px 22px). Bottom still reserves the step-counter strip (see
       .step-indicator below) — it's out of the flex flow, so without this the description/Cerrar
       button would run straight over it; just needed slightly less room now that everything else
       shrank too. The collapsed rule drops it further, since the counter is hidden there. */
    padding: 10px 14px 20px;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.9), inset 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
#tutorialPanel.tuto-out {
    animation: tuto-sign-out 0.22s ease-in forwards;
    pointer-events: none;
}
#tutorialPanel.tuto-in {
    animation: tuto-sign-in 0.35s cubic-bezier(0.22,1,0.36,1) forwards;
    pointer-events: none;
}

#tutorialPanel:hover {
    border-color: var(--panel-border-hover);
    box-shadow: 6px 6px 14px rgba(0, 0, 0, 0.95), inset 0 0 12px rgba(0, 0, 0, 0.6);
}

/* Collapse toggle — same ▼(expanded)/▲(collapsed) convention as #btnToggleCommandCard, its own
   corner button (no shared .panel-title-bar to hang off here, so this positions itself directly
   against the panel instead). */
#btnToggleTutorial {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--gold);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 2px;
    line-height: 1.4;
    transition: background 0.1s ease, border-color 0.1s ease;
}
#btnToggleTutorial:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--panel-border-hover);
}
/* Collapsed: keep only the title (what to do) visible — the longer description, the close button
   and the step counter all drop out. Same idea as #commandCardBody's collapse, just no separate
   wrapper div to hide since the whole panel is small enough that hiding individual children is
   simpler here. */
#tutorialPanel.tuto-collapsed p,
#tutorialPanel.tuto-collapsed .step-indicator,
#tutorialPanel.tuto-collapsed #btnCloseTutorial {
    display: none;
}
/* No step counter down there to clear anymore once collapsed, so the reserved bottom room below
   goes away with it. */
#tutorialPanel.tuto-collapsed {
    padding-bottom: 10px;
}

/* "que eso esté en una esquina abajo" — the step counter used to be a full-width row ABOVE the
   title, which both pushed the title down and competed with it for attention. Absolutely
   positioned into the panel's bottom-left corner instead (last child in the DOM, see index.html),
   out of the flex flow entirely: the title now gets the top of the panel to itself, and hiding
   this when collapsed shifts nothing else around. The panel reserves room for it via its own
   padding-bottom below, so it never lands on top of the description or the Cerrar button. */
#tutorialPanel .step-indicator {
    position: absolute;
    bottom: 5px;
    left: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gold);
    font-weight: bold;
    line-height: 1.2;
    opacity: 0.75; /* secondary info now that it's out of the title's spot — present, not competing */
}

#tutorialPanel h2 {
    font-family: var(--font-heading);
    font-size: 17px;
    color: var(--gold-bright);
    margin-bottom: 5px; /* was 7px — less air under the title, per "el titulo menos padding tb" */
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px #000;
}

/* Text sizes above/below are trimmed lightly, not the full 20% the box shrank by — the mobile
   override further down already learned this lesson once ("cut too aggressively (~30% smaller)
   before; text especially needed to grow back up") and there's no reason to repeat it here. */
#tutorialPanel p {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-light);
    text-shadow: 1px 1px 1px #000;
}

#btnCloseTutorial {
    margin-top: 8px;
    background: linear-gradient(to bottom, #a06b3a, #5c4033);
    border: 2px ridge var(--panel-border-inner);
    border-radius: 0;
    color: var(--text-light);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: bold;
    padding: 5px 16px;
    cursor: pointer;
    text-shadow: 1px 1px 2px #000;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    transition: all 0.1s ease;
}

#btnCloseTutorial:hover {
    background: linear-gradient(to bottom, #bdae93, #8b5a2b);
    border-color: #ffdf80;
}

#btnCloseTutorial:active {
    transform: scale(0.97);
    border-style: inset;
}

/* Cola de avisos de reliquias: filas pequeñas apiladas a la izquierda, debajo del minimapa (top/left
   los pone _placeRelicQueue según dónde esté el minimapa; esto es solo el valor de partida).
   Sustituye a la tarjeta grande (.chest-notification), que tapaba el centro de la pantalla. */
.relic-queue {
    position: fixed;
    top: 380px;
    left: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    pointer-events: none;
    max-width: calc(100% - 44px);
}
.relic-chip {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 7px;
    max-width: 280px;
    padding: 4px 4px 4px 9px;
    font-size: 12px;
    line-height: 1.25;
    color: var(--text-light);
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    text-shadow: 1px 1px 1px #000;
    animation: relicChipIn 0.25s ease-out;
}
.relic-chip:hover { border-color: var(--panel-border-hover); }
.relic-chip .rc-icon { color: var(--gold-bright); font-size: 13px; flex-shrink: 0; }
.relic-chip .rc-text { font-weight: bold; color: var(--gold-bright); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.relic-chip.ready { border-color: #4f9a4f; }
.relic-chip.strike { border-color: #b0502f; }
.relic-chip.strike .rc-icon, .relic-chip.strike .rc-text { color: #f0a47f; }
.relic-chip.ready .rc-icon, .relic-chip.ready .rc-text { color: #8fe08f; }
.relic-chip.ach { border-color: #c9a227; }   /* logro desbloqueado */
.relic-chip.ach .rc-icon, .relic-chip.ach .rc-text { color: #f0d060; }
.relic-chip .rc-close {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 14px; line-height: 1; padding: 2px 5px; flex-shrink: 0;
}
.relic-chip .rc-close:hover { color: var(--text-light); }
.relic-queue .rc-clear {
    pointer-events: auto; background: rgba(0, 0, 0, 0.45); border: 1px solid var(--panel-border); border-radius: 3px;
    color: var(--text-muted); font-size: 11px; padding: 2px 8px; cursor: pointer; text-shadow: 1px 1px 1px #000;
}
.relic-queue .rc-clear:hover { color: var(--text-light); border-color: var(--panel-border-hover); }
.relic-queue .rc-more { pointer-events: none; font-size: 11px; color: var(--text-muted); text-shadow: 1px 1px 1px #000; padding-right: 4px; }
@keyframes relicChipIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }

/* Relic / free-building notification card */
.chest-notification {
    top: 130px;
    left: 50%;
    transform: translateX(-50%);
    width: 560px;
    max-width: calc(100% - 40px);
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 2px;
    padding: 16px 26px;
    box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.9), inset 0 0 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
}

.chest-notification:hover {
    border-color: var(--panel-border-hover);
    box-shadow: 6px 6px 14px rgba(0, 0, 0, 0.95), inset 0 0 12px rgba(0, 0, 0, 0.6);
}

.chest-notif-text strong {
    display: block;
    font-family: var(--font-heading);
    font-size: 19px;
    color: var(--gold-bright);
    margin-bottom: 8px;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px #000;
}

.chest-notif-text span {
    display: block;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-light);
    text-shadow: 1px 1px 1px #000;
}

.chest-notif-text .chest-notif-hint {
    margin-top: 8px;
    color: var(--gold);
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chest-notif-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
}

.chest-notif-close:hover {
    color: var(--text-light);
}

/* Skill area wrapper */
.skill-area {
    /* Was flex-direction:column — SKILLS stacked directly on top of STATS, each carrying its own
       full 4px-ridge button chrome, made this the tallest column in #topBar and (since #topBar
       uses align-items:stretch) dragged the WHOLE bar's height up to match it. Side by side now,
       same as every other cluster in the bar. */
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Countdown panel (before first chest) */
.tree-countdown {
    cursor: default;
    min-width: 130px;
    justify-content: center;
}

.countdown-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.countdown-label {
    font-family: var(--font-body);
    font-size: 9px;
    font-weight: 600;
    color: #7a9068;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.countdown-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.countdown-value {
    font-family: var(--font-numbers);
    font-size: 26px;
    font-weight: 700;
    color: #c8e8a0;
    line-height: 1;
}

.countdown-unit {
    font-family: var(--font-body);
    font-size: 11px;
    color: #6a8858;
    font-weight: 400;
}

/* "Next: X 🌲" inside SKILLS button */
.next-chest-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-family: var(--font-body);
    font-size: 9px;
    color: #7a9060;
    letter-spacing: 0.3px;
    pointer-events: none;
    line-height: 1.1;
}

.next-chest-info .fa-tree {
    color: #7dbe6a;
    font-size: 10px;
}

/* Short mode (icon-only SKILLS button, see _updateTopBarFit): drop the "Next:" word and lead
   with the tree icon instead of trailing it — "🌲 48" instead of "Next: 48 🌲". */
.skill-tree-btn.icon-only .next-chest-label {
    display: none;
}
.skill-tree-btn.icon-only .next-chest-info .fa-tree {
    order: -1;
}

/* Skill Tree Button */
.skill-tree-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 16px;
    flex: 0 1 auto;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--gold-bright);
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    transition: border-color 0.15s ease, color 0.15s ease;
}
.skill-btn-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Narrow-desktop degradation (see _updateTopBarFit in main.js) — drops the "SKILLS"/"STATS"
   word so the button is just its icon (plus, for SKILLS, whatever compact counters already sit
   next to/under it — those stay, they're actual info, not a decorative label). */
.skill-tree-btn.icon-only {
    padding: 4px 10px;
}
.skill-tree-btn.icon-only .skill-btn-label {
    display: none;
}
.skill-tree-btn.icon-only #relicCountBadge {
    display: none;
}

.skill-tree-btn:hover {
    border-color: var(--panel-border-hover);
    color: #fff;
}

.skill-tree-btn.skill-has-points {
    border-color: #ffd700;
    color: #ffd700;
    animation: skillPulse 1.4s ease-in-out infinite;
}

@keyframes skillPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 215, 0, 0.4); }
    50%       { box-shadow: 0 0 18px rgba(255, 215, 0, 0.9); }
}

.skill-badge {
    font-size: 14px;
    font-weight: 900;
    color: #ffd700;
}

/* Punto rojo del botón de Novedades — solo visible mientras haya una entrada del CHANGELOG más
   reciente que la última vez que el jugador abrió el panel (ver _updateChangelogDot). */
.changelog-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #e05050;
    box-shadow: 0 0 4px rgba(224, 80, 80, 0.8);
}
.changelog-entry { margin-bottom: 14px; }
.changelog-entry:last-child { margin-bottom: 0; }
.changelog-entry-date {
    font-family: 'Roboto Mono', monospace;
    font-size: 10px;
    color: #8a7c5e;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
/* Subtítulo de sección dentro de una versión (ver _buildChangelogHTML): mismo tono que la
   fecha pero en Cinzel, para que se lea como cabecera y no como una viñeta más. */
.changelog-section {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    color: #c8a050;
    letter-spacing: .6px;
    margin: 10px 0 3px;
}
.changelog-entry .changelog-section:first-of-type { margin-top: 2px; }
.changelog-entry ul { margin: 0; padding-left: 18px; }
.changelog-entry li { font-size: 12px; color: #e8dfd0; line-height: 1.7; }
.changelog-divider { border: none; border-top: 1px solid #3a2e1e; margin: 14px 0; }


/* ── Skill Card Modal ────────────────────────────────────────────────────── */
.skill-card-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scOverlayIn 0.2s ease forwards;
}

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

.skill-card-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 32px 36px 36px;
    background: var(--panel-bg-gradient);
    border: 4px ridge var(--panel-border);
    border-radius: 4px;
    box-shadow: 0 0 60px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.4);
    max-width: 500px;
    width: calc(100% - 40px);
    max-height: 85vh;
    overflow-y: auto;
    animation: scPanelIn 0.25s cubic-bezier(0.22,1,0.36,1) forwards;
}

@keyframes scPanelIn {
    from { transform: scale(0.88); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.skill-card-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 900;
    color: var(--gold-bright);
    letter-spacing: 2px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    text-align: center;
    margin: 0;
}

.skill-card-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.skill-card-view-tree-btn:hover {
    background: rgba(180,140,40,0.28) !important;
    border-color: #c8a030 !important;
    box-shadow: 0 0 12px rgba(200,160,48,0.35);
}

.skill-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 14px 18px 14px 16px;
    position: relative;
    width: 100%;
    background: linear-gradient(160deg, #3d3024 0%, #1a140f 100%);
    border: 3px ridge var(--panel-border);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.6);
}

.skill-card:hover {
    transform: scale(1.055);
    border-color: var(--gold);
    box-shadow: 0 0 22px rgba(223,178,86,0.45), 2px 2px 12px rgba(0,0,0,0.7);
}

.skill-card:active {
    transform: scale(0.99);
}

.skill-card-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    filter: grayscale(0.4);
}

.skill-card-disabled:hover {
    transform: none;
    border-color: var(--panel-border);
    box-shadow: 2px 2px 10px rgba(0,0,0,0.6);
}

.skill-card-icon {
    font-size: 28px;
    color: var(--gold);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    line-height: 1;
    flex-shrink: 0;
    width: 36px;
    text-align: center;
}

.skill-card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.skill-card-name {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    color: var(--gold-bright);
    text-align: left;
    letter-spacing: 0.8px;
    line-height: 1.3;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}

.skill-card-desc {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--text-muted);
    text-align: left;
    line-height: 1.4;
    flex: 1;
}

/* Debug label in skill tree */
.stk-debug-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: #7a9068;
    text-align: center;
    letter-spacing: 0.8px;
    padding: 3px 10px;
    opacity: 0.7;
}

/* ── Skill Card Tree (debug view) ─────────────────────────────────────────── */
#stkCardTreeContainer {
    padding: 16px 20px;
    overflow: auto;
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #8b5a2b #1a140f;
}
#stkCardTreeContainer::-webkit-scrollbar { width: 6px; height: 6px; }
#stkCardTreeContainer::-webkit-scrollbar-track { background: #1a140f; }
#stkCardTreeContainer::-webkit-scrollbar-thumb { background: #6b4018; border-radius: 3px; }

/* Each node = card + optional arrow + optional children column */
.sct-node {
    display: flex;
    align-items: flex-start;
    gap: 0;
}
.sct-kids-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sct-arrow {
    color: #5a4020;
    font-size: 20px;
    align-self: center;
    padding: 0 4px;
    flex-shrink: 0;
    line-height: 1;
}

/* The card itself */
.sct-card {
    width: 130px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px 10px;
    background: linear-gradient(160deg, #3d3024 0%, #1a140f 100%);
    border: 2px ridge var(--panel-border);
    border-radius: 4px;
    position: relative;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.6);
}
.sct-active {
    border-color: #38c850;
    box-shadow: 0 0 12px rgba(56,200,80,0.3), 2px 2px 8px rgba(0,0,0,0.6);
    background: linear-gradient(160deg, #1e3018 0%, #111a0e 100%);
}
.sct-available {
    border-color: #dfb256;
    box-shadow: 0 0 12px rgba(223,178,86,0.25), 2px 2px 8px rgba(0,0,0,0.6);
}
.sct-locked {
    border-color: #2e2618;
    opacity: 0.45;
}

/* Badge top-right corner */
.sct-badge {
    position: absolute;
    top: 3px; right: 5px;
    font-size: 12px;
    font-weight: 700;
}
.sct-badge-active { color: #38c850; }
.sct-badge-avail  { color: #dfb256; }

.sct-icon {
    font-size: 26px;
    line-height: 1;
}
.sct-active   .sct-icon { color: #38c850; text-shadow: 0 0 8px rgba(56,200,80,0.5); }
.sct-available .sct-icon { color: #dfb256; text-shadow: 0 0 8px rgba(223,178,86,0.4); }
.sct-locked   .sct-icon { color: #4a3820; }

.sct-name {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    color: var(--gold-bright);
    text-align: center;
    letter-spacing: 0.5px;
    line-height: 1.3;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}
.sct-locked .sct-name { color: #5a4a30; }

.sct-desc {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
}
.sct-sub {
    font-size: 9px;
    color: #7a5a2a;
    text-align: center;
    line-height: 1.3;
}

/* Skill Tree Panel */
.skill-tree-panel {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 0;
    border: none;
    /* Excluded from --ui-scale (it also has .game-ui, which would otherwise zoom it) — this is
       a fullscreen takeover screen, not a HUD panel, and zoom shrinking a 100vw/100dvh box left
       a visible border around it instead of staying edge-to-edge at any scale but 100%. */
    zoom: 1 !important;
    background: #080700;
}
#stkContainer {
    flex: 1;
    min-height: 0;
    overflow: hidden; /* navigation is zoom+drag, not scroll — see initStkPanZoom() */
    padding: 0;
    background: #0d0f0a;
    position: relative;
    cursor: grab;
}
#stkContainer.stk-dragging { cursor: grabbing; }

/* Minimapa del árbol (ver _stkDrawMinimap). Va DENTRO de #stkContainer, que es position:relative
   con overflow:hidden, así que queda anclado a su esquina y recortado como el resto. El tamaño en
   píxeles lo fija el JS a partir de la proporción del árbol — aquí solo el marco. */
#stkMinimap {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 5;
    background: rgba(13, 15, 10, 0.88);
    border: 1px solid #3a4030;
    border-radius: 4px;
    cursor: pointer;
    touch-action: none;   /* el arrastre sobre la miniatura lo gestiona el pointermove, no el scroll */
}

/* Nodes (64×64, icon-only) are free-positioned (absolute, set in JS) radiating out from the
   center — one spoke per branch, depth along the spoke = position in that branch's chain.
   The whole thing is panned/zoomed via a CSS transform (see initStkPanZoom()). */
#stkGrid {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}
/* Matriz del modo arreglo (ver stkToggleArrangeMode / renderSkillTree): una celda por nodo, con
   una línea por celda y otra más marcada cada 5. Aquí NO va ninguna medida — el paso lo elige
   stkGridCell (botón "Celda" de la barra dev), así que tanto background-size como background-position
   los fija el JS en cada render, en el propio espacio de coordenadas de los nodos. El orden de las
   4 capas debe coincidir con el que arma renderSkillTree: acento-X, acento-Y, celda-X, celda-Y. */
#stkGrid.stk-grid-arrange {
    background-image:
        linear-gradient(to right,  rgba(64,224,208,0.34) 0 1px, transparent 1px),
        linear-gradient(to bottom, rgba(64,224,208,0.34) 0 1px, transparent 1px),
        linear-gradient(to right,  rgba(64,224,208,0.14) 0 1px, transparent 1px),
        linear-gradient(to bottom, rgba(64,224,208,0.14) 0 1px, transparent 1px);
    background-repeat: repeat;
}
/* Dos nodos imantados a la MISMA celda: lo único que puede romper una cuadrícula sin que se note a
   simple vista cuando uno tapa al otro. Se marca en rojo mientras dure el modo arreglo. */
#stkGrid.stk-grid-arrange .stk-cell-collision {
    outline: 2px solid #ff5a5a !important;
    box-shadow: 0 0 12px rgba(255, 90, 90, 0.7);
}

.stk-link {
    stroke: #2a2c22;
    stroke-width: 2;
    stroke-dasharray: 4 4;
}
.stk-link.stk-link-active {
    stroke: #8a6a1a;
    stroke-width: 3;
    stroke-dasharray: none;
}
.stk-link.stk-link-highlight {
    stroke: #e07020 !important;
    stroke-width: 4 !important;
    stroke-dasharray: none !important;
}

.stk-cell {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    position: relative;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    z-index: 1;
}

/* Skills that unlock/gift a building are square instead of round */
.stk-cell.stk-cell-square {
    border-radius: 8px;
}

/* AVAILABLE — soft gold, subtle glow */
.stk-cell.available {
    background: linear-gradient(160deg, #22280f 0%, #131809 100%);
    border: 2px solid #8a6a1a;
    box-shadow: 0 0 6px rgba(160,120,30,0.2);
}
.stk-cell.available:hover {
    transform: scale(1.15);
    border-color: #c8a030;
    box-shadow: 0 0 14px rgba(200,160,48,0.35);
    z-index: 2;
}

/* PURCHASED — bright green, clearly completed */
.stk-cell.purchased {
    background: linear-gradient(160deg, #0d2e0d 0%, #071807 100%);
    border: 2px solid #2e7a2e;
    box-shadow: 0 0 12px rgba(60,160,60,0.3), inset 0 0 8px rgba(60,160,60,0.1);
}
.stk-cell.purchased:hover { transform: scale(1.15); z-index: 2; }

/* LOCKED — almost invisible */
.stk-cell.locked {
    background: #0a0c08;
    border: 2px solid #1a1c16;
    opacity: 0.55;
}
.stk-cell.locked:hover { transform: scale(1.15); opacity: 0.85; z-index: 2; }

.stk-cell.stk-cell-prereq-highlight {
    border-color: #e07020 !important;
    box-shadow: 0 0 18px rgba(220,110,30,0.6) !important;
    opacity: 1 !important;
    transform: scale(1.1);
    z-index: 2;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

/* LEGACY (prestige reset tiers) — a different family from the gold/green of the rest of the
   tree: purchased = red; purchasable = ORANGE with a pulse ("que los comprados salgan en rojo
   pero los que están para comprar se vean naranjas, que se distinga mejor"). */
.stk-cell.stk-cell-legacy.available {
    background: linear-gradient(160deg, #2e1a08 0%, #1a0e04 100%);
    border: 2px solid #d07020;
    box-shadow: 0 0 8px rgba(230,130,40,0.4);
    animation: stkLegacyPulse 1.4s ease-in-out infinite;
}
.stk-cell.stk-cell-legacy.available:hover {
    transform: scale(1.15);
    border-color: #ff9a3c;
    box-shadow: 0 0 16px rgba(255,150,50,0.6);
    z-index: 2;
}
.stk-cell.stk-cell-legacy.available .stk-cell-icon { color: #ff9a3c; }
.stk-cell.stk-cell-legacy.available .stk-cell-label { color: #f0b070; }
@keyframes stkLegacyPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(230,130,40,0.35); }
    50%      { box-shadow: 0 0 18px rgba(255,150,50,0.7); }
}
.stk-cell.stk-cell-legacy.purchased {
    background: linear-gradient(160deg, #2a0a0a 0%, #150505 100%);
    border: 2px solid #8a2a2a;
    box-shadow: 0 0 12px rgba(180,40,40,0.3), inset 0 0 8px rgba(180,40,40,0.1);
}
.stk-cell.stk-cell-legacy.purchased .stk-cell-icon { color: #c85050; }

/* Marks the current relic card options when peeking at the tree from the card modal */
.stk-cell.stk-cell-peek-pick {
    border-color: #40d0e0 !important;
    box-shadow: 0 0 4px rgba(64,208,224,0.5), 0 0 20px rgba(64,208,224,0.55) !important;
    opacity: 1 !important;
    z-index: 2;
    animation: stkPeekPulse 1.1s ease-in-out infinite;
}
@keyframes stkPeekPulse {
    0%, 100% { box-shadow: 0 0 4px rgba(64,208,224,0.4), 0 0 14px rgba(64,208,224,0.4); }
    50%      { box-shadow: 0 0 8px rgba(64,208,224,0.7), 0 0 26px rgba(64,208,224,0.75); }
}

/* Purchase-order badge — small numbered notification-style bubble on owned nodes showing the
   order they were bought in this run (e.g. "3" for the 3rd skill ever picked). Top-right corner,
   neutral grey so it reads as informational, not an alert. */
.stk-cell-order-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    border-radius: 50%;
    background: #6a6a6a;
    border: 2px solid #1a1a1a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.6);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
}

.stk-cell-icon {
    font-size: 22px;
    line-height: 1;
}
.stk-cell.available .stk-cell-icon { color: #b89030; }
.stk-cell.purchased .stk-cell-icon { color: #5aaa5a; }
.stk-cell.locked    .stk-cell-icon { color: #45483a; font-size: 16px; }

/* Node name label — shows the skill's translated name (or "???" while still a mystery) */
.stk-cell-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    /* 2px, no 4: con el paso de rejilla en 100px la etiqueta de dos lineas llegaba a 60,4px
       bajo el centro de su nodo y el anillo de progreso del nodo de ABAJO empieza a 61px
       (STK_CELL+14 centrado, o sea que sobresale 39px). 0,6px de margen = la etiqueta, opaca y
       en z-index 3, recortaba el arco superior del anillo en 38 de los 106 nodos. Con 2px de
       margen y line-height 1.1 la holgura sube a 3px. Si se vuelve a tocar el paso de rejilla o
       el tamano del anillo, rehacer esta cuenta. */
    margin-top: 2px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    color: #d8d0b8;
    background: rgba(0,0,0,0.7);
    padding: 1px 5px;
    border-radius: 3px;
    /* Con el paso de rejilla en 100px una etiqueta de una sola linea tendria que caber en 92px,
       y a 10px de fuente eso corta el 54% de los nombres del arbol ("Area de Recolecc..."). Se
       envuelve a DOS lineas en su lugar: el nombre entero se lee y el solape horizontal tampoco
       ocurre. Cabe de sobra en vertical — nodo de 64px centrado + 4px de margen + 24,4px de
       etiqueta llega a 60,4px bajo el centro, y el nodo de la fila siguiente no empieza hasta los
       68px. El clamp a 2 lineas es el tope que protege esa holgura si algun nombre creciera. */
    white-space: normal;
    text-align: center;
    line-height: 1.1;
    max-width: 96px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    pointer-events: none;
    z-index: 3;
}
.stk-cell.locked .stk-cell-label { color: #7a7a6a; }
.stk-cell.available .stk-cell-label { color: #d4a840; }

/* Big hover tooltip: name/description, or the lock reason, for whichever node is hovered */
#stkTooltip {
    position: fixed;
    z-index: 50;
    width: 300px;
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 4px;
    padding: 16px 20px;
    box-shadow: 4px 4px 14px rgba(0,0,0,0.9), inset 0 0 10px rgba(0,0,0,0.5);
    pointer-events: none;
}
#stkTooltip .stk-tip-name {
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold-bright);
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px #000;
}
#stkTooltip .stk-tip-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-light);
}

/* Worker-stats hover breakdown (Cap/Rate/Spd on a farm/quarry/etc. info panel) — shows the
   itemized terms that add up to the displayed number, see _wstat/_showWstatTooltip. */
#wstatTooltip {
    position: fixed;
    z-index: 60;
    min-width: 150px;
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    border-radius: 4px;
    padding: 8px 10px;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.85), inset 0 0 8px rgba(0,0,0,0.5);
    pointer-events: none;
    display: none;
}
#wstatTooltip .wst-line {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 11px;
    color: var(--text-light);
    white-space: nowrap;
    line-height: 1.5;
}
#wstatTooltip .wst-total {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.2);
    font-weight: 700;
    color: var(--gold-bright);
}

/* Build-menu hover info card — shown on hover over a build button, before placing anything.
   See _showBuildInfo/_hideBuildInfo. */
#buildInfoTooltip {
    position: fixed;
    z-index: 100010;   /* por encima de las ventanas (reinicio de Legado: 10001); no tapa clics (pointer-events: none) */
    max-width: 300px;
    background: var(--panel-bg-gradient);
    border: 2px ridge var(--panel-border);
    border-radius: 4px;
    padding: 10px 12px;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.85), inset 0 0 8px rgba(0,0,0,0.5);
    pointer-events: none;
    display: none;
}
#buildInfoTooltip .bminfo-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 15px;
    font-weight: 700;
    color: var(--gold-bright);
    margin-bottom: 6px;
    white-space: nowrap;
}
#buildInfoTooltip .bminfo-desc {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-light);
}

/* Click popup shown for a relic-card candidate node while peeking at the tree — same
   look as the hover tooltip, but interactive (has a "choose this" button) and stays
   open until dismissed, since a hover tooltip would vanish before the click lands. */
#stkPickPopup {
    position: fixed;
    z-index: 55;
    width: 300px;
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--gold);
    border-radius: 4px;
    padding: 16px 20px;
    box-shadow: 4px 4px 14px rgba(0,0,0,0.9), inset 0 0 10px rgba(0,0,0,0.5);
}
#stkPickPopup .stk-pick-popup-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}
#stkPickPopup .stk-tip-name {
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold-bright);
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px #000;
}
#stkPickPopup .stk-tip-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-light);
    margin-bottom: 14px;
}
#stkPickPopup .stk-pick-popup-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(160deg,#2a1a00,#130d00);
    border: 2px solid var(--gold);
    border-radius: 6px;
    color: var(--gold-bright);
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
}
#stkPickPopup .stk-pick-popup-btn:hover {
    background: linear-gradient(160deg,#3a2400,#1a1200);
    box-shadow: 0 0 10px rgba(223,178,86,0.4);
}

.skill-points-row {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 0;
}

.skill-points-row strong {
    color: #ffd700;
    font-size: 16px;
}

.chest-progress-row {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
}

.skill-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--panel-border), transparent);
}

/* --- Branched skill tree layout --- */
.skill-tree-branches {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-start;
}

.skill-branch {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.skill-branch-header {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    padding: 5px 4px;
    border: 1px solid var(--panel-border);
    border-bottom: none;
    border-radius: 2px 2px 0 0;
    background: rgba(0,0,0,0.3);
    margin-bottom: 0;
}

.skill-branch-nodes {
    border: 1px solid var(--panel-border);
    border-radius: 0 0 2px 2px;
    background: rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 6px;
}

.skill-branch-connector {
    width: 2px;
    height: 10px;
    background: var(--gold);
    opacity: 0.35;
    margin: 0 auto;
    flex-shrink: 0;
}

.skill-fork {
    display: flex;
    flex-direction: row;
    gap: 6px;
    width: 100%;
    position: relative;
}
/* Horizontal bar linking the two fork branches */
.skill-fork::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--gold);
    opacity: 0.35;
}
.skill-fork-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.skill-node {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    padding: 8px 8px;
}

.skill-node-icon {
    font-size: 20px;
    color: var(--gold);
    min-width: 22px;
    text-align: center;
    padding-top: 2px;
}

.skill-node-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.skill-node-name {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    color: var(--gold-bright);
    line-height: 1.2;
}

.skill-node-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
}

.skill-buy-btn {
    background: linear-gradient(to bottom, #6b3a1f, #3d1f0a);
    border: 2px outset #8b5a2b;
    color: var(--text-light);
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.1s ease;
    border-radius: 2px;
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

.skill-buy-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #8b5a2b, #5c3a18);
    border-color: #dfb256;
}

.skill-buy-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Active skill (already bought) */
.skill-buy-btn.skill-active {
    background: linear-gradient(to bottom, #1a3d1a, #0f280f);
    border-color: #4a8a4a;
    color: #7dbe6a;
    opacity: 1;
}

/* Pending/selected for next run */
.skill-buy-btn.skill-selected {
    background: linear-gradient(to bottom, #5a4500, #3a2c00);
    border-color: #ffd700;
    border-style: solid;
    color: #ffd700;
    opacity: 1;
    animation: skill-pulse 1.5s ease-in-out infinite;
}

@keyframes skill-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 215, 0, 0.4); }
    50%       { box-shadow: 0 0 10px rgba(255, 215, 0, 0.8); }
}

/* Marked for removal next run */
.skill-buy-btn.skill-removing {
    background: linear-gradient(to bottom, #4a0000, #2a0000);
    border-color: #cc3333;
    border-style: solid;
    color: #ff6666;
    opacity: 1;
    animation: skill-pulse-red 1.5s ease-in-out infinite;
}

@keyframes skill-pulse-red {
    0%, 100% { box-shadow: 0 0 4px rgba(200, 50, 50, 0.4); }
    50%       { box-shadow: 0 0 10px rgba(200, 50, 50, 0.8); }
}

/* Locked (prereq not met) */
.skill-buy-btn.skill-locked {
    background: linear-gradient(to bottom, #2a2a2a, #1a1a1a);
    border-color: #444;
    color: #555;
    opacity: 1;
}

/* Nueva Partida — bottom bar */
.skill-new-run-bar {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 0 14px;
    background: rgba(8,7,0,0.7);
    border-top: 1px solid #2e2210;
}

.skill-new-run-btn {
    padding: 12px 48px;
    background: linear-gradient(to bottom, #5a3000, #2e1400);
    border: 2px solid #8b5a2b;
    border-radius: 4px;
    color: #c89050;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.skill-new-run-btn:hover {
    background: linear-gradient(to bottom, #7a4200, #4a2000);
    border-color: #dfb256;
    color: #f0c870;
    box-shadow: 0 4px 18px rgba(0,0,0,0.6);
}

.skill-new-run-btn.skill-new-run-ready {
    background: linear-gradient(to bottom, #6a5000, #3e2e00);
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 18px rgba(255,215,0,0.35);
}

.skill-new-run-btn.skill-new-run-ready:hover {
    background: linear-gradient(to bottom, #8a6a00, #5a4200);
    box-shadow: 0 0 28px rgba(255,215,0,0.55);
}

/* ---- Canvas Skill Tree ---- */

/* Floating info card — overlays canvas bottom-left */
#stkInfo {
    position: absolute;
    bottom: 24px;
    left: 24px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(160deg, #1c1810 0%, #110e08 100%);
    border: 2px solid #5a4820;
    border-radius: 6px;
    padding: 16px 18px 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.75), inset 0 1px 0 rgba(255,220,100,0.07);
    pointer-events: auto;
    z-index: 10;
}
#stkInfoTop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.stk-branch-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #a88040;
    background: rgba(255,200,80,0.07);
    border: 1px solid #3a2e10;
    border-radius: 3px;
    padding: 2px 8px;
    white-space: nowrap;
}
.stk-close-btn {
    background: none;
    border: none;
    color: #5a4820;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.1s;
}
.stk-close-btn:hover { color: #c08030; }
.stk-name {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: #f0d070;
    line-height: 1.15;
    letter-spacing: 0.3px;
}
.stk-desc {
    font-size: 13px;
    color: #c8b880;
    line-height: 1.5;
    border-left: 3px solid #3a2e10;
    padding-left: 10px;
}
#stkInfoFooter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid #2a2210;
    padding-top: 10px;
}
.stk-state {
    font-size: 11px;
    color: #7a6a38;
    flex: 1;
    line-height: 1.3;
}
.stk-buy-btn {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    padding: 7px 18px;
    border-radius: 3px;
    border: 2px solid #8b5a2b;
    cursor: pointer;
    white-space: nowrap;
    background: linear-gradient(to bottom, #4a2a0a, #281408);
    color: #c8a060;
    transition: all 0.12s ease;
    flex-shrink: 0;
}
.stk-buy-btn:hover:not(:disabled) { background: linear-gradient(to bottom, #6a4a1a, #4a2a08); border-color: #dfb256; color: #fff0c0; }
.stk-buy-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stk-btn-add    { background: linear-gradient(to bottom, #1a3a0a, #0f280a); border-color: #4a8a2a; color: #90e060; }
.stk-btn-add:hover:not(:disabled)  { background: linear-gradient(to bottom, #2a5a14, #1a3a0a); border-color: #8ade4a; color: #c0ff80; }
.stk-btn-desel  { background: linear-gradient(to bottom, #3a2400, #1e1200); border-color: #c8922a; color: #e8a840; }
.stk-btn-desel:hover { background: linear-gradient(to bottom, #5a3c08, #3a2400); color: #ffd060; }
.stk-btn-keep   { background: linear-gradient(to bottom, #1a0808, #0e0404); border-color: #c04040; color: #ff8080; }
.stk-btn-cancel { background: linear-gradient(to bottom, #08101e, #040a12); border-color: #4a80c0; color: #80b8ff; }

/* Destroy building panel */
.destroy-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.destroy-panel-header strong {
    color: var(--text-light);
    text-transform: none;
    letter-spacing: 0;
}

.destroy-refund-info {
    font-size: 13px;
    padding: 6px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    min-height: 24px;
}

.panel-close-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--gold);
    cursor: pointer;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-body);
    line-height: 1.4;
    pointer-events: auto;
    transition: background 0.1s, border-color 0.1s;
}
.panel-close-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--panel-border-hover);
}

/* Panel minimize/collapse */
.panel-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.panel-collapse-btn {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--gold);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 2px;
    font-family: var(--font-body);
    transition: background 0.1s ease, border-color 0.1s ease;
    line-height: 1.4;
    pointer-events: none; /* decorative — the parent .panel-title-bar catches the click instead */
}

/* #btnToggleCommandCard is a sibling of .panel-title-bar (not nested inside it) so it can stay
   reachable on mobile even when the title bar itself is hidden — it needs its own click handling
   and its own positioning to still land in the same visual spot the old nested layout gave it. */
#btnToggleCommandCard {
    position: absolute;
    top: 8px;
    right: 16px;
    pointer-events: auto;
    /* Same reasoning as .build-tab-bar's own z-index right below — #commandCardBody being a flex
       item now paints at an implicit z-index:0, and this had none at all (z-index:auto), so DOM
       order (this comes before commandCardBody) could leave it covered instead of on top. */
    z-index: 5;
}

.panel-title-bar:hover .panel-collapse-btn {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--panel-border-hover);
}

/* The skill tree is a fullscreen takeover (unlike every other panel, which is a small docked
   box) — its own close button gets much more visual weight to match, instead of the same
   tiny corner "✕" every other panel uses. */
.stk-close-btn {
    font-size: 26px !important;
    padding: 4px 16px !important;
    line-height: 1 !important;
}

.panel-title-bar h3 {
    margin-bottom: 0;
}

#commandCardBody {
    margin-top: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    /* The cap itself now lives on #commandCard (see its own rule right above — same original
       calc(), just covering the whole card instead of only this body, so Cosméticos' pinned
       coin-balance/eraser row above this doesn't make that tab taller overall than
       Construcciones). flex:1 1 auto is what makes this the piece that actually shrinks to make
       room for it; min-height:0 overrides flexbox's default "never shrink below content size" so
       the scrollbar can actually kick in instead of just pushing the card past its own cap. */
    flex: 1 1 auto;
    min-height: 0;
    transition: opacity 0.15s ease;
}

/* Shared themed scrollbar — every scrollable panel in the game (build menu, stats, skill-card
   choice, slot picker...) uses this same gold-on-dark design instead of the browser default.
   Apply via class="themed-scrollbar" on whatever element has overflow:auto/scroll. */
.themed-scrollbar {
    scrollbar-width: auto;
    scrollbar-color: #8b5a2b #1a140f;
}
.themed-scrollbar::-webkit-scrollbar { width: 14px; }
.themed-scrollbar::-webkit-scrollbar-track {
    background: #1a140f;
    border-left: 1px solid #3d3024;
}
.themed-scrollbar::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #a0692a, #6b4018, #a0692a);
    border-radius: 6px;
    border: 2px solid #dfb256;
}
.themed-scrollbar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #dfb256, #a0692a, #dfb256);
    border-color: #ffdf80;
}


/* Animations and Responsive Styles */
/* ── Top bar chrome ──
   #topBar is ONE solid recuadro (its own border/bg/shadow, like .ui-panel) instead of several
   loose pieces each with their own frame — the sections inside stay transparent and are
   separated by thin divider lines (.topbar-sep) instead. Unconditional (no media query), so
   this same skin carries through into the MOBILE PORTRAIT breakpoint near the end of this file
   too — that block only changes the bar's position/wrapping/sizing, never its look; an earlier
   version of it went fully transparent with each section as its own separate floating chip, but
   that read as a different, unfinished-looking header rather than a resized version of this one.
   #btnSettings used to be excluded from this list, keeping its own self-contained
   .settings-gear-btn border/bg/shadow "system" on desktop — "que también sea así en desktop":
   now it's in the list too, flattened + auto-sized to match #btnStats/#btnAchievements
   everywhere, not just on mobile (see that rule right below, and its own former mobile-only
   block further down, now just the position override it always also needed). */
#topBar {
    background: var(--panel-bg-gradient);
    border: 3px ridge var(--panel-border);
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 0 10px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}
.logo-panel,
#gameTimerPanel,
.top-resources-panel,
#treeCountdown,
#btnSkillTree,
#btnStats,
#btnAchievements,
#btnRetos,
#btnSettings,
.stats-panel {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
/* #btnSettings dropped its old fixed 44×44 .settings-gear-btn box along with the border above —
   auto-sized to its own icon + padding instead, same idiom .skill-tree-btn.icon-only already
   uses for STATS/LOGROS once their text label drops (see that rule elsewhere in this file). */
#btnSettings {
    width: auto !important;
    height: auto !important;
    padding: 6px 10px !important;
    font-size: 18px !important;
}
#btnSkillTree:hover,
#btnStats:hover,
#btnAchievements:hover,
#btnRetos:hover,
#btnSettings:hover {
    background: rgba(223, 178, 86, 0.08) !important;
}
/* Separadores verticales de la cabecera: FUERA.
   Cada panel ya tiene su propio fondo y su borde, así que la rayita entre ellos no separaba nada
   que no estuviera separado — solo añadía ruido a una barra que va justa de sitio (más aún ahora
   con el banner). Los elementos se quedan en el DOM porque _updateTopBarFit los enciende y apaga
   junto al logo y al reloj; al ponerles display:none aquí, ese `style.display = ''` los devuelve
   a oculto y no a visible. */
.topbar-sep {
    display: none;
    width: 1px;
    align-self: stretch;
    margin: 10px 0;
    background: var(--panel-border);
    opacity: 0.5;
    flex-shrink: 0;
}

/* Last rung of _updateTopBarFit()'s shrink ladder (drop logo → drop timer → icon-only buttons →
   compact villager stats → THIS), toggled by JS, not a media query — it has to work independent
   of the MOBILE PORTRAIT breakpoint below, which only ever fires in portrait orientation. A
   landscape phone, or a plain narrow/windowed desktop browser, can fall below the bar's minimum
   comfortable single-line width without ever matching that breakpoint, and previously just had
   nothing left to do but overflow. This wraps the (by now already-minimal) remaining content
   onto a second row instead of clipping it. */
#topBar.topbar-2line {
    flex-wrap: wrap;
    row-gap: 4px;
    justify-content: center;
}
#topBar.topbar-2line .topbar-sep { display: none; }

/* Minimap resize grip — bottom-right corner on desktop, top-left on mobile (see
   initMinimapResize() in main.js for why: the panel itself is pinned, not draggable, so this is
   the only way left to make it bigger/smaller). Three diagonal notches via a repeating gradient,
   same idea as a native OS resize grip. 135deg here (desktop's own corner) — "rótala 90 grados a
   la derecha" from the previous 45deg. Mobile gets its own opposite rotation instead of reusing
   this angle (see the MOBILE PORTRAIT block's own #minimapResizeHandle rule) — "en móvil rótala
   90 grados a la izquierda", i.e. -45deg, not the same 135deg desktop uses now. */
#minimapResizeHandle {
    background:
        linear-gradient(135deg, transparent 0 40%, var(--panel-border) 40% 46%, transparent 46% 60%, var(--panel-border) 60% 66%, transparent 66% 80%, var(--panel-border) 80% 86%, transparent 86%);
    opacity: 0.8;
}
#minimapResizeHandle:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════
   MOBILE PORTRAIT — the ONE and ONLY responsive breakpoint in this entire file. There are
   exactly two designs: everything above this point (unconditional, no media query) is the
   desktop layout; everything inside this block is the mobile-vertical override. No other
   @media query exists anywhere else in index.css — if you're about to add one, it almost
   certainly belongs in here instead, or this condition needs to grow to cover the new case.
   Also covers tablets in portrait (iPad-class widths up to 1024px), whose header otherwise
   overflows/gets cut off under the desktop topbar layout. Must match _MQ_PORTRAIT in main.js
   exactly — both gate the same behavior; there is no equivalent "desktop" JS media query
   because desktop is simply !_MQ_PORTRAIT.matches everywhere in the code.
   ═══════════════════════════════════════════════════ */
#buildScrollBar { display: none; }   /* solo móvil vertical, ver _initBuildScrollBar */
@media (max-width: 1024px) and (orientation: portrait) {

    /* ── TOP BAR — same elements as desktop (no more separate mobile-only duplicates, no more
       drag-anywhere positioning), just compact and wrapped into as many rows as it takes. Same
       ONE-solid-recuadro skin as desktop (see the unconditional #topBar rule above) — this used
       to go transparent with each section as its own separate dark chip; kept the desktop look
       instead, just pinned full-width at the very top edge. ── */
    #topBar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: auto;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center;
        justify-content: center;
        gap: 4px;
        /* Right padding reserves the corner #btnSettings is absolutely positioned into (see its
           own rule below) so no other header content flows underneath it: it ends up ~32px wide
           at right:6px, so 44px leaves a ~6px gap. Was 56px, sized for the old fixed 44×44 gear —
           that left ~18px of dead space no longer needed, which is real estate a narrow phone
           header can't spare. */
        padding: 4px 6px;   /* el engranaje ya no va en la esquina: está en la 2.ª fila (ver abajo) */
        border-radius: 0;
        background: var(--panel-bg-gradient);
        border: 3px ridge var(--panel-border);
        border-top: none;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55), inset 0 0 10px rgba(0, 0, 0, 0.35);
        /* No more per-child transform:scale dance — every child is a normal flex item again
           (like desktop), so the ordinary .game-ui zoom:var(--ui-scale) inheritance just works. */
    }

    /* "el mensaje de necesitas un camino y tal que se vea arriba encima del header" — en desktop
       #buildToast vive cerca del panel de construir (bottom:80px, ver su estilo inline en
       index.html), pero en móvil ese panel ocupa la parte de abajo de la pantalla y el aviso pasa
       desapercibido ahí. Lo sube arriba del todo, por encima de la cabecera — su z-index:600 (ya
       en el inline) es más alto que el de #topBar (auto), así que queda pintado ENCIMA de la
       cabecera, no empujándola ni ocupando hueco aparte. !important porque el bottom/top vienen
       fijados inline en el propio elemento.
    */
    #buildToast {
        top: 6px !important;
        bottom: auto !important;
    }

    .logo-panel        { display: none !important; }
    /* Game timer: dropped too — logo + timer + resources + villager/territory was wrapping to a
       full 3rd row on top of everything else, tall enough that the offer/boost strips positioned
       just under the header (see _positionMobileOfflineStrips in main.js) had noticeably less
       clearance to work with. The timer is the least essential of the four (resources, skills,
       and villagers/territory all stay), and it's still one tap away in Stats. */
    #gameTimerPanel    { display: none !important; }
    #topbarSepLogo,
    #topbarSepTimer    { display: none !important; }

    /* Still relative to #topBar itself, and still vertically centered off the bar's own live
       height — see the desktop rule for why a fixed top offset can't work here (the mobile header
       is exactly the layout that wraps to a 2nd row, so it's the case that broke first). Only the
       right inset changes: 6px to match the header's own mobile padding (4px 44px 4px 6px, see
       #topBar above) instead of sitting flush against its very edge. The transform has to be
       repeated because this rule would otherwise not carry it — and it needs !important since the
       properties around it do. The flat/auto-sized look itself (background/border/width/height)
       is unconditional now, see #btnSettings's own base rule further up — this only overrides the
       one thing that's genuinely still mobile-specific: a slightly smaller icon than desktop's,
       matching the same shrink every other header icon gets at this width. */
    #btnSettings {
        position: static !important;
        transform: none !important;
        order: 4;
        flex-shrink: 0;
        padding: 4px 8px !important;
        font-size: 16px !important;
    }
    /* Cabecera en dos filas fijas (propuesta de JC): 1.ª los recursos, a todo el ancho; 2.ª Población/Territorio a la izquierda y los botones
       (habilidades, estadísticas, logros, retos) + ajustes a la derecha. Antes el contenido fluía y se partía donde caía. */
    #topBar { justify-content: space-between; }
    #topBar .topbar-sep { display: none !important; }
    #topResourcesPanel { order: 1; flex: 1 1 100% !important; justify-content: center; padding-left: 2px; padding-right: 2px; }
    #topBar .stats-panel { order: 2; }
    #hudSkillArea { order: 3; margin-left: auto; }
    #cgBannerHeaderSlot { order: 5; }

    /* ── SETTINGS PANEL: centered modal, not a corner-docked card ──
       "que el ajustes sea un panel centrado en medio de la pantalla y lo demás difuminado y no
       clickeable" — desktop's own top:70px/right:20px corner spot (see the unconditional rule)
       makes no sense on a narrow phone: not enough width for a 280px card to sit beside anything,
       and nothing behind it needs to stay visible/reachable the way it does on desktop (the whole
       point of Settings here is a focused, modal stop). #settingsBackdrop (see index.html,
       toggled alongside this panel in toggleSettingsPanel()) is the same dimmed full-screen layer
       every OTHER modal in this game already uses (#controlsModal, #statsPanel,
       #achievementsPanel, ...) — same rgba(0,0,0,0.82), so this reads as one consistent "modal"
       language instead of a one-off. Being a real element (not just this panel's own ::before)
       is also what makes the rest of the screen genuinely non-clickeable: it physically sits in
       front of the canvas in paint order, absorbing the tap instead of letting it fall through to
       whatever building/tile is underneath — tapping it closes the panel too, same as any other
       modal's backdrop. */
    #settingsBackdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.82);
        z-index: 899; /* one below .settings-panel's own z-index:900, just needs to sit behind it */
    }
    .settings-panel {
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%) !important;
        width: calc(100vw - 32px) !important;
        max-width: 340px !important;
        /* Desktop's max-height formula (100vh - 190px) reserves margin for corner-specific
           neighbours — the collapsed build panel, the CrazyGames overlay — none of which matter
           once this is a centered modal over a dimmed backdrop instead. */
        max-height: 80vh !important;
    }

    /* ── Recursos: fila compacta (misma disposición horizontal que en desktop) ── */
    .top-resources-panel {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center;
        gap: 0;
        flex: 0 0 auto;
        padding: 3px 8px;
    }
    .top-res-sep   { display: none !important; }
    /* Medidas en vw para que los 5 recursos quepan en la fila de arriba también en pantallas de 320px (sin media query, ver cabecera del bloque) */
    .top-res       { padding: 0 clamp(2px, 1.3vw, 6px); gap: clamp(2px, 1vw, 4px); }
    .top-res-value { font-size: clamp(9px, 2.9vw, 11px); line-height: 1; min-width: 0; }
    .res-icon-hud  { width: clamp(11px, 3.6vw, 14px); height: clamp(11px, 3.6vw, 14px); }
    .top-res-rate  { display: none !important; } /* "en pc" — no space for it on a phone-width header */

    /* ── Aldeanos / Territorio: mismo bloque que desktop, al mínimo ──
       :not(#spectatorInfoPanel) on the display rule — that panel shares .stats-panel purely for
       layout (see its own HTML comment) but starts display:none inline and is only ever shown
       by initSpectatorMode() toggling that inline style; forcing it visible here with
       !important leaked it into normal gameplay on mobile/narrow widths. The sizing rules below
       (gap/padding/etc.) still apply to it once it's actually shown — only forced visibility is
       excluded. ── */
    .stats-panel:not(#spectatorInfoPanel) {
        display: flex !important;
        gap: 8px;
        padding: 3px 8px;
    }
    #spectatorInfoPanel.stats-panel {
        gap: 8px;
        padding: 3px 8px;
    }
    .stats-panel .top-stat { gap: 3px; padding: 0 4px; }
    .stats-panel .top-stat-label { font-size: 7px; letter-spacing: 0.5px; }
    .stats-panel .top-stat-value { font-size: 12px; }
    /* Igual que .top-res-value justo arriba: en vertical no sobra ancho para reservar hueco,
       y el baile de un par de píxeles importa menos que que quepa todo. */
    #villagerValue, #tilesValue { min-width: 0; }

    /* ── SKILLS / STATS: icono + contadores compactos (igual que .icon-only en desktop
       estrecho), sin la palabra "SKILLS"/"STATS" ni el badge de reliquias totales — el
       contador de árboles restantes SÍ se mantiene, es información activa, no una etiqueta. ── */
    .skill-area {
        flex-direction: row !important;
        gap: 4px;
        flex-shrink: 0;
        align-items: stretch;
        justify-content: center;
    }
    #treeCountdown { display: none !important; }
    .skill-tree-btn {
        padding: 4px 8px !important;
    }
    .skill-btn-label,
    #relicCountBadge { display: none !important; }
    .skill-btn-main i { font-size: 16px !important; }
    /* #nextChestInfo's own display (flex/none) is driven entirely by JS (updateUI/_stkUpdateArea)
       — nothing to override here, just reuse the same icon-first compact order as desktop. */
    #nextChestInfo .next-chest-label { display: none; }
    #nextChestInfo .fa-tree { order: -1; }

    /* ── CONTROLS MODAL: the W A S D row has no touch equivalent at all (no physical keyboard on
       mobile) — every other row in there mentions both the PC gesture and its touch counterpart
       in the same line (see ctrl.key_* in lang.js), but there's nothing to say here, so it's
       hidden outright instead of forcing a translated label onto an unreachable control. ── */
    #ctrlRowWasd { display: none !important; }

    /* ── MINIMAP: an outer ceiling, no matter what ──
       "que pueda ser bastante más grande en móvil" — was 33vw, now 75vw, matching
       _minimapMaxSize()'s own JS-side ceiling (keep both in sync if either changes — that
       function's own clamp reads live off getBoundingClientRect, so the two can never disagree
       even though this is the one that actually paints). _minimapDefaultGeometry()'s own mobile
       default (120px) is already sized for a ~390px phone, but the panel is still user-resizable
       (see #minimapResizeHandle/initMinimapResize in main.js) up to this — and whatever size that
       lands on gets persisted (see saveMinimapGeometry). min-width is relaxed too: CSS resolves a
       min/max conflict in min-width's favor, so leaving the desktop 120px floor in place here
       could still win over 75vw on a genuinely small phone and defeat the cap it's meant to
       enforce. Height isn't set here on purpose — the resize handler always writes it equal to
       width directly, so it stays square without any separate enforcement pass. */
    /* min-height acompaña a min-width: el contenedor es cuadrado y se redimensiona con un único
       valor para los dos lados, así que soltar solo uno de los dos suelos es lo que convertía un
       tamaño malo en una BARRA naranja (ancho al suelo, alto a cero) en vez de en un cuadrado
       pequeño reconocible. Aquí se sueltan ambos a la vez, igual que en escritorio se ponen ambos. */
    #minimapContainer {
        max-width: 75vw !important;
        min-width: 0 !important;
        min-height: 0 !important;
    }

    /* "en pc deberían estar las flechas de agrandar en la esquina inferior derecha" (see the
       desktop default in index.html) — mobile keeps its own opposite corner instead: the panel
       is anchored bottom-right there (see _minimapDefaultGeometry), so top-left is its free one.
       initMinimapResize() (main.js) checks _MQ_PORTRAIT at drag-start to flip the grow direction
       to match, same live check every other mobile-specific behavior here already keys off. */
    #minimapResizeHandle {
        top: 0 !important;
        left: 0 !important;
        bottom: auto !important;
        right: auto !important;
        /* "en móvil rótala 90 grados a la izquierda" — the opposite turn from desktop's 135deg
           (see the unconditional rule above), not the same angle: -45deg here, same gradient
           stops otherwise. */
        background:
            linear-gradient(-45deg, transparent 0 40%, var(--panel-border) 40% 46%, transparent 46% 60%, var(--panel-border) 60% 66%, transparent 66% 80%, var(--panel-border) 80% 86%, transparent 86%) !important;
    }

    /* ── ZOOM +/- : the bottom-center desktop spot doesn't exist on mobile — the whole bottom
       strip is the build bar below (#commandCard, bottom:0 there too) — so this moves to the
       right edge, vertically centered, clear of both the header above and the bar below. Back to
       stacked (column) here too — a horizontal pair would stick out past the edge instead of
       hugging it. ── */
    #zoomControls {
        bottom: auto !important;
        /* 38% y no 50%: el minimapa va pegado encima del panel de construir y, con el panel alto (Cosméticos) o en pantallas bajas,
           su borde de arriba llegaba a pisar el + / - . Algo más arriba del centro lo deja libre. */
        top: 38% !important;
        left: auto !important;
        right: 8px !important;
        transform: translateY(-50%) !important;
        flex-direction: column !important;
    }

    /* ── TUTORIAL CROWDING: the minimap isn't much use this early anyway (barely anything's been
       explored yet) and the tutorial dialog sits right where it lives on this narrow a screen —
       hidden for the whole tutorial (see _updateMobileTutoCrowding in main.js — body.fn-tuto-
       crowded), not just while the dialog is expanded. Trying to show it from Settings while this
       is active shows a toast instead (see _toggleMinimapFromSettings). The offline boost strip
       used to be hidden here too, but now has its own dedicated spot instead (see #zoomControls'
       rule above and _positionMobileOfflineStripsNow) — clear of the tutorial dialog either way,
       nothing left to hide it FOR.
       #offlineAdOfferStrip (the "extra resources available" + 1-min countdown strip) is the
       opposite case: it still sits top-right right below the header (same spot _positionTutorial-
       Panel pins the dialog to), and on a narrow phone the dialog is nearly full-width there —
       "se solapa y se ve mal" — so it's hidden for the whole tutorial too, same convention as the
       minimap above. The offer itself isn't lost — _pendingOfflineAdOffer just keeps waiting, the
       strip reappears the moment fn-tuto-crowded clears (tutorial finished or closed). ── */
    body.fn-tuto-crowded #minimapContainer,
    body.fn-tuto-crowded #offlineAdOfferStrip {
        display: none !important;
    }

    /* "que se oculte el mapa cuando entro a una ficha de edificio o de aldeano para que no se vea
       partido por el fondo" — toggled by updateUI() (main.js), see its own comment: the minimap's
       mobile spot sits in the same bottom-of-screen region #selectionPanel takes over, so its
       background otherwise visibly cut the map in half. Purely transient (not the saved show/hide
       preference, see toggleMinimap/saveMinimapHidden) — gone the instant the selection closes. */
    body.fn-selection-crowded #minimapContainer {
        display: none !important;
    }

    /* ── BOTTOM BUILD BAR ── */
    #commandCard {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: auto !important;
        /* Undoes the desktop rule's max-height/flex-column — mobile deliberately leaves this
           whole card uncapped (the collapse tab is its escape hatch), with #commandCardBody
           owning its own separate 60vh cap+scroll instead (see that rule further down). */
        max-height: none !important;
        padding: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        z-index: 200 !important;
    }
    #commandCard .panel-title-bar { display: none !important; }

    /* Collapse tab: the title bar itself (which normally holds this button) is hidden above to
       save space, so this is pulled out as its own small always-reachable tab sitting just above
       the bar — see toggleCommandCard() in main.js, which persists collapsed/expanded and hides
       #commandCardBody entirely when collapsed. */
    #btnToggleCommandCard {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: absolute !important;
        top: -22px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
        width: 44px;
        height: 22px;
        background: rgba(10,8,4,0.85);
        border: 1px solid rgba(139,90,43,0.6);
        border-bottom: none;
        border-radius: 6px 6px 0 0;
        font-size: 14px;
    }

    /* Same flap treatment as #btnToggleCommandCard right above, just pinned left instead of
       centered so the two never overlap. */
    #buildTabBar {
        top: -24px !important;
        left: 6px !important;
    }
    #buildTabBar .build-tab-btn { width: 28px; height: 24px; }

    /* En móvil el panel ocupa todo el ancho y no hay lateral del que colgar las categorías: van en una fila sobre la lista. */
    #decoCatBar {
        position: static !important;
        flex-direction: row !important;
        gap: 3px;
        padding: 4px 6px;
    }
    #decoCatBar .deco-cat-btn {
        flex: 1 1 0;
        width: auto;
        height: 32px;
        border: 2px ridge var(--panel-border);
        border-radius: 6px;
    }
    #decoCatBar .deco-cat-btn.active { border-color: #6a4a1a; }

    /* 4-column grid that grows downward with however many building/decoration types are
       unlocked — same effective cap on BOTH tabs since they share this one element (Cosméticos
       used to have no cap at all here, tall enough with 12+ types to grow up into the offline-
       boost/extra-resources strips near the top of the screen; Construcciones never happened to
       have enough types to reach that far, but nothing was actually stopping it either). 60vh
       matches #selectionPanel's own mobile cap right below — same "bottom-anchored sheet, leave
       the top of the screen clear" reasoning. The collapse tab above is still the full-hide
       escape hatch; this is what keeps a merely-tall (not collapsed) panel from overlapping
       what's above it.
       display is deliberately NOT !important: toggleCommandCard() collapses this via a plain
       el.style.display='none' — an !important stylesheet rule would always beat that plain
       inline value and the panel would never actually be able to hide. */
    #commandCardBody {
        display: grid;
        /* "los precios con 3-4 recursos se cortan, qué tal 3 columnas" — de 4 a 3 le da a cada
           botón ~36% más de ancho (en un móvil típico, de ~78px a ~106px), que es justo la
           dimensión que le faltaba a la rejilla 2x2 de coste (ver overflow:hidden de
           #buildingsGrid .command-btn más abajo — el propio comentario de ese recorte ya
           avisaba de este problema). Solo construcciones: la pestaña de decoración sigue a 4
           (ver .deco-tab-active), su información es más simple y no sufre el mismo recorte.
           A cambio se ven 6 edificios de golpe en vez de 8 (mismas 2 filas de 76px) — un scroll
           más para la lista completa. */
        grid-template-columns: repeat(3, 1fr) !important;
        /* "el tamaño máximo de alto del panel building sea 2 filas, y ya scroll" — exactly 2 rows
           of the 76px-tall building buttons below plus their 6px row gap and the container's own
           8px top+bottom padding: 76×2 + 6 + 16 = 174px. Fixed px rather than the old 32vh: a
           row-count target should mean the same thing on every screen, not stretch/shrink with
           viewport height the way a vh value would. Shared by both tabs (#buildingsGrid AND
           #decorationsGrid become display:contents into this same grid — see below), so this
           caps both at once — "en decoración que sea el mismo alto que el build" is this same
           174px, unchanged, just with #decorationsGrid's own smaller buttons fitting more rows
           into it (see .deco-tab-active below). Still scrolls for the rest either way — nothing's
           hidden, just not all visible at once. */
        max-height: 174px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding: 8px !important;
        gap: 6px !important;
        position: relative; /* anchors #buildCancelZone's overlay below */
    }
    /* Era 180px (10x el ancho original de 18px, a petición expresa de entonces) — "es gigante,
       hazla un 20% de lo que es actualmente": 180px * 0.2 = 36px. Border-radius/border del pomo
       reescalados a juego con el nuevo ancho, misma proporción que llevaban a 180px. */
    /* El margen de 12px de escritorio sobraba aquí (el relleno de 8px ya separa la rejilla del borde) y en Cosméticos se sumaba al margen
       de la fila de monedas/borrador: ~60px de hueco muerto que robaban sitio al mapa. Fila de monedas pegada y compacta. */
    #commandCardBody { margin-top: 0 !important; }
    #decoCoinDisplay { margin: 6px 8px 0 !important; gap: 6px !important; }
    body.fn-build-dragging #decoCoinDisplay { display: none !important; }
    /* 14px: los 36px de antes se veían como una barra enorme en CrazyGames (aquí no se notaba porque el emulador no desborda la lista). El scroll
       con el dedo se hace deslizando la propia lista; la barra es solo indicador/asa extra. */
    #commandCardBody::-webkit-scrollbar { width: 14px !important; }
    #commandCardBody::-webkit-scrollbar-thumb { border-radius: 6px !important; border-width: 2px !important; }
    /* "si arrastro un botón ya no se selecciona, se hace scroll" — al encoger la barra de arriba,
       los botones pasaron a ocupar la práctica totalidad del ancho scrolleable, así que casi
       cualquier arrastre (el roce normal de un dedo al pulsar) empieza SOBRE un botón y el
       navegador lo interpreta como "el usuario quiere hacer scroll", cancelando el click aunque
       apenas se haya movido. touch-action:none dejamos que sea el propio botón (no el gesto por
       defecto del navegador) quien decida qué pasa con un toque que empieza en él — el scroll
       real sigue funcionando desde cualquier otro punto (el hueco entre botones, la barra ancha
       de arriba). Nunca afecta a ratón/desktop, solo a gestos táctiles.
    */
    /* pan-y y no none: con none el navegador no podía empezar el scroll vertical desde un botón, y
       los botones llenan casi toda la caja de 174px — solo se podía hacer scroll desde los 6px de
       hueco o la barra lateral ("I find it hard to scroll up and down the catalog"). El touchmove
       de la rejilla (ver main.js, _pendingBuildTouch) YA trata el gesto vertical como scroll y
       deja pasar; lo horizontal sigue siendo del JS (arrastrar para construir), que pan-y no toca.
       Un toque corto sigue siendo toque: el JS espera 10px antes de decidir nada. */
    /* Ahora none: arrastrar un botón en cualquier dirección es construir (ver _initMobileBuildDrag) y la lista se desplaza con la barra
       ancha de la derecha (#buildScrollBar, ver _initBuildScrollBar). Pedido de JC: el scroll con el dedo sobre los botones liaba. */
    #commandCardBody .command-btn { touch-action: none; }
    /* Hueco a la derecha para la barra, y fuera la barra nativa (en móvil no se puede arrastrar) */
    #commandCardBody { padding-right: 44px !important; scrollbar-width: none; }
    #commandCardBody::-webkit-scrollbar { width: 0 !important; display: none; }
    #buildScrollBar {
        position: absolute; right: 6px; width: 30px; z-index: 6;
        background: rgba(0,0,0,0.35); border: 1px solid rgba(139,105,20,0.55); border-radius: 15px;
        touch-action: none;
    }
    #buildScrollThumb {
        position: absolute; left: 3px; right: 3px; border-radius: 12px;
        background: linear-gradient(180deg, #e0b452, #a8792a); border: 1px solid #f0d890;
        box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    }
    /* Rayitas de agarre en el centro del asa */
    #buildScrollThumb::after {
        content: ''; position: absolute; left: 6px; right: 6px; top: 50%; height: 10px; transform: translateY(-50%);
        background: repeating-linear-gradient(180deg, rgba(60,40,10,0.7) 0 2px, transparent 2px 4px);
    }
    /* Decoración se queda en 4 columnas (construcción bajó a 3, ver la regla base de arriba) —
       toggled by _switchBuildTab() (see main.js) alongside the tab switch itself, since
       #commandCardBody is the one shared element both tabs render into. Con nombres largos
       ("Grave with Cross", "Water and Shovel"...) el min-width:auto por defecto de un grid item
       podía forzar esa columna más ancha que las demás — ver min-width:0 en la regla de
       .command-btn más abajo, que es lo que de verdad garantiza el mismo ancho en todas. */
    #commandCardBody.deco-tab-active {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    #commandCardBody.deco-tab-active #decorationsGrid .command-btn {
        height: 56px !important;
        padding: 3px 1px !important;
        gap: 1px !important;
    }
    #commandCardBody.deco-tab-active #decorationsGrid .btn-icon {
        font-size: 17px !important;
    }
    #commandCardBody.deco-tab-active #decorationsGrid .btn-icon-img {
        width: 17px !important;
        height: 17px !important;
    }
    /* No room for the "Diseñado por JC" line at this row height (56px) — the desktop panel
       (see .btn-desc's base rule) is where that credit is meant to be read. */
    #decorationsGrid .btn-desc {
        display: none !important;
    }

    /* #buildingsGrid/#decorationsGrid stop being their own flex row and instead hand their
       children straight to the grid above (display:contents removes their own box but keeps the
       children as direct grid items). Not !important: toggleCommandCard() collapses
       #commandCardBody via a plain inline style too, same reasoning as its own rule above.
       (#buildTabBar itself is a sibling of #commandCardBody now, not a child — see its own flap
       rule further up — so it doesn't need a grid-column span here anymore.) */
    #buildingsGrid, #decorationsGrid { display: contents; }
    /* No longer a grid child (moved out of #commandCardBody entirely — see index.html — so it
       stays pinned above the scroll instead of scrolling away with the buttons below). #commandCard
       itself drops to padding:0 on this breakpoint (see its own mobile rule), so this needs its
       own horizontal breathing room, matching the grid's own 8px. */
    #decoCoinDisplay { padding: 0 8px; margin: 8px 0; }
    /* #buildCancelZone used to swap places with #buildingsGrid (hide the grid, show this in the
       freed space) — but the grid button the drag actually STARTED on lived inside it, and
       hiding/un-rendering the element a touch is currently anchored to mid-gesture is a known way
       to make mobile browsers silently drop the rest of that touch sequence (no touchend ever
       lands, so releasing over a valid tile did nothing — see _showCancel in main.js, which no
       longer touches #buildingsGrid's display at all now). Overlaying instead: same opaque panel
       background as everywhere else, absolutely positioned over the whole grid, pointer-events:none
       so it never intercepts the touch it's sitting on top of — the grid underneath stays exactly
       as present/rendered as it was before the drag started. */
    #buildCancelZone {
        position: absolute;
        inset: 0;
        z-index: 5;
        background: var(--panel-bg-gradient);
    }

    /* compact square buttons — scoped to the bottom build bar (both tabs) only, so the selection
       panel's recruit/upgrade rows (which share the same .command-btn/.commands-grid classes)
       keep their normal full-width, readable layout instead of being squashed into tiny icons. */
    #buildingsGrid .command-btn, #decorationsGrid .command-btn {
        width: 100% !important;
        /* Sin esto un grid item vale min-width:auto por defecto, que es el ancho mínimo de SU
           propio contenido — un nombre largo con white-space:nowrap (ver .btn-label) empujaba esa
           columna más ancha que las demás (las 4/5 dejaban de ser iguales) y de paso impedía que
           text-overflow:ellipsis llegara a activarse nunca, porque la caja nunca se encogía lo
           bastante como para necesitar truncar. */
        min-width: 0 !important;
        height: 76px !important;
        /* Un edificio con 3+ recursos de coste (renderCostHTML pasa a rejilla 2x2 con
           parts.length>=3 — ver main.js) podía necesitar más de las 76px fijas del botón, y sin
           esto ese sobrante se veía literalmente por fuera del botón, encima de la fila de abajo
           ("se salen algunos recursos del boton"). Con overflow:hidden se recorta en vez de
           desbordar visualmente — ver también el line-height más ajustado de .btn-cost abajo,
           que ayuda a que quepan las 2 filas de coste sin necesidad de recortar nada. */
        overflow: hidden !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 4px 2px !important;
        gap: 2px !important;
        text-align: center !important;
    }
    #buildingsGrid .btn-icon-wrap, #decorationsGrid .btn-icon-wrap {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0 !important;
    }
    #buildingsGrid .btn-size, #decorationsGrid .btn-size { display: none !important; }
    #buildingsGrid .btn-icon, #decorationsGrid .btn-icon { font-size: 22px !important; }
    #decorationsGrid .btn-icon-img { width: 22px !important; height: 22px !important; }
    #buildingsGrid .btn-info, #decorationsGrid .btn-info {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 1px !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    #buildingsGrid .btn-label, #decorationsGrid .btn-label {
        font-size: 10px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        line-height: 1.15 !important;
    }
    #buildingsGrid .btn-cost, #decorationsGrid .btn-cost { font-size: 9px !important; white-space: nowrap !important; line-height: 1.1 !important; }
    /* "no caben, como hacemos para que los precios se vean bien" — un coste de 4-5 recursos (la
       Casa en fases avanzadas: madera+comida+lana+piedra+oro) ocupa 3 filas en la rejilla 2x2 de
       renderCostHTML y no entra en las 76px fijas del botón (ver overflow:hidden más arriba, que
       hasta ahora solo lo recortaba en vez de dejarlo caber). Encoge letra, icono y huecos aún
       más SOLO para ese caso — el de 3 recursos, más común, se queda con el tamaño normal de
       arriba, que ya encajaba bien. */
    #buildingsGrid .btn-cost .cost-dense { font-size: 7px !important; gap: 0 4px !important; }
    #buildingsGrid .btn-cost .cost-dense .res-icon-hud { width: 10px !important; height: 10px !important; }

    /* ── SELECTION PANEL ── */
    /* Upgrade/purchase rows (recruit villager, upgrade axe/pickaxe/barrow, quarry logistics...):
       name (+ description, when a button has one — e.g. Logística de Cantera) on the left, price
       on the right, instead of everything stacked in one column — that used to make some of
       these buttons 4-5 lines tall on a narrow screen. Grid instead of flex specifically because
       the label+desc pair needs to stay stacked in ITS OWN column while price sits beside both of
       them, vertically centered — a plain flex-direction:row would put desc as a THIRD column
       instead of grouping it under the label. */
    #selectionPanel .btn-info {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        grid-template-rows: auto auto !important;
        column-gap: 8px !important;
        align-items: center !important;
    }
    #selectionPanel .btn-label { grid-column: 1; grid-row: 1; }
    #selectionPanel .btn-desc  { grid-column: 1; grid-row: 2; margin-top: 0 !important; }
    #selectionPanel .btn-cost  {
        grid-column: 2;
        grid-row: 1 / -1;
        text-align: right;
        margin-top: 0 !important;
    }
    #selectionPanel {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-height: 60vh !important;
        overflow-y: auto !important;
        touch-action: pan-y; /* re-enable native scroll — body has touch-action:none globally */
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        z-index: 300 !important;
    }
    /* Logro fijado sin nada más seleccionado (ver el toggle de .fn-pinned-ach-only en updateUI):
       ese z-index:300 de arriba es para la ficha de edificio/aldeano, que necesita tapar el HUD
       mientras se interactúa con ella — la tarjeta del logro es solo informativa y no necesita
       eso, así que en su lugar va detrás de casi todo (por debajo de .game-ui's z-index:10). */
    #selectionPanel.fn-pinned-ach-only { z-index: 5 !important; }
    /* #wstatTooltip's desktop z-index (60) only clears the desktop #selectionPanel (z-index:50)
       above — mobile's #selectionPanel jumps to 300 (full-width sheet, see right above), so
       without this the tap-to-show breakdown (see _toggleWstatTooltip) would render underneath
       the panel and never actually be visible. */
    #wstatTooltip { z-index: 9000 !important; }
    /* destroyPanel replaced by header icon buttons on portrait */
    #selectionPanel #destroyPanel { display: none !important; }
    /* Bonus + Worker side by side instead of stacked (see renderSelectionStatus's own comment
       on why they're built as separate strings) — desktop leaves this row as a plain block, so
       it's untouched there; only portrait turns it into two columns. Each column keeps its own
       divider/header exactly as before, just narrower. */
    .binfo-bonus-worker-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 10px;
        align-items: start;
    }
    .binfo-bonus-worker-row .divider { margin: 6px 0 4px !important; }
    /* Worker stats: one label/value pair per row instead of desktop's two side by side — this
       column only has half the panel's width now (see .binfo-bonus-worker-row above), so the
       4-col layout was cramming 4 columns into that and wrapping badly. Label flexes, value
       stays compact on the right. */
    .binfo-worker-grid {
        grid-template-columns: 1fr auto !important;
    }
    /* mobile action icon buttons — display is NOT !important on either of these: updateUI()
       hides #mobSelActions entirely for the town center (no move/delete) and hides
       #mobBtnDemolish specifically for unique buildings (no demolish) via plain
       el.style.display='none'; an !important rule here would always beat that and show them
       regardless of what's selected. */
    #mobSelActions { display: flex; }
    .mob-act-btn {
        width: 40px !important; height: 40px !important;
        border-radius: 4px !important; border-width: 2px !important;
        border-style: solid !important;
        display: flex; align-items: center !important;
        justify-content: center !important;
        font-size: 17px !important; padding: 0 !important;
        cursor: pointer; flex-shrink: 0 !important;
    }
    /* Mover: a diferencia de Demoler, sí necesita hueco para el precio (#mobMoveCost, ver
       main.js) — algunos edificios cuestan 3-4 recursos distintos para mover (mismo
       renderCostHTML que el panel de escritorio, con su propia rejilla 2x2). "que la cruz esté
       en el mismo sitio pero los recursos a su izquierda" — antes crecía en columna (icono
       arriba, precio debajo); row-reverse mantiene el icono en el mismo punto de siempre (el
       primero en el HTML, #mobMoveCost va después) pero lo ancla a la DERECHA del botón, con el
       precio extendiéndose hacia la izquierda en vez de hacia abajo. width:auto + max-width para
       que nunca desborde el header aunque el coste tenga varios recursos — .selection-info de
       abajo se encoge para dejarle sitio en vez de que la fila entera se salga por el lado. */
    .mob-act-move {
        width: auto !important;
        max-width: 130px !important;
        height: 40px !important;
        min-height: 40px !important;
        flex-direction: row-reverse !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 3px 8px !important;
        font-size: 15px !important;
    }
    .mob-move-cost {
        font-size: 8px !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
        font-weight: 700;
        text-align: right;
    }
    /* Mismos tonos que .command-btn-danger/.command-btn-positive (ver su comentario) — marrones,
       nada de gris ni rojo/verde: Demolish reutiliza el marrón rojizo oscuro del Cancelar de
       Reto, Move un marrón más claro/cálido que el de un botón de construir normal. Aquí SÍ se
       tiñe el icono (es lo único que llevan, sin texto) con un tono más claro que el fondo para
       que se note encima. Pause usa un tono dorado/ámbar propio — ni el marrón de mover ni el
       rojizo de demoler, para que se distinga de un vistazo cuál de los tres es cuál. */
    .mob-act-demolish{ background: #362119 !important; border-color: #6e3f30 !important; color: #d4a090 !important; }
    .mob-act-move    { background: #4a3826 !important; border-color: #8b5a2b !important; color: #d4b896 !important; }
    .mob-act-pause   { background: #3a3020 !important; border-color: #7a6a2b !important; color: #e0c890 !important; }
    .mob-act-btn:disabled,
    .mob-act-btn.mob-act-unaffordable { opacity: 0.4 !important; }
    /* Deja sitio al ahora-más-ancho .mob-act-move sin que la fila entera se salga: el nombre del
       edificio se trunca con "…" en vez de forzar overflow horizontal en .selection-header. */
    .selection-info { min-width: 0 !important; overflow: hidden !important; }
    .selection-label, .selection-workers {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }

    /* "en moviles la ficha de los aldeanos mucho mas pequeña, sin previa del icono y todo mas
       pequeñito" — el retrato de 150×150 (ver #villagerInfoPortrait en index.html) se come media
       pantalla sin dar más información que el nombre/curro/stats de al lado; se oculta entero. El
       resto se encoge a juego con el resto del panel en vertical — font-size !important porque
       casi todo dentro de la ficha viene con su tamaño puesto inline desde JS (ver
       _renderVillagerInfo), no por clase, así que una regla externa normal no le ganaría. */
    #villagerInfoPortrait { display: none !important; }
    #villagerSelContent .selection-label { font-size: 12px !important; }
    #villagerSelContent .selection-workers { font-size: 10px !important; }
    #villagerSelContent .selection-status { font-size: 10px !important; }
    /* .villager-nav-btn (the ◀/▶ cycle arrows) only — NOT every <button> in the panel. "el boton
       mas grande de dejar de seguir y el bocadillo se ve muy pequeño": a blanket `button` selector
       here was also squashing the "Dejar de controlar" button (see .villager-stop-btn below) down
       to this same tiny circle, wrapping its own label across two lines — real bug report. */
    #villagerSelContent .villager-nav-btn {
        width: 18px !important;
        height: 18px !important;
        font-size: 9px !important;
    }
    /* Player-avatar-only hint text + "stop controlling" button (see _renderVillagerInfo) — kept
       comfortably READABLE/TAPPABLE on purpose, unlike the rest of this block: it's the one
       control surface in this whole card, not a passive stat, so it doesn't get the same shrink. */
    #villagerSelContent .villager-avatar-hint { font-size: 13px !important; }
    #villagerSelContent .villager-stop-btn {
        font-size: 14px !important;
        padding: 10px 22px !important;
        width: auto !important;
        height: auto !important;
    }
    #villagerInfoStats span, #villagerInfoJobTimes span { font-size: 11px !important; }
    #villagerInfoStats img { width: 12px !important; height: 12px !important; }
    #villagerInfoStats > div, #villagerInfoJobTimes > div { padding: 2px 0 !important; }

    /* "en móvil no puedas pinear un logro... no hay pantalla suficiente" — la chincheta ya no
       hace nada en móvil (ver el gate de _MQ_PORTRAIT en _togglePinAchievement, main.js); esto
       quita además la propia afordancia visual del panel de Logros para no invitar a tocar un
       botón que no va a hacer nada. */
    .ach-pin-btn { display: none !important; }

    /* ── OVERLAYS ── */
    .skill-tree-panel {
        inset: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-height: none !important;
    }

    /* modals full-width */
    #statsPanel > div,
    #skillCardModal .skill-card-panel {
        min-width: 0 !important;
        width: 94vw !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
    }

    .skill-card-row {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Save-slot menu (main menu, before a game loads): single stacked column instead of the
       desktop wrapped row — see the unconditional/default rule near the top of this file. */
    /* Una columna */
    #menuSlotGrid {
        grid-template-columns: 1fr !important;
        width: min(420px, 92vw) !important;
        max-width: 100% !important;
        gap: 12px !important;
    }
    #menuSlotGrid .slot-card-wrap { width: 100% !important; }
    /* Tarjeta en vertical como en escritorio, más compacta; la lista acaba antes de los enlaces del pie (que van fijos abajo) */
    #menuSlotPicker { max-height: calc(100dvh - 330px) !important; }
    #menuSlotPicker .sc-pick-title { font-size: 13px; letter-spacing: 1px; text-align: left; padding-right: 90px; }   /* deja sitio al Volver */
    .slot-card.sc-full .sc-thumb { aspect-ratio: auto; height: 190px; }   /* el mapa cuadrado y centrado en una franja más baja */
    .slot-card.sc-full .sc-body { padding: 10px 12px 12px; gap: 6px; }
    .sc-title { font-size: 15px; }
    .sc-stat { padding: 4px 6px; }
    .sc-stat b { font-size: 12px; }
    .sc-play { padding: 5px 9px; font-size: 11px; }
    .slot-card.sc-empty { min-height: 0; }
    .sc-empty-in { flex-direction: row; padding: 14px; gap: 12px; text-align: left; }
    .sc-plus { width: 40px; height: 40px; font-size: 16px; flex-shrink: 0; }

    /* ── TUTORIAL PANEL: sized down from desktop, but readable — was cut too aggressively
       (~30% smaller) before; text especially needed to grow back up. ── */
    #tutorialPanel {
        width: 392px !important;
        /* Third value reserves the bottom-corner step counter's strip, same as the desktop rule —
           this shorthand is !important, so it would otherwise flatten that reservation back to a
           uniform 12px and let the description run over the counter. */
        padding: 12px 18px 20px !important;
    }
    /* Needs !important + the same specificity trick for the same reason: the collapsed state has
       no counter to clear, but the shorthand above is !important and would win otherwise. */
    #tutorialPanel.tuto-collapsed { padding-bottom: 9px !important; }
    #tutorialPanel .step-indicator { font-size: 10px !important; bottom: 4px !important; left: 10px !important; }
    #tutorialPanel h2 { font-size: 17px !important; margin-bottom: 7px !important; }
    #tutorialPanel p  { font-size: 13px !important; }
    #btnCloseTutorial { font-size: 11px !important; padding: 5px 14px !important; margin-top: 7px !important; }

    /* ── OFFLINE BOOST STRIP: vertical column, narrow enough to sit in the left margin below the
       minimap (see _positionMobileOfflineStripsNow in main.js) — was a wide horizontal row, which
       never fit that narrow a spot ("que sean botones en vertical el banco de tiempo en movil").
       #offlineBoostTiersGroup is the inner wrapper (index.html inline style) that actually holds
       the ×2/×3/×5/×10 buttons + timer + info button — needs !important since its own gap is set
       inline. ── */
    .offline-boost-strip {
        padding: 6px !important;
        gap: 4px !important;
        flex-direction: column !important;
        width: 56px; /* was 44px — too narrow for the ad-time button's 2-word label ("MÁS"/"TIEMPO",
           "TIME"/"BOOST") to fit without spilling past the panel's own edge; the ×2/×3/×5/×10 tier
           buttons above don't need this much room but center fine with the extra space. */
    }
    #offlineBoostTiersGroup {
        flex-direction: column !important;
        gap: 4px !important;
        width: 100%;
    }
    .offline-boost-btn {
        font-size: 10px !important;
        padding: 4px 0 !important;
        width: 100%;
        text-align: center;
    }
    .offline-boost-time { font-size: 10px !important; margin: 2px 0 !important; text-align: center; }
    .offline-boost-info-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 10px !important;
        align-self: center;
    }
    /* "en móviles el texto de ver anuncio por acelerar el juego se ve muy grande" — this button
       (icon + label side by side, desktop's own row layout) had no mobile override at all, so it
       kept trying to fit its full-length label ("Consigue Acelerador de Tiempo"/"Get Time
       Accelerator") next to the icon inside this same 44px column — badly overflowed/clipped.
       Stacked instead (icon on top, text below) so the label gets the full 44px-minus-padding
       width to itself rather than sharing it with the icon; adtime.watch_short_compact
       (_updateAdTimeBonusButton, main.js) is the actual shorter text this now has room for. */
    .ad-time-inline-btn {
        flex-direction: column !important;
        align-items: stretch !important; /* desktop's own rule is align-items:center — without overriding it, children size to their own natural width and just center-overflow past this 44px column instead of wrapping to fit it */
        gap: 2px !important;
        padding: 4px 2px !important;
        width: 100%;
        font-size: 13px !important;
    }
    .ad-time-inline-btn #adTimeBonusCooldown {
        font-size: 7.5px !important;
        letter-spacing: 0 !important; /* desktop's 0.5px letter-spacing was just enough extra width to force a mid-word break at this column's size */
        white-space: normal !important;
        overflow-wrap: normal !important; /* was break-word — that chopped words mid-letter ("BOO"/"ST!"); wrap only at the space between words instead ("no cortar las palabras") */
        word-break: keep-all !important;
        min-width: 0; /* flex items default to min-width:auto, which fights wrapping/shrinking in a constrained flex column like this one */
        text-align: center;
        line-height: 1.15 !important;
    }

    /* ── AD-OFFER STRIP ("Recursos extra disponibles"): "ese mensaje ponlo arriba debajo del
       header a la derecha" — no longer stacked with the time-bank strip on the left (it's
       time-sensitive, has its own countdown, and reads better as its own thing up top — see
       _positionMobileOfflineStripsNow in main.js, which handles the actual position; this is just
       sizing). ── */
    #offlineAdOfferStrip {
        padding: 4px 8px !important;
        gap: 4px !important;
        font-size: 10px !important;
    }
    #offlineAdOfferStripTimer { font-size: 9px !important; }

    /* ── OFFLINE BOOST modal card ("Impulso Offline"): ~20% smaller ── */
    #offlineBoostPanel > div {
        min-width: 256px !important;
        max-width: 336px !important;
        padding: 22px 26px !important;
        border-radius: 8px !important;
    }
    #offlineBoostPanel > div > button { font-size: 16px !important; top: 8px !important; right: 11px !important; }
    #offlineBoostPanel h2 { font-size: 14px !important; margin-bottom: 13px !important; padding-bottom: 8px !important; }
    #offlineBoostPanelGained { font-size: 10px !important; margin-bottom: 5px !important; }
    #offlineBoostPanelTotal  { font-size: 13px !important; margin-bottom: 11px !important; }
    #offlineBoostPanel .divider { margin: 0 0 10px !important; }
    #offlineBoostPanel p { font-size: 10px !important; }
}

/* ── Loading screen ─────────────────────────────────────────────────────────── */
#lv-char {
    animation: lv-bob 0.35s ease-in-out alternate infinite;
}
@keyframes lv-bob {
    from { transform: translateY(0); }
    to   { transform: translateY(-5px); }
}

/* ── Opciones de Visualización (modal) ────────────────────────────────────────────────────
   "si no tienes pantalla completa no ves la X para cerrar": la caja no tenía tope de alto y,
   centrada en el overlay, se salía por arriba y por abajo con la X fuera de la vista. Ahora la
   caja cabe siempre en la ventana (max-height) y es el cuerpo el que hace scroll, así la
   cabecera y la X quedan fijas. En escritorio, dos columnas (un grupo por celda) para que
   normalmente no haga falta scroll; en móvil, una. */
.display-options-box {
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: min(760px, 100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 24px 28px;
}
.display-options-box > h2 { flex: 0 0 auto; }
.display-options-box .settings-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 36px;
    row-gap: 0;
    align-content: start;
}
.display-options-box .settings-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}
.display-options-box .settings-group .settings-group-title { margin-top: 0; }
/* Divisores de Opciones: a todo el ancho de la rejilla, una raya con el nombre de la parte en medio */
.opt-section {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0 14px;
    color: #c8a050; font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase;
}
.opt-section::before, .opt-section::after { content: ''; flex: 1 1 auto; height: 1px; background: linear-gradient(90deg, transparent, #8b6914, transparent); }
.opt-section > span { white-space: nowrap; }
.opt-section ~ .opt-section { margin-top: 10px; }
@media (max-width: 720px) {
    .display-options-box { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 20px 16px; }
    /* En el móvil la barra de desplazamiento flota ENCIMA del contenido y tapaba las casillas: hueco a la derecha para ella */
    .display-options-box .settings-body { grid-template-columns: 1fr; padding-right: 18px !important; }
}

/* Cupo de acarreadores del dique (−/+ en la ficha del dique, ver adjustDockWorkers) */
/* Filas de trabajadores (dique seco, mulas, barco, zanjas, astillero) como tarjeta: icono · nombre y cifra · barrita · −/+.
   Antes era un recuadro con borde "ridge" y dos círculos que se veían dentados ("se ve un poco cutre"). */
.worker-stepper {
    box-sizing: border-box; max-width: 100%; min-width: 0;   /* en la rejilla del panel, sin esto la fila pedía el ancho de su texto entero y se salía */
    align-items: center; gap: 8px;
    margin: 6px 0; padding: 7px 8px;
    background: linear-gradient(180deg, rgba(255,220,150,0.05), rgba(0,0,0,0.28));
    border: 1px solid rgba(139,105,20,0.55); border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,220,150,0.06);
}
.worker-stepper .ws-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.worker-stepper .ws-icon {
    flex: none; width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(200,160,80,0.12); color: #dfb256; font-size: 13px;
}
.worker-stepper .ws-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.worker-stepper .ws-line { display: flex; align-items: center; gap: 6px; }
.worker-stepper .ws-line .ws-bar { flex: 1; min-width: 0; }
.worker-stepper .ws-name { min-width: 0; font-size: 11px; color: #b8a680; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worker-stepper .ws-val { flex: none; font-size: 12px; color: #c8b890; white-space: nowrap; font-variant-numeric: tabular-nums; }
.worker-stepper .ws-val b { font-size: 14px; color: #f0c860; }
.worker-stepper .ws-bar { height: 4px; border-radius: 2px; background: rgba(0,0,0,0.45); overflow: hidden; }
.worker-stepper .ws-bar > span { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, #a8792a, #e0b452); transition: width 0.3s ease; }
/* −/+: cuadrados redondeados con relieve suave (ya no círculos) */
.dock-workers-btn {
    flex: none; width: 32px; height: 32px; padding: 0;
    font-size: 12px;
    border-radius: 8px;
    background: linear-gradient(180deg, #3a2e22, #1f1810);
    border: 1px solid rgba(200,160,80,0.55);
    color: var(--gold);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255,220,150,0.15), 0 1px 3px rgba(0, 0, 0, 0.5);
    transition: filter 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}
.dock-workers-btn:hover:not(:disabled) { border-color: var(--panel-border-hover); color: var(--gold-bright); filter: brightness(1.15); }
.dock-workers-btn:active:not(:disabled) { transform: translateY(1px); }
.dock-workers-btn:disabled { opacity: 0.3; cursor: default; }


/* ===== Menú principal: ciudad de fondo oscurecida + panel de botones =====
   El fondo es una captura real de una ciudad (assets/menu_bg.jpg), como cuando se visita una
   ciudad compartida, pero muy atenuada para que los botones se lean. El zoom lento da vida
   sin gastar nada (solo transform, sin repintar el canvas del juego). */
#mainMenu { overflow: hidden; }
#mainMenu .menu-bg {
    position: absolute; inset: -4%;
    background: #0a0804;
    image-rendering: pixelated;
    filter: brightness(.38) saturate(.85) blur(1.5px);
    z-index: 0;
}
/* Plan B sin ciudad viva (reducir movimiento, ahorro de datos, o si no llega a tiempo): imagen fija
   con un zoom lento. Con ciudad viva el fondo parte de negro y se mueve la cámara del propio juego. */
#mainMenu .menu-bg.static {
    background: #0a0804 url('assets/menu_bg.jpg') center / cover no-repeat;
    animation: menuBgDrift 70s ease-in-out infinite alternate;
}
#mainMenu .menu-vignette {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 46%, rgba(10,8,4,.10) 0%, rgba(10,8,4,.55) 62%, rgba(10,8,4,.92) 100%),
        /* Fundido por arriba y por abajo: la ciudad se disuelve en el fondo del menú, como una miniatura */
        linear-gradient(to bottom, #0a0804 0%, rgba(10,8,4,.82) 8%, rgba(10,8,4,0) 26%, rgba(10,8,4,0) 70%, rgba(10,8,4,.85) 90%, #0a0804 100%);
}
@keyframes menuBgDrift {
    from { transform: scale(1.02) translate(0, 0); }
    to   { transform: scale(1.14) translate(-1.5%, -1.5%); }
}
@media (prefers-reduced-motion: reduce) { #mainMenu .menu-bg.static { animation: none; } }
#mainMenu > :not(.menu-bg):not(.menu-vignette) { z-index: 1; }
#mainMenu > h1 {
    position: relative;
    font-size: clamp(30px, 7vw, 60px) !important;
    letter-spacing: 6px !important;
    text-align: center;
    text-shadow: 0 2px 0 #6a4a1a, 0 0 28px rgba(223,178,86,.55), 0 4px 24px rgba(0,0,0,.9) !important;
}
/* Panel de cristal para los botones principales y para el selector de partidas */
#menuMainOptions, #menuSlotPicker {
    position: relative;
    box-sizing: border-box;
    padding: 20px 22px !important;
    background: linear-gradient(160deg, rgba(42,34,27,.78), rgba(20,15,10,.82));
    border: 1px solid #8b6914;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.65), inset 0 0 0 1px rgba(223,178,86,.12);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#menuMainOptions { width: min(320px, 90vw) !important; }
#menuMainOptions .menu-btn { width: 100%; box-sizing: border-box; }
#btnMenuPlay { font-size: 18px; padding: 14px 20px; letter-spacing: 1.5px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 12px; }
#btnMenuPlay i { font-size: 0.7em; opacity: 0.85; }
/* Cabecera del panel de inicio: PARTIDA N entre rayas, resumen de la partida debajo (ver _menuMainHeadHTML) */
#menuMainOptions .mm-head { display: flex; flex-direction: column; align-items: center; gap: 7px; margin-bottom: 4px; text-align: center; }
#menuMainOptions .mm-slot {
    display: flex; align-items: center; gap: 10px; width: 100%;
    font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: #c8a050;
}
#menuMainOptions .mm-slot::before, #menuMainOptions .mm-slot::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(200,160,80,0.6)); }
#menuMainOptions .mm-slot::after { background: linear-gradient(90deg, rgba(200,160,80,0.6), transparent); }
#menuMainOptions .mm-sub { font-size: 12px; color: #a8987c; }
#menuMainOptions .mm-legacy { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; color: #c8b890; }
#menuMainOptions .mm-legacy > i { color: #dfb256; font-size: 11px; }
#menuMainOptions .mm-legacy b { color: #e8d5a0; font-weight: 600; }
#menuMainOptions .mm-legacy .sc-pips { flex: none; }   /* en la tarjeta de partida se estira; aquí va todo junto y centrado */
#menuMainOptions .mm-stats { display: flex; justify-content: center; gap: 14px; font-size: 12px; color: #c8b890; font-variant-numeric: tabular-nums; }
#menuMainOptions .mm-stats i { color: #c8a050; margin-right: 5px; font-size: 11px; }
/* "Ver partidas guardadas": discreto, para que el que manda sea Continuar */
#btnChangeSlot {
    align-items: center; justify-content: center; gap: 8px;
    background: transparent !important; border: 1px solid rgba(200,160,80,0.32) !important; box-shadow: none !important;
    font-size: 13px !important; padding: 10px 14px !important; color: #c8b890 !important;
}
#btnChangeSlot:hover { border-color: rgba(223,178,86,0.75) !important; color: #f0d890 !important; background: rgba(200,160,80,0.06) !important; }
#btnChangeSlot i { color: #c8a050; }
/* Enlaces secundarios: discretos, sin cajas — icono con su nombre corto debajo, apagados hasta pasar/tocar. Dos grupos
   (comunidad · juego) con un separador fino; en PC una fila, en móvil dos filas de tres iguales (el separador se oculta). */
#menuFooterLinks {
    position: absolute !important;
    left: 0; right: 0; bottom: 18px;
    display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 4px;
    padding: 0 16px;
}
#menuFooterLinks .menu-btn {
    width: auto !important; min-width: 74px;
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 5px !important;
    padding: 8px 10px !important;
    background: transparent !important; border: none !important; box-shadow: none !important;
    color: #a8987c !important; opacity: .8;
    font-family: inherit; font-size: 10px !important; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
    white-space: nowrap; text-decoration: none;
    transition: color .15s, opacity .15s, transform .15s;
}
#menuFooterLinks .menu-btn i { font-size: 17px; color: #c8a050; opacity: .85; transition: opacity .15s; }
#menuFooterLinks .menu-btn:hover, #menuFooterLinks .menu-btn:focus-visible { color: #f0d890 !important; opacity: 1; transform: translateY(-1px); }
#menuFooterLinks .menu-btn:hover i { opacity: 1; }
.menu-foot-sep { width: 1px; height: 30px; margin: 0 10px; background: linear-gradient(180deg, transparent, rgba(200,160,80,.45), transparent); }
/* El punto de "hay novedades" sobre el icono */
#menuFooterLinks #changelogDotMenu { position: absolute; top: 4px; right: calc(50% - 16px); }
@media (max-width: 560px) {
    #menuFooterLinks { bottom: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px 4px; max-width: 360px; margin: 0 auto; }
    #menuFooterLinks .menu-btn { min-width: 0; padding: 7px 4px !important; }
    .menu-foot-sep { display: none; }
}

/* Fondo vivo del menú: el iframe va dentro de .menu-bg, así que hereda su oscurecido/desenfoque. */
#mainMenu .menu-bg-city {
    position: absolute; inset: 0; width: 100%; height: 100%;
    border: 0; pointer-events: none;
    opacity: 0; transition: opacity 1.2s ease;
}
#mainMenu .menu-bg-city.on { opacity: 1; }
/* Dentro del iframe (?menubg=1): solo el canvas del juego, nada de interfaz */
body.fn-menubg > *:not(#gameCanvas):not(script) { display: none !important; }
body.fn-menubg { background: #0a0804; overflow: hidden; }

/* Rótulo de la ciudad del fondo: nombre de la ciudad y del jugador, en la esquina de arriba a la izquierda (los enlaces de abajo ocupan sitio) y muy suave */
#menuBgCaption {
    position: absolute !important;
    left: 20px; top: 18px; right: auto;
    max-width: 55vw; text-align: left; pointer-events: none;
    font-family: 'Cinzel', serif; font-size: 11px; letter-spacing: .5px;
    color: rgba(235,220,185,.5);
    text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.8);
    opacity: 0; transition: opacity .6s ease;
}
#menuBgCaption.on { opacity: 1; }
#menuBgCaption #menuBgPlayer { color: rgba(223,178,86,.7); font-weight: 600; }
#menuBgCaption #menuBgBy { opacity: .7; font-style: italic; }

/* Logros por mundo: pestañas del panel (solo con el mundo 2 a la vista), etiqueta en cada tarjeta y
   atenuado de lo que se gana en el otro mundo. */
.ach-tabs { flex-shrink: 0; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.ach-tab {
    font-family: 'Cinzel', serif; font-size: 12px; font-weight: 700; letter-spacing: .5px;
    color: var(--text-muted); background: transparent; cursor: pointer;
    border: 1px solid var(--panel-border); border-radius: 6px; padding: 5px 12px;
}
.ach-tab:hover { border-color: var(--panel-border-hover); color: var(--text-light); }
.ach-tab.active { color: #2a1e10; background: linear-gradient(160deg, #dfb256, #a97d2f); border-color: #6a4a1a; }
.ach-world-tag {
    display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 9px; font-weight: 700;
    letter-spacing: .5px; text-transform: uppercase; vertical-align: middle;
    color: var(--gold); border: 1px solid var(--panel-border); border-radius: 4px;
}
.ach-card.other-world:not(.unlocked) { opacity: .55; }

/* Móvil: la barra de desplazamiento flota ENCIMA del contenido (no ocupa sitio como en PC) y tapaba casillas, botones y textos
   del borde derecho. Hueco a la derecha en los paneles con scroll que no lo tenían (ver también .display-options-box). */
@media (max-width: 720px) {
    #changelogPanelBody, #howtoBody, #retosPanelBody, #achievementsPanelBody { padding-right: 16px !important; box-sizing: border-box; }
}

/* Ciudades de la comunidad: etiqueta del mundo de cada ciudad (si el servidor la manda en city.world) */
.city-card-world { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 8px; background: rgba(110,170,90,0.2); color: #a8d890; border: 1px solid rgba(110,170,90,0.45); }
.city-card-world.w2 { background: rgba(80,150,200,0.2); color: #9fd0f0; border-color: rgba(80,150,200,0.45); }

/* Selector de idioma del menú principal (arriba a la derecha): un desplegable compacto con el globo, en dorado como el resto del menú */
.menu-lang { display: flex; align-items: center; gap: 6px; border: 1px solid var(--panel-border); border-radius: 4px; padding: 3px 8px; color: var(--gold); font-size: 12px; cursor: pointer; background: rgba(10, 8, 4, .55); }
.menu-lang select { background: transparent; color: var(--gold); border: none; font: inherit; font-weight: 700; letter-spacing: .5px; cursor: pointer; outline: none; padding: 1px 0; }
.menu-lang select option { background: #2a2018; color: #e8d5a0; }

/* Tienda (ver SHOP_PACKS en main.js): tarjetas en rejilla, 3 columnas en PC y 1 en móvil vertical */
.shop-box { background: linear-gradient(160deg, #2a221b, #1a140f); border: 2px ridge #8b6914; border-radius: 10px; padding: 24px 26px 20px; width: min(860px, 94vw); max-height: 88vh; max-height: 88dvh; overflow-y: auto; position: relative; box-sizing: border-box; }
.shop-title { font-family: 'Cinzel', serif; color: #c8a050; margin: 0 28px 4px 0; font-size: 20px; }
.shop-subtitle { color: #d8c7a4; font-size: 13px; margin-bottom: 12px; }
.shop-preview { background: rgba(200, 160, 80, .14); border: 1px solid #6a5a2a; border-radius: 6px; color: #e8d5a0; font-size: 12px; padding: 7px 10px; margin-bottom: 12px; }
.shop-packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.shop-pack { position: relative; display: flex; flex-direction: column; background: rgba(0, 0, 0, .22); border: 1px solid #5a4a2a; border-radius: 8px; padding: 14px; min-width: 0; }
.shop-pack-recommended { border-color: #8fd67a; }
.shop-pack-best { border-color: #dfb256; box-shadow: 0 0 10px rgba(223, 178, 86, .25); }
.shop-badge { position: absolute; top: -9px; right: 10px; background: #dfb256; color: #2a1c08; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; border-radius: 4px; padding: 2px 7px; }
.shop-pack-recommended .shop-badge { background: #8fd67a; color: #12280a; }
.shop-amount { font-family: 'Cinzel', serif; color: #f0e0c0; font-size: 20px; font-weight: 700; }
.shop-amount i { color: #dfb256; font-size: 15px; }
.shop-amount-label { color: #a8957a; font-size: 12px; margin-bottom: 8px; }
.shop-perks { list-style: none; margin: 0 0 12px; padding: 0; flex: 1 1 auto; }
.shop-perks li { display: flex; gap: 7px; color: #d8c7a4; font-size: 12px; line-height: 1.35; margin-top: 5px; }
.shop-perks i { color: #8fd67a; font-size: 11px; margin-top: 3px; }
.shop-buy { width: 100%; }
.shop-note { color: #8a7a60; font-size: 11px; line-height: 1.4; margin-top: 5px; }
.shop-preview-flash { animation: shopPreviewFlash .9s ease-out; }
@keyframes shopPreviewFlash { 0%, 35% { background: rgba(223, 178, 86, .55); border-color: #dfb256; color: #fff3d6; } 100% { background: rgba(200, 160, 80, .14); border-color: #6a5a2a; color: #e8d5a0; } }

/* Los 3 colores de las guirnaldas personalizadas (ver _setGarlandColor) */
#decorationsGrid .garland-colors { display: flex; align-items: center; gap: 8px; text-transform: none; }
#decorationsGrid .garland-colors input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid #8b5a2b; background: #2a221b; cursor: pointer; }
#decorationsGrid .garland-count { display: inline-flex; gap: 3px; }
#decorationsGrid .garland-count button { min-width: 26px; height: 26px; font: 600 13px var(--font-body, inherit); color: #f4e8d3; background: #3d3024; border: 1px solid #5d4630; cursor: pointer; padding: 0 6px; }
#decorationsGrid .garland-count button[aria-pressed=true] { background: #dfb256; border-color: #ffdf80; color: #2a1a10; }
/* Cada color con su botón de quitar; quitado, queda un hueco punteado con un + */
#decorationsGrid .garland-slot { position: relative; display: inline-flex; }
#decorationsGrid .garland-slot .garland-x { position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; padding: 0; border-radius: 50%; border: 1px solid #8b5a2b; background: #2a221b; color: #f4e8d3; font: 700 12px/1 sans-serif; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#decorationsGrid .garland-slot .garland-x:disabled { opacity: 0.3; cursor: default; }
#decorationsGrid .garland-slot.off input[type=color] { visibility: hidden; }
#decorationsGrid .garland-slot.off { width: 34px; height: 26px; border: 1px dashed #8b5a2b; box-sizing: border-box; }
#decorationsGrid .garland-slot.off .garland-x { position: static; margin: auto; width: 100%; height: 100%; border: 0; border-radius: 0; background: none; color: #dfb256; font-size: 16px; }
/* Colores de las guirnaldas como escudos, y la tablilla de tintes */
.garland-swatch { width: 24px; height: 28px; padding: 0; border: 0; cursor: pointer; background: #c8a050; clip-path: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%); position: relative; }
.garland-swatch::before { content: ''; position: absolute; inset: 2px; background: var(--c); clip-path: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%); box-shadow: inset 3px 3px 0 rgba(255,255,255,0.18), inset -3px -4px 0 rgba(0,0,0,0.22); }
.garland-swatch:focus-visible { outline: 2px solid #ffdf80; outline-offset: 2px; }
#decorationsGrid .garland-slot.off .garland-swatch { visibility: hidden; }
#decorationsGrid .garland-slot.off { width: 24px; height: 28px; }
.garland-palette { position: fixed; z-index: 9000; width: 200px; padding: 10px 12px 12px; background: #2a221b; border: 2px solid #8b5a2b; box-shadow: inset 0 0 0 1px #dfb256, 0 8px 24px rgba(0,0,0,0.55); }
.garland-palette .gp-title { font: 700 14px 'Cinzel', Georgia, serif; color: #dfb256; text-align: center; margin-bottom: 8px; letter-spacing: 0.04em; }
.garland-palette .gp-grid { display: grid; grid-template-columns: repeat(6, 24px); gap: 6px 7px; justify-content: center; }
.garland-palette .gp-dye.on { background: #ffdf80; }
.garland-palette .gp-dye:hover { filter: brightness(1.15); }
.garland-palette .gp-other { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; font-size: 13px; color: #bdae93; cursor: pointer; }
.garland-palette .gp-other input { width: 28px; height: 22px; padding: 0; border: 1px solid #8b5a2b; background: none; cursor: pointer; }
/* Miniaturas de los diseños de bandera, con tus colores */
#decorationsGrid .flag-designs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; text-transform: none; }
#decorationsGrid .flag-design-row { display: flex; flex-wrap: wrap; gap: 5px; }
#decorationsGrid .flag-design { padding: 2px; border: 1px solid #5d4630; background: #3d3024; cursor: pointer; line-height: 0; }
#decorationsGrid .flag-design canvas { width: 30px; height: 20px; image-rendering: pixelated; display: block; }
#decorationsGrid .flag-design[aria-pressed=true] { border-color: #ffdf80; background: #dfb256; }

/* Decoración: sin "Diseñado por JC" en ningún tamaño. En PC, rejilla de 3 con la imagen grande y en color, el precio pequeño debajo
   y el nombre como tooltip (ver el mouseover de #decorationsGrid en main.js). El botón del anuncio y los títulos ocupan la fila entera. */
#decorationsGrid .btn-desc { display: none !important; }
@media not all and (max-width: 1024px) and (orientation: portrait) {
    #decorationsGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    #decorationsGrid > :is(.deco-section-label, #btnDecoAd, .deco-fav-empty, .wx-grid, .wx-buy-bar) { grid-column: 1 / -1; }
    #decorationsGrid .command-btn:not(#btnDecoAd) { flex-direction: column; justify-content: center; gap: 4px; padding: 7px 2px 5px; text-align: center; min-height: 76px; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-label,
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-size { display: none; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-icon-img { width: 44px; height: 44px; filter: none; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-icon { font-size: 30px; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-info { align-items: center; min-width: 0; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-cost-row { justify-content: center; }
    #decorationsGrid .command-btn:not(#btnDecoAd) .btn-cost { font-size: 10px; }
    #decorationsGrid .command-btn:disabled .btn-icon-img { filter: grayscale(1); opacity: 0.55; }
}

/* Camino y Quitar caminos en una fila: el Camino ocupa lo que queda y Quitar caminos es un botón cuadrado a su derecha */
.road-row { gap: 8px; grid-column: 1 / -1; align-items: stretch; }
.road-row > #btnBuildRoad { flex: 1 1 auto; min-width: 0; }
.road-row > #btnRoadErase { flex: 0 0 64px; width: 64px; justify-content: center; padding: 6px; }
.road-row > #btnRoadErase .btn-icon-wrap { min-width: 0; }
#btnRoadErase.active { border-color: #e8c040; box-shadow: inset 0 0 0 1px #e8c040; background: linear-gradient(160deg, #4a3a22 0%, #2a2016 100%); }

/* Panel de construir: miniatura del edificio en vez del icono (ver _applyBuildThumbs). Sin el tamaño en casillas, para que quepa; gris si no se puede */
.build-thumb { width: 52px; height: auto; image-rendering: pixelated; display: block; }
#buildingsGrid .command-btn.has-thumb .btn-icon-wrap { min-width: 52px; }
/* En gris, como los de decoración: a color solo el del botón con el ratón encima. Sin poderse construir, además apagado */
#buildingsGrid .build-thumb { filter: grayscale(1); transition: filter 0.15s ease; }
#buildingsGrid .command-btn:hover:not(:disabled) .build-thumb { filter: none; }
#buildingsGrid .command-btn:disabled .build-thumb { opacity: 0.55; }
/* La barra de desplazamiento del panel pegada al borde derecho (el panel tiene 16 px de margen a cada lado); el contenido no queda debajo */
@media not all and (max-width: 1024px) and (orientation: portrait) {
    #commandCardBody { margin-right: -16px; padding-right: 6px; }
}
.road-row > #btnBuildRoad { width: auto; }
@media (max-width: 1024px) and (orientation: portrait) { #buildingsGrid .build-thumb { width: 30px; height: auto; } #buildingsGrid .command-btn.has-thumb .btn-icon-wrap { min-width: 30px; } }
/* Con la miniatura, algún botón (iconos de coste en fila) pedía más ancho que el panel y empujaba la columna: la goma del Camino quedaba
   cortada. La columna no crece por su contenido; lo que no quepa en un botón se recorta dentro de él. */
@media not all and (max-width: 1024px) and (orientation: portrait) {
    #buildingsGrid { grid-template-columns: minmax(0, 1fr); }
    #buildingsGrid .command-btn { min-width: 0; }
    #buildingsGrid .command-btn .btn-info { min-width: 0; }
}

/* Moneda de decoración: diamante azul, para no confundirla con el oro */
.ach-tier-coin .fa-gem, .ach-coin-hint .fa-gem, .shop-perks .fa-gem { color: #6fd8f2; }
.wx-price .fa-gem { color: #6fd8f2; }
.skin-cell img[src*="high_bridge"] { width: 72px; height: 36px; }

/* Estilos de camino: botón cuadrado en la fila del Camino y panel debajo (ver _renderRoadStylePanel) */
.road-row > #btnRoadStyle { flex: 0 0 64px; width: 64px; justify-content: center; padding: 6px; }
.road-row > #btnRoadStyle .btn-icon-wrap { min-width: 0; }
#btnRoadStyle .rs-ico { width: 32px; height: 32px; image-rendering: pixelated; display: block; border-radius: 3px; }
#btnRoadStyle.active { border-color: #e8c040; box-shadow: inset 0 0 0 1px #e8c040; }
.road-style-panel { grid-column: 1 / -1; padding: 8px; background: rgba(0, 0, 0, 0.25); border: 1px solid #5d4630; border-radius: 6px; }
.rs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rs-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 2px; background: rgba(0, 0, 0, 0.25); border: 1px solid #5d4630; border-radius: 4px; color: var(--text-muted); font-size: 10.5px; line-height: 1.15; cursor: pointer; min-width: 0; }
.rs-cell:hover { border-color: #a07c4c; }
.rs-cell.selected { border-color: #e8c040; box-shadow: inset 0 0 0 1px #e8c040; color: var(--text); }
.rs-cell.current .rs-name { font-weight: 700; }
.rs-tex { display: flex; gap: 2px; }
.rs-tex img { width: 24px; height: 24px; image-rendering: pixelated; display: block; border-radius: 2px; }
.rs-name { text-align: center; overflow-wrap: anywhere; }
.rs-price { font-size: 10px; color: #6fd8f2; }
.rs-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.3; }
.road-style-panel .skin-apply { width: 100%; margin-top: 8px; }
/* Con el botón de estilo, tres en la fila: los dos cuadrados más estrechos para que quepa "Camino" */
.road-row > #btnRoadErase, .road-row > #btnRoadStyle { flex-basis: 50px; width: 50px; padding: 4px; }
.road-row { gap: 6px; }
/* Fila del Camino con tres botones: sin el "1×1" (en un camino no dice nada), icono más estrecho y los dos cuadrados de 44 */
.road-row > #btnBuildRoad .btn-size { display: none; }
.road-row > #btnBuildRoad .btn-icon-wrap { min-width: 34px; }
.road-row > #btnBuildRoad { padding-left: 8px; padding-right: 6px; gap: 8px; }
.road-row > #btnRoadErase, .road-row > #btnRoadStyle { flex-basis: 44px; width: 44px; padding: 3px; }
#btnRoadStyle .rs-ico { width: 28px; height: 28px; }
.skin-cell img[src*="forest"] { width: 56px; height: 56px; }

/* Panel de controles de la decoración: abajo en el centro, sin capturar el ratón (ver _updateDecoKeys) */
.deco-keys { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; pointer-events: none; max-width: min(440px, calc(100vw - 32px)); padding: 8px 12px 9px; background: linear-gradient(160deg, rgba(46, 34, 20, 0.95) 0%, rgba(28, 21, 13, 0.95) 100%); border: 2px solid #c8893a; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); color: var(--text, #f0e0c0); font-size: 12.5px; line-height: 1.3; }
.deco-keys .dk-title { font-family: var(--font-title, inherit); color: #e8c040; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 5px; }
.deco-keys .dk-row { display: flex; align-items: flex-start; gap: 9px; margin-top: 4px; }
.deco-keys .dk-key { flex: none; min-width: 26px; padding: 1px 6px; text-align: center; font-weight: 700; font-size: 11.5px; color: #2a1d10; background: linear-gradient(180deg, #f4dfa8 0%, #d8b468 100%); border: 1px solid #8a6630; border-bottom-width: 2px; border-radius: 4px; white-space: nowrap; }
.deco-keys .dk-txt { flex: 1 1 auto; }
.deco-keys .dk-now { display: block; color: #a8d8a0; font-size: 11.5px; }
@media (max-width: 1024px) and (orientation: portrait) { .deco-keys { bottom: auto; top: 128px; font-size: 12px; } }

/* Mismo aspecto que la tarjeta de Ctrl (#ctrlHint, en _ctrlHintShow) */
.deco-keys { background: rgba(20, 16, 10, 0.93); border: 2px ridge #8b6914; box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7); color: #e8d5a0; text-shadow: 1px 1px 1px #000; font-size: 12px; line-height: 1.45; padding: 10px 14px; }
.deco-keys .dk-title { font-family: 'Cinzel', serif; color: #dfb256; letter-spacing: 1px; font-size: 11px; text-transform: none; }
.deco-keys .dk-key { text-shadow: none; }
.deco-keys { bottom: 76px; }
@media (max-width: 1024px) and (orientation: portrait) { .deco-keys { bottom: auto; } }
/* Móvil vertical: mucho más pequeño (pedido de JC: tapaba media pantalla). Sin título, letra menuda, el estado en la misma línea */
@media (max-width: 1024px) and (orientation: portrait) {
    .deco-keys { top: 112px; max-width: min(250px, calc(100vw - 32px)); padding: 3px 7px 4px; font-size: 10px; line-height: 1.25; border-width: 1px; }
    .deco-keys .dk-title { display: none; }
    .deco-keys .dk-row { gap: 5px; margin-top: 2px; align-items: baseline; }
    .deco-keys .dk-title + .dk-row { margin-top: 0; }
    .deco-keys .dk-key { min-width: 0; padding: 0 4px; font-size: 9px; border-bottom-width: 1px; border-radius: 3px; }
    .deco-keys .dk-now { display: inline; font-size: 9.5px; margin-left: 4px; }
}
.skin-cell .skin-price { font-size: 10px; color: #6fd8f2; }
/* "Ver anuncio" en los paneles de skins y de estilos de camino (como #btnDecoAd) */
.skin-ad { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 6px; padding: 7px 10px; background: #132436; border: 1px solid #2f5c8a; border-radius: 5px; color: var(--text, #f0e0c0); font-size: 12px; cursor: pointer; text-align: left; }
.skin-ad span { flex: 1 1 auto; font-weight: 700; }
.skin-ad b { color: #44cc44; white-space: nowrap; }
.skin-ad:hover:not(:disabled) { border-color: #5a8ac0; }
.skin-ad:disabled { opacity: 0.6; cursor: default; }
/* Clima: los bloqueados, con candado (se desbloquean todos juntos, ver _wxBuy) */
.wx-btn.locked .wx-price { color: #a89070; }
#wxBuyBar { flex-direction: column; gap: 4px; }
.road-style-panel .skin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.skin-ad.skin-shop { background: linear-gradient(160deg, #4a3a1c 0%, #2e2412 100%); border-color: #c8893a; }
.skin-ad.skin-shop:hover { border-color: #e8c040; }
/* Diamantes: "Ver anuncio" y la tienda en la misma fila (ver #decoGemRow) */
#decorationsGrid > #decoGemRow { grid-column: 1 / -1; display: flex; gap: 6px; }
#decoGemRow > .command-btn { flex: 1 1 0; min-width: 0; }
#decorationsGrid #btnDecoShop { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 0; padding: 8px 10px; gap: 10px; background: linear-gradient(160deg, #4a3a1c 0%, #2e2412 100%); border-color: #c8893a; }
#decorationsGrid #btnDecoShop .btn-label { display: block !important; font-weight: 700; }
#decorationsGrid #btnDecoShop:hover { border-color: #e8c040; }
#decorationsGrid #decoGemRow #btnDecoShop { flex-direction: row; justify-content: center; min-height: 0; padding: 8px 10px; gap: 8px; }
#decorationsGrid #decoGemRow #btnDecoShop .btn-icon-wrap { min-width: 0; }
/* Con el panel estrecho, "Ver anuncio" pasa a dos líneas en vez de cortarse (antes nowrap) */
#decorationsGrid #decoGemRow #btnDecoAd { gap: 8px; padding-left: 8px; padding-right: 8px; }
#decorationsGrid #decoGemRow #btnDecoAd .btn-info { min-width: 0; }
#decorationsGrid #decoGemRow #btnDecoAd .btn-label { white-space: normal; line-height: 1.15; overflow-wrap: anywhere; }
.shop-gems-note { margin: 6px 0 10px; text-align: center; color: #6fd8f2; font-size: 13px; }
.sc-gems, .mm-sub + .sc-gems { display: block; font-size: 11px; color: #6fd8f2; margin-top: 2px; }
/* Tienda: códigos de agradecimiento (rol de Discord / créditos), ver _shopClaimsHTML */
.shop-claims { background: rgba(88, 101, 242, 0.12); border: 1px solid #5865F2; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 12.5px; color: #e8d5a0; }
.shop-claims-title { font-weight: 700; color: #aab4ff; margin-bottom: 4px; }
.shop-claims p { margin: 0 0 8px; line-height: 1.4; }
.shop-claim-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.shop-claim-row code { font-size: 20px; letter-spacing: 3px; font-weight: 700; color: #f4dfa8; background: rgba(0, 0, 0, 0.35); padding: 2px 10px; border-radius: 5px; }
.shop-claim-row .menu-btn { width: auto; padding: 4px 10px; font-size: 12px; margin: 0; }
.shop-claim-discord { display: inline-flex; align-items: center; gap: 6px; color: #aab4ff; text-decoration: none; font-weight: 600; }
.shop-claim-discord:hover { text-decoration: underline; }
/* Carta extra (anuncio o tienda): marca en la esquina, ver _skillCardExtraIds */
.skill-card-extra-tag { position: absolute; top: -9px; right: 12px; padding: 1px 8px; font-size: 10.5px; font-weight: 700; color: #2a1d10; background: linear-gradient(180deg, #f4dfa8 0%, #d8b468 100%); border: 1px solid #8a6630; border-radius: 4px; white-space: nowrap; pointer-events: none; }
/* Móvil: barra de la decoración que se coloca (ver _updateDecoTouchBar): previa + botones (Girar, Lado, Diseño, Otro reparto, Voltear, Cancelar) */
/* left/right 0 + margin auto + max-content: centrada sin que left:50% le deje solo media pantalla de ancho (y apile los botones) */
.deco-touch-bar { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 8px; padding: 6px 8px; max-width: calc(100vw - 24px);
    background: rgba(20, 16, 10, 0.94); border: 2px ridge #8b6914; border-radius: 8px; box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7); }
.deco-touch-bar .dtb-prev { flex: none; width: 56px; height: 56px; image-rendering: pixelated; background: rgba(60, 90, 40, 0.55); border: 1px solid #6a4a1a; border-radius: 5px; }
.deco-touch-bar .dtb-btns { display: flex; gap: 6px; flex-wrap: nowrap; }
.deco-touch-bar .dtb-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 56px; min-height: 56px; padding: 4px 6px; white-space: nowrap; cursor: pointer;
    background: linear-gradient(160deg, #4a3a1c 0%, #2e2412 100%); border: 1px solid #c8893a; border-radius: 6px; color: #e8d5a0; font-size: 11px; font-weight: 700; line-height: 1.1; }
.deco-touch-bar .dtb-btn i { color: var(--gold); font-size: 16px; }
.deco-touch-bar .dtb-btn small { font-size: 9.5px; font-weight: 400; color: #a8d8a0; }
.deco-touch-bar .dtb-cancel { border-color: #8a4a3a; }
.deco-touch-bar .dtb-cancel i { color: #e07a6a; }
@media (max-width: 1024px) and (orientation: portrait) { .deco-touch-bar { bottom: auto; top: 112px; } }
/* Móvil vertical: la decoración sin nombres y a color (pedido de JC), como en PC: la imagen más grande en el hueco del nombre. Los botones en
   modo "Cancelar" sí enseñan su texto (es lo único que llevan). Sin diamantes suficientes, en gris. */
@media (max-width: 1024px) and (orientation: portrait) {
    #decorationsGrid .command-btn:not(#btnDecoAd):not(#btnDecoShop):not(.btn-cancel-mode) .btn-label { display: none !important; }
    #decorationsGrid .command-btn:not(#btnDecoAd):not(#btnDecoShop) .btn-icon-img { filter: none; width: 30px !important; height: 30px !important; }
    #decorationsGrid .command-btn:not(#btnDecoAd):not(#btnDecoShop):disabled .btn-icon-img { filter: grayscale(1); opacity: 0.55; }
}
/* Móvil vertical, botones de construir (pedido de JC): arriba el nombre; abajo, a la izquierda la imagen y a la derecha lo que cuesta, un
   recurso por línea. Solo los edificios de la rejilla (#buildingsGrid > botón): la fila del Camino (#roadRow) se queda como está. .btn-info
   pasa a display:contents para que su nombre y su coste se repartan en la rejilla del propio botón. */
@media (max-width: 1024px) and (orientation: portrait) {
    /* Solo los que se ven: con !important, un botón escondido por el juego (style display:none, p. ej. la Zanja en el Mundo 1 o un
       edificio aún bloqueado) volvía a salir en la lista */
    #buildingsGrid > .command-btn:not(.btn-cancel-mode):not([style*="display: none"]):not([style*="display:none"]) {
        display: grid !important; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr;
        grid-template-areas: 'name name' 'img cost'; align-items: center; column-gap: 6px !important; row-gap: 2px !important; padding: 4px 6px !important;
    }
    #buildingsGrid > .command-btn:not(.btn-cancel-mode) .btn-info { display: contents !important; }
    #buildingsGrid > .command-btn:not(.btn-cancel-mode) .btn-label { grid-area: name; justify-self: center; }
    #buildingsGrid > .command-btn:not(.btn-cancel-mode) .btn-icon-wrap { grid-area: img; justify-self: center; }
    #buildingsGrid > .command-btn:not(.btn-cancel-mode) .btn-cost { grid-area: cost; justify-self: start; text-align: left; white-space: normal !important; display: flex !important; flex-direction: column; align-items: flex-start; gap: 0; }
    #buildingsGrid > .command-btn:not(.btn-cancel-mode) .btn-cost .cost-grid { display: flex !important; flex-direction: column; align-items: flex-start; gap: 0 !important; }
}
/* Móvil vertical: los avisos de debajo del minimapa (reliquias, huelgas, logros, barcas) más pequeños (pedido de JC) */
@media (max-width: 1024px) and (orientation: portrait) {
    .relic-queue { gap: 3px; }
    .relic-chip { font-size: 10px; gap: 5px; max-width: 220px; padding: 2px 2px 2px 6px; border-width: 1px; }
    .relic-chip .rc-icon { font-size: 10px; }
    .relic-chip .rc-close { font-size: 12px; padding: 1px 4px; }
    .relic-queue .rc-clear, .relic-queue .rc-more { font-size: 9.5px; }
}
/* Móvil vertical: el banco de tiempo en fila, encima del panel de construir (ver _positionMobileOfflineStripsNow, que le pone .mob-row) */
@media (max-width: 1024px) and (orientation: portrait) {
    .offline-boost-strip.mob-row { flex-direction: row !important; width: auto !important; padding: 2px 4px !important; gap: 3px !important; align-items: center; }
    .offline-boost-strip.mob-row #offlineBoostTiersGroup { flex-direction: row !important; gap: 3px !important; width: auto !important; }
    .offline-boost-strip.mob-row .offline-boost-btn { width: 27px !important; padding: 3px 0 !important; font-size: 9.5px !important; }
    .offline-boost-strip.mob-row .offline-boost-time { font-size: 9.5px !important; margin: 0 2px !important; }
    .offline-boost-strip.mob-row .offline-boost-info-btn { width: 18px !important; height: 18px !important; font-size: 9px !important; }
    .offline-boost-strip.mob-row .offline-boost-ad-sep { width: 1px !important; height: 18px !important; margin: 0 1px !important; }
    .offline-boost-strip.mob-row .ad-time-inline-btn { flex-direction: row !important; align-items: center !important; width: auto !important; padding: 2px 4px !important; gap: 3px !important; font-size: 11px !important; }
    .offline-boost-strip.mob-row .ad-time-inline-btn #adTimeBonusCooldown { font-size: 7.5px !important; max-width: 48px; }
}
/* Móvil vertical: la flecha de plegar el panel, a la izquierda junto a las pestañas (pedido de JC): en el centro se solapaba con el banco
   de tiempo, que ahora va en fila a la derecha (ver .offline-boost-strip.mob-row) */
@media (max-width: 1024px) and (orientation: portrait) {
    #btnToggleCommandCard { left: 108px !important; transform: none !important; width: 36px; }
}
/* Móvil vertical: la tienda más compacta, 2 paquetes por fila (pedido de JC: mucho scroll) */
@media (max-width: 1024px) and (orientation: portrait) {
    .shop-box { padding: 14px 10px 12px; }
    .shop-title { font-size: 17px; margin-bottom: 2px; }
    .shop-subtitle { font-size: 11px; margin-bottom: 8px; }
    .shop-packs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 6px; }
    .shop-pack { padding: 9px 7px 7px; }
    .shop-badge { font-size: 8.5px; padding: 1px 5px; top: -7px; right: 6px; }
    .shop-amount { font-size: 15px; }
    .shop-amount i { font-size: 11px; }
    .shop-amount-label { font-size: 10px; margin-bottom: 4px; }
    .shop-perks { margin-bottom: 7px; }
    .shop-perks li { font-size: 10px; line-height: 1.25; margin-top: 3px; gap: 5px; }
    .shop-perks i { font-size: 9px; margin-top: 2px; }
    .shop-buy { padding: 6px 4px !important; font-size: 13px !important; }
    .shop-note { font-size: 9.5px; }
    .shop-claims { font-size: 11px; padding: 7px 8px; }
    .shop-claim-row code { font-size: 16px; }
}

/* Ventanas sin esquinas redondeadas (pedido de JC): el mismo canto recto que el menú de construir (.ui-panel, 3px).
   Casi todas las cajas de ventana llevan su borde ridge escrito en línea (en index.html y en las que monta main.js), así que
   esta regla las pilla todas sin tocarlas una a una; solo div: los botones con borde ridge se quedan como están. Las de la
   segunda línea tienen el redondeo en esta hoja. Fichas, botones y etiquetas pequeñas no cambian. */
div[style*="ridge"] { border-radius: 3px !important; }
.howto-box, #menuMainOptions, #menuSlotPicker, .shop-box, #stkInfo, .deco-keys, .deco-touch-bar, .road-style-panel, .display-options-box { border-radius: 3px !important; }
