/* Layout: one centred column (eyebrow, serif name, link pills); the game is a full-screen layer over it. Single dark theme by choice. */
:root {
  color-scheme: dark;
  --bg: #0e0f12;
  --panel: #16181d;
  --line: #262932;
  --ink: #f2f1ec;
  --muted: #7d818c;
  --soft: #b4b8c2;
  --faint: #3f434d;
  --accent: #3b8eea;
  --display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --body: "DM Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
a, button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

#trail { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.game { z-index: 2; }

/* ---------- Home ---------- */
.home {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px 16px;
  text-align: center;
}
.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--faint);
}
.name {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(54px, 13vw, 132px);
  line-height: 1;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 0.24em;
}
.name .word { display: inline-flex; }
.name .ch {
  display: inline-block;
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1), opacity 0.35s, color 0.3s;
  transition-delay: calc(var(--i) * 22ms);
}
.name:hover .ch, .name:focus-visible .ch { transform: translateY(-7px); }
.name.falling .ch {
  transform: translateY(110vh) rotate(var(--r));
  opacity: 0;
  transition: transform 0.75s cubic-bezier(.55,0,.9,.4), opacity 0.75s;
  transition-delay: calc(var(--d) * 1ms);
}
.hint {
  margin: -8px 0 0;
  font-size: 13px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s, transform 0.25s;
}
.hint i { font-style: normal; color: var(--accent); }
.name:hover + .hint, .name:focus-visible + .hint, .hint.near { opacity: 1; transform: none; }
@media (hover: none) { .hint { opacity: 0.8; transform: none; animation: hintIn 0.6s ease-out 1.5s backwards; } .home.away .hint { opacity: 0; } @keyframes hintIn { from { opacity: 0; transform: translateY(-4px); } } }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s, transform 0.2s;
}
.pill svg { width: 12px; height: 12px; opacity: 0.6; }
.pill { cursor: pointer; }
.pill:hover { color: var(--ink); border-color: var(--faint); transform: translateY(-1px); }
.home.away .eyebrow, .home.away .links, .home.away .hint { opacity: 0; pointer-events: none; }
.eyebrow, .links { transition: opacity 0.4s; }

.pill.extra {
  --p: 0;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1;
  opacity: var(--p);
  transform: translateY(calc((1 - var(--p)) * 8px));
  transition: opacity 0.18s, transform 0.18s, color 0.2s, border-color 0.2s;
}
.pill.extra:focus-visible, .pill.extra.soon { --p: 1 !important; }
.pill.extra.soon { color: var(--ink); border-color: var(--faint); }
@media (prefers-reduced-motion: reduce) { .pill.extra { transition: none; } }

.lang {
  position: fixed; top: 16px; right: 16px; z-index: 1;
  display: flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel);
}
.lang button {
  border: 0; background: transparent;
  color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  padding: 6px 10px; border-radius: 8px;
  cursor: pointer;
}
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--line); color: var(--ink); }

