/* ─────────────────────────────────────────────
   SLOP RUNNER — style.css
   Aesthetic: Kinetic Brutalism
   Fonts: Bebas Neue (display) + IBM Plex Mono (body)
───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=IBM+Plex+Mono:wght@400;500;700&display=swap');

/* ── Variables ──────────────────────────────── */
:root {
  --bg: #F0EBE1;
  --bg-2: #E8E2D6;
  --ink: #1A1A1A;
  --ink-2: #3A3A3A;
  --ink-muted: #7A7A7A;
  --red: #E63B2E;
  --green: #00A878;
  --slate: #8A9BB0;
  --white: #FAFAF8;
  --active-color: #E63B2E;
  --active-accent: #FF6B5B;

  --font-display: 'Bebas Neue', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 3px;
  --border: 2px solid var(--ink);
  --shadow: 4px 4px 0px var(--ink);
  --shadow-sm: 2px 2px 0px var(--ink);
  --transition: 120ms ease-out;
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  cursor: crosshair;
}
button { cursor: crosshair; font-family: var(--font-mono); border: none; background: none; }
input, textarea { font-family: var(--font-mono); }

/* ── Grain texture overlay ──────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
}

/* ── HUD ────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: var(--ink);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 3px solid var(--active-color);
}
.hud-left { display: flex; align-items: center; gap: 16px; }
.hud-logo {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--white);
}
.hud-logo span { color: var(--red); }
#hud-rank { font-size: 11px; font-weight: 700; letter-spacing: 2px; }
.hud-right { display: flex; align-items: center; gap: 20px; font-size: 11px; }
#hud-xp { color: var(--slate); }
#hud-streak { color: var(--red); font-weight: 700; }

/* ── Phase container ────────────────────────── */
#app { padding-top: 48px; min-height: 100vh; }

.phase { display: none; min-height: calc(100vh - 48px); animation: phase-in 200ms ease-out; }
.phase.active { display: block; }

@keyframes phase-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── MENU PHASE ─────────────────────────────── */
#phase-menu {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 40px 20px;
}
#phase-menu.active { display: flex; }

.menu-eyebrow { font-size: 11px; letter-spacing: 4px; color: var(--ink-muted); margin-bottom: 16px; }
.menu-title {
  font-family: var(--font-display);
  font-size: clamp(64px, 12vw, 130px);
  line-height: 0.9;
  letter-spacing: 4px;
}
.menu-title span { color: var(--red); }
.menu-subtitle { font-size: 13px; color: var(--ink-muted); margin-top: 16px; max-width: 400px; line-height: 1.6; }

/* Rank card on menu */
.menu-rank-card {
  margin-top: 28px;
  width: 100%;
  max-width: 440px;
  background: var(--white);
  color: var(--ink);
  border: var(--border);
  border-left: 6px solid var(--active-rank-color, var(--slate));
  box-shadow: var(--shadow);
  padding: 20px 24px;
  text-align: left;
}
.menu-rank-row { display: flex; justify-content: space-between; align-items: baseline; }
#menu-rank {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 3px;
}
#menu-xp { font-size: 12px; color: var(--ink-muted); font-weight: 700; }
#menu-rank-title { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); margin-top: 2px; text-transform: uppercase; }
#menu-rank-desc { font-size: 12px; line-height: 1.6; color: var(--ink-2); margin-top: 8px; }
.rank-progress-track {
  height: 5px;
  background: var(--bg-2);
  border: 1px solid var(--ink);
  margin-top: 12px;
}
.rank-progress-fill { height: 100%; transition: width 600ms ease; }
#menu-next-rank { font-size: 10px; color: var(--ink-muted); letter-spacing: 1px; margin-top: 6px; }

.menu-actions { display: flex; gap: 12px; margin-top: 24px; }
.btn-primary {
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 4px;
  padding: 14px 40px;
  border: var(--border);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.btn-primary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--ink);
  background: var(--red);
}
.btn-primary:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 3px;
  padding: 14px 32px;
  border: var(--border);
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.btn-secondary:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--ink);
}

.menu-hint { margin-top: 20px; font-size: 10px; color: var(--slate); letter-spacing: 1px; }

