/* Where Agents Go: one stylesheet for the lobby, the notes page and the game frame. */

:root {
  --ink: #0b0d10;
  --ink-2: #14181d;
  --ink-3: #1c2128;
  --paper: #e8ecef;
  --muted: #8a94a3;
  --line: rgba(232, 236, 239, 0.13);
  --coral: #e5484d;
  --aqua: #2bd4c4;
  --amber: #f5a524;
  --violet: #6ea8fe;
  --accent: var(--coral);
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: "Inter", "Helvetica Neue", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 4px;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-size: 16.5px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body { margin: 0; min-height: 100svh; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow.small { margin-top: 18px; }

kbd {
  font-family: var(--mono);
  font-size: 0.68em;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 6px;
  background: rgba(11, 13, 16, 0.28);
  border: 1px solid rgba(11, 13, 16, 0.3);
}
@media (pointer: coarse) { kbd { display: none; } }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--ink-3);
  color: var(--paper);
  font-weight: 650;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: rgba(232, 236, 239, 0.35); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.ghost kbd, .btn:not(.primary) kbd { background: rgba(232, 236, 239, 0.08); border-color: var(--line); }

.link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  background: none;
  border: 0;
  padding: 0 2px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: 0.85rem;
}
.link:hover { color: var(--paper); }

/* ---------- game frame ---------- */

.game-page {
  height: 100svh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
.game-page #app { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.bar {
  flex: none;
  height: 58px;
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: var(--ink);
}
.bar-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 3px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.bar-back:hover { color: var(--paper); background: var(--ink-2); }

.hud { display: flex; align-items: baseline; justify-content: center; gap: 12px; white-space: nowrap; min-width: 0; }
.hud-score { font-family: var(--mono); font-weight: 500; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.hud-sub { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) {
  .bar-back-label { display: none; }
  .bar-back { padding: 0 14px; }
  .hud { gap: 8px; }
  .hud-score { font-size: 1.25rem; }
  .hud-sub { font-size: 0.68rem; letter-spacing: 0.04em; }
  .bar-tools { gap: 0; }
}

.bar-tools { justify-self: end; display: flex; gap: 6px; }
.tool {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tool:hover { color: var(--paper); background: var(--ink-2); border-color: var(--line); }
.tool svg { width: 22px; height: 22px; fill: currentColor; }

.stage { position: relative; flex: 1; min-height: 0; }
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
  cursor: crosshair;
}
/* Keyboard players can see when the play area has focus. */
.stage canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -5px; }

