:root {
  color: #17191c;
  background: #f4f5f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  --ink: #17191c;
  --muted: #687078;
  --line: #d8dcdf;
  --paper: #ffffff;
  --green: #147d4f;
  --green-soft: #e9f6ef;
  --red: #b43131;
  --red-soft: #fff0ef;
  --yellow: #f2cb4d;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { border: 0; border-radius: 6px; background: var(--ink); color: white; font-weight: 750; padding: 0.8rem 1.15rem; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #4b91dc; outline-offset: 2px; }
.quiet { padding: 0.5rem 0.7rem; background: transparent; color: var(--ink); border: 1px solid var(--line); }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: linear-gradient(135deg, #f6d75b 0 18%, #f4f5f6 18% 100%); }
.login-panel { width: min(100%, 390px); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 2rem; box-shadow: 0 18px 55px rgb(23 25 28 / 10%); }
.login-panel h1 { margin: 0.25rem 0 0.5rem; font-size: 2rem; }
.eyebrow { margin: 0; color: #695614; font-size: 0.75rem; font-weight: 850; text-transform: uppercase; }
.subtle { color: var(--muted); margin: 0 0 1.5rem; }
label { display: grid; gap: 0.4rem; margin: 0.9rem 0; font-size: 0.85rem; font-weight: 750; }
input { width: 100%; min-height: 44px; border: 1px solid #b9bec3; border-radius: 5px; padding: 0.7rem; }
.login-panel button { width: 100%; margin-top: 0.4rem; }
.error { color: var(--red); min-height: 1.2rem; font-size: 0.85rem; }
.game-view { min-height: 100vh; }
header { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 2rem; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); text-decoration: none; font-weight: 900; }
.account { display: flex; align-items: center; gap: 0.8rem; min-width: 0; }
#displayName { max-width: min(28vw, 240px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-band { min-height: 78px; display: grid; grid-template-columns: repeat(4, minmax(64px, 110px)) 1fr; align-items: center; gap: 1.2rem; padding: 0 2rem; background: #25282c; color: white; }
.progress-band div:not(.progress-track) { display: grid; }
.progress-band strong { font-size: 1.3rem; }
.progress-band span { font-size: 0.7rem; color: #b9c0c6; text-transform: uppercase; }
.progress-band .correct strong { color: #61d99a; }
.progress-band .wrong strong { color: #ff8a84; }
.progress-track { height: 7px; background: #454a50; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--yellow); transition: width 160ms ease; }
.start-view, .complete-view, .card-view { width: min(920px, calc(100% - 2rem)); margin: 0 auto; }
.start-view, .complete-view { padding: clamp(3rem, 10vh, 7rem) 0; }
.start-view h1, .complete-view h1 { margin: 0.5rem 0; font-size: clamp(2rem, 5vw, 3.8rem); }
.start-view > p:not(.eyebrow) { max-width: 590px; color: var(--muted); font-size: 1.1rem; }
.card-view { padding: 2rem 0 4rem; }
.task-meta { display: grid; grid-template-columns: auto auto auto 1fr; align-items: center; gap: 0.55rem; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }
.task-meta span { border: 1px solid var(--line); padding: 0.35rem 0.48rem; border-radius: 4px; }
.task-meta time { justify-self: end; color: var(--ink); font: 800 1.15rem ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.card-view h1 { max-width: 760px; margin: 1.3rem 0 1rem; font-size: clamp(1.55rem, 4vw, 2.6rem); line-height: 1.12; }
.task-context, #correctAnswer { white-space: pre-wrap; background: #25282c; color: #f3f5f6; padding: 1rem; border-radius: 5px; overflow-x: auto; }
.editor-label { margin-top: 1.5rem; }
textarea { display: block; width: 100%; height: 260px; resize: vertical; border: 1px solid #aeb4b9; border-radius: 5px; background: var(--paper); color: #111418; padding: 1rem; font: 500 1rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0; tab-size: 4; }
.result { margin-top: 1rem; padding: 1rem; border-left: 5px solid; }
.result.correct { color: #0e5838; background: var(--green-soft); border-color: var(--green); }
.result.wrong { color: #7d2525; background: var(--red-soft); border-color: var(--red); }
.result p { margin: 0.35rem 0 0; }
.action-row { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; margin-top: 1rem; }
.action-row span { color: var(--muted); font-size: 0.78rem; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 1.2rem 0 2rem; background: var(--line); border: 1px solid var(--line); }
.stat { min-height: 100px; display: grid; align-content: center; gap: 0.2rem; padding: 1rem; background: var(--paper); }
.stat strong { font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }
.trend-panel { margin: 1rem 0 2rem; padding: 1rem; background: #fff8dc; border-left: 5px solid var(--yellow); }
[hidden] { display: none !important; }

@media (max-width: 680px) {
  header { padding: 0 1rem; }
  .account { gap: 0.4rem; }
  .progress-band { grid-template-columns: repeat(4, 1fr); gap: 0.5rem; padding: 0.75rem 1rem; }
  .progress-track { grid-column: 1 / -1; }
  .task-meta { grid-template-columns: auto auto 1fr; }
  .task-meta time { grid-column: 1 / -1; justify-self: start; margin-top: 0.5rem; }
  textarea { height: 230px; font-size: 0.92rem; }
  .action-row { align-items: stretch; flex-direction: column; }
  .action-row button { width: 100%; }
  .action-row span { text-align: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