/* ── HOW TO PLAY PHASE ──────────────────────── */
#phase-howto {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px;
  max-width: 680px;
  margin: 0 auto;
}
#phase-howto.active { display: flex; }

.howto-title { font-family: var(--font-display); font-size: 56px; letter-spacing: 4px; align-self: flex-start; margin-bottom: 8px; }
.howto-subtitle { font-size: 12px; letter-spacing: 3px; color: var(--ink-muted); align-self: flex-start; margin-bottom: 32px; }

.howto-steps { width: 100%; display: flex; flex-direction: column; }
.howto-step {
  display: grid;
  grid-template-columns: 56px 1fr;
  border: var(--border);
  border-bottom: none;
  background: var(--white);
}
.howto-step:last-child { border-bottom: var(--border); }
.howto-step-num {
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--white);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: var(--border);
  padding: 16px 0;
}
.howto-step-body { padding: 16px 20px; }
.howto-step-title { font-size: 13px; font-weight: 700; letter-spacing: 2px; margin-bottom: 4px; }
.howto-step-desc { font-size: 12px; line-height: 1.6; color: var(--ink-2); }
.howto-step-accent { color: var(--red); font-weight: 700; }

/* Cue mechanic explainer */
.howto-cue-demo {
  width: 100%;
  margin-top: 24px;
  border: var(--border);
  padding: 16px 20px;
  background: var(--white);
}
.howto-cue-label { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); margin-bottom: 12px; }
.howto-cue-states { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-cue {
  padding: 8px 14px;
  border: 2px solid var(--ink);
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
}
.demo-cue.neutral { background: var(--bg); }
.demo-cue.correct { background: var(--ink); color: var(--green); border-color: var(--green); box-shadow: 2px 2px 0 var(--green); }
.demo-cue.wrong { background: var(--ink); color: var(--red); border-color: var(--red); box-shadow: 2px 2px 0 var(--red); }
.demo-cue.pending { background: var(--ink); color: var(--white); border-color: var(--slate); }

.howto-frameworks { width: 100%; margin-top: 24px; }
.howto-fw-label { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); margin-bottom: 12px; }
.howto-fw-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.howto-fw-chip { border: var(--border); padding: 10px 6px; text-align: center; font-family: var(--font-display); font-size: 14px; letter-spacing: 1px; }

.howto-scoring {
  width: 100%;
  margin-top: 24px;
  border: var(--border);
  background: var(--ink);
  color: var(--white);
  padding: 20px;
}
.howto-scoring-title { font-family: var(--font-display); font-size: 22px; letter-spacing: 2px; margin-bottom: 12px; color: var(--red); }
.howto-score-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px solid #333; }
.howto-score-row:last-child { border-bottom: none; }
.howto-score-pts { color: var(--green); font-weight: 700; }
.howto-score-pts.neg { color: var(--red); }

/* ── DOMAIN SELECT PHASE ────────────────────── */
#phase-domain {
  display: none;
  flex-direction: column;
  padding: 40px 20px;
  max-width: 900px;
  margin: 0 auto;
}
#phase-domain.active { display: flex; }

.domain-header { margin-bottom: 32px; }
.domain-eyebrow { font-size: 10px; letter-spacing: 4px; color: var(--ink-muted); margin-bottom: 8px; }
.domain-title { font-family: var(--font-display); font-size: 48px; letter-spacing: 2px; }

#domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.domain-card {
  background: var(--white);
  border: var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: left;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.domain-card:hover {
  transform: translate(-3px, -3px);
  box-shadow: 7px 7px 0px var(--ink);
  border-color: var(--fw-color);
}
.domain-card:active { transform: translate(2px, 2px); box-shadow: none; }
.domain-label { font-family: var(--font-display); font-size: 32px; letter-spacing: 2px; color: var(--fw-color); line-height: 1; }
.domain-name { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: var(--ink-muted); }
.domain-desc { font-size: 12px; color: var(--ink-2); line-height: 1.5; margin-top: 4px; }
.domain-mastery { height: 3px; background: var(--bg-2); margin-top: 16px; }
.mastery-bar { height: 100%; transition: width 600ms ease; }
.domain-mastery-label { font-size: 10px; color: var(--ink-muted); letter-spacing: 1px; }