/* ---------- Link confirmation ---------- */
.ask {
  position: fixed; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(8, 9, 11, 0.66);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: askFade 0.2s ease-out;
}
.ask[hidden] { display: none; }
.ask-card {
  position: relative;
  font-family: "Manrope", "DM Sans", "Segoe UI", system-ui, sans-serif;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  text-align: left;
  animation: askRise 0.28s cubic-bezier(.2,.8,.2,1);
}
.ask-head { display: flex; flex-direction: column; gap: 14px; }
.ask-card h2 { margin: 0; font-family: inherit; font-weight: 800; font-size: 22px; letter-spacing: -0.02em; line-height: 1.2; color: var(--ink); padding-right: 36px; }
.ask-addr { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; user-select: text; -webkit-user-select: text; }
.ask-copy {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.ask-copy svg { width: 15px; height: 15px; }
.ask-copy:hover { border-color: var(--faint); }
.ask-copy.done { color: var(--accent); border-color: var(--accent); }
.ask-dest {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
}
.ask-host { font-size: 20px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.ask-url { font-size: 14px; color: var(--soft); overflow-wrap: anywhere; }
.ask-check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--soft); cursor: pointer; }
.ask-check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
.ask-row { display: flex; gap: 10px; }
.ask-row .pill { flex: 1; justify-content: center; padding: 14px 18px; border-radius: 14px; font-size: 16px; color: var(--ink); background: transparent; cursor: pointer; }
.ask-row .primary { color: var(--bg); background: var(--ink); border-color: var(--ink); }
.ask-row .primary svg { opacity: 1; }
@keyframes askFade { from { opacity: 0; } }
@keyframes askRise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@media (max-width: 560px) {
  .ask { align-items: flex-end; padding: 0; }
  .ask-card { max-width: none; border-radius: 26px 26px 0 0; border-bottom: 0; padding: 14px 22px 26px; animation-name: askSheet; }
  .ask-card::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--faint); }
  @keyframes askSheet { from { transform: translateY(100%); } }
}
@media (prefers-reduced-motion: reduce) { .ask, .ask-card { animation: none; } }

/* ---------- Game ---------- */
.game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.35s;
}
.game[hidden] { display: none; }
.game.on { opacity: 1; }
.game {
  display: grid;
  grid-template-columns: 264px minmax(0, 560px);
  grid-template-rows: minmax(0, 1fr);
  justify-content: center;
  align-items: stretch;
  gap: 32px;
  padding: 24px;
}
.game.intro-open { grid-template-columns: minmax(0, 560px); grid-template-rows: minmax(0, 1fr); }
.game.intro-open .side { display: none; }
.side {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  max-height: 100%;
  overflow: auto;
}
.side-head { display: flex; flex-direction: column; gap: 8px; }
.side-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.05; color: var(--ink); }
.side-head p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--soft); }
.stats { display: flex; flex-direction: column; }
.stat { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.stat span { font-size: 14px; font-weight: 500; color: var(--soft); }
.stat b { font-size: 46px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat.next b { font-family: var(--display); font-weight: 400; font-size: 36px; color: var(--accent); min-height: 36px; }
.keys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.keys li { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink); }
.keys .k { display: inline-flex; gap: 4px; }
.keys kbd svg, .steps kbd svg { width: 13px; height: 13px; display: block; }
.keys kbd {
  font: inherit; font-size: 13px; font-weight: 600;
  min-width: 30px; padding: 4px 8px; text-align: center;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--faint); border-bottom-width: 2px; border-radius: 7px;
}
.keys kbd.space { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; padding: 7px 12px; }
.keys kbd.space svg { width: 34px; height: 12px; display: block; }
.close {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.close:hover { border-color: var(--faint); }
.main { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; min-height: 0; }
.stage { flex: 1; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: center; position: relative; }
canvas { display: block; }
.pad { display: none; gap: 10px; }
.pad button {
  width: 68px; height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}
.pad button { display: inline-flex; align-items: center; justify-content: center; }
.pad svg { width: 24px; height: 24px; display: block; }
.pad button:active { border-color: var(--accent); }
@media (pointer: coarse) { .pad { display: flex; } .keys { display: none; } }
@media (max-width: 760px) {
  .game { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 12px; padding: 12px; }
  .side { align-self: stretch; flex-direction: row; align-items: center; gap: 14px; padding: 10px 14px; overflow: visible; }
  .side-head, .keys { display: none; }
  .stats { flex-direction: row; gap: 18px; flex: 1; }
  .stat { flex-direction: column; align-items: flex-start; gap: 4px; padding: 0; border: 0; }
  .stat { flex-direction: row; align-items: baseline; gap: 8px; }
  .stat span { font-size: 13px; }
  .stat b { font-size: 24px; }
  .stat.next b { font-size: 24px; min-height: 24px; }
  .close { padding: 8px 12px; }
}

.msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  text-align: center;
  background: rgba(14, 15, 18, 0.72);
}
.msg[hidden] { display: none; }
.msg h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(30px, 6vw, 46px); line-height: 1.1; text-wrap: balance; }
.msg > * { position: relative; }
.msg #fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.msg p { margin: 0; color: var(--ink); font-size: 20px; font-weight: 500; line-height: 1.4; }
.msg #msgAuto { color: var(--soft); font-size: 18px; font-weight: 400; font-variant-numeric: tabular-nums; }
.msg.win { background: rgba(14, 15, 18, 0.88); }
.msg.win h2 { font-size: clamp(40px, 8vw, 72px); }
.msg .pill[hidden] { display: none; }
.msg .ent {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 20px; margin-left: 2px;
  border: 1px solid rgba(14, 15, 18, 0.25);
  border-bottom-width: 2px; border-radius: 5px;
  color: var(--bg);
}
.msg .ent svg { width: 12px; height: 12px; display: block; }
@media (pointer: coarse) { .msg .ent { display: none; } }
.msg .row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.msg button { cursor: pointer; }
.msg .row[hidden] { display: none; }
.msg .primary { color: var(--bg); background: var(--ink); border-color: var(--ink); }

