/* Four directions, one page. Everything a look can change is a custom
   property set from its module; the structure below is shared. */

:root {
  --bg: #0a1220; --ink: #ece5d3; --ink-2: #9aa6b8; --accent: #f0b45e; --accent-2: #a9c8e8;
  --rule: rgba(236,229,211,0.22); --card: rgba(8,14,26,0.66); --card-blur: 12px;
  --font-display: Georgia, serif; --font-body: Georgia, serif; --hud-font: Georgia, serif; --radius: 2px;
  --chrome: #0a0c12; --chrome-ink: #cfd3dc; --chrome-dim: #7a8090; --chrome-rule: #1c2030;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; overflow: hidden;
  background: var(--chrome); color: var(--ink); font-family: var(--font-body);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- chrome ---------- */
.chrome {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--chrome-ink); background: var(--chrome); z-index: 5; transition: opacity .3s, transform .3s;
}
.chrome--top {
  display: flex; align-items: center; gap: 14px; padding: calc(8px + var(--sat)) calc(14px + var(--sar)) 8px calc(14px + var(--sal)); border-bottom: 1px solid var(--chrome-rule);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; flex: 0 0 auto; }
.brand-mark { font-weight: 800; letter-spacing: .18em; font-size: 13px; }
.brand-sub { font-size: 11px; color: var(--chrome-dim); }
.tabs { display: flex; gap: 6px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: flex; align-items: baseline; gap: 7px; padding: 7px 12px; border: 1px solid var(--chrome-rule);
  border-radius: 999px; background: transparent; cursor: pointer; font-size: 13px; white-space: nowrap; color: var(--chrome-dim);
}
.tab b { font-size: 11px; opacity: .7; }
.tab.is-on { color: #fff; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tab .sw { width: 10px; height: 10px; border-radius: 50%; align-self: center; background: var(--sw, #888); }
.pad { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--chrome-dim); }
.pad-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }

.chrome--bottom {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 8px calc(14px + var(--sar)) calc(10px + var(--sab)) calc(14px + var(--sal)); border-top: 1px solid var(--chrome-rule);
}
.steps { display: flex; gap: 4px; }
.step {
  padding: 7px 11px; border: 1px solid var(--chrome-rule); border-radius: 6px; background: transparent; cursor: pointer;
  font-size: 12px; color: var(--chrome-dim);
}
.step.is-on { color: #fff; border-color: var(--chrome-ink); background: #161a26; }
.readout { min-width: 0; }
.readout-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.readout-name { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: .02em; color: #fff; }
.readout-tag { margin: 0; font-size: 12.5px; color: var(--chrome-dim); }
.readout-blurb { margin: 3px 0 0; font-size: 12.5px; line-height: 1.4; color: #aab0bf; max-width: 100ch; }
.readout-keys { margin: 4px 0 0; font-size: 11px; color: var(--chrome-dim); }
kbd { font: 10.5px/1 ui-monospace, Menlo, monospace; padding: 2px 5px; border: 1px solid #2a2f3f; border-bottom-width: 2px; border-radius: 4px; color: #cfd3dc; }
.bare-btn { width: 36px; height: 36px; border: 1px solid var(--chrome-rule); border-radius: 8px; background: transparent; cursor: pointer; font-size: 16px; }

body.bare .chrome { position: fixed; left: 0; right: 0; opacity: 0; pointer-events: none; }
body.bare .chrome--top { top: 0; transform: translateY(-100%); }
body.bare .chrome--bottom { bottom: 0; transform: translateY(100%); }
body.bare { grid-template-rows: 0 1fr 0; }

/* ---------- stage ---------- */
.stage { position: relative; overflow: hidden; background: var(--bg); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; inset: 0; pointer-events: none; display: none; font-family: var(--hud-font); color: var(--ink); text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
body.screen-play .hud, body.screen-surge .hud { display: block; }
.hud-l { position: absolute; left: calc(12px + var(--sal)); top: 10px; }
.hud-c { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; white-space: nowrap; }
.hud-r { position: absolute; right: calc(12px + var(--sar)); top: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
body.bare .hud-l, body.bare .hud-c, body.bare .hud-r { top: calc(10px + var(--sat)); }
.stores { list-style: none; margin: 0; padding: 8px 10px; display: grid; grid-template-columns: auto auto; gap: 2px 10px; font-size: 13px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); }
.stores li { display: contents; }
.stores li span { color: var(--ink-2); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; align-self: baseline; }
.stores li b { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }
.stores li.low b { color: var(--accent); }
.hud-year { font-family: var(--font-display); font-size: 17px; letter-spacing: .04em; }
.hud-gauge { display: flex; align-items: center; gap: 7px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.gauge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); transition: background .3s, box-shadow .3s; }
.gauge-dot.rising { background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.5); } }
.hud-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); }
.hud-souls { font-family: var(--font-display); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.speed { display: flex; gap: 2px; margin-top: 8px; pointer-events: auto; }
.speed button { width: 36px; height: 30px; border: 1px solid var(--rule); background: var(--card); color: var(--ink-2); cursor: pointer; font-size: 10px; letter-spacing: -.05em; border-radius: var(--radius); }
.speed button.is-on { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--card)); }
.hud-hint { position: absolute; left: 0; right: 0; bottom: calc(96px + var(--sab)); margin: 0; text-align: center; font-size: 12px; color: var(--ink-2); opacity: .85; padding: 0 12px; }
body:not(.bare) .hud-hint { bottom: 96px; }