.btn-back { background: none; border: none; font-size: 11px; letter-spacing: 2px; color: var(--ink-muted); padding: 8px 0; align-self: flex-start; margin-top: 24px; }
.btn-back:hover { color: var(--ink); }

/* ── LOADING PHASE ──────────────────────────── */
#phase-loading { display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }
#phase-loading.active { display: flex; }
.loading-label { font-size: 10px; letter-spacing: 4px; color: var(--ink-muted); }
#loading-domain { font-family: var(--font-display); font-size: 64px; letter-spacing: 4px; animation: loading-pulse 1s ease-in-out infinite; }
@keyframes loading-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.loading-dots { color: var(--ink-muted); font-size: 20px; letter-spacing: 8px; }

/* ── PLAYING PHASE ──────────────────────────── */
#phase-playing { display: none; flex-direction: column; height: calc(100vh - 48px); overflow: hidden; }
#phase-playing.active { display: flex; }

#timer-bar { height: 6px; background: var(--bg-2); flex-shrink: 0; }
#timer-bar-fill { height: 100%; background: var(--active-color); transition: width 1s linear, background 500ms; width: 100%; }

#play-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--bg-2); flex-shrink: 0; }
#play-domain-badge { font-family: var(--font-display); font-size: 18px; letter-spacing: 3px; color: var(--white); padding: 2px 12px; }
#timer-display { font-family: var(--font-display); font-size: 36px; letter-spacing: 2px; color: var(--active-color); transition: color 500ms; min-width: 80px; text-align: right; }
@keyframes timer-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.timer-pulse { animation: timer-beat 0.5s ease-in-out infinite; }

#play-body { display: grid; grid-template-columns: 1fr 340px; flex: 1; overflow: hidden; }

#scenario-panel { padding: 24px; border-right: 2px solid var(--ink); display: flex; flex-direction: column; overflow-y: auto; }
.scenario-eyebrow { font-size: 10px; letter-spacing: 4px; color: var(--ink-muted); margin-bottom: 16px; }
#scenario-text { font-size: 15px; line-height: 1.8; color: var(--ink); flex: 1; }

.word-reveal { display: inline; opacity: 0; animation: word-in 300ms ease forwards; }
@keyframes word-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes inject-flash {
  0% { background: transparent; }
  30% { background: color-mix(in srgb, var(--active-color) 12%, transparent); }
  100% { background: transparent; }
}
.cue-injected { animation: inject-flash 600ms ease; border-radius: 2px; }

#fallback-notice { display: none; font-size: 10px; color: var(--slate); letter-spacing: 1px; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--slate); }

#verdict-area { margin-top: 20px; padding-top: 20px; border-top: 2px solid var(--ink); flex-shrink: 0; }
.verdict-label { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); margin-bottom: 8px; }
#verdict-input {
  width: 100%;
  background: var(--bg-2);
  border: 2px solid var(--ink);
  padding: 12px;
  font-size: 13px;
  color: var(--ink);
  resize: none;
  height: 72px;
  outline: none;
  transition: border-color var(--transition);
}
#verdict-input:focus { border-color: var(--active-color); }
#verdict-input:disabled { opacity: 0.5; }

#submit-btn {
  margin-top: 10px;
  width: 100%;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 4px;
  padding: 12px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
#submit-btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); background: var(--active-color); }
#submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Toolkit panel ──────────────────────────── */
#toolkit-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--white); }
#toolkit-header { padding: 16px 20px 12px; border-bottom: 2px solid var(--ink); flex-shrink: 0; }
.toolkit-eyebrow { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); margin-bottom: 2px; }
.toolkit-title { font-family: var(--font-display); font-size: 22px; letter-spacing: 2px; }
.toolkit-hint { font-size: 10px; color: var(--slate); margin-top: 2px; }

#cue-deck { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
#cue-deck::-webkit-scrollbar { width: 4px; }
#cue-deck::-webkit-scrollbar-thumb { background: var(--bg-2); }

