/* Looks (2026-11-15, owner: "redo any visuals, especially the landing
   screen"). Three looks, each a set of tokens under :root[data-look=...]
   plus a few touches; every screen reads the same tokens (styles.css,
   battle.css). The title screen's art is per look (src/ui/title.js).
   Picked in Settings, or ?look=room|terminal|dungeon to try one. */

/* ============================================================ tokens */

:root[data-look='room'] {
  --bg: #070c18;
  --bg-2: #0c1630;
  --panel: rgba(15, 26, 50, 0.78);
  --panel-solid: #101c36;
  --panel-2: #172849;
  --line: rgba(120, 170, 255, 0.17);
  --line-2: rgba(120, 170, 255, 0.34);
  --ink: #e7efff;
  --muted: #8ea3c4;
  --accent: #4fd1ff;
  --accent-2: #ffb547;
  --accent-ink: #03121d;
  --good: #4ade80;
  --bad: #ff5d6c;
  --crit: #ffd166;
  --enemy: #ff5d6c;
  --rare: #60a5fa;
  --epic: #c084fc;
  --hp: #4ade80;
  --cpu: #67e8f9;
  --code-bg: #050a15;
  --code-kw: #c084fc;
  --code-fn: #7cc4ff;
  --code-num: #ffd166;
  --code-com: #5f7396;
  --dock: #0a1224;
  --sheet: rgba(9, 16, 32, 0.97);
  --bbar: rgba(5, 10, 22, 0.62);
  --chip: #0b2440;
  --ico-cut: #050a15;
  --glow: rgba(79, 209, 255, 0.32);
  --radius: 14px;
  --font-ui: var(--sans);
  --font-display: var(--sans);
}

:root[data-look='terminal'] {
  --bg: #020602;
  --bg-2: #061206;
  --panel: rgba(57, 255, 106, 0.035);
  --panel-solid: #061006;
  --panel-2: rgba(57, 255, 106, 0.08);
  --line: rgba(57, 255, 106, 0.3);
  --line-2: rgba(57, 255, 106, 0.55);
  --ink: #b9f8c6;
  --muted: #5f9d6c;
  --accent: #39ff6a;
  --accent-2: #ffd75f;
  --accent-ink: #021005;
  --good: #39ff6a;
  --bad: #ff5f56;
  --crit: #ffd75f;
  --enemy: #ff5f56;
  --rare: #5fd7ff;
  --epic: #d78bff;
  --hp: #39ff6a;
  --cpu: #5fd7ff;
  --code-bg: #010401;
  --code-kw: #d78bff;
  --code-fn: #5fd7ff;
  --code-num: #ffd75f;
  --code-com: #3f7a4c;
  --dock: #010401;
  --sheet: rgba(2, 8, 3, 0.97);
  --bbar: rgba(1, 5, 2, 0.75);
  --chip: #031203;
  --ico-cut: #010401;
  --glow: rgba(57, 255, 106, 0.35);
  --radius: 2px;
  --font-ui: var(--mono);
  --font-display: var(--mono);
}

:root[data-look='dungeon'] {
  --bg: #120c10;
  --bg-2: #1c1317;
  --panel: #1f161a;
  --panel-solid: #1f161a;
  --panel-2: #2c2025;
  --line: #4b3530;
  --line-2: #7a5640;
  --ink: #f4e7d1;
  --muted: #b39d86;
  --accent: #ffb84d;
  --accent-2: #e0573f;
  --accent-ink: #2a1300;
  --good: #8fd14f;
  --bad: #e65a43;
  --crit: #ffd34d;
  --enemy: #e65a43;
  --rare: #6aa8ff;
  --epic: #c58cff;
  --hp: #8fd14f;
  --cpu: #6fd3e8;
  --code-bg: #0d080a;
  --code-kw: #e09cff;
  --code-fn: #8cc4ff;
  --code-num: #ffd34d;
  --code-com: #7a6656;
  --dock: #160f12;
  --sheet: rgba(22, 15, 18, 0.98);
  --bbar: rgba(14, 9, 11, 0.7);
  --chip: #2a1c12;
  --ico-cut: #0d080a;
  --glow: rgba(255, 170, 60, 0.32);
  --radius: 4px;
  --font-ui: var(--sans);
  --font-display: var(--mono);
}

