/* Spot the Hazard UI styles. Design tokens in three layers (TECHNICAL_ROADMAP.md T13):
   1. primitives: raw palette and scales, never used directly by components
   2. semantic: what a colour means (surface, ink, success, danger...)
   3. component: per-component decisions built on the semantic layer */
:root {
  color-scheme: light;
  /* 1. primitives (NEW_ART_DIRECTION.md §2) */
  --navy-950: #0d1726; --navy-900: #13213a; --navy-800: #1c2f4f; --navy-700: #284068; --navy-300: #a9b8cf;
  --blue-600: #1f5fae; --blue-500: #2f74c8; --blue-100: #e3edf9;
  --steel-0: #ffffff; --steel-50: #f4f6f9; --steel-100: #e9edf2; --steel-150: #dfe4eb; --steel-200: #d6dce5; --steel-400: #9aa5b4; --steel-600: #5b6778; --steel-900: #1b2433;
  --yellow-400: #f2c12e; --yellow-500: #d9a816; --yellow-800: #7a5800; --yellow-50: #fdf3d4; --yellow-25: #fff8e6;
  --green-600: #25844f; --green-800: #1d6b40; --green-50: #e5f4ec;
  --red-600: #c4372f; --red-800: #a32820; --red-50: #fbe8e6;
  --amber-600: #b9770e;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius-xs: 2px; --radius-s: 4px; --radius-m: 6px; --radius-pill: 999px;
  --text-xs: 11px; --text-s: 13px; --text-m: 15px; --text-l: 18px; --text-xl: 24px;
  /* 2. semantic */
  --surface-shell: var(--navy-950); --surface-rail: var(--navy-900); --surface-work: var(--steel-50); --surface-panel: var(--steel-100); --surface-raised: var(--steel-0);
  --bg: var(--surface-work); --panel: var(--surface-raised); --ink: var(--steel-900); --muted: var(--steel-600); --line: var(--steel-200);
  --text-inverse: #ffffff; --text-inverse-muted: var(--navy-300);
  --accent: var(--blue-600); --accent-hover: var(--blue-500); --accent-soft: var(--blue-100);
  --ok: var(--green-600); --ok-ink: var(--green-800); --ok-soft: var(--green-50);
  --bad: var(--red-600); --bad-ink: var(--red-800); --bad-soft: var(--red-50);
  --warn: var(--yellow-400); --warn-ink: var(--yellow-800); --warn-soft: var(--yellow-50);
  --cta: var(--yellow-400); --cta-hover: var(--yellow-500); --cta-ink: var(--navy-950);
  --scene-bg: var(--steel-100);
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 8px 24px rgba(13,23,38,.18); --shadow-s: 0 1px 2px rgba(13,23,38,.08);
  --scrim: rgba(13,23,38,.6);
  --focus: var(--blue-500);
  /* 3. component */
  --hud: rgba(13,23,38,.92); --hud-ink: #ffffff; --hud-label: var(--navy-300);
  --radius: var(--radius-m);
  --btn-radius: var(--radius-s);
  --chip-bg: var(--steel-100); --chip-hover: var(--steel-150);
  --rail-w: 216px;
  --toolbar-bg: var(--navy-900); --toolbar-line: var(--navy-700);
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: var(--text-m)/1.4 var(--font-body); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: block; }