/* ---------- How to play ---------- */
/* Demo fall order (time slots 1-5): aba (p4), Ca (p1), yev (p5), B (p3), vid (p2). */
.intro {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(14, 15, 18, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.intro[hidden] { display: none; }
.intro-card {
  position: relative;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.intro-card { font-family: "Manrope", "DM Sans", "Segoe UI", system-ui, sans-serif; }
.intro-card h2 { margin: 0; padding-right: 40px; font-family: inherit; font-weight: 800; font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; color: var(--ink); }
.demo { --dp: 28px; --dcell: 24px; --dhalf: 171px; --dwg: 10px;
  position: relative; height: 128px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; border-radius: 12px; background: var(--bg); }
.demo-row { display: flex; gap: calc(var(--dp) - var(--dcell)); padding-bottom: 10px; }
.demo-row span { width: var(--dcell); text-align: center; font-family: var(--display); font-size: 20px; color: var(--faint); }
.demo-row .wg { margin-left: var(--dwg); }
.demo-row .h1 { animation: demoH2 11s infinite; }
.demo-row .h2 { animation: demoH5 11s infinite; }
.demo-row .h3 { animation: demoH4 11s infinite; }
.demo-row .h4 { animation: demoH1 11s infinite; }
.demo-row .h5 { animation: demoH3 11s infinite; }
.demo-piece { position: absolute; bottom: 42px; display: flex; gap: calc(var(--dp) - var(--dcell)); }
.demo-piece.p1 { left: calc(50% - var(--dhalf)); animation: demoF2 11s infinite; }
.demo-piece.p2 { left: calc(50% - var(--dhalf) + var(--dp)*2); animation: demoF5 11s infinite; }
.demo-piece.p3 { left: calc(50% - var(--dhalf) + var(--dp)*5 + var(--dwg)); animation: demoF4 11s infinite; }
.demo-piece.p4 { left: calc(50% - var(--dhalf) + var(--dp)*6 + var(--dwg)); animation: demoF1 11s infinite; }
.demo-piece.p5 { left: calc(50% - var(--dhalf) + var(--dp)*9 + var(--dwg)); animation: demoF3 11s infinite; }
.demo-piece span {
  width: var(--dcell); height: var(--dcell);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--ink); color: var(--bg);
  font-family: var(--display); font-size: 17px;
  animation: demoTile 11s infinite;
}
@media (max-width: 500px) {
  .demo { --dp: 24px; --dcell: 20px; --dhalf: 146px; --dwg: 8px; }
  .demo-row span { font-size: 18px; }
  .demo-piece span { font-size: 15px; }
}
@keyframes demoTile {
  0%, 72% { background: var(--ink); }
  76%, 90% { background: var(--accent); }
  95%, 100% { background: var(--ink); }
}
@keyframes demoF1 {
  0%, 0% { transform: translateY(-84px); opacity: 0; }
  3% { opacity: 1; }
  13% { transform: translateY(0); }
  92% { transform: translateY(0); opacity: 1; }
  97%, 100% { transform: translateY(0); opacity: 0; }
}
@keyframes demoF2 {
  0%, 15% { transform: translateY(-84px); opacity: 0; }
  18% { opacity: 1; }
  27% { transform: translateY(0); }
  92% { transform: translateY(0); opacity: 1; }
  97%, 100% { transform: translateY(0); opacity: 0; }
}
@keyframes demoF3 {
  0%, 29% { transform: translateY(-84px); opacity: 0; }
  32% { opacity: 1; }
  39% { transform: translateY(0); }
  92% { transform: translateY(0); opacity: 1; }
  97%, 100% { transform: translateY(0); opacity: 0; }
}
@keyframes demoF4 {
  0%, 41% { transform: translateY(-84px); opacity: 0; }
  44% { opacity: 1; }
  53% { transform: translateY(0); }
  92% { transform: translateY(0); opacity: 1; }
  97%, 100% { transform: translateY(0); opacity: 0; }
}
@keyframes demoF5 {
  0%, 55% { transform: translateY(-84px); opacity: 0; }
  58% { opacity: 1; }
  67% { transform: translateY(0); }
  92% { transform: translateY(0); opacity: 1; }
  97%, 100% { transform: translateY(0); opacity: 0; }
}
@keyframes demoH1 {
  0%, 12% { color: var(--faint); }
  14%, 92% { color: var(--accent); }
  97%, 100% { color: var(--faint); }
}
@keyframes demoH2 {
  0%, 26% { color: var(--faint); }
  28%, 92% { color: var(--accent); }
  97%, 100% { color: var(--faint); }
}
@keyframes demoH3 {
  0%, 38% { color: var(--faint); }
  40%, 92% { color: var(--accent); }
  97%, 100% { color: var(--faint); }
}
@keyframes demoH4 {
  0%, 52% { color: var(--faint); }
  54%, 92% { color: var(--accent); }
  97%, 100% { color: var(--faint); }
}
@keyframes demoH5 {
  0%, 66% { color: var(--faint); }
  68%, 92% { color: var(--accent); }
  97%, 100% { color: var(--faint); }
}
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; font-weight: 500; line-height: 1.5; color: var(--soft); }
.steps .n {
  flex: none;
  width: 24px; height: 24px; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--line); color: var(--ink);
  font-size: 13px; font-weight: 600;
}
.intro-x, .ask-x {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.intro-x:hover, .ask-x:hover { background: var(--line); color: var(--ink); }
.intro-x svg, .ask-x svg { width: 17px; height: 17px; display: block; }
.steps .sk { display: flex; flex-direction: column; gap: 8px; }
.steps .sk-item { display: flex; align-items: center; gap: 8px; }
.steps .sk-item em { font-style: normal; color: var(--soft); }
.steps kbd {
  font: inherit; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 24px; padding: 0 6px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--faint); border-bottom-width: 2px; border-radius: 6px;
}
.steps .kset, .steps .pset { display: inline-flex; gap: 4px; }
.steps kbd.space svg { width: 22px; height: 8px; display: block; }
.steps .pset { display: none; }
.steps .pset svg { width: 14px; height: 14px; display: block; }
@media (pointer: coarse) { .steps .kset { display: none; } .steps .pset { display: inline-flex; } }
.intro-card .pill.primary { justify-content: center; padding: 13px 18px; font-size: 16px; cursor: pointer; color: var(--bg); background: var(--ink); border-color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .demo-piece, .demo-piece span, .demo-row span { animation: none; } }

@media (prefers-reduced-motion: reduce) {
  .name .ch, .name.falling .ch, .game, .hint, .pill { transition-duration: 0.01s; transition-delay: 0s; } .hint { animation: none; }
}