/* ============================================================ the page */

body { font-family: var(--font-ui, var(--sans)); }
h1, h2, h3 { font-family: var(--font-display, var(--sans)); }

:root[data-look='room'] body {
  background:
    radial-gradient(ellipse 80% 45% at 50% -8%, rgba(79, 209, 255, 0.16), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 181, 71, 0.06), transparent 70%),
    linear-gradient(rgba(120, 170, 255, 0.04) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(var(--bg-2), var(--bg) 60%);
  background-attachment: fixed;
}
:root[data-look='terminal'] body { background: radial-gradient(ellipse at 50% 40%, #061306, var(--bg) 75%); background-attachment: fixed; }
:root[data-look='dungeon'] body {
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(255, 150, 50, 0.14), transparent 70%),
    linear-gradient(rgba(0, 0, 0, 0.32) 2px, transparent 2px) 0 0 / 56px 28px,
    linear-gradient(90deg, rgba(0, 0, 0, 0.28) 2px, transparent 2px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(0, 0, 0, 0.28) 2px, transparent 2px) 28px 28px / 56px 56px,
    var(--bg);
  background-attachment: fixed;
}

/* Terminal: scanlines and a vignette over everything, and a phosphor glow on what matters. */
:root[data-look='terminal'] body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.55));
}
:root[data-look='terminal'] :is(h1, h2, .primary, .accent, .t-name, .door-title, .reward-name, .s-name) { text-shadow: 0 0 6px rgba(57, 255, 106, 0.55); }
:root[data-look='terminal'] :is(h1, h2) { text-transform: lowercase; letter-spacing: 0.02em; }
:root[data-look='terminal'] h2:not(.s-name, .card h2)::before { content: '## '; color: var(--muted); }

