:root {
    --a: #2a1707;
    --b: #7a5116;
    --c: #f2c14e;
    --i: #fbf1d8;
    --cell: min(36px, calc((100vw - 64px)/10));
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px)
}

* {
    box-sizing: border-box
}

[hidden] {
    display: none !important
}

html,
body {
    margin: 0
}

body {
    min-height: 100vh;
    color: var(--i);
    font-family: Georgia, serif;
    background: radial-gradient(ellipse at 50% 0, var(--b), var(--a) 70%) fixed;
    padding: 12px 12px 28px;
    overflow-x: hidden;
    transition: background .6s
}

body::before {
    content: "";
    position: fixed;
    left: 50%;
    top: 50%;
    width: min(130vw, 900px);
    aspect-ratio: 1;
    translate: -50% -50%;
    border-radius: 50%;
    background: repeating-conic-gradient(var(--c) 0 .6deg, transparent .6deg 30deg);
    -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%, #000 64%, transparent 65%);
    mask: radial-gradient(circle, transparent 60%, #000 61%, #000 64%, transparent 65%);
    opacity: .2;
    animation: spin 240s linear infinite;
    pointer-events: none
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background-image: radial-gradient(var(--c) 1px, transparent 1.6px), radial-gradient(var(--i) 1px, transparent 1.6px);
    background-size: 90px 90px, 140px 140px;
    background-position: 0 0, 40px 60px;
    opacity: .13;
    animation: drift 40s linear infinite;
    pointer-events: none
}

@keyframes spin {
    to {
        rotate: 360deg
    }
}

@keyframes drift {
    to {
        background-position: 0 -90px, 40px -80px
    }
}

.w {
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: auto;
    text-align: center
}

button {
    font: inherit;
    color: inherit;
    background: rgba(0, 0, 0, .3);
    border: 1px solid var(--c);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer
}

.tabs {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 10px;
    scrollbar-width: thin
}

.tabs button {
    flex: 0 0 auto
}

.tabs button {
    font-size: 20px
}

.tabs small {
    display: block;
    font-size: 11px;
    opacity: .8
}

.tabs .on {
    background: var(--c);
    color: #111
}

#era {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--c)
}

h1 {
    margin: 4px 0 8px;
    font-size: clamp(24px, 7vw, 34px);
    text-shadow: 0 0 18px var(--c)
}

#chip {
    display: inline-block;
    background: var(--c);
    color: #111;
    font: 700 13px 'Courier New', monospace;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px
}

.bw {
    display: inline-block;
    padding: 8px;
    border: 1px solid var(--c);
    border-radius: 14px;
    background: rgba(0, 0, 0, .4);
    box-shadow: 0 0 30px rgba(0, 0, 0, .6), 0 0 24px rgba(255, 255, 255, .05) inset
}

.bd {
    display: grid;
    grid-template-columns: repeat(10, var(--cell));
    position: relative
}

#ov {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1
}

.ce {
    width: var(--cell);
    height: var(--cell);
    display: grid;
    place-items: center;
    font: 700 calc(var(--cell)*.55) 'Courier New', monospace;
    cursor: pointer;
    user-select: none;
    position: relative;
    z-index: 2;
    border-radius: 6px
}

.ce.sel {
    background: var(--c);
    color: #111;
    transform: scale(1.12)
}

.hint {
    font-size: 12px;
    opacity: .75;
    margin: 8px 0
}

.wl {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    justify-content: center;
    list-style: none;
    padding: 0;
    font: 700 14px 'Courier New', monospace
}

.wl li::before {
    content: "• ";
    color: var(--k, var(--c))
}

.wl li.x {
    text-decoration: line-through;
    text-decoration-color: var(--k);
    text-decoration-thickness: 3px;
    opacity: .8
}

#lp {
    margin: 14px 0;
    padding: 12px;
    border: 1px dashed var(--c);
    border-radius: 12px;
    background: rgba(0, 0, 0, .3)
}

#lp h3 {
    margin: 0;
    font-size: 13px;
    letter-spacing: 2px;
    color: var(--c)
}

#lt {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center
}