/* ── Cue card states ────────────────────────── */
.cue-card {
  background: var(--bg);
  border: 2px solid var(--ink);
  padding: 12px;
  text-align: left;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: crosshair;
}
.cue-card:hover:not(:disabled):not(.selected-pending):not(.cue-correct):not(.cue-wrong) {
  transform: translateX(-3px);
  border-color: var(--fw-color);
  background: var(--white);
}

/* Pending — selected but not yet revealed */
.cue-card.selected-pending {
  background: var(--ink);
  color: var(--white);
  border-color: var(--slate);
  box-shadow: 2px 2px 0 var(--slate);
  cursor: not-allowed;
}
.cue-card.selected-pending .cue-id { color: var(--slate); }
.cue-card.selected-pending .cue-flags { color: #666; }

/* Correct — revealed green after submit */
.cue-card.cue-correct {
  background: var(--ink);
  color: var(--white);
  border-color: var(--green) !important;
  box-shadow: 3px 3px 0 var(--green) !important;
  cursor: default;
}
.cue-card.cue-correct .cue-id { color: var(--green) !important; }
.cue-card.cue-correct .cue-text { color: var(--white); }
.cue-card.cue-correct .cue-flags { color: #aaa; }

/* Wrong — selected but incorrect, revealed red after submit */
.cue-card.cue-wrong {
  background: var(--ink);
  color: var(--white);
  border-color: var(--red) !important;
  box-shadow: 3px 3px 0 var(--red) !important;
  cursor: default;
}
.cue-card.cue-wrong .cue-id { color: var(--red) !important; }
.cue-card.cue-wrong .cue-text { color: var(--white); }
.cue-card.cue-wrong .cue-flags { color: #888; }

.cue-id { font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--active-color); }
.cue-text { font-size: 13px; font-weight: 700; line-height: 1.3; }
.cue-flags { font-size: 10px; color: var(--ink-muted); line-height: 1.4; }

/* ── Slop meter ─────────────────────────────── */
#slop-section { padding: 12px 16px; border-top: 2px solid var(--ink); flex-shrink: 0; }
.slop-label { font-size: 10px; letter-spacing: 3px; color: var(--ink-muted); display: flex; justify-content: space-between; margin-bottom: 6px; }
#slop-value { color: var(--ink); font-weight: 700; }
#slop-track { height: 12px; background: var(--bg-2); border: 2px solid var(--ink); }
#slop-fill { height: 100%; background: var(--green); transition: width 500ms ease, background 500ms; }

/* ── RESULT PHASE ───────────────────────────── */
/*
   Design principle: raw terminal readout on cream.
   No filled dark cards. Everything lives on the bg.
   Colour = accent lines, tags, and labels only.
   Energy comes from large type + tight contrast.
*/
#phase-result {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 64px;
  max-width: 640px;
  margin: 0 auto;
}
#phase-result.active { display: flex; }

/* ── Verdict + score hero ── */
.result-hero { text-align: center; width: 100%; }

.result-verdict {
  font-family: var(--font-display);
  font-size: clamp(72px, 14vw, 110px);
  letter-spacing: 8px;
  line-height: 0.9;
  display: block;
}
.result-verdict.correct  { color: var(--green); }
.result-verdict.incorrect { color: var(--red); }

.result-points {
  font-family: var(--font-display);
  font-size: 52px;
  letter-spacing: 3px;
  display: block;
  margin-top: 6px;
}
.result-points.positive { color: var(--green); }
.result-points.negative { color: var(--red); }

/* Quip line */
#result-quip {
  display: block;
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 14px;
  padding: 8px 16px;
  border-left: 4px solid currentColor;
  text-align: left;
  align-self: flex-start;
  line-height: 1.5;
  max-width: 480px;
}
#result-quip.quip-correct { color: var(--green); }
#result-quip.quip-close   { color: #0891B2; }
#result-quip.quip-miss    { color: var(--ink-muted); }

.result-meta {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--ink-muted);
  text-transform: uppercase;
  align-self: flex-start;
}
.result-meta span::before { content: "▸ "; }

/* ── Divider ── */
.result-divider {
  width: 100%;
  border: none;
  border-top: 2px solid var(--ink);
  margin: 28px 0 20px;
}