/* Dungeon: headings in small caps of type, stone panels with a pixel bevel. */
:root[data-look='dungeon'] :is(h1, h2) { text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
:root[data-look='dungeon'] h2 { font-size: 15px; }

/* Scenes behind the map and rewards: the floor's colour over the look's own background. */
:root body[data-scene='inbox'] { background: radial-gradient(ellipse at 50% -10%, rgba(140, 150, 255, 0.22), transparent 60%), linear-gradient(#171833, var(--bg) 70%); background-attachment: fixed; }
:root body[data-scene='network'] { background: radial-gradient(ellipse at 50% -10%, rgba(90, 220, 160, 0.2), transparent 60%), linear-gradient(#0e2620, var(--bg) 70%); background-attachment: fixed; }
:root body[data-scene='datacenter'] { background: radial-gradient(ellipse at 50% -10%, rgba(239, 80, 70, 0.16), transparent 60%), linear-gradient(#111b26, var(--bg) 70%); background-attachment: fixed; }

/* ============================================================ shared parts */

/* Panels */
:is(.card, .hud, .door, .reward, .place, .fmap-wrap, .s-hero, .s-kit, .stats div, .history li, .achievements li, .fn, .t-continue, .t-tile, .look-card) {
  background: var(--panel);
  border-color: var(--line);
  border-radius: var(--radius);
}
:root[data-look='room'] :is(.card, .hud, .door, .reward, .place, .fmap-wrap, .s-hero, .s-kit, .t-continue, .t-tile, .look-card) {
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.28);
}
:root[data-look='dungeon'] :is(.card, .hud, .door, .reward, .place, .fmap-wrap, .s-hero, .s-kit, .t-continue, .t-tile, .look-card, .mode, .tile, .tool, .chip-add) {
  border-width: 2px;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 220, 170, 0.06), 0 3px 0 rgba(0, 0, 0, 0.55);
}

/* Buttons */
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.primary .ico { width: 18px; height: 18px; }
.ghost {
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2, var(--line));
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}
.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.mode.on { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }

:root[data-look='room'] .primary { background: linear-gradient(180deg, #7fe0ff, #33b9ef); box-shadow: 0 6px 20px rgba(79, 209, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
:root[data-look='room'] .end { background: linear-gradient(180deg, #7fe0ff, #33b9ef); }
:root[data-look='terminal'] :is(.primary, .end) { border-radius: 2px; box-shadow: 0 0 14px rgba(57, 255, 106, 0.35); text-transform: lowercase; }
:root[data-look='terminal'] :is(.ghost, .mode, .tool, .chip-add, .tile, .t-tile) { border-radius: 2px; }
:root[data-look='dungeon'] :is(.primary, .end) {
  border-radius: 4px;
  border: 2px solid #5a2d0c;
  background: linear-gradient(#ffd98a, #ffb84d 48%, #e8901f 52%, #d47a12);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(90, 45, 12, 0.35), 0 3px 0 #3a1c06;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  font-weight: 800;
}
:root[data-look='dungeon'] :is(.primary, .end):active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 1px 0 #3a1c06; }
:root[data-look='dungeon'] .ghost { border-width: 2px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; font: 700 13px var(--mono); }

/* Screen headers: a back button as a pill, the title beside it, pinned on scroll. */
header.back {
  position: sticky;
  top: 0;
  z-index: 6;
  margin: -12px -16px 12px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.back .link {
  min-height: 34px;
  padding: 4px 12px 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
:root[data-look='terminal'] header.back .link { border-radius: 2px; }
header.back h1 { font-size: 19px; }

/* ============================================================ the title screen */

.title { min-height: calc(100dvh - 44px); display: flex; flex-direction: column; text-align: center; padding-top: 0; }
.t-hero { position: relative; height: clamp(200px, 36dvh, 300px); margin: -12px -16px 4px; overflow: hidden; }
.t-brand { margin: 8px 0 14px; }
.t-name { margin: 0; line-height: 1; }
.t-sub { color: var(--muted); font-size: 14px; margin: 8px auto 0; max-width: 300px; }
.t-actions { display: grid; gap: 8px; }
.t-actions .wide { margin: 0; }
.t-start { font-size: 17px; min-height: 54px; }
.t-confirm { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--crit); background: var(--panel); text-align: left; }
.t-confirm .row2 { display: flex; gap: 8px; margin-top: 10px; }
.t-confirm .row2 button { flex: 1; }

.t-continue {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px 10px 8px;
  border: 1px solid var(--accent);
  text-align: left;
  color: var(--ink);
}
.t-continue:hover { box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--glow); }
.tc-art { flex: none; width: 58px; height: 58px; }
.tc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tc-label { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; color: var(--accent); }
.tc-label .ico { width: 14px; height: 14px; }
.tc-where { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-stats { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.tc-stats .ico-hp { color: var(--bad); width: 13px; height: 13px; }
.tc-stats .bar { height: 6px; min-width: 40px; }
.tc-stats .bar.good .fill { background: var(--hp); }
.tc-cash { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; color: var(--crit); font: 700 12px var(--mono); }
.tc-cash .ico { width: 13px; height: 13px; }

.t-menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.t-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 70px;
  padding: 10px 4px;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
}
.t-tile:hover { border-color: var(--accent); }
.t-tile > .ico { width: 22px; height: 22px; color: var(--accent); }
.t-cmd { display: none; }
.t-count { position: absolute; top: 5px; right: 6px; font: 700 10px var(--mono); color: var(--crit); }
.t-note { margin-top: -3px; font-size: 10px; color: var(--muted); }
.t-terminal .t-note { margin: 0 0 0 auto; font-size: 12px; }
.t-foot { margin: auto 0 0; padding-top: 18px; font-size: 11px; color: var(--muted); }

/* ---------- Incident Room: the live threat map */
.tm {
  background: radial-gradient(ellipse 90% 70% at 42% 55%, rgba(30, 80, 150, 0.35), transparent 70%), linear-gradient(#081126, #070c18);
  border-bottom: 1px solid var(--line);
}
.tm::after { content: ''; position: absolute; inset: auto 0 0; height: 40%; background: linear-gradient(transparent, var(--bg)); pointer-events: none; z-index: 1; }
.tm-map { position: absolute; left: 0; right: 0; top: 30px; width: 100%; height: calc(100% - 52px); }
.tm-grid line { stroke: rgba(120, 170, 255, 0.07); stroke-width: 0.5; }
.tm-edge { stroke: rgba(120, 170, 255, 0.32); stroke-width: 1.1; animation: tmEdge 13s ease-in-out infinite; animation-delay: var(--d); }
.tm-host { fill: #0f2b52; stroke: #4fd1ff; stroke-width: 1.2; animation: tmHost 13s ease-in-out infinite; animation-delay: var(--d); }
.tm-halo { fill: none; stroke: #ff5d6c; stroke-width: 1; opacity: 0; transform-box: fill-box; transform-origin: center; animation: tmHalo 13s ease-out infinite; animation-delay: var(--d); }
.tm-node.zero .tm-host { stroke-width: 1.6; }
.tm-label { font: 600 7px var(--mono); fill: #7f95b8; letter-spacing: 0.04em; }
.tm-pkt { fill: #8ae8ff; }
@keyframes tmEdge { 0%, 7% { stroke: rgba(120, 170, 255, 0.32); } 11%, 64% { stroke: rgba(255, 93, 108, 0.75); } 74%, 100% { stroke: rgba(120, 170, 255, 0.32); } }
@keyframes tmHost { 0%, 7% { fill: #0f2b52; stroke: #4fd1ff; } 11%, 64% { fill: #4d1220; stroke: #ff5d6c; } 74%, 100% { fill: #0f2b52; stroke: #4fd1ff; } }
@keyframes tmHalo { 0%, 8% { opacity: 0; transform: scale(0.5); } 11% { opacity: 1; transform: scale(1); } 22% { opacity: 0; transform: scale(2.4); } 100% { opacity: 0; } }
.tm-chip { position: absolute; z-index: 2; top: 9px; display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; background: rgba(5, 10, 22, 0.75); border: 1px solid var(--line); font: 700 10px var(--mono); letter-spacing: 0.1em; }
.tm-chip.live { left: 12px; color: #ff8b95; }
.tm-chip.live i { width: 7px; height: 7px; border-radius: 50%; background: #ff5d6c; box-shadow: 0 0 6px #ff5d6c; animation: blink 1.2s steps(2) infinite; }
.tm-chip.threat { right: 12px; color: var(--accent-2); border-color: rgba(255, 181, 71, 0.45); }
.tm-chip .ico { width: 12px; height: 12px; }
.tm-sweep {
  position: absolute;
  z-index: 0;
  left: 41%;
  top: 52%;
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(79, 209, 255, 0.09), transparent 18%);
  animation: spin 7s linear infinite;
  pointer-events: none;
}
.tm-hero { position: absolute; z-index: 2; right: 8px; bottom: 22px; width: 96px; height: 96px; filter: drop-shadow(0 0 14px rgba(79, 209, 255, 0.4)); }
.tm-ticker { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; height: 20px; overflow: hidden; border-top: 1px solid var(--line); background: rgba(5, 10, 22, 0.85); font: 600 10px/20px var(--mono); color: var(--accent-2); white-space: nowrap; text-align: left; }
.tm-ticker span { display: inline-block; padding-left: 100%; animation: ticker 40s linear infinite; }
@keyframes ticker { to { transform: translateX(-100%); } }

.t-room .t-kicker { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px; font: 700 11px var(--mono); letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent); }
.t-room .t-kicker .ico { width: 13px; height: 13px; }
.t-room .t-name {
  font-size: clamp(38px, 11vw, 48px);
  font-weight: 900;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ffffff 10%, #a9e6ff 55%, #4fd1ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(79, 209, 255, 0.35));
}

/* ---------- Terminal: the boot screen */
.tt { height: auto; min-height: 168px; padding: 18px 16px 4px; text-align: left; }
.tt-log { margin: 0; font: 12px/1.65 var(--mono); color: var(--ink); white-space: pre; overflow: hidden; }
.tt-line { display: flex; justify-content: space-between; gap: 10px; }
.tt-line b { font-weight: 700; }
.tt-line b.ok { color: var(--accent); }
.tt-line b.alert { color: var(--bad); text-shadow: 0 0 6px rgba(255, 95, 86, 0.6); }
.tt-prompt { justify-content: flex-start; color: var(--accent); margin-top: 6px; text-shadow: 0 0 6px rgba(57, 255, 106, 0.6); }
.tt-cursor { display: inline-block; width: 0.6em; height: 1.05em; margin-left: 4px; vertical-align: -2px; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1s steps(2) infinite; }
.tt.boot .tt-line { opacity: 0; animation: ttLine 0.01s linear forwards; animation-delay: calc(var(--i) * 0.32s + 0.15s); }
.tt.boot .tt-line > span { display: inline-block; clip-path: inset(0 100% 0 0); animation: ttType 0.28s steps(16) forwards; animation-delay: calc(var(--i) * 0.32s + 0.15s); }
.tt.boot ~ :is(.t-brand, .t-actions, .t-menu, .t-foot) { opacity: 0; animation: ttShow 0.35s ease-out forwards; animation-delay: 2.3s; }
@keyframes ttLine { to { opacity: 1; } }
@keyframes ttType { to { clip-path: inset(0 0 0 0); } }
@keyframes ttShow { to { opacity: 1; } }
.t-terminal .t-name.pixel svg { display: block; width: 100%; max-width: 330px; height: auto; margin: 0 auto; color: var(--accent); filter: drop-shadow(0 0 4px rgba(57, 255, 106, 0.9)) drop-shadow(0 0 18px rgba(57, 255, 106, 0.35)); }
.t-terminal .t-sub::before { content: '# '; color: var(--muted); }
.t-terminal .t-sub { color: var(--muted); }
.t-terminal .t-continue { border-style: dashed; }
.t-terminal .tc-label::before { content: '> '; }
.t-terminal .tc-label .ico { display: none; }
.t-terminal .t-menu { grid-template-columns: 1fr; gap: 0; margin-top: 10px; text-align: left; }
.t-terminal .t-tile { flex-direction: row; justify-content: flex-start; min-height: 40px; padding: 6px 4px; border: 0; border-bottom: 1px dashed var(--line); background: none; font-size: 14px; }
.t-terminal .t-tile > .ico, .t-terminal .t-label { display: none; }
.t-terminal .t-cmd { display: inline; color: var(--ink); }
.t-terminal .t-cmd::before { content: '> '; color: var(--accent); }
.t-terminal .t-tile:hover .t-cmd { color: var(--accent); text-shadow: 0 0 6px rgba(57, 255, 106, 0.6); }
.t-terminal .t-count { position: static; margin-left: auto; }
.t-terminal .t-foot::before { content: '-- '; }

/* ---------- Dungeon: the gate */
.dg { background: #0d080b; border-bottom: 2px solid #3a2620; }
.dg-wall {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 45% 55% at 50% 58%, rgba(255, 140, 40, 0.22), transparent 70%),
    linear-gradient(#2a1d21 0 0) padding-box;
  background-color: #241a1e;
}
.dg-wall::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#140d10 3px, transparent 3px) 0 0 / 40px 22px,
    linear-gradient(90deg, #140d10 3px, transparent 3px) 0 0 / 40px 44px,
    linear-gradient(90deg, #140d10 3px, transparent 3px) 20px 22px / 40px 44px;
  opacity: 0.9;
}
.dg-wall::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(5, 2, 4, 0.75)); }
.dg-arch {
  position: absolute;
  left: 50%;
  bottom: 16%;
  width: 156px;
  height: 154px;
  transform: translateX(-50%);
  border-radius: 78px 78px 0 0;
  background: repeating-conic-gradient(from -90deg at 50% 100%, #5a4448 0 9deg, #4a3639 9deg 10deg);
  padding: 12px 12px 0;
  box-shadow: 0 0 0 3px #140d10, inset 0 0 0 3px #140d10;
}
.dg-door {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 66px 66px 0 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, #3a0f12, #0a0507 70%);
  box-shadow: inset 0 0 18px #000;
}
.dg-leds { position: absolute; left: 14%; right: 14%; top: 18%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px 0; }
.dg-leds i { justify-self: center; width: 3px; height: 3px; border-radius: 1px; background: #2a8cff; box-shadow: 0 0 4px #2a8cff; opacity: 0.25; animation: dgLed 2.2s steps(2) infinite; animation-delay: calc(var(--n) * -0.37s); }
.dg-leds i:nth-child(5n) { background: #ff4a3d; box-shadow: 0 0 4px #ff4a3d; }
.dg-leds i:nth-child(7n) { background: #4dff7a; box-shadow: 0 0 4px #4dff7a; }
@keyframes dgLed { 50% { opacity: 1; } }
.dg-foe { position: absolute; width: 46px; height: 46px; filter: brightness(0.55) saturate(0.7) drop-shadow(0 0 6px rgba(255, 60, 40, 0.5)); }
.dg-foe.f1 { left: 4%; bottom: 2%; }
.dg-foe.f2 { right: 2%; bottom: 8%; transform: scaleX(-1); }
.dg-foe.f3 { left: 38%; bottom: 26%; width: 34px; height: 34px; filter: brightness(0.35) drop-shadow(0 0 6px rgba(255, 60, 40, 0.5)); }
.dg-torch { position: absolute; top: 30%; width: 8px; height: 30px; background: linear-gradient(#6b4a2f, #3a2617); border: 2px solid #140d10; border-radius: 2px; }
.dg-torch.l { left: calc(50% - 116px); }
.dg-torch.r { right: calc(50% - 116px); }
.dg-torch::after { content: ''; position: absolute; left: 50%; top: -6px; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 160, 60, 0.28), transparent 65%); animation: dgGlow 2.6s ease-in-out infinite; pointer-events: none; }
.dg-torch i { position: absolute; left: 50%; top: -20px; width: 16px; height: 22px; margin-left: -8px; border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%; background: radial-gradient(ellipse at 50% 75%, #fff4c2 0 18%, #ffcf4d 30%, #ff8a1f 55%, rgba(255, 70, 20, 0) 72%); transform-origin: 50% 90%; animation: dgFlame 0.9s ease-in-out infinite alternate; }
.dg-torch.r i { animation-delay: -0.45s; }
@keyframes dgFlame { 0% { transform: scale(1, 1) rotate(-3deg); } 50% { transform: scale(0.92, 1.12) rotate(2deg); } 100% { transform: scale(1.06, 0.94) rotate(-1deg); } }
@keyframes dgGlow { 50% { opacity: 0.75; transform: scale(0.95); } }
.dg-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 17%; background: linear-gradient(#2e2226, #150e11); border-top: 3px solid #140d10; }
.dg-floor::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, 0.45) 2px, transparent 2px) 0 0 / 34px 100%; }
.dg-hero { position: absolute; z-index: 2; left: 50%; bottom: 7%; width: 92px; height: 92px; transform: translateX(-50%); filter: drop-shadow(0 0 10px rgba(255, 160, 60, 0.35)); }
.t-dungeon .t-name.pixel svg { display: block; width: 100%; max-width: 320px; height: auto; margin: 0 auto; color: #ffcf6b; filter: drop-shadow(0 2px 0 #b8640f) drop-shadow(0 2px 0 #5a2d0c) drop-shadow(0 0 16px rgba(255, 170, 60, 0.4)); }
.t-dungeon .t-sub { color: var(--muted); font-style: italic; }
.t-dungeon .t-tile { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: 0.04em; }
.t-dungeon .t-continue { border: 2px solid var(--accent); }

/* ============================================================ setup: pick your class */

.s-roster { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0 0 10px; }
.s-pick { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 6px 2px 6px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.s-pick.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 0 18px var(--glow); }
.s-pick.locked { opacity: 0.5; filter: grayscale(1); }
.s-pick-art { position: relative; width: 46px; height: 46px; }
.s-pick-name { font-size: 10px; line-height: 1.15; text-align: center; color: var(--muted); }
.s-pick.on .s-pick-name { color: var(--ink); font-weight: 700; }
.s-hero { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); }
.s-portrait { position: relative; flex: none; width: 104px; height: 104px; }
.s-portrait .sprite { position: relative; z-index: 1; }
.s-glow { position: absolute; inset: 12% 2% -6%; border-radius: 50%; background: radial-gradient(circle, var(--glow), transparent 70%); }
.s-info { flex: 1; min-width: 0; }
.s-name { margin: 0 0 3px; font-size: 21px; }
.s-blurb { margin: 0 0 8px; font-size: 13px; line-height: 1.35; color: var(--muted); }
.s-stats { display: grid; gap: 4px; }
.s-stat { display: grid; grid-template-columns: 58px 1fr 32px; align-items: center; gap: 6px; font-size: 11px; }
.s-stat-l { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.s-stat-l .ico { width: 12px; height: 12px; }
.s-stat .bar { height: 6px; min-width: 0; }
.s-stat .bar .fill { background: var(--accent); }
.s-stat-v { font: 700 11px var(--mono); text-align: right; }
.s-kit { margin: 10px 0 2px; padding: 10px 12px; border: 1px solid var(--line); }
.s-kit-head { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.s-kit-head .ico { color: var(--accent); }
.s-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.s-chip { padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); font: 600 11px var(--mono); color: var(--code-fn); }
.s-chip.ev { color: var(--crit); }
.code.s-code { margin: 0; font-size: 12px; }
.setup .foot.sticky { margin-top: 8px; }
.setup .foot.sticky .wide { margin: 0; }

/* ============================================================ settings: looks */

.look-list { display: grid; gap: 8px; }
.look-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); color: var(--ink); text-align: left; }
.look-card.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.look-swatch { flex: none; display: grid; grid-template-columns: repeat(2, 16px); gap: 3px; padding: 4px; border-radius: 8px; background: rgba(0, 0, 0, 0.35); }
.look-swatch i { width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.look-body { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.look-body strong { font-size: 15px; }

/* ============================================================ the fight, in each look */

:root[data-look='terminal'] .battle .field::before { content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; background: rgba(57, 255, 106, 0.04); mix-blend-mode: screen; }
:root[data-look='dungeon'] .tile { border-width: 2px; }
.mainchip .mc-cpu { flex: none; display: inline-flex; align-items: center; gap: 2px; padding: 1px 5px; border-radius: 6px; background: var(--chip); color: var(--cpu); font: 700 11px var(--mono); }
.mainchip .mc-cpu .ico { width: 12px; height: 12px; }

@media (prefers-reduced-motion: reduce) {
  .tm-edge, .tm-host, .tm-halo, .tm-sweep, .tm-ticker span, .tt-cursor, .dg-leds i, .dg-torch i, .dg-torch::after, .tm-chip.live i { animation: none !important; }
  .tt.boot .tt-line, .tt.boot .tt-line > span, .tt.boot ~ * { animation: none !important; opacity: 1 !important; clip-path: none !important; }
}

/* HP bars are green in every look (the accent is for actions). */
.bar.good .fill, .hp .bar .fill { background: var(--hp); }
.hp .bar.low .fill { background: var(--bad); }

/* Taller phones: bigger characters and the enemies a little lower, so the field isn't half empty. */
.foes { top: clamp(10px, 5dvh, 56px); }
.foes.n1 .foe .sprite-wrap, .foes.n2 .foe .sprite-wrap { width: clamp(104px, 17dvh, 150px); height: clamp(104px, 17dvh, 150px); }
.foes.n3 .foe .sprite-wrap { width: clamp(90px, 14dvh, 120px); height: clamp(90px, 14dvh, 120px); }
.foes.n1 .foe { max-width: 220px; }
.foes.n2 .foe { max-width: 170px; flex-basis: 42%; }
.hero .sprite-wrap { width: clamp(108px, 16dvh, 140px); height: clamp(108px, 16dvh, 140px); }

/* Each look tints the floors' scenes to match (the characters keep their colours). */
:root[data-look='terminal'] .scene-back { filter: grayscale(1) sepia(1) hue-rotate(68deg) saturate(2.4) brightness(0.5); }
:root[data-look='terminal'] .scene-datacenter .field::after { filter: hue-rotate(110deg); }
:root[data-look='dungeon'] .scene-back { filter: sepia(0.55) hue-rotate(-18deg) saturate(1.2) brightness(0.8); }
:root[data-look='dungeon'] .scene-back::after { border-top: 3px solid #140d10; background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.35) 2px, transparent 2px), linear-gradient(#2c2025, #150e11); background-size: 40px 100%, auto; }

/* ============================================================ results */
.res-head { text-align: center; padding: 8px 0 4px; }
.res-art { position: relative; width: 120px; height: 120px; margin: 0 auto 4px; }
.res-art .sprite { position: relative; z-index: 1; }
.res-glow { position: absolute; inset: 10% 0 -8%; border-radius: 50%; background: radial-gradient(circle, var(--glow), transparent 70%); }
.res-lost .res-glow, .res-quit .res-glow { background: radial-gradient(circle, color-mix(in srgb, var(--bad) 35%, transparent), transparent 70%); }
.sprite.down { transform: rotate(-14deg) translateY(8px); opacity: 1; filter: grayscale(0.85) brightness(0.7); }
.results h1 { font-size: 34px; margin: 2px 0 8px; }
.res-won h1 { color: var(--good); text-shadow: 0 0 18px color-mix(in srgb, var(--good) 45%, transparent); }
.res-lost h1 { color: var(--bad); text-shadow: 0 0 18px color-mix(in srgb, var(--bad) 40%, transparent); }
.stats dd { color: var(--ink); }
.code-did li { padding: 8px 10px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.code-did .bar .fill { background: var(--accent); }

/* Pinned footers: the main button takes the room, a link sits beside it. */
.foot.sticky { display: flex; align-items: center; gap: 8px; }
.foot.sticky .primary { flex: 1; margin: 0; }
.foot.sticky .link.center { flex: none; margin: 0; }

/* Rewards: a stripe in the rarity's colour down the left. */
.reward { position: relative; }
.reward::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2, var(--line)); }
.reward.r-rare::before { background: var(--rare); }
.reward.r-epic::before { background: var(--epic); box-shadow: 0 0 10px var(--epic); }
.pick-door { font-size: 20px; }

/* The loading line, before the app starts. */
.boot { font: 13px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.boot::after { content: '_'; animation: blink 1s steps(2) infinite; }
/* Corners follow the look everywhere (Terminal is square, Dungeon nearly so). */
:is(.code, .editor-code, .mode, .tool, .chip-add, .tile, .status, .shop-services button, .inc-result) { border-radius: min(var(--radius), 12px); }

/* Short phones (667px and so on): the title still fits without scrolling. */
@media (max-height: 720px) {
  .t-hero { height: 176px; }
  .t-brand { margin: 4px 0 10px; }
  .t-room .t-name { font-size: 36px; }
  .t-room .t-kicker { margin-bottom: 2px; }
  .t-sub { font-size: 13px; margin-top: 6px; }
  .t-continue { padding-top: 6px; padding-bottom: 6px; }
  .tc-art { width: 48px; height: 48px; }
  .t-menu { margin-top: 8px; gap: 6px; }
  .t-tile { min-height: 58px; padding: 7px 4px; }
  .t-foot { padding-top: 10px; }
  .tt { min-height: 0; padding-top: 12px; }
  .tt-log { font-size: 11px; line-height: 1.5; }
  .t-terminal .t-tile { min-height: 34px; }
  .t-terminal .t-name.pixel svg, .t-dungeon .t-name.pixel svg { max-width: 290px; }
  .dg-arch { width: 128px; height: 126px; padding: 10px 10px 0; }
  .dg-hero { width: 78px; height: 78px; }
  .dg-torch.l { left: calc(50% - 100px); }
  .dg-torch.r { right: calc(50% - 100px); }
  .tm-hero { width: 80px; height: 80px; }
}