.lc {
    width: var(--cell);
    height: var(--cell);
    padding: 0;
    font: 700 calc(var(--cell)*.55) 'Courier New', monospace
}

.lc:active {
    transform: scale(.9)
}

.rw {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    padding: 6px;
    border-radius: 10px;
    border-left: 4px solid transparent;
    text-align: left
}

.rw.act {
    background: rgba(255, 255, 255, .08);
    border-left-color: var(--c)
}

.rw b {
    flex: 0 0 74px;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--c)
}

.sg {
    display: flex;
    gap: 4px;
    flex: 1;
    min-width: 0
}

.sl {
    flex: 1 1 0;
    min-width: 0;
    max-width: 40px;
    height: 44px;
    padding: 0;
    font: 700 20px 'Courier New', monospace;
    background: rgba(255, 255, 255, .1)
}

.sl.nx {
    border-color: #fff;
    box-shadow: 0 0 8px var(--c)
}

.sl.lk {
    background: var(--c);
    color: #111
}

#msg {
    min-height: 22px;
    font-size: 14px
}

.md {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, .85);
    padding: 16px;
    overflow: auto
}

.card {
    max-width: 520px;
    border: 1px solid var(--c);
    border-radius: 16px;
    padding: 22px;
    background: linear-gradient(160deg, var(--a), #000 150%);
    text-align: left;
    box-shadow: 0 0 40px var(--c)
}

#mk {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--c)
}

.card h2 {
    margin: 6px 0 10px
}

.card p {
    line-height: 1.6;
    margin: 0 0 16px
}

.ar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

#mb {
    background: var(--c);
    color: #111;
    font-weight: 700
}

/* ===== Encabezado de caso y pistas ===== */
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px }
#cn { font: 700 13px 'Courier New', monospace; letter-spacing: 3px; color: var(--c) }
#hint { font-size: 14px; padding: 6px 12px }
#hint:disabled { opacity: .5 }
.pb { height: 4px; background: #fff2; border-radius: 4px; overflow: hidden; margin-bottom: 10px }
#pbf { display: block; height: 100%; width: 0; background: var(--c); transition: width .9s }
.ce.hl { animation: hl 1s ease-in-out infinite; background: var(--c); color: #111; z-index: 3 }
.wl li.hl { color: var(--c); animation: blink 1s infinite }
.sl.gh { opacity: .5; border-style: dashed; color: var(--c) }
.lc.pulse { animation: hl 1s ease-in-out infinite }
.sl.lk { animation: pop .45s }
@keyframes hl { 50% { box-shadow: 0 0 0 5px var(--c), 0 0 18px var(--c); transform: scale(1.18) } }
@keyframes blink { 50% { opacity: .3 } }
@keyframes pop { 0% { transform: scale(.4) } 70% { transform: scale(1.25) } 100% { transform: scale(1) } }
.ce { transition: transform .15s, background .2s }
.ce:hover { background: rgba(255, 255, 255, .14); transform: scale(1.1) }
#ov line { animation: fin .4s }
@keyframes fin { from { opacity: 0 } }
.card { animation: rise .5s }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.96) } }
h1 { animation: rise .8s }