/* build palette */
.palette { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: stretch; gap: 0; pointer-events: auto; background: linear-gradient(to top, color-mix(in srgb, var(--bg) 88%, transparent), transparent); padding: 10px calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
body:not(.bare) .palette { padding-bottom: 10px; }
.palette-scroll { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-width: 0; padding: 2px; }
.palette-scroll::-webkit-scrollbar { display: none; }
.pal-btn { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 96px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); cursor: pointer; text-align: left; color: var(--ink); }
.pal-btn b { font-weight: 500; font-size: 13.5px; }
.pal-btn small { font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.pal-btn i { display: block; width: 22px; height: 14px; margin-bottom: 3px; border-radius: 1px; background: var(--accent-2); opacity: .8; clip-path: polygon(50% 0, 100% 35%, 100% 100%, 0 100%, 0 35%); }
.pal-btn.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.pal-btn.is-on i { background: var(--accent); opacity: 1; }
.palette-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px; padding-left: 8px; flex: 0 0 auto; }
.palette-sel { font-size: 11px; color: var(--ink-2); max-width: 130px; text-align: right; line-height: 1.3; }
.build-btn { padding: 12px 20px; border: 1px solid var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 24%, var(--card)); color: var(--ink); font-size: 15px; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.build-btn:active { transform: translateY(1px); }
.toast { position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%); margin: 0; padding: 8px 14px; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); font-size: 13.5px; white-space: nowrap; pointer-events: none; }

/* ---------- banner ---------- */
.banner { position: absolute; left: 0; right: 0; top: 22%; text-align: center; pointer-events: none; animation: banner 1.1s ease-out both; text-shadow: 0 2px 8px rgba(0,0,0,.8); padding: 0 16px; }
@keyframes banner { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.banner .kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--accent); }
.banner .name { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 6vw, 44px); font-weight: 600; line-height: 1.05; }
.banner .line { margin: 8px 0 0; font-size: 16px; color: var(--ink-2); font-style: italic; }