/* ── Section labels ── */
.result-section-label {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--ink-muted);
  text-transform: uppercase;
  align-self: flex-start;
  margin-bottom: 10px;
}

/* ── Rank-up banner ── */
#result-rankup {
  display: none;
  width: 100%;
  padding: 12px 20px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 4px;
  text-align: center;
  border-top: 4px solid currentColor;
  border-bottom: 4px solid currentColor;
  margin-bottom: 20px;
  animation: rankup-flash 0.6s ease-in-out 5;
}
@keyframes rankup-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Rank readout ── */
.result-rank-card {
  width: 100%;
  padding: 0;
  border-left: 5px solid var(--slate);  /* overridden inline with rank colour */
  padding-left: 16px;
  background: transparent;
}
.result-rank-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
#result-rank-name {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 4px;
  line-height: 1;
}
#result-rank-title {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--ink-muted);
  text-transform: uppercase;
}
#result-rank-desc {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-top: 6px;
  max-width: 460px;
}
.rank-progress-track {
  height: 4px;
  background: var(--bg-2);
  border: 1px solid var(--ink);
  margin-top: 12px;
}
#result-rank-progress-fill { height: 100%; transition: width 900ms ease; }
#result-next-rank {
  font-size: 10px;
  color: var(--ink-muted);
  letter-spacing: 1px;
  margin-top: 5px;
}

/* ── Flaw readout ── */
.result-flaw-card {
  width: 100%;
  padding: 0;
  border-left: 5px solid var(--red);
  padding-left: 16px;
  background: transparent;
}
#result-flaw-tag {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 3px;
  color: var(--red);
  line-height: 1;
}
#result-flaw-desc {
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-top: 8px;
  max-width: 480px;
}

/* ── Correct cues ── */
#result-correct-cues { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.result-cue-item {
  font-size: 12px;
  padding: 8px 14px;
  background: transparent;
  border-left: 4px solid var(--green);
  padding-left: 14px;
  line-height: 1.4;
  font-weight: 700;
  color: var(--ink-2);
}

/* ── Session readout ── */
.result-session {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: transparent;
}
.result-session-col {
  padding: 16px 20px;
}
.result-session-col:first-child {
  border-right: 2px solid var(--ink);
}
.result-session-label {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: block;
}
.result-session-val {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 1px;
  color: var(--ink);
  display: block;
}

/* ── Action buttons ── */
.result-actions { display: flex; gap: 12px; margin-top: 28px; width: 100%; }
.btn-action {
  flex: 1;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 3px;
  padding: 14px 12px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.btn-action:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
  background: var(--active-color);
}
.btn-action.secondary { background: var(--bg); color: var(--ink); }
.btn-action.secondary:hover { background: var(--red); color: var(--white); }

/* ── Global scrollbar ───────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--ink-muted); }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 640px) {
  #play-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #toolkit-panel { border-right: none; border-top: 2px solid var(--ink); max-height: 280px; }
  #scenario-panel { border-right: none; }
  .result-actions { flex-direction: column; }
  #phase-result { padding: 32px 16px; }
  .menu-actions { flex-direction: column; align-items: center; }
  .howto-fw-grid { grid-template-columns: repeat(3, 1fr); }
}
/* ═══════════════════════════════════════════════
   NEW SECTIONS — Recipe, Profile, Library, Commons
═══════════════════════════════════════════════ */

/* ── Menu secondary links ───────────────────── */
.menu-secondary-actions {
  display: flex;
  gap: 24px;
  margin-top: 12px;
}
.btn-text-link {
  background: none;
  border: none;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--ink-muted);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}
.btn-text-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ── Profile Prompt Phase ───────────────────── */
#phase-profile-prompt {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 48px 24px;
}
#phase-profile-prompt.active { display: flex; }

.profile-prompt-wrap {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.profile-prompt-eyebrow {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--ink-muted);
}
.profile-prompt-q {
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 2px;
  line-height: 1.1;
}
.profile-prompt-sub {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
}
.profile-prompt-input,
.profile-prompt-select {
  width: 100%;
  background: var(--white);
  border: var(--border);
  padding: 14px 16px;
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--ink);
  outline: none;
  margin-top: 8px;
  box-shadow: var(--shadow-sm);
}
.profile-prompt-input:focus { border-color: var(--green); }
.profile-prompt-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