/* ===== Ambiente animado por epoca ===== */
#fx, #glow, #deco { position: fixed; inset: 0; pointer-events: none; z-index: 0 }
#deco { transition: transform .4s ease-out }
.dc { position: absolute; opacity: .13; filter: drop-shadow(0 0 12px var(--c)); animation: fl var(--d) ease-in-out infinite alternate }
@keyframes fl { from { transform: translate(0, 0) rotate(-6deg) } to { transform: translate(var(--dx), -34px) rotate(8deg) } }
#glow.sun { background: radial-gradient(circle at 82% 12%, var(--c) 0, transparent 24%); opacity: .35; animation: gp 6s ease-in-out infinite alternate }
#glow.aurora { background: linear-gradient(115deg, transparent 20%, #3dffb066 40%, #4d8bff66 60%, transparent 80%); background-size: 200% 100%; filter: blur(30px); opacity: .5; animation: au 14s ease-in-out infinite alternate }
#glow.nebula { background: radial-gradient(ellipse at 20% 30%, #7a4dff66, transparent 50%), radial-gradient(ellipse at 80% 70%, var(--c), transparent 55%); opacity: .28; animation: gp 9s ease-in-out infinite alternate }
#glow.neon { background: repeating-linear-gradient(0deg, #0000 0 3px, #0004 3px 4px), linear-gradient(120deg, #ff3cac44, #4de1ff44, #ff3cac44); background-size: 100% 100%, 300% 300%; animation: ne 8s linear infinite }
#glow.fog { background: radial-gradient(ellipse at 30% 80%, #ffffff30, transparent 60%), radial-gradient(ellipse at 80% 60%, #ffffff22, transparent 55%); filter: blur(18px); animation: fg 18s ease-in-out infinite alternate }
#glow.fire { background: radial-gradient(ellipse at 50% 112%, #ff7a1aaa, transparent 55%); animation: fk 2.4s ease-in-out infinite alternate }
#glow.sea { background: linear-gradient(180deg, transparent 55%, #4de1ff44); animation: wv 5s ease-in-out infinite alternate }
@keyframes gp { to { opacity: .55; transform: scale(1.08) } }
@keyframes au { to { background-position: 100% 0 } }
@keyframes ne { to { background-position: 0 0, 300% 0 } }
@keyframes fg { to { transform: translateX(40px) scale(1.1) } }
@keyframes fk { from { opacity: .45 } to { opacity: .95 } }
@keyframes wv { to { transform: translateY(18px) } }

/* ===== Portal temporal entre casos (se dibuja en js/portal.js) ===== */
#portal { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 20; cursor: pointer; touch-action: manipulation }
.tb { display: flex; gap: 6px }
#snd { font-size: 14px; padding: 6px 10px }
@media (prefers-reduced-motion: reduce) { body::before, body::after, .dc { animation: none } }

/* ===== Archivo del Saboteador y mapa de épocas ===== */
#inf, #map { margin: 0 2px }
#ar .card { width: min(100%, 520px) }
.kick { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--c) }
#mpw { position: relative; border: 1px solid var(--c); border-radius: 12px; background: rgba(0, 0, 0, .35); margin: 10px 0 18px; overflow: hidden }
#mps { max-height: 44vh; overflow-y: auto; overscroll-behavior: contain }
#mp { display: block; width: 100%; height: auto }
.fg { position: absolute; inset: 0 0 auto 0; height: 84px; z-index: 2; pointer-events: none; background: linear-gradient(var(--a), #0000); backdrop-filter: blur(2px); -webkit-mask: linear-gradient(#000, #0000); mask: linear-gradient(#000, #0000) }
.nd { cursor: pointer }
.nd circle { fill: rgba(0, 0, 0, .6); stroke-width: 3 }
.nd text { font-size: 22px; text-anchor: middle; dominant-baseline: central; pointer-events: none }
.nd.cur circle { animation: pl 1.4s ease-in-out infinite }
.nd.fog { opacity: .35; cursor: default }
.nd.fog text { fill: var(--i); font: 700 20px Georgia, serif }
@keyframes pl { 50% { stroke-width: 7 } }
.en { border-left: 4px solid var(--k, var(--c)); padding: 6px 12px; margin: 10px 0; background: rgba(0, 0, 0, .25); border-radius: 0 10px 10px 0 }
.en b { font-size: 13px; color: var(--k, var(--c)) }
.en small { display: block; opacity: .7; font-size: 12px }
.en h3 { margin: 2px 0 4px; font-size: 16px }
.en p { margin: 0; font-size: 14px; line-height: 1.5 }
.en.fl { animation: hl 1s ease-in-out 2 }

/* ===== Código de viajero ===== */
.cod { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap }
#cd { font: 700 18px 'Courier New', monospace; letter-spacing: 2px; user-select: all; padding: 6px 10px; border: 1px dashed var(--c); border-radius: 8px; background: rgba(0, 0, 0, .3) }
#ci { flex: 1 1 150px; min-width: 0; font: 700 16px 'Courier New', monospace; letter-spacing: 2px; text-transform: uppercase; color: inherit; background: rgba(0, 0, 0, .3); border: 1px solid var(--c); border-radius: 10px; padding: 8px 10px }
#cm { min-height: 20px }