/* ---------- overlay screens ---------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; padding: 16px; overflow: hidden; }
body.bare .overlay { padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal)); }
.overlay > * { pointer-events: auto; }
.card { width: min(100%, 540px); max-height: 100%; overflow-y: auto; background: var(--card); backdrop-filter: blur(var(--card-blur)); -webkit-backdrop-filter: blur(var(--card-blur)); border: 1px solid var(--rule); border-radius: var(--radius); padding: 26px 28px; }
.eyebrow { margin: 0 0 8px; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-2); }
.word { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(50px, 11vw, 88px); line-height: .95; letter-spacing: .02em; color: var(--ink); }
.tag { margin: 14px 0 0; font-size: 18px; line-height: 1.35; color: var(--ink); }
.tag--sub { margin-top: 6px; font-size: 15px; color: var(--ink-2); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.btn { display: block; width: 100%; padding: 12px 16px; border: 1px solid var(--rule); border-radius: var(--radius); background: transparent; text-align: left; cursor: pointer; font-size: 16px; transition: background .15s, border-color .15s, transform .15s; }
.btn:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn:active { transform: translateY(1px); }
.btn--primary { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); }
.btn--primary::after { content: "→"; float: right; color: var(--accent); }
.foot { margin: 16px 0 0; font-size: 13px; color: var(--ink-2); }

.title-card { width: min(100%, 580px); padding: 0; background: none; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; overflow: visible; }
.title-card .word { text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.title-card .tag, .title-card .tag--sub, .title-card .eyebrow { text-shadow: 0 1px 6px rgba(0,0,0,.7); }
.title-card .actions { max-width: 320px; }
.title-card .btn { background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.title-card .btn--primary { background: color-mix(in srgb, var(--accent) 22%, color-mix(in srgb, var(--bg) 60%, transparent)); }
body.screen-title .overlay { align-items: flex-end; padding-bottom: 5vh; }

.story .kicker, .result .kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--accent); }
.story .name, .result .name { margin: 0 0 16px; font-family: var(--font-display); font-size: 38px; line-height: 1; font-weight: 600; }
.story p.line { margin: 0 0 12px; font-size: 17px; line-height: 1.5; }
.story .voice { display: flex; align-items: center; gap: 8px; margin: 18px 0 0; font-size: 12.5px; color: var(--ink-2); }
.story .voice i { display: inline-block; width: 22px; height: 10px; background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 4px); opacity: .8; animation: wave 1.2s linear infinite; }
@keyframes wave { to { background-position: 4px 0; } }
.result .stats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.result .stats li { display: flex; flex-direction: column; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius); }
.result .stats span { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.result .stats b { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.result p.line { margin: 0 0 14px; font-size: 16px; line-height: 1.5; font-style: italic; }
.result .board { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.result .board li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--rule); font-size: 15px; }
.result .board li.you { color: var(--accent); }
.result .board li b { letter-spacing: .12em; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .brand-sub { display: none; }
  .chrome--top { gap: 8px; }
  .tab .name { display: none; }
  .tab { padding: 8px 10px; }
  .chrome--bottom { grid-template-columns: 1fr auto; gap: 8px; padding-top: 6px; }
  .steps { grid-column: 1 / -1; }
  .readout-blurb, .readout-keys { display: none; }
  .readout-name { font-size: 13px; }
  .readout-tag { font-size: 11.5px; }
  .card { padding: 20px 18px; }
  .stores { grid-template-columns: auto auto; padding: 6px 8px; font-size: 12px; gap: 1px 8px; }
  .stores li span { font-size: 9.5px; letter-spacing: .08em; }
  .hud-year { font-size: 14px; }
  .hud-gauge { font-size: 10px; letter-spacing: .1em; }
  .hud-souls { font-size: 24px; }
  .speed button { width: 32px; height: 30px; }
  .pal-btn { min-width: 88px; padding: 8px 9px; }
  .pal-btn small { display: none; }
  .hud-hint { font-size: 11px; }
  .banner { top: 18%; }
  .word { font-size: clamp(44px, 14vw, 72px); }
  .tag { font-size: 16px; }
  .result .stats { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 520px) {
  .readout-blurb, .readout-keys { display: none; }
}