/* ── Profile Full Screen ────────────────────── */
#phase-profile,
#phase-library,
#phase-commons {
  display: none;
  flex-direction: column;
  padding: 48px 24px;
}
#phase-profile.active,
#phase-library.active,
#phase-commons.active { display: flex; }

.settings-wrap,
.library-wrap {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.settings-eyebrow {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.settings-title {
  font-family: var(--font-display);
  font-size: 48px;
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.settings-sub {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin-bottom: 28px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.settings-label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--ink-muted);
  font-weight: 700;
}
.settings-input {
  background: var(--white);
  border: var(--border);
  padding: 12px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--ink);
  outline: none;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.settings-input:focus { border-color: var(--green); }
.settings-textarea {
  height: 80px;
  resize: vertical;
}

/* ── Library filters ────────────────────────── */
.library-filters {
  margin-bottom: 20px;
}
.library-filter-select {
  max-width: 220px;
}

/* ── Library / Commons card ─────────────────── */
.library-card {
  background: var(--white);
  border: var(--border);
  border-left: 5px solid var(--fw-color, var(--ink));
  box-shadow: var(--shadow-sm);
  padding: 20px 20px 16px;
  margin-bottom: 16px;
}
.library-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.library-card-domain {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 2px;
}
.library-card-flaw {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink-muted);
}
.library-card-skill {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  line-height: 1.4;
}
.library-card-meta {
  font-size: 10px;
  color: var(--slate);
  letter-spacing: 1px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--bg-2);
}
.library-empty,
.commons-empty,
.commons-loading {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
  padding: 24px 0;
}

/* ── Recipe fields (shared by draft + library) ─ */
.recipe-field {
  margin-bottom: 12px;
}
.recipe-field-label {
  display: block;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--ink-muted);
  margin-bottom: 3px;
}
.recipe-field-value {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.recipe-action-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.recipe-action-list li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ── Recipe capture on result screen ───────── */
.recipe-intro-text {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.6;
  margin-bottom: 16px;
  align-self: flex-start;
  max-width: 480px;
}
#recipe-draft-card {
  width: 100%;
  background: var(--white);
  border: var(--border);
  border-left: 5px solid var(--green);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}
.recipe-draft-loading {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--slate);
  animation: loading-pulse 1s ease-in-out infinite;
}
.recipe-draft-blank-note {
  font-size: 11px;
  color: var(--slate);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--slate);
}
.recipe-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 8px;
}
.recipe-actions .btn-action {
  flex: none;
  padding: 10px 18px;
  font-size: 14px;
}

/* ── Recipe edit inputs ─────────────────────── */
.recipe-edit-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--ink);
  outline: none;
  margin-bottom: 6px;
}
.recipe-edit-input:focus { border-color: var(--green); }
.recipe-edit-textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--ink);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--ink);
  outline: none;
  resize: vertical;
  min-height: 64px;
  margin-bottom: 6px;
}
.recipe-edit-textarea:focus { border-color: var(--green); }
.recipe-action-input { margin-bottom: 4px !important; }

/* ── Commons save button ────────────────────── */
.commons-save-btn {
  margin-top: 14px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 2px;
  padding: 8px 16px;
  border: var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  cursor: crosshair;
}
.commons-save-btn:hover:not(:disabled) {
  background: var(--ink);
  color: var(--white);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}
.commons-save-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Mobile additions ───────────────────────── */
@media (max-width: 640px) {
  .menu-secondary-actions { gap: 16px; }
  .profile-prompt-actions { flex-direction: column; }
  .recipe-actions { flex-direction: column; }
  .recipe-actions .btn-action { width: 100%; }
}

/* ── Quota notice banner ────────────────────── */
#quota-notice {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ink);
  color: var(--slate);
  font-size: 11px;
  letter-spacing: 1px;
  line-height: 1.5;
  padding: 10px 20px;
  text-align: center;
  border-top: 2px solid #F4A124;
  z-index: 200;
}