/* Forest Nothing — estilos de la web.
 *
 * La paleta sale del propio juego para que la web no parezca de otro producto:
 *   #1a140f  fondo del mapa exportado (main.js, downloadMinimapImage)
 *   #8a6d3a  territorio de la ciudad
 *   #2f6b2f  bosque
 *   #e8c000  reliquia (el acento)
 *   #123049  mar
 * Tipografía: Cinzel para titulares (la misma que usa el HUD del juego — ver main.js's
 * 'Cinzel',serif) y Inter para el cuerpo, en vez de la fuente del sistema — sin esto todo el
 * sitio leía como una plantilla genérica en vez de algo hecho para este juego en concreto.
 */

:root {
    --bg:          #14100c;
    --bg-panel:    #1f1913;
    --bg-panel-2:  #2a221a;
    --border:      #3d3226;
    --text:        #e8ddcc;
    --text-dim:    #a3937c;
    --brown:       #8a6d3a;
    --green:       #2f6b2f;
    --green-soft:  #8fcf6f;
    --gold:        #e8c000;
    --sea:         #123049;
    --red:         #d06a5a;
    --radius:      10px;
    --radius-sm:   6px;
    --maxw:        1120px;
    --font-head:   'Cinzel', Georgia, serif;
    --font-body:   'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --shadow-card: 0 2px 10px rgba(0,0,0,0.28);
    --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.4);
    --shadow-pop:  0 12px 40px rgba(0,0,0,0.5);
    --ease:        cubic-bezier(0.2, 0.7, 0.3, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    /* A very faint radial vignette instead of a flat fill — the game's own screens never sit on
       pure flat color either, and it's the cheapest way to stop long pages reading as a plain
       browser default background. */
    background:
        radial-gradient(ellipse 1200px 600px at 50% -10%, rgba(138,109,58,0.10), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .logo, .btn, .tab {
    font-family: var(--font-head);
}

a { color: var(--green-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* --- Cabecera --------------------------------------------------------------------------- */

header.site {
    border-bottom: 1px solid var(--border);
    background: rgba(20, 16, 12, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 1px 0 rgba(0,0,0,0.3);
}
header.site .wrap {
    display: flex; align-items: center; gap: 24px;
    height: 64px;
}
.logo {
    font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em;
    color: var(--text); white-space: nowrap;
    display: flex; align-items: center; gap: 8px;
}
.logo:hover { text-decoration: none; color: var(--gold); }
header.site nav { display: flex; gap: 22px; margin-left: auto; align-items: center; }
header.site nav a {
    color: var(--text-dim); font-size: 0.88rem; font-family: var(--font-body);
    font-weight: 500; transition: color 0.15s var(--ease);
}
header.site nav a:hover, header.site nav a.active { color: var(--text); text-decoration: none; }
header.site nav a.active { color: var(--gold); }

/* --- Botones ---------------------------------------------------------------------------- */

.btn {
    display: inline-block; padding: 12px 24px; border-radius: var(--radius);
    background: var(--brown); color: #fff; font-weight: 600; font-size: 0.92rem;
    letter-spacing: 0.02em;
    border: none; cursor: pointer; transition: filter 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s var(--ease);
    text-align: center;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2), var(--shadow-card);
}
.btn:hover { filter: brightness(1.15); text-decoration: none; transform: translateY(-1px); box-shadow: 0 3px 0 rgba(0,0,0,0.2), var(--shadow-card-hover); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.btn.primary { background: var(--green); }
.btn.gold { background: linear-gradient(160deg, #f3d158, var(--gold)); color: #2b2205; }
.btn.ghost {
    background: transparent; border: 1px solid var(--border); color: var(--text-dim);
    box-shadow: none;
}
.btn.ghost:hover { border-color: var(--brown); color: var(--text); box-shadow: none; transform: none; }
.btn.small { padding: 8px 16px; font-size: 0.82rem; }

/* --- Portada ---------------------------------------------------------------------------- */

.hero { padding: 88px 0 64px; text-align: center; }
.hero h1 {
    font-size: clamp(2.3rem, 6vw, 3.6rem); margin: 0 0 18px; line-height: 1.15;
    letter-spacing: -0.01em; font-weight: 700;
}
.hero p.lead {
    font-size: clamp(1rem, 2.4vw, 1.2rem); color: var(--text-dim);
    max-width: 620px; margin: 0 auto 36px;
}
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.section { padding: 52px 0; border-top: 1px solid var(--border); }
.section h2 {
    font-size: 1.6rem; margin: 0 0 6px; font-weight: 700;
}
.section .sub { color: var(--text-dim); margin: 0 0 28px; font-size: 0.95rem; font-family: var(--font-body); }
.section-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.section-head h2 { margin: 0; font-size: 1.3rem; }
.section-head .sub { margin: 4px 0 0; }
.section-head.spaced { margin-top: 44px; }
.score-unit { font-weight: 400; color: var(--text-dim); font-family: var(--font-body); }
.tabs + .tabs { margin-top: 10px; }
.tabs + .deco-grid, .tabs + .tabs + .deco-grid { margin-top: 16px; }

/* Shared page intro used by every inner page (cities/decorations/devlog/retos/create) — kept as
   one class instead of each page repeating its own inline margin/font-size. */
.page-title { margin: 40px 0 30px; }
.page-title h2 { font-size: 1.9rem; margin: 0; }
.page-title .sub { margin: 6px 0 0; }

.load-more-wrap { text-align: center; margin: 36px 0 20px; }

.feature-grid {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.feature-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; box-shadow: var(--shadow-card);
}
.feature-icon {
    width: 44px; height: 44px; border-radius: 10px; margin-bottom: 14px;
    background: linear-gradient(160deg, var(--brown), #5f4a26);
    display: flex; align-items: center; justify-content: center; font-size: 18px; color: #fff;
}
.feature-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.feature-card p { margin: 0; color: var(--text-dim); font-size: 0.92rem; }

/* --- Rejilla de ciudades ---------------------------------------------------------------- */

.city-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
}

.city-card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    display: flex; flex-direction: column;
    transition: border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
    box-shadow: var(--shadow-card);
    /* Thumbnails are only ~100x100 source pixels (see main.js's _captureMinimapThumbnail). A
       card can stretch much wider than that on a wide screen (auto-fill + 1fr has no ceiling),
       and even with pixelated scaling that turns crisp pixel art into an ugly oversized blur of
       giant squares. Capping the card keeps the upscale factor sane at every viewport width. */
    max-width: 300px;
}
.city-card:hover { border-color: var(--brown); transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.city-card .thumb {
    aspect-ratio: 1; background: #0d0a07; display: block; width: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges; /* older Firefox used its own keyword before adopting pixelated */
}
/* El canvas del render propio, cuando no hay miniatura del servidor. */
.city-card canvas.thumb {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}
.city-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.city-card h3 {
    margin: 0; font-size: 1rem; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.city-card h3 a { color: var(--text); }
.city-card .meta {
    font-size: 0.8rem; color: var(--text-dim);
    display: flex; gap: 10px; flex-wrap: wrap;
}
.city-card .meta .by { color: var(--green-soft); }
.city-card .foot {
    margin-top: auto; display: flex; align-items: center; gap: 8px;
    padding-top: 4px;
}
.city-card .foot .btn { margin-left: auto; }
.meta-sep { opacity: 0.4; }

/* --- Votos ------------------------------------------------------------------------------ */

.votes { display: flex; align-items: center; gap: 4px; }
.vote-btn {
    background: none; border: 1px solid var(--border); color: var(--text-dim);
    width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
    font-size: 0.95rem; line-height: 1; display: grid; place-items: center;
    transition: all 0.13s;
}
.vote-btn:hover:not(:disabled) { border-color: var(--brown); color: var(--text); }
.vote-btn:disabled { opacity: 0.45; cursor: wait; }
.vote-btn.up.on   { background: var(--green); border-color: var(--green); color: #fff; }
.vote-btn.down.on { background: var(--red);   border-color: var(--red);   color: #fff; }
.vote-score {
    min-width: 30px; text-align: center; font-variant-numeric: tabular-nums;
    font-weight: 600; font-size: 0.9rem;
}

/* --- Pestañas de orden ------------------------------------------------------------------ */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
    padding: 8px 16px; border-radius: 999px; cursor: pointer; font-size: 0.9rem;
    background: var(--bg-panel); border: 1px solid var(--border); color: var(--text-dim);
    transition: all 0.13s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--brown); border-color: var(--brown); color: #fff; }

.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 20px 0 24px; }
.filters select {
    background: var(--bg-panel); border: 1px solid var(--border); color: var(--text);
    padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; font-family: inherit;
}

/* --- city.html: full-screen from the very first frame -------------------------------------
   Same black #.live-overlay ends up using, so the loading/error state before it appears and
   the live view itself never visibly hand off — no flash of the normal site header/footer for
   the one frame before this page replaces itself, because that markup isn't even here (see the
   page's own comment) and this fills the viewport immediately instead of waiting on content. */
#main {
    position: fixed; inset: 0; background: #000;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
#main .state { border: none; max-width: 420px; }

/* --- Ver en vivo (pantalla completa) -------------------------------------------------------
   city.html's ENTIRE content now: no static overview page underneath anymore (see city.html's
   own comment) — landing on a shared city link goes straight into this. */

.live-overlay {
    position: fixed; inset: 0; z-index: 10000; background: #000;
}
.live-overlay-frame { width: 100%; height: 100%; border: 0; display: block; }
.live-overlay-bar {
    position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 2;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center;
    padding: 10px; max-width: calc(100% - 32px);
}
.live-overlay-bar .votes {
    background: rgba(20, 16, 12, 0.75); backdrop-filter: blur(4px);
    padding: 4px 6px; border-radius: 999px;
}
/* Share / Back to the site — solid dark background instead of the site's usual transparent
   .btn.ghost, so they stay readable sitting directly over the live game view underneath. */
.live-overlay-btn {
    background: rgba(20, 16, 12, 0.85); backdrop-filter: blur(4px);
    color: var(--text); border: 1px solid rgba(255,255,255,0.12);
}
.live-overlay-btn:hover { background: rgba(30, 24, 18, 0.9); border-color: var(--brown); }

/* Version history — only rendered when a city has been re-shared at least once (see city.html's
   own load()); most cities never show this at all. A vertical column on the left, clear of the
   game's own top header/HUD (which the horizontal bar this replaced used to sit over). */
.version-strip {
    position: absolute; top: 50%; left: 16px; transform: translateY(-50%); z-index: 2;
    display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 100px);
    overflow-y: auto; padding: 10px;
    background: rgba(20, 16, 12, 0.75); backdrop-filter: blur(4px); border-radius: 12px;
}
.version-strip-item {
    display: flex; align-items: center; gap: 8px; text-align: left;
    background: none; border: none; cursor: pointer; padding: 4px; border-radius: 8px;
    color: var(--text-dim); font-size: 0.68rem; font-family: inherit; line-height: 1.35;
}
.version-strip-item:hover { background: rgba(255,255,255,0.06); }
.version-strip-item.active { color: var(--gold); }
.version-strip-thumb {
    flex-shrink: 0; width: 40px; height: 40px; border-radius: 5px; overflow: hidden; background: #0d0a07;
    border: 2px solid transparent; display: flex; align-items: center; justify-content: center;
}
.version-strip-item.active .version-strip-thumb { border-color: var(--gold); }
.version-strip-thumb img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.version-strip-thumb i { font-size: 0.9rem; }
.version-strip-label { display: flex; flex-direction: column; }

/* --- Devlog ----------------------------------------------------------------------------- */

.devlog-entry {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
    box-shadow: var(--shadow-card);
}
.devlog-entry .head { margin-bottom: 10px; }
.devlog-entry .date { color: var(--text); font-size: 0.98rem; font-weight: 700; }
.devlog-entry .devlog-section {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-dim); font-weight: 700; margin: 16px 0 6px;
}
.devlog-entry .devlog-section:first-child { margin-top: 0; }
.devlog-entry ul { margin: 0; padding-left: 20px; }
.devlog-entry li { margin-bottom: 5px; }
.devlog-entry li::marker { color: var(--brown); }

/* --- Estados ---------------------------------------------------------------------------- */

.state {
    text-align: center; padding: 52px 20px; color: var(--text-dim);
    border: 1px dashed var(--border); border-radius: var(--radius);
}
.state.error { border-color: var(--red); color: var(--red); }
.state code {
    background: var(--bg-panel-2); padding: 2px 6px; border-radius: 4px;
    font-size: 0.85em; color: var(--text);
}
.state .hint { opacity: 0.8; }
.state .state-action { margin-top: 16px; }

.skeleton {
    background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-panel-2) 50%, var(--bg-panel) 75%);
    background-size: 200% 100%; animation: shimmer 1.3s infinite;
    border-radius: var(--radius); border: 1px solid var(--border);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton.card { aspect-ratio: 0.82; }
.skeleton.block { height: 140px; margin-bottom: 16px; }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    .city-card:hover { transform: none; }
}

/* --- Aviso de copiado ------------------------------------------------------------------- */

.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(16px);
    background: var(--green); color: #fff; padding: 11px 22px; border-radius: 999px;
    font-size: 0.9rem; font-weight: 600; opacity: 0; pointer-events: none;
    transition: opacity 0.22s, transform 0.22s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Pie -------------------------------------------------------------------------------- */

footer.site {
    border-top: 1px solid var(--border); margin-top: 64px; padding: 32px 0 44px;
    color: var(--text-dim); font-size: 0.87rem;
    background: rgba(0,0,0,0.15);
}
footer.site .wrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
footer.site span:first-child { font-family: var(--font-head); font-weight: 700; color: var(--text); }
footer.site nav { margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap; }
footer.site nav a { transition: color 0.15s var(--ease); }
footer.site nav a:hover { color: var(--text); text-decoration: none; }

/* --- Decorations: official gallery -------------------------------------------------------- */

.deco-official-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}
.deco-official-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; text-align: center;
    box-shadow: var(--shadow-card); transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.deco-official-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.deco-official-thumb {
    width: 64px; height: 64px; margin: 0 auto 10px; background: #0d0a07; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
}
.deco-official-thumb img {
    width: 48px; height: 48px; image-rendering: pixelated; image-rendering: -moz-crisp-edges;
}
.deco-official-name { font-size: 0.88rem; font-weight: 600; }
.deco-official-by { font-size: 0.72rem; color: var(--text-dim); margin-top: 2px; }

/* --- Decorations: link to the full editor page ----------------------------------------------- */

.deco-back-link {
    display: inline-block; color: var(--text-dim); font-size: 0.85rem; text-decoration: none;
}
.deco-back-link:hover { color: var(--text); text-decoration: underline; }

.deco-create-cta {
    display: flex; align-items: center; gap: 16px; width: 100%; margin: 36px 0;
    background: linear-gradient(135deg, var(--brown), #5f4a26);
    color: #fff; border-radius: var(--radius); padding: 20px 24px;
    text-decoration: none; transition: filter 0.15s var(--ease), transform 0.08s var(--ease), box-shadow 0.15s var(--ease);
    box-shadow: var(--shadow-card);
}
.deco-create-cta:hover { filter: brightness(1.1); text-decoration: none; box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.deco-create-cta:active { transform: translateY(1px); }
.deco-create-cta-icon {
    flex: none; width: 46px; height: 46px; border-radius: 50%;
    background: rgba(255,255,255,.15); display: grid; place-items: center; font-size: 18px;
}
.deco-create-cta-copy { display: flex; flex-direction: column; gap: 3px; }
.deco-create-cta-copy strong { font-size: 1.1rem; }
.deco-create-cta-copy small { font-size: 0.82rem; opacity: 0.88; font-weight: 500; }
@media (max-width: 560px) { .deco-create-cta-copy small { display: none; } }

/* --- Decorations: editor -------------------------------------------------------------------- */

.deco-editor {
    display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 260px;
    align-items: start;
}
@media (max-width: 760px) { .deco-editor { grid-template-columns: 1fr; } }

.deco-editor-canvas-col { display: flex; flex-direction: column; align-items: center; }

.deco-start-from { width: 100%; max-width: 340px; margin-bottom: 16px; }
.deco-start-from-label {
    display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-dim); margin-bottom: 6px;
}
.deco-start-from-strip {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.deco-start-from-item {
    flex: none; width: 34px; height: 34px; padding: 4px; background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.deco-start-from-item:hover { border-color: var(--brown); }
.deco-start-from-item img {
    width: 100%; height: 100%; image-rendering: pixelated; image-rendering: -moz-crisp-edges;
}
.deco-import-btn { display: inline-block; }

.deco-page-title { margin: 36px 0 24px; }
.deco-page-title h2 { font-size: 1.9rem; margin: 10px 0 0; }
.deco-hint { color: var(--text-dim); font-size: 0.8rem; margin: 10px 0 0; }
.deco-hint.center { text-align: center; font-size: 0.76rem; margin-top: 6px; }
.deco-editor-actions { display: flex; gap: 8px; margin-top: 10px; }
.deco-input {
    width: 100%; box-sizing: border-box; background: var(--bg-panel-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font-size: 0.85rem;
    font-family: var(--font-body); margin-bottom: 8px; transition: border-color 0.15s var(--ease);
}
.deco-input:focus { outline: none; border-color: var(--brown); }
.deco-input::placeholder { color: var(--text-dim); }

.deco-size-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }
.deco-editor-canvas {
    width: min(100%, 340px); aspect-ratio: 1; background: #0d0a07;
    border: 1px solid var(--border); border-radius: 6px;
    image-rendering: pixelated; image-rendering: -moz-crisp-edges;
    cursor: crosshair; touch-action: none;
    /* Grid lines: a CSS overlay sized in PERCENT (not px), so it scales exactly with however big
       the canvas actually renders — see create.html's updateGridOverlay() for why px would not
       work here. Two 1D gradients (vertical lines repeating across X, horizontal repeating down
       Y) rather than baking a grid into the bitmap, which would eat into pixel colors. */
    background-image:
        linear-gradient(to right, rgba(255,255,255,.12) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,.12) 1px, transparent 1px);
    background-repeat: repeat;
}
.deco-editor-canvas-lg { width: min(100%, 440px); }
.deco-palette {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
    max-width: 340px; margin-top: 14px;
}
.deco-current-color {
    display: flex; flex-direction: column; gap: 8px;
    width: 100%; max-width: 340px; margin: 12px auto 0; padding: 12px;
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.8rem; color: var(--text-dim);
}
.deco-current-color-head { display: flex; align-items: center; gap: 8px; }
.deco-current-color-swatch {
    width: 26px; height: 26px; border-radius: 5px; border: 1px solid var(--border); flex: none;
}
.deco-hsl-title {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px;
}
.deco-hsl-row {
    display: grid; grid-template-columns: 14px 1fr 34px; align-items: center; gap: 8px;
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase; color: var(--text-dim);
}
.deco-hsl-row input[type="range"]:disabled { opacity: 0.4; }
/* The track's own color comes from JS (see create.html's updateSliderGradients) — this just
   strips each browser's default track chrome so that background actually shows through, and
   gives every browser the same plain white thumb on top of it. */
.deco-gradient-slider {
    width: 100%; height: 8px; border-radius: 4px; outline: none; cursor: pointer;
    -webkit-appearance: none; appearance: none; background: #444;
}
.deco-gradient-slider::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: transparent; }
.deco-gradient-slider::-moz-range-track { height: 8px; border-radius: 4px; background: transparent; }
.deco-gradient-slider::-webkit-slider-thumb {
    -webkit-appearance: none; margin-top: -4px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; border: 2px solid var(--border); box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.deco-gradient-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border);
    background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.deco-hsl-val {
    font-variant-numeric: tabular-nums; text-align: right; font-weight: 600;
    text-transform: none; color: var(--text);
}
.deco-swatch {
    position: relative;
    width: 26px; height: 26px; border-radius: 5px; border: 2px solid transparent;
    cursor: pointer; padding: 0;
}
.deco-swatch-num {
    position: absolute; bottom: -4px; right: -4px;
    background: rgba(0,0,0,0.75); color: #fff; font-size: 8px; font-weight: 700;
    border-radius: 999px; min-width: 13px; height: 13px; line-height: 13px; text-align: center;
    padding: 0 2px; pointer-events: none;
}
.deco-swatch.active { border-color: var(--text); }
.deco-swatch-eraser {
    background:
        linear-gradient(45deg, #3a3248 25%, transparent 25%, transparent 75%, #3a3248 75%) 0 0 / 8px 8px,
        linear-gradient(45deg, #3a3248 25%, #1f1913 25%, #1f1913 75%, #3a3248 75%) 0 0 / 8px 8px;
}
/* Same checkerboard as the eraser (so "see-through" reads consistently) with a dark wash on top
   — this IS DECO_SHADOW_COLOR itself (rgba(0,0,0,0.4)) as the top layer, not a lookalike. */
.deco-swatch-shadow {
    background:
        linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)),
        linear-gradient(45deg, #3a3248 25%, transparent 25%, transparent 75%, #3a3248 75%) 0 0 / 8px 8px,
        linear-gradient(45deg, #3a3248 25%, #1f1913 25%, #1f1913 75%, #3a3248 75%) 0 0 / 8px 8px;
}
/* An unfilled slot: dashed border, no color, just its number — clicking it opens the shared
   slotColorInput aimed at that slot (see create.html's palette click handler), it doesn't select
   anything for painting on its own. */
.deco-swatch-empty {
    background: transparent; border: 2px dashed var(--border);
}
.deco-swatch-empty:hover { border-color: var(--brown); }
.deco-swatch-add {
    background: var(--bg-panel); border: 1px dashed var(--border); color: var(--text-dim);
    font-size: 15px; font-weight: 700; line-height: 1;
}
.deco-swatch-add:hover { border-color: var(--brown); color: var(--text); }

.side-panel {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow-card);
}
.side-panel h3 { margin: 0 0 4px; font-size: 1.05rem; }
.deco-editor-side .side-panel + .side-panel { margin-top: 16px; }
.deco-preview-canvas {
    width: 100%; aspect-ratio: 3 / 2; image-rendering: pixelated; image-rendering: -moz-crisp-edges;
    border-radius: 4px; display: block;
}

/* --- Decorations: community gallery ---------------------------------------------------------- */

.deco-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.deco-card {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: var(--shadow-card); transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.deco-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-3px); }
.deco-card-thumb {
    aspect-ratio: 1.6; display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    /* Same grass.png the "on the ground" preview scene tiles (see js/decorations.js) — a
       decoration reads a lot better sitting on ground than floating on flat dark panel color. */
    background-color: #0d0a07;
    background-image: url('../assets/preview/grass.png');
    background-repeat: repeat;
    background-size: 32px 32px;
    image-rendering: pixelated; image-rendering: -moz-crisp-edges;
}
.deco-card-thumb canvas {
    /* Every design is square (tilesW === tilesH always), but its native pixel size can be as
       small as 16x16 — max-width/max-height alone never kicks in at that size (it's already far
       under any % of the box), so the canvas rendered at native resolution and looked tiny. A
       fixed width + aspect-ratio forces it to actually scale UP regardless of source size, unlike
       the box it sits in (aspect-ratio 1.6, not square). */
    width: 72%; aspect-ratio: 1 / 1; image-rendering: pixelated; image-rendering: -moz-crisp-edges;
}
/* Clicking the thumb opens #decoPreviewModal with the same "on the ground" scene create.html's
   editor shows while drawing — voting on a tiny raw sprite alone doesn't tell you much about how
   it'd actually read in a real city. */
.deco-preview-modal {
    display: none; position: fixed; inset: 0; z-index: 200; background: rgba(10,7,4,0.85);
    align-items: center; justify-content: center; padding: 20px;
}
.deco-preview-modal.show { display: flex; }
.deco-preview-modal-inner {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; max-width: 480px; width: 100%; position: relative;
    max-height: 90vh; overflow-y: auto; /* retos.html's milestone+skill timeline can run long */
    box-shadow: var(--shadow-pop);
}
.deco-preview-modal-close {
    position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(0,0,0,0.4); border: 1px solid var(--border); color: var(--text-dim);
    font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.deco-preview-modal-close:hover { color: var(--text); border-color: var(--brown); }
.deco-preview-modal h3 { margin: 0 0 12px; padding-right: 24px; font-size: 1.05rem; }
.deco-preview-modal-caption { color: var(--text-dim); font-size: 0.8rem; margin: 10px 0 0; }
.deco-preview-modal-votes { margin-top: 14px; }
.deco-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.deco-card h3 { margin: 0; font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.deco-card .meta { font-size: 0.78rem; color: var(--text-dim); }
.deco-card .foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deco-adopted-badge {
    background: var(--green); color: #fff; font-size: 0.65rem; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em;
}
.deco-floor-badge {
    background: var(--sea); color: #cfe6f7; font-size: 0.65rem; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em;
}
.deco-rejected-badge {
    background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 700;
    padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em;
}
.deco-final-score { font-size: 0.78rem; color: var(--text-dim); }

/* --- Challenges (retos.html) ------------------------------------------------------------------ */

.reto-card-thumb {
    position: relative; background-color: #0d0a07; cursor: default;
    background-image: none; /* overrides .deco-card-thumb's grass tiling — this is a real screenshot, not pixel art on ground */
}
.reto-card-thumb img {
    width: 100%; height: 100%; object-fit: cover;
    image-rendering: auto; /* overrides .deco-card-thumb canvas's pixelated rule — a real screenshot reads better smoothed, not blocky */
}
.reto-card-thumb i { font-size: 1.6rem; color: var(--text-dim); }
.reto-rank-badge {
    position: absolute; top: 6px; left: 6px; z-index: 1;
    font-size: 0.7rem; font-weight: 800; padding: 3px 8px; border-radius: 999px;
    background: rgba(0,0,0,0.7); color: var(--text);
}
.reto-rank-1 { background: var(--gold); color: #2b2205; }
.reto-rank-2 { background: #c9c9c9; color: #222; }
.reto-rank-3 { background: #b3803f; color: #2b1c05; }

.reto-detail-map { width: 100%; border-radius: 6px; display: block; margin-top: 4px; }
.reto-detail-stats { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.reto-detail-stat-row {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: 0.82rem; padding: 4px 0; border-bottom: 1px solid var(--border);
}
.reto-detail-stat-row span:first-child { color: var(--text-dim); }
.reto-detail-subhead { margin: 18px 0 4px; font-size: 0.85rem; color: var(--text); }
.reto-skill-star { color: var(--gold); margin-right: 5px; }

/* --- Character skins (characters.html / create-character.html) -------------------------------- */

.skin-poses { display: flex; flex-wrap: wrap; gap: 10px; }
.skin-pose { text-align: center; font-size: 0.72rem; color: var(--text-dim); cursor: default; }
.skin-pose canvas { image-rendering: pixelated; background: #2d5a27; border: 1px solid var(--border); border-radius: 4px; display: block; margin: 0 auto 3px; }
.skin-pose.part { cursor: pointer; }
.skin-pose.part canvas { background: repeating-conic-gradient(#2a2218 0 25%, #221b12 0 50%) 0 0 / 8px 8px; }
.skin-pose.part.sel canvas { border-color: var(--gold); }