/* Home */
/* App shell (NEW_ART_DIRECTION.md §8) */
.shell.on { display: flex; }
.rail { width: var(--rail-w); flex: none; background: var(--surface-rail); color: var(--text-inverse); display: flex; flex-direction: column; gap: 2px; padding: max(16px, env(safe-area-inset-top)) 10px 16px max(10px, env(safe-area-inset-left)); border-right: 1px solid var(--toolbar-line); }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font: 700 21px/1.05 var(--font-display); letter-spacing: .2px; }
.rail-brand { justify-content: center; }
.rail-brand img { display: block; height: auto; }
.brand-logo { width: 100%; max-width: 188px; filter: drop-shadow(0 2px 6px rgb(0 0 0 / .35)); }
.rail-brand .brand-icon { display: none; width: 44px; }
.rail-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--radius-s); color: var(--text-inverse-muted); font-weight: 600; font-size: 14px; text-align: left; position: relative; transition: background .15s, color .15s; }
.rail-item .ic { width: 20px; height: 20px; flex: none; }
.rail-item:hover { background: var(--navy-800); color: #fff; }
.rail-item.on { background: var(--navy-800); color: #fff; }
.rail-item.on::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; background: var(--cta); }
.rail-spacer { flex: 1; }
.rail :focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--focus); }
.shell-main { flex: 1; min-width: 0; overflow-y: auto; background: var(--surface-work); padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 32px 24px; }
.home-wrap { max-width: 1180px; margin: 0 auto; }
.page-head { margin-bottom: 16px; }
.page-head .eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.page-head h1 { margin: 0 0 6px; font: 700 38px/1.05 var(--font-display); color: var(--ink); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-raised); overflow: hidden; margin-bottom: 16px; }
.seg button { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); border-right: 1px solid var(--line); transition: background .15s, color .15s; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--steel-50); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.seg button i { width: 8px; height: 8px; background: var(--fam); display: inline-block; }
#fam-filter { display: flex; flex-wrap: nowrap; max-width: 100%; width: max-content; overflow-x: auto; scrollbar-width: none; }
#fam-filter::-webkit-scrollbar { display: none; }
#fam-filter button { flex: none; white-space: nowrap; }
@media (max-width: 900px), (max-height: 500px) { #fam-filter button { padding: 7px 11px; } }
.empty-filter { margin-top: 12px; }
@media (max-width: 1100px), (max-height: 500px) {
  :root { --rail-w: 64px; }
  .rail-brand .brand-logo { display: none; } .rail-brand .brand-icon { display: block; }
  .rail-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rail-brand { padding: 0 4px 14px; justify-content: center; } .rail-item { justify-content: center; padding: 12px 0; }
}
@media (max-height: 500px) { .shell-main { padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px 16px; } .page-head h1 { font-size: 28px; } .page-head .lead { margin-bottom: 8px; } .how { display: none; } }
h2, h3, .pill span, .stat .v { font-family: var(--font-display); }
.pill span { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.pill.streak { background: var(--cta); color: var(--cta-ink); }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 640px; }
.how { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.how span { background: var(--surface-raised); border: 1px solid var(--line); border-left: 3px solid var(--cta); border-radius: var(--radius-xs); padding: 5px 10px; font-size: 13px; color: var(--muted); }
.how b { color: var(--ink); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { --fam: var(--accent); background: var(--surface-raised); border: 1px solid var(--line); border-top: 4px solid var(--fam); border-radius: var(--radius); box-shadow: var(--shadow-s); overflow: hidden; text-align: left; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--accent); border-top-color: var(--fam); box-shadow: 0 6px 18px rgba(13,23,38,.12); }
.card[hidden] { display: none; }
.card .thumb { aspect-ratio: 16/10; background: var(--scene-bg) center/cover no-repeat; border-bottom: 1px solid var(--line); }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.card .area { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card .title { font: 600 21px/1.15 var(--font-display); }
.card .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px 10px; margin-top: 4px; }
.card .meta > span { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.card .best { color: var(--ok-ink); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.card .lsrs { display: flex; gap: 4px; margin-top: 6px; }
.card .lsrs svg { width: 22px; height: 22px; }
.helmets { display: inline-flex; gap: 2px; vertical-align: -2px; }
.helmets i { width: 14px; height: 10px; border-radius: 7px 7px 2px 2px; background: var(--line); display: inline-block; }
.helmets i.on { background: var(--cta); box-shadow: inset 0 -2px 0 var(--yellow-500); }
.view-canvas.aim { cursor: crosshair; }
.medal-reveal { display: flex; align-items: center; gap: 14px; background: var(--surface-raised); border: 1px solid var(--line); border-left: 4px solid var(--cta); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 14px; }
.medal-reveal b { display: block; font: 700 24px/1.1 var(--font-display); }
.medal-reveal small { color: var(--muted); font-size: 13px; }
.medal-reveal .medal-ic { animation: medal-in .6s cubic-bezier(.2,1.5,.4,1) both; flex: none; }
.medal-reveal.none { border: 0; background: transparent; padding-left: 0; }
@keyframes medal-in { 0% { transform: scale(.2) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.rules-sum { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.rs { display: flex; align-items: center; gap: 8px; background: var(--surface-raised); border-radius: var(--radius-s); padding: 4px 12px 4px 4px; font-size: 13px; border: 1px solid var(--line); border-left: 4px solid var(--ok); }
.rs.half { border-left-color: var(--warn); } .rs.bad { border-left-color: var(--bad-ink); }
.rs svg { width: 28px; height: 28px; } .rs b { font-family: var(--font-display); font-size: 16px; }
.section-h small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.item[role="button"] { cursor: pointer; } .item[role="button"]:hover { box-shadow: 0 0 0 2px var(--accent); }
.review { position: absolute; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(760px, calc(100% - 140px)); background: var(--surface-raised); border-radius: var(--radius); border-top: 3px solid var(--accent); box-shadow: var(--shadow); padding: 10px; display: none; gap: 10px; align-items: center; }
.review.on { display: flex; }
.review .iconbtn:disabled { opacity: .35; cursor: default; }
.rv-body { flex: 1; display: flex; gap: 10px; align-items: flex-start; min-width: 0; font-size: 14px; }
.rv-body svg { width: 44px; height: 44px; flex: none; }
.rv-body .n { font-weight: 650; } .rv-body .r { color: var(--accent); font-weight: 600; font-size: 13px; }
.rv-body .note { color: var(--muted); font-size: 13px; } .rv-body .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.rv-body .note b { color: var(--ok-ink); } .rv-body .note.strong { color: var(--ink); font-size: 14px; display: block !important; }
.rv-safe { white-space: nowrap; } .rv-safe[aria-pressed="true"] { background: var(--ok-ink); color: #fff; border-color: var(--ok-ink); }
.rv-body .tag.ok { color: var(--ok-ink); } .rv-body .tag.bad { color: var(--bad-ink); } .rv-body .tag.half { color: var(--warn-ink); }
body:has(.review.on) .finish { display: none; }
@media (max-height: 500px) { .rv-safe span { font-size: 12px; } .review { padding: 6px; } .rv-body svg { width: 32px; height: 32px; } .rv-body .note { display: none; } }

/* Game */
#game { background: var(--scene-bg); }
#stage { position: absolute; inset: 0; }
.view-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; align-items: center; pointer-events: none; }
.hud > * { pointer-events: auto; }
.pill { background: var(--hud); color: #fff; border-radius: var(--radius-s); padding: 8px 14px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.pill small { font-weight: 500; color: var(--hud-label); }
.iconbtn { background: var(--hud); color: #fff; width: 40px; height: 40px; border-radius: var(--radius-s); display: grid; place-items: center; flex: none; transition: background .15s; }
.iconbtn:hover { background: var(--navy-800); }
.iconbtn svg { width: 20px; height: 20px; }
.spacer { flex: 1; }
.hud .title { color: #fff; font: 600 18px/1.2 var(--font-display); letter-spacing: .2px; background: var(--hud); padding: 9px 14px; border-radius: var(--radius-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.zoom { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.finish { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 16px; font-weight: 600; box-shadow: var(--shadow-s); }
.finish:hover { border-color: var(--accent); }
.markers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mk { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.mk.ok { background: var(--ok); border: 3px solid #fff; }
.mk.ok.wrong { background: var(--warn); color: var(--cta-ink); }
.mk.pending { background: var(--accent); border: 3px solid #fff; animation: pulse 1s infinite; }
.mk.miss { background: var(--bad); width: 26px; height: 26px; font-size: 14px; animation: fade 1.2s forwards; }
.mk.missed { background: #fff; color: var(--bad-ink); border: 3px dashed var(--bad); }
.ring { position: absolute; border: 3px solid var(--ok); border-radius: 12px; pointer-events: none; }
.ring.missed { border-color: var(--bad-ink); border-style: dashed; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.15); } }
@keyframes fade { 0% { opacity: 1; transform: translate(-50%,-50%) scale(.6); } 20% { transform: translate(-50%,-50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1); } }
.toast { position: absolute; left: 50%; top: 62px; transform: translateX(-50%); background: var(--hud); color: #fff; padding: 8px 14px; border-radius: var(--radius-s); border-left: 3px solid var(--cta); font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
.toast.on { opacity: 1; }
.list-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.list-items .li { text-align: left; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; font-weight: 550; background: var(--surface-raised); }
.list-items .li:hover { border-color: var(--accent); }
.list-items .li:disabled { opacity: .5; cursor: default; }
.list-items small { color: var(--ok-ink); font-weight: 700; }
.row-end { display: flex; justify-content: flex-end; margin-top: 10px; }
.view-canvas:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.iconbtn.off { opacity: .7; }
#mute .x { display: none; } #mute.off .x { display: inline; } #mute.off .wave { display: none; }
/* G2 feedback */
.pts { position: absolute; transform: translate(-50%, -50%); font: 700 22px/1 var(--font-display); color: var(--ok-ink); text-shadow: 0 1px 0 #fff, 0 0 6px rgba(255,255,255,.9); animation: rise 1.1s ease-out forwards; pointer-events: none; }
.pts.neg { color: var(--bad-ink); }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
#stage.shake { animation: shake .28s ease-in-out; }
@keyframes shake { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } 100% { transform: none; } }
#stage.cooling { filter: saturate(.4) brightness(.92); transition: filter .3s; }
.stamp { display: none; }
.stamp.on { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 6px 12px 6px 6px; border: 3px solid var(--ok); border-radius: var(--radius-s); color: var(--ok-ink); font: 700 18px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .5px; transform: rotate(-3deg); animation: stamp .35s cubic-bezier(.2,1.6,.4,1) both; }
.stamp svg { width: 36px; height: 36px; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(-3deg) scale(1.8); } 100% { opacity: 1; transform: rotate(-3deg) scale(1); } }
.feedback .txt span { display: block; }
.feedback .txt .right-look { margin-top: 4px; color: var(--muted); font-size: 13px; }
.feedback .txt .right-look b { display: inline; color: var(--ok-ink); }
.feedback .txt .lbl-hz { display: inline; color: var(--bad-ink); }

/* Rule picker */
.sheet-bg { position: absolute; inset: 0; background: var(--scrim); display: none; align-items: flex-end; justify-content: center; }
.sheet-bg.on { display: flex; }
.sheet { background: var(--surface-work); width: min(920px, 100%); max-height: 92%; overflow-y: auto; border-radius: var(--radius) var(--radius) 0 0; border-top: 4px solid var(--cta); padding: 14px 16px max(14px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
.sheet h2 { margin: 0 0 2px; font-size: 22px; font-weight: 600; }
.sheet p.sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.rules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rule { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 10px 6px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: 13px; line-height: 1.25; font-weight: 550; transition: border-color .15s, box-shadow .15s; }
.rule:hover { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rule svg { width: 44px; height: 44px; }
.rule.right { border-color: var(--ok-ink); box-shadow: inset 0 0 0 1px var(--ok-ink); background: var(--ok-soft); }
.sheet.wrong .rule.right { animation: glow 1s ease-in-out 2; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(47,154,95,.35); } }
.rule.wrongpick { border-color: var(--bad-ink); box-shadow: inset 0 0 0 1px var(--bad-ink); background: var(--bad-soft); }
.feedback { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-s); border-left: 4px solid var(--ok); display: none; gap: 10px; align-items: flex-start; }
.feedback.on { display: flex; }
.feedback.good { background: var(--ok-soft); }
.feedback.bad { background: var(--warn-soft); border-left-color: var(--warn); }
.feedback .txt { flex: 1; font-size: 14px; }
.feedback .txt b { display: block; margin-bottom: 2px; }
.btn { background: var(--cta); color: var(--cta-ink); border-radius: var(--btn-radius); padding: 10px 18px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--cta-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--steel-200); color: var(--steel-600); cursor: default; transform: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--steel-600); }
.btn.ghost:hover { background: var(--surface-raised); border-color: var(--accent); color: var(--accent); }

/* End */
#end { overflow-y: auto; background: var(--surface-work); padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
#end.on { display: block; }
.end-wrap { max-width: 980px; margin: 0 auto; }
.end-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 14px; }
.end-head h2 { margin: 0; font-size: 32px; font-weight: 700; flex: 1 1 260px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 16px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 12px 16px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .k { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.main .v { color: var(--accent); }
.debrief { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.item { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; display: flex; gap: 10px; align-items: flex-start; border-left: 4px solid var(--ok); }
.item.missed { border-left-color: var(--bad-ink); }
.item.half { border-left-color: var(--warn); }
.item svg { width: 40px; height: 40px; flex: none; }
.item .n { font-weight: 650; }
.item .r { font-size: 13px; color: var(--accent); font-weight: 600; }
.item .note { font-size: 13px; color: var(--muted); } .item .note b { color: var(--ok-ink); }
.item .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.item .tag.ok { color: var(--ok-ink); } .item .tag.bad { color: var(--bad-ink); } .item .tag.half { color: var(--warn-ink); }
.end-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.newbest { background: var(--warn); color: var(--cta-ink); border-radius: var(--radius-xs); padding: 4px 10px; font-size: 13px; font-weight: 700; }


/* Home extras */
.home-top { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.home-top .grow { flex: 1 1 320px; min-width: 0; }
.section-h { font: 600 12px/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.card .thumb.empty { display: grid; place-items: center; color: var(--muted); font-weight: 600; }

/* Editor */
#editor { background: var(--bg); display: none; }
#editor.on { display: grid; grid-template-columns: 270px 1fr 270px; grid-template-rows: auto 1fr auto; }
.ed-top { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); background: var(--toolbar-bg); color: #fff; border-bottom: 1px solid var(--toolbar-line); flex-wrap: nowrap; }
@media (max-width: 1120px) { .ed-top { flex-wrap: wrap; } }
.ed-top input, .ed-top select { background: var(--navy-800) !important; color: #fff !important; border-color: var(--toolbar-line) !important; }
.ed-top select option { color: var(--ink); background: #fff; }
.ed-top .tbtn { background: transparent; color: #fff; border: 1px solid var(--toolbar-line); }
.ed-top .tbtn:hover { background: var(--navy-800); }
.ed-top .tbtn.primary { background: var(--cta); color: var(--cta-ink); border-color: var(--cta); }
.ed-top .tbtn.primary:hover { background: var(--cta-hover); }
.ed-top .tbtn:disabled { color: var(--navy-300); background: transparent; }
.ed-top :focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--focus); }
.ed-top input, .ed-top select, .ed-panel input, .ed-panel select, .ed-panel textarea, .modal input, .modal select, .modal textarea { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--steel-400); border-radius: var(--radius-s); padding: 6px 8px; min-width: 0; transition: border-color .15s; }
.ed-panel input:hover, .ed-panel select:hover, .ed-panel textarea:hover, .modal input:hover, .modal select:hover, .modal textarea:hover { border-color: var(--steel-600); }
select { appearance: none; -webkit-appearance: none; padding-right: 26px !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%235b6778' stroke-width='2'/%3E%3C/svg%3E") !important; background-repeat: no-repeat !important; background-position: right 6px center !important; background-size: 16px !important; }
.ed-top input#ed-title { flex: 1 1 120px; max-width: 220px; min-width: 80px; font-weight: 600; }
.ed-top .tbtn.ico { padding: 6px 7px; } .ed-top .tbtn.ico .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ed-top .grow { flex: 1; }
.stepper { display: flex; flex: none; border: 1px solid var(--toolbar-line); border-radius: var(--radius-s); overflow: hidden; }
.stepper button { padding: 6px 10px; font-weight: 600; font-size: 13px; color: var(--navy-300); white-space: nowrap; border-right: 1px solid var(--toolbar-line); }
.stepper button:last-child { border-right: 0; }
.stepper button:hover { background: var(--navy-800); color: #fff; }
.stepper button b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: var(--radius-xs); background: var(--navy-700); color: #fff; font-size: 11px; margin-right: 6px; }
.stepper button.on { background: var(--navy-800); color: #fff; box-shadow: inset 0 -2px 0 var(--cta); }
.stepper button.on b { background: var(--cta); color: var(--cta-ink); }
#editor[data-stage="place"] .hz-only, #editor:not([data-stage="place"]) .place-only { display: none; }

.stagepane { display: flex; flex-direction: column; gap: 10px; }
.hz-list { display: flex; flex-direction: column; gap: 6px; }
.hz-row { display: flex; gap: 8px; align-items: flex-start; text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--bad); border-radius: var(--radius-s); padding: 6px 8px; font-size: 13px; background: var(--surface-raised); }
.hz-row.warn { border-left-color: var(--warn); }
.hz-row svg { width: 30px; height: 30px; flex: none; }
.hz-row b { display: block; } .hz-row small { color: var(--muted); display: block; }
.hz-row.on { box-shadow: 0 0 0 2px var(--accent); }
.variants { display: flex; flex-direction: column; gap: 6px; background: var(--yellow-25); border: 1px solid var(--yellow-50); border-radius: var(--radius-s); padding: 8px; }
.variants .vb { display: flex; gap: 8px; align-items: center; text-align: left; font-size: 13px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius-s); padding: 4px 6px; }
.variants .vb.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.variants .vb img { width: 40px; height: 40px; object-fit: contain; }
/* phase 6: layers list, multi-selection note, shortcuts table */
.layers { margin-top: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-2); }
.layers summary { cursor: pointer; font-weight: 600; font-size: var(--text-s); padding: var(--space-1) 0; }
.layer-list { display: flex; flex-direction: column; gap: 2px; max-height: 280px; overflow-y: auto; }
.layer { display: flex; align-items: center; gap: var(--space-2); text-align: left; font-size: var(--text-s); border: 1px solid transparent; background: var(--surface-raised); border-radius: var(--radius-s); padding: 2px var(--space-1); }
.layer:hover { border-color: var(--line); }
.layer.on { border-color: var(--accent); background: var(--accent-soft); }
.layer img { width: 28px; height: 28px; object-fit: contain; flex: none; }
.layer span { flex: 1; min-width: 0; }
.layer small { display: block; color: var(--muted); font-size: var(--text-xs); }
.layer .dot { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--bad); flex: none; }
.sel-multi { font-size: var(--text-s); background: var(--accent-soft); border-radius: var(--radius-s); padding: var(--space-1) var(--space-2); margin: 0; }
table.keys { width: 100%; border-collapse: collapse; font-size: var(--text-s); margin-bottom: var(--space-3); }
table.keys th { text-align: left; padding: var(--space-2) 0 var(--space-1); font-size: var(--text-s); }
table.keys td { padding: 3px 0; border-bottom: 1px solid var(--line); }
table.keys td:first-child { width: 45%; }
kbd { font-family: inherit; font-size: var(--text-xs); background: var(--surface-panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: var(--radius-s); padding: 1px 6px; }
.opt-color { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-color button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); }
.opt-color button.on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.opt-choice { display: flex; gap: 6px; flex-wrap: wrap; }
.opt-choice button { padding: var(--space-1) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: var(--text-s); background: var(--surface-panel); }
.opt-choice button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pal[draggable="true"] { cursor: grab; }
#check-pane { display: flex; flex-direction: column; gap: 8px; }
#check-pane .pane-h { margin: 0; font-size: 16px; }
#check-pane .issue { flex-wrap: wrap; }
#check-pane .issue .m { flex-basis: 100%; }
b.ok { color: var(--ok-ink); }
.ed-top select { flex: 0 0 auto; width: 158px; }
@media (max-width: 1440px) {
  .ed-top select#ed-decor { width: 146px; }
  .ed-top .lbl-c { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ed-top #ed-test, .ed-top #ed-back { padding: 6px 7px; }
  .stepper button { padding: 6px 8px; }
  .stepper button b { margin-right: 5px; }
}
.ed-top .grow { min-width: 4px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface-raised); border: 1px solid var(--steel-400); border-radius: var(--radius-s); padding: 6px 10px; font-weight: 600; font-size: 13px; white-space: nowrap; transition: background .15s, border-color .15s; }
.tbtn .ic, .btn .ic { width: 16px; height: 16px; flex: none; }
.tbtn:hover { border-color: var(--accent); }
.tbtn.primary { background: var(--cta); color: var(--cta-ink); border-color: var(--cta); }
.tbtn.primary:hover { background: var(--cta-hover); }
.tbtn.danger { color: var(--bad-ink); }
.tbtn:disabled { color: var(--steel-400); border-color: var(--steel-200); background: transparent; cursor: default; }
.ed-panel { background: var(--surface-work); overflow-y: auto; padding: 10px; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.ed-left { border-right: 1px solid var(--line); padding-left: max(10px, env(safe-area-inset-left)); }
.ed-right { border-left: 1px solid var(--line); padding-right: max(10px, env(safe-area-inset-right)); }
#ed-stage { position: relative; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 8px 4px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.pal-cat { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 0 2px; }
.palette { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pal { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; line-height: 1.15; text-align: center; background: #fff; }
.pal img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.pal:hover { border-color: var(--steel-600); }
.pal.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.pal .hz { color: var(--bad-ink); font-weight: 700; }
.pal .st-n { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field > span { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.field textarea { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; }
.row > * { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }
.hint.warn { color: var(--warn-ink); }
.ed-status { grid-column: 1 / -1; background: var(--surface-panel); border-top: 1px solid var(--line); padding: 6px max(12px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.ed-status b { color: var(--ink); }
.ed-status .placing { color: var(--accent); font-weight: 600; }
.preview { background: var(--scene-bg) repeating-conic-gradient(var(--steel-150) 0 25%, var(--steel-50) 0 50%) 0 0 / 16px 16px; border-radius: var(--radius-s); min-height: 140px; display: grid; place-items: center; padding: 6px; }
.preview img { max-height: 180px; }
.empty-sel { color: var(--muted); font-size: 13px; }
#sel-box:not([hidden]), #sel-box .hz-only, #sel-box .place-only { display: flex; flex-direction: column; gap: 12px; }
#editor[data-stage="place"] #sel-box .hz-only, #editor:not([data-stage="place"]) #sel-box .place-only { display: none; }
.modal-bg { position: fixed; inset: 0; background: var(--scrim); display: none; place-items: center; z-index: 40; padding: 16px; }
.modal-bg.on { display: grid; }
.modal { background: var(--surface-work); border-radius: var(--radius); border-top: 4px solid var(--accent); padding: 18px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.modal h3 { margin: 0; }
.open-list { display: flex; flex-direction: column; gap: 6px; }
.open-list .oi { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; background: var(--surface-raised); }
.open-list .oi .t { flex: 1; min-width: 0; }
.open-list .oi .t small { display: block; color: var(--muted); }
.badge { display: inline-block; border-radius: var(--radius-xs); padding: 1px 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.badge.pub, .ed-status .pub { color: var(--ok-ink); } .badge.pub { background: var(--ok-soft); }
.badge.draft { background: var(--warn-soft); color: var(--warn-ink); } .ed-status .draft { color: var(--warn-ink); font-weight: 600; }
.issues { display: flex; flex-direction: column; gap: 6px; }
.issue { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--radius-s); padding: 6px 8px; font-size: 13px; background: var(--surface-raised); }
.issue.error { border-left-color: var(--bad-ink); }
.issue .lvl { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--warn-ink); white-space: nowrap; }
.issue.error .lvl { color: var(--bad-ink); }
.issue .m { flex: 1; }
.helmets .dim { opacity: .25; } .hint.ok { color: var(--ok-ink); font-weight: 600; } b.bad { color: var(--bad-ink); }
@media (max-width: 900px) { #editor.on { grid-template-columns: 210px 1fr 210px; } .palette { grid-template-columns: repeat(2, 1fr); } }

/* Loading + rotate */
.loading { position: absolute; inset: 0; display: none; place-items: center; background: var(--scene-bg); color: var(--muted); font-weight: 600; }
.loading.on { display: grid; }
#rotate { position: fixed; inset: 0; background: var(--surface-shell); color: #fff; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; z-index: 50; }
#rotate svg { width: 72px; height: 72px; animation: rot 2s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 820px) { body.playing #rotate, body.editing #rotate { display: flex; } }

@media (max-height: 500px) {
  .rules { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .rule { flex-direction: row; text-align: left; padding: 6px 8px; font-size: 12px; }
  .rule svg { width: 32px; height: 32px; flex: none; }
  .sheet { padding-top: 10px; }
  .sheet h2 { font-size: 16px; }
  .sheet p.sub { margin-bottom: 8px; }
  .stats .v { font-size: 20px; }
}
@media (max-width: 640px) {
  .rules { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .debrief { grid-template-columns: 1fr; }
}
/* accessibility baseline */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hud :focus-visible, .zoom :focus-visible { outline-color: #fff; box-shadow: 0 0 0 4px var(--focus); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Style guide (?styleguide=1) */
.sg { overflow-y: auto; background: var(--surface-work); }
.sg-main { max-width: 1100px; margin: 0 auto; padding: 32px 24px 48px; }
.sg-main h1 { margin: 0 0 6px; font: 700 38px/1.05 var(--font-display); }
.sg-main .eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.sg-sw { display: grid; grid-template-columns: 36px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px; font-size: 13px; }
.sg-sw i { grid-row: 1 / 3; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: var(--radius-xs); }
.sg-sw code, .sg-ic code, .sg-k { font: 500 11px/1.3 ui-monospace, monospace; color: var(--muted); }
.sg-type { display: flex; flex-direction: column; gap: 14px; }
.sg-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.sg-inline { position: static; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; overflow: visible; }
.sg-navy .ed-top { padding: 10px; border-radius: var(--radius-s); }
.sg-scene { background: var(--scene-bg); padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.sg-rules { max-width: 760px; }
.btn.sg-hover { background: var(--cta-hover); } .btn.ghost.sg-hover { background: var(--surface-raised); border-color: var(--accent); color: var(--accent); }
.badge.arch, .badge.old { border: 1px solid var(--steel-400); color: var(--muted); }
.sg-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.sg-ic { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--ink); }
.sg-ic .ic { width: 24px; height: 24px; }
.sg-controls.ed-panel { flex-direction: row; flex-wrap: wrap; align-items: flex-end; background: transparent; padding: 0; overflow: visible; gap: 12px; }
.ed-panel input:disabled, .ed-panel select:disabled, .modal input:disabled { background: var(--steel-100); color: var(--steel-600); border-color: var(--steel-200); }

/* ---------- Phase 2: environment, new scene dialog, versions ---------- */
.ed-top .env-chip { flex: none; gap: 8px; max-width: 220px; overflow: hidden; white-space: nowrap; }
.ed-top .env-chip i { width: 10px; height: 10px; flex: none; background: var(--fam, var(--accent)); border-radius: var(--radius-xs); box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.ed-top .env-chip span { overflow: hidden; text-overflow: ellipsis; }
.env-dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.env-dims .field span { white-space: nowrap; }
.env-dims input { width: 100%; min-width: 0; box-sizing: border-box; }
.env-size, .ns-size { display: flex; width: 100%; margin-bottom: 0; }
.env-size button, .ns-size button { flex: 1; justify-content: center; padding: 8px 6px; }
.ns-size button { flex-direction: column; gap: 2px; }
.ns-size small, [data-kind] small { font-weight: 500; color: var(--muted); font-size: 11px; }
.modal.wide { width: min(760px, calc(100vw - 32px)); }
.ns-body { margin-top: 14px; }
.ns-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; max-height: 52vh; overflow: auto; padding: 2px; }
.ns-card { display: flex; flex-direction: column; text-align: left; background: var(--surface-raised); border: 1px solid var(--line); border-top: 3px solid var(--fam); border-radius: var(--radius-m); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.ns-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ns-card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-work); }
.ns-card span { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; }
.ns-card small { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.versions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ver { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-raised); padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; }
.ver-h { display: flex; align-items: center; gap: 8px; }
.ver small { color: var(--muted); font-size: 12px; }
.ver p { margin: 2px 0; font-size: 13px; }
.ver-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ver-a .tbtn { font-size: 12px; padding: 4px 8px; }
/* Phase 6: version compare */
.cmp-pick { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.cmp { max-height: min(52vh, 420px); overflow-y: auto; margin: var(--space-2) 0; }
.cmp h4 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-s); }
.cmp h4 small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.cmp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cmp-list li { display: flex; align-items: center; gap: var(--space-2); font-size: 13px; padding: 4px 6px; border-radius: var(--radius-xs); background: var(--surface-raised); border: 1px solid var(--line); }
.cmp-list .m { flex: 1; min-width: 0; }
.cmp-list .tbtn { font-size: 12px; padding: 3px 8px; }
.cmp .tag { flex: none; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: var(--radius-pill); }
.cmp .tag.add { background: var(--ok-soft); color: var(--ok-ink); }
.cmp .tag.rm { background: var(--bad-soft); color: var(--bad-ink); }
.cmp .tag.mv { background: var(--accent-soft); color: var(--ink); }
.cmp .tag.ch { background: var(--warn-soft); color: var(--warn-ink); }
.cmp-txt { display: block; margin-top: 2px; font-size: 12px; }
.cmp-txt del { display: block; color: var(--bad-ink); }
.cmp-txt ins { display: block; color: var(--ok-ink); text-decoration: none; }
@media (max-width: 600px) { .cmp-pick { grid-template-columns: 1fr; } }

/* ---------- Phase 3: structure stage ---------- */
.st-lib { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.st-pal { padding: 4px 4px 6px; font-size: 11.5px; font-weight: 600; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); min-height: 44px; }
.st-pal img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.st-pal:hover { border-color: var(--accent); }
.st-pal.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
#st-box { display: flex; flex-direction: column; gap: 10px; }
#st-box .check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- phase 4: hazard library, hazards stage, general hazards in the game ---------- */
.tag-other { display: inline-block; white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--navy-700); background: var(--steel-100); border-radius: var(--radius-xs); padding: 1px 6px; }
.feedback .cons { display: block; font-size: 13px; color: var(--muted); }
.feedback .tag-other { margin: 2px 0; width: fit-content; display: block; }
.debrief-h { grid-column: 1 / -1; margin: 6px 0 0; font-family: var(--font-display); font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sev { display: inline-flex; gap: 2px; vertical-align: middle; } .sev i { width: 7px; height: 12px; background: var(--steel-200); border-radius: 1px; } .sev i.on { background: var(--bad); }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; } .cat-chip svg { width: 24px; height: 24px; flex: none; }
.lsr-i svg { width: 24px; height: 24px; } .lsrs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
/* library screen */
#library { flex-direction: column; background: var(--surface-work); }
#library.on { display: flex; }
.lib-top { display: flex; align-items: center; gap: 10px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); background: var(--toolbar-bg); color: #fff; border-bottom: 1px solid var(--toolbar-line); }
.lib-top .tbtn { background: transparent; color: #fff; border: 1px solid var(--toolbar-line); } .lib-top .tbtn:hover { background: var(--navy-800); }
.lib-top .tbtn.primary { background: var(--cta); color: var(--cta-ink); border-color: var(--cta); }
.lib-top :focus-visible { outline-color: #fff; box-shadow: 0 0 0 5px var(--focus); }
.lib-title { margin: 0; font-family: var(--font-display); font-size: 20px; letter-spacing: .02em; }
.lib-count { color: var(--text-inverse-muted); font-size: 13px; } .lib-top .grow { flex: 1; }
.lib-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-panel); }
.lib-filters input, .lib-filters select { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--steel-400); border-radius: var(--radius-s); padding: 6px 8px; min-width: 0; }
.lib-filters input { flex: 1 1 200px; } .lib-filters select { flex: 0 1 150px; width: 150px; }
.lib-table .nw { white-space: nowrap; }
.lib-msg { margin: 0; padding: 0 12px; min-height: 0; font-size: 13px; color: var(--ok-ink); } .lib-msg:not(:empty) { padding: 6px 12px; }
.lib-main { flex: 1; min-height: 0; display: flex; }
.lib-body { flex: 1; min-width: 0; overflow: auto; padding: 0 12px 16px; }
.lib-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lib-table th { position: sticky; top: 0; background: var(--surface-work); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); z-index: 1; }
.lib-table td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lib-table tr.on td { background: var(--accent-soft); }
.lib-name { display: block; text-align: left; max-width: 360px; } .lib-name b { display: block; } .lib-name small { display: block; color: var(--muted); }
.lib-name:hover b { color: var(--accent); }
.lib-table .badge { margin: 2px 4px 0 0; }
.lib-drawer { width: 380px; flex: none; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface-panel); padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.lib-drawer[hidden] { display: none; }
.lib-drawer p { margin: 0; } .lib-drawer ul { margin: 0; padding-left: 18px; }
.dr-h { display: flex; align-items: flex-start; gap: 8px; } .dr-h h3 { margin: 0; flex: 1; font-family: var(--font-display); font-size: 18px; }
.dr-meta { color: var(--muted); }
.dr-grid { display: grid; grid-template-columns: 88px 1fr; gap: 6px 10px; align-items: center; } .dr-grid > span:nth-child(odd) { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.dr-rule { display: flex; align-items: center; gap: 6px; } .dr-rule svg { width: 26px; height: 26px; flex: none; }
.dr-uses > div, .dr-ver > div { border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-raised); padding: 6px 8px; margin-bottom: 4px; } .dr-uses small { display: block; color: var(--muted); }
.dr-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
/* definition form and picker */
.df { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
.df-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.df .row { display: flex; gap: 8px; } .df .row > .field { flex: 1; min-width: 0; }
.df fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; margin: 0; background: var(--surface-raised); }
.df legend { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 0 4px; }
.chk-list { display: flex; flex-direction: column; gap: 3px; } .chk-list.acts { max-height: 260px; overflow-y: auto; }
.chk-list .grp { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.chk { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; } .chk input { margin-top: 3px; accent-color: var(--accent); }
.modal select[multiple] { padding: 2px; }
.modal.wide:has(.df), .modal.wide:has(.pk-list), .modal.wide:has(.diff) { width: min(920px, calc(100vw - 32px)); }
.pk-filters { display: flex; flex-wrap: wrap; gap: 6px; } .pk-filters input { flex: 1 1 200px; } .pk-filters select { flex: 0 1 180px; }
.pk-list { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.pk-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-raised); padding: 6px 8px; }
.pk-row .t { flex: 1; min-width: 0; } .pk-row .t small { display: block; color: var(--muted); } .pk-ic svg { width: 32px; height: 32px; display: block; }
.diff { width: 100%; border-collapse: collapse; font-size: 13px; } .diff th, .diff td { text-align: left; vertical-align: top; padding: 6px; border-bottom: 1px solid var(--line); } .diff thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.diff td:last-child { background: var(--ok-soft); }
/* hazards stage */
.hz-row.gen { border-left-color: var(--navy-700); }
.hz-row .badge { margin-top: 3px; margin-right: 4px; }
#hz-box:not([hidden]) { display: flex; flex-direction: column; gap: 12px; }
#hz-box [hidden] { display: none !important; }
#hz-box .field small { color: var(--muted); }
.hz-type { margin-bottom: 0; } .hz-type button { padding: 6px 9px; font-size: 12px; }
.hz-items, .hz-on { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--steel-100); border-radius: var(--radius-pill); padding: 2px 4px 2px 10px; font-size: 12px; }
.chip button { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; } .chip button:hover { background: var(--steel-200); } .chip svg { width: 14px; height: 14px; }
.hz-on .tbtn { font-size: 12px; white-space: normal; text-align: left; }
.zone-dims .field { flex: 1; min-width: 0; } .zone-dims input { width: 100%; }
#hz-pick[aria-pressed="true"], #hz-draw[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.hz-update { display: flex; flex-direction: column; gap: 4px; background: var(--warn-soft); border-left: 4px solid var(--warn); border-radius: var(--radius-s); padding: 8px 10px; font-size: 13px; }
.hz-update .tbtn { align-self: flex-start; }
@media (max-width: 1100px) { .lib-drawer { width: 320px; } .lib-table td:nth-child(5), .lib-table th:nth-child(5), .lib-table td:nth-child(8), .lib-table th:nth-child(8) { display: none; } }
@media (max-width: 900px), (max-height: 500px) { .df { grid-template-columns: 1fr; } .lib-drawer { position: fixed; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); width: min(380px, 92vw); } }

/* phase 5: element thumbnails in the hazard picker and the library drawer */
.pk-row .thumb { width: 40px; height: 40px; object-fit: contain; flex: none; }
.dr-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.dr-thumbs .thumb { width: 64px; height: 64px; object-fit: contain; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-s); }

/* Phase 6 QA: touch targets of at least 44 px on touch screens (sth-game-ux-review) */
@media (pointer: coarse) {
  .iconbtn { width: 44px; height: 44px; }
  #fam-filter button { min-height: 44px; }
  .rail-item { min-width: 44px; min-height: 44px; }
  #editor .tbtn, #editor .stepper button, #ed-grid, #pal-search, #ed-title, #ed-env { min-height: 40px; }
  #editor .tbtn.ico, #ed-back, #ed-test { min-width: 40px; min-height: 40px; }
  #finish { min-height: 44px; }
}

/* Phase 6: compact editor toolbar on phones and narrow windows (one row, secondary actions in "More") */
.ed-more-wrap { position: relative; display: none; }
.ed-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column; }
.ed-menu[hidden] { display: none; }
.ed-menu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 44px; border-radius: var(--radius-xs); font-size: 14px; font-weight: 500; text-align: left; color: var(--ink); }
.ed-menu button:hover, .ed-menu button:focus-visible { background: var(--steel-100); }
.ed-menu .ic { width: 18px; height: 18px; flex: none; color: var(--muted); }
@media (max-width: 1120px), (max-height: 500px) {
  .ed-top { flex-wrap: nowrap; gap: 4px; }
  .ed-top .ed-sec { display: none; }
  .ed-more-wrap { display: block; }
  .ed-top input#ed-title { flex: 1 1 60px; max-width: 160px; }
  .ed-top #ed-env { max-width: 150px; overflow: hidden; }
  .ed-top #ed-env span { overflow: hidden; text-overflow: ellipsis; }
  .stepper button:not(.on) .st-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stepper button:not(.on) b { margin-right: 0; }
  .stepper button { padding: 6px 8px; }
  .ed-top .lbl-s { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ed-top #ed-save { padding: 6px 8px; }
}

/* Difficulty level (lot 6) */
.level-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.level-row .seg { margin-bottom: 0; }
.level-lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.level-row .hint { font-size: 13px; color: var(--muted); }
.hint-btn { position: relative; }
.hint-btn b { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
.hint-btn:disabled { opacity: .45; }

/* Situations mode (lot 7) */
.quick-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.quick-row .hint { font-size: 13px; color: var(--muted); }
.quick-btns { display: inline-flex; gap: 6px; }
.quick-btns .btn { padding: 6px 12px; font-size: 13px; }
#situations { background: var(--surface-work); overflow-y: auto; }
.sit-wrap { max-width: 1040px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 24px; }
.sit-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sit-top .title { font: 700 22px/1.1 var(--font-display); color: var(--ink); }
.sit-top .spacer { flex: 1; }
.sit-top .pill { background: var(--surface-raised); border: 1px solid var(--line); color: var(--ink); padding: 6px 12px; border-radius: var(--radius-s); font-weight: 700; }
.sit-top .pill small { color: var(--muted); font-weight: 600; margin-right: 6px; }
.sit-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.sit-img { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-s); display: flex; align-items: center; justify-content: center; min-height: 320px; padding: 12px; }
.sit-img img { width: 100%; max-height: 420px; object-fit: contain; }
.sit-name { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.sit-q { margin: 0 0 12px; font: 700 26px/1.1 var(--font-display); color: var(--ink); }
.sit-verdict { display: flex; gap: 10px; margin-bottom: 14px; }
.sit-verdict .btn { flex: 1; padding: 14px; font-size: 16px; }
.sit-safe { background: var(--ok-ink); } .sit-unsafe { background: var(--bad-ink); }
.sit-verdict .btn:disabled { opacity: .45; }
.sit-verdict .btn.right { opacity: 1; box-shadow: 0 0 0 3px var(--ok-soft), 0 0 0 5px var(--ok-ink); }
.sit-verdict .btn.wrong { opacity: 1; box-shadow: 0 0 0 3px var(--bad-soft), 0 0 0 5px var(--bad-ink); }
.sit-sub { grid-column: 1 / -1; margin: 0; font-weight: 700; color: var(--ink); }
#sit-rules { margin-bottom: 14px; }
.sit-fb { border-left: 4px solid var(--ok-ink); background: var(--surface-raised); padding: 12px 14px; border-radius: var(--radius-s); }
.sit-fb.bad { border-left-color: var(--bad-ink); }
.sit-fb p { margin: 0 0 8px; font-size: 14px; line-height: 1.4; }
.sit-h { font-weight: 700; font-size: 16px !important; }
.sit-rule { display: flex; align-items: center; gap: 8px; font-weight: 600; } .sit-rule svg { width: 30px; height: 30px; }
.sit-twin { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; font-weight: 700; color: var(--ok-ink); }
.sit-twin img { width: 140px; height: 100px; object-fit: contain; background: #fff; border: 2px solid var(--ok-ink); border-radius: var(--radius-s); }
.sit-end h2 { font: 700 30px/1.1 var(--font-display); margin: 0 0 14px; color: var(--ink); }
.sit-missed { display: grid; gap: 8px; margin-bottom: 16px; }
.sit-missed .item { display: flex; gap: 12px; align-items: flex-start; }
.sit-missed img { width: 96px; height: 72px; object-fit: contain; background: #fff; border-radius: var(--radius-s); flex: none; }
@media (max-width: 760px), (max-height: 500px) { .sit-card { grid-template-columns: 1fr 1fr; gap: 12px; } .sit-img { min-height: 200px; } .sit-q { font-size: 20px; } .sit-verdict .btn { padding: 10px; } }
.sit-missed .item { border-left: 4px solid var(--bad-ink) !important; }

/* Facilitator mode (lot 8) */
.facil-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); margin-left: auto; cursor: pointer; }
.facil-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
body.facil .hud .pill, body.facil #finish, body.facil #list-open { display: none; }
.facil-q { margin-top: 6px; color: var(--accent); }