.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -12px);
  padding: 9px 16px;
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 650;
  font-size: 0.88rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.ov {
  position: absolute;
  inset: 0;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  background: rgba(11, 13, 16, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  user-select: text;
  -webkit-user-select: text;
}
.ov[hidden] { display: none; }
.ov[data-kind="over"] { background: rgba(11, 13, 16, 0.6); }
/* Before a run, let more of the exercise's own scene show around the briefing card. */
.ov[data-kind="title"] { background: rgba(11, 13, 16, 0.56); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@media (min-width: 900px) and (min-height: 640px) {
  .ov[data-kind="title"] .card { width: min(520px, 100%); }
}

.card {
  /* Auto margins centre the card when it fits and let a tall one scroll from its top. */
  margin: auto;
  width: min(460px, 100%);
  padding: clamp(22px, 5vw, 34px);
  border-radius: 6px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(28, 33, 40, 0.96), rgba(20, 24, 29, 0.96));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: rise 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

.card h1 { font-size: clamp(2.1rem, 8vw, 3rem); line-height: 1; font-weight: 800; letter-spacing: -0.03em; margin: 8px 0 12px; }
.card .pitch { font-size: 1.08rem; color: var(--paper); }
.card .how { margin: 18px 0 16px; display: grid; gap: 9px; counter-reset: how; }
.card .how li {
  counter-increment: how;
  position: relative;
  padding-left: 34px;
  color: var(--muted);
  font-size: 0.95rem;
}
.card .how li::before {
  content: counter(how);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink);
  background: var(--accent);
}
.card .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.card .row .btn { white-space: nowrap; flex: 1 1 auto; }
.card .best { margin-top: 14px; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.card .best b { color: var(--paper); font-weight: 500; }
.card .extra { margin-top: 16px; padding: 12px 14px; border-radius: 3px; border: 1px dashed var(--line); font-size: 0.92rem; color: var(--muted); }
.card .extra b { color: var(--paper); }

.hook { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.hook summary::-webkit-details-marker { display: none; }
.hook summary::after { content: "+"; margin-left: auto; font-size: 1.1rem; letter-spacing: 0; }
.hook[open] summary::after { content: "\2013"; }
.hook summary { cursor: pointer; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); min-height: 48px; display: flex; align-items: center; }
.hook p { margin-top: 8px; color: var(--muted); font-size: 0.92rem; }

.prefs { margin-top: 2px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; }

.bigscore {
  margin-top: 6px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(3rem, 14vw, 4.6rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.delta { margin-top: 4px; color: var(--muted); }
.delta.good { color: var(--paper); font-weight: 650; }
.lines { margin-top: 16px; display: grid; gap: 6px; font-family: var(--mono); font-size: 0.86rem; color: var(--muted); }
.stamps-new { margin-top: 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.stamps-new li { display: flex; flex-direction: column; padding: 10px 14px; border-radius: 3px; border: 1px solid var(--accent); }
.stamps-new span { color: var(--muted); font-size: 0.85rem; }

/* ---------- lobby ---------- */

.site { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }

.masthead { display: flex; flex-wrap:wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 0; }
.wordmark { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 750; letter-spacing: -0.02em; font-size: 1.1rem; }
.wordmark i { width: 28px; height: 28px; border-radius: 50%; background: conic-gradient(from 210deg, var(--coral), var(--amber), var(--aqua), var(--violet), var(--coral)); position: relative; flex: none; }
.wordmark i::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--ink); }
.wordmark { white-space: nowrap; min-height: 48px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.masthead nav { display: flex; gap: 6px; }
.masthead nav a { white-space: nowrap; }
@media (max-width: 560px) {
  /* On a phone the page is short enough to scroll; keep only the link that leaves it. */
  .masthead nav a[href^="#"], .masthead nav a[href*="/#"] { display: none; }
}
.masthead nav a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px; border-radius: 3px; color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.masthead nav a:hover { color: var(--paper); background: var(--ink-2); }

.hero { position: relative; margin: 0 calc(-1 * var(--gutter)); padding: clamp(28px, 7vw, 76px) var(--gutter) clamp(28px, 5vw, 56px); overflow: hidden; border-radius: 0; }
.hero-copy { position: relative; display: grid; gap: 20px; max-width: 34rem; }
.hero h1 { font-size: clamp(2.5rem, 8vw, 5rem); line-height: 0.96; letter-spacing: -0.045em; font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--amber); }
.hero p { max-width: 50ch; font-size: 1.1rem; color: #b6bec9; }
.hero p b { color: var(--paper); font-weight: 600; }
/* The painting fills the hero; its left side is painted dark and quiet, and a wash keeps the words readable. */
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 78% 50%; }
.hero.has-art { min-height: clamp(420px, 56vw, 640px); display: flex; align-items: center; }
.hero.has-art::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, rgba(11, 13, 16, 0.94) 0%, rgba(11, 13, 16, 0.82) 34%, rgba(11, 13, 16, 0.18) 62%, rgba(11, 13, 16, 0) 80%), linear-gradient(0deg, rgba(11, 13, 16, 0.9), rgba(11, 13, 16, 0) 22%); }
.hero.has-art .hero-copy { z-index: 2; }
@media (max-width: 720px) {
  .hero.has-art { align-items: flex-end; min-height: 560px; }
  .hero-art { object-position: 70% 20%; height: 62%; }
  .hero.has-art::before { background: linear-gradient(0deg, rgba(11, 13, 16, 1) 0%, rgba(11, 13, 16, 0.96) 46%, rgba(11, 13, 16, 0) 72%); }
}

.dailies { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-top: 22px; }
.daily {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent) 2%, transparent) 60%);
  text-decoration: none;
}
.daily h2 { font-size: 1.2rem; letter-spacing: -0.02em; margin-top: 4px; }
.daily p { color: var(--muted); font-size: 0.95rem; }
@media (max-width: 560px) { .daily { grid-template-columns: 1fr; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: clamp(36px, 6vw, 64px) 0 18px; }
.section-head h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); letter-spacing: -0.03em; }
.section-head p { color: var(--muted); font-family: var(--mono); font-size: 0.86rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--ink-2);
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.game-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.game-card canvas { display: block; width: 100%; aspect-ratio: 16 / 10; background: var(--ink); }
.game-card .cover { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--ink-3); }
.game-card .skill { font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.game-card .body { padding: 18px 20px 20px; display: grid; gap: 8px; flex: 1; }
.game-card h3 { font-size: 1.45rem; letter-spacing: -0.025em; display: flex; align-items: center; gap: 10px; }
.game-card h3::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.game-card .pitch { color: var(--muted); font-size: 0.96rem; }
.game-card .meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.game-card .foot { margin-top: auto; padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-card .play { font-weight: 700; color: var(--accent); }
.game-card .record { font-family: var(--mono); font-size: 0.86rem; color: var(--muted); }
.game-card .record b { color: var(--paper); font-weight: 500; }
.dots { display: inline-flex; gap: 5px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
/* A last card alone on its row spans the row, picture beside text, instead of leaving two gaps. */
@media (min-width: 900px) {
  .grid > .game-card:last-child:nth-child(3n + 1) { grid-column: 1 / -1; flex-direction: row; }
  .grid > .game-card:last-child:nth-child(3n + 1) > :first-child { width: 50%; flex: none; }
  .grid > .game-card:last-child:nth-child(3n + 1) .body { align-content: center; }
}

.passport { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.passport section { padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--line); }
.passport h3 { font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.passport h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.passport li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 6px 0; color: var(--muted); font-size: 0.88rem; }
.passport li b { display: block; color: var(--muted); font-weight: 600; }
.passport li.on b { color: var(--paper); }
.passport li::before { content: ""; width: 16px; height: 16px; margin-top: 3px; border-radius: 50%; border: 1.5px dashed var(--muted); }
.passport li.on::before { border: 0; background: var(--accent); }

.principles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.principles article { padding: 20px; border-radius: var(--radius); background: var(--ink-2); border: 1px solid var(--line); }
.principles h3 { font-size: 1.05rem; margin-bottom: 6px; letter-spacing: -0.01em; }
.principles p { color: var(--muted); font-size: 0.93rem; }

.footer { margin-top: clamp(44px, 8vw, 90px); padding: 26px 0 40px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 28px; justify-content: space-between; color: var(--muted); font-size: 0.86rem; }
.footer a { text-underline-offset: 3px; }

/* ---------- notes page ---------- */

.prose { max-width: 74ch; padding-bottom: 20px; }
.prose h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1; letter-spacing: -0.04em; margin: clamp(20px, 5vw, 48px) 0 16px; }
.prose h2 { font-size: 1.5rem; letter-spacing: -0.02em; margin: 44px 0 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 1.2rem; margin: 24px 0 4px; color: var(--paper); }
.prose p { color: #b6bec9; margin: 10px 0; }
.prose p.lede { font-size: 1.15rem; color: var(--paper); }
.prose ul { display: grid; gap: 8px; margin: 12px 0; padding-left: 20px; list-style: disc; color: #b6bec9; }
.prose li::marker { color: var(--muted); }
.prose a { color: var(--paper); text-underline-offset: 3px; }
.prose .tag { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.prose .tag.weak { border-color: rgba(255, 194, 75, 0.5); color: var(--amber); }
.prose table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.92rem; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.prose td { color: #b6bec9; }
@media (max-width: 560px) {
  .prose table { font-size: 0.84rem; }
  .prose th, .prose td { padding: 8px 6px; overflow-wrap: anywhere; }
  .prose th { letter-spacing: 0.04em; }
}
.sources { font-size: 0.86rem; }
.sources li { overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- course styling: condensed capitals for headings, mono for labels ---------- */
h1, h2, h3, .card h1, .wordmark, .bigscore { font-family: var(--display); }
.hero h1, .card h1, .prose h1 { text-transform: uppercase; letter-spacing: 0.005em; font-weight: 700; line-height: 0.92; }
.hero h1 { font-size: clamp(3rem, 9.5vw, 6.2rem); }
.hero h1 em { color: var(--paper); opacity: 0.55; }
.section-head h2, .game-card h3, .daily h2, .passport h3, .principles h3, .prose h2 { text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.game-card h3 { font-size: 1.7rem; }
.game-card h3::before, .passport h3::before { border-radius: 0; width: 4px; height: 0.9em; }
.btn { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.82rem; font-weight: 500; }
.wordmark { text-transform: uppercase; letter-spacing: 0.14em; font-size: 1.05rem; font-weight: 600; gap: 10px; }
.wordmark i { width: 22px; height: 22px; border-radius: 50%; background: none; border: 2px solid var(--paper); border-right-color: var(--coral); }
.wordmark i::after { display: none; }
.bigscore { font-family: var(--mono); letter-spacing: -0.02em; }
.game-card, .card, .daily, .passport section, .principles article { border-radius: 4px; }
.game-card .skill { display: flex; gap: 10px; color: var(--muted); }
.game-card .skill b { color: var(--accent); font-weight: 500; }
.dots i, .passport li::before { border-radius: 1px; }
.setting-head { margin: clamp(30px, 5vw, 52px) 0 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.setting-head h3 { font-size: 1.25rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.setting-head p { color: var(--muted); font-size: 0.95rem; max-width: 62ch; }
.hero p.disclaimer { margin-top: 6px; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* Very narrow phones: keep the header inside the screen. */
@media (max-width: 380px) {
  .wordmark { letter-spacing: 0.05em; font-size: 0.95rem; gap: 8px; }
  .wordmark i { width: 18px; height: 18px; }
  header nav a { font-size: 0.85rem; }
}
