:root {
  --bg: #eef4f3;
  --panel: #ffffff;
  --ink: #1c2b2d;
  --muted: #5b6f72;
  --line: #d5e1e0;
  --teal: #1a6b73;
  --teal-hover: #15585f;
  --coral: #e07a5f;
  --coral-hover: #c96a52;
  --accent: var(--coral);
  --accent-hover: var(--coral-hover);
  --disabled: #8aa0a3;
  --correct: #1a7f37;
  --wrong: #c62828;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a {
  color: inherit;
}

.top-bar,
.game-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--teal);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  background:
    linear-gradient(#fff, #fff) center / 14px 2px no-repeat,
    linear-gradient(#fff, #fff) center / 2px 14px no-repeat;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 1.05rem;
}

.brand-sub {
  font-size: 0.75rem;
  opacity: 0.85;
}

.auth-bar {
  flex-shrink: 0;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-actions[hidden] {
  display: none !important;
}

.auth-email {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 72px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  font-weight: 700;
}

.lede {
  margin: 0 0 32px;
  max-width: 42rem;
  color: var(--muted);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--teal);
  border-bottom: 3px solid var(--teal);
  border-radius: 8px;
  text-decoration: none;
}

.game-card.suggested {
  border-color: var(--coral);
  border-top-color: var(--coral);
  box-shadow: 0 0 0 1px var(--coral);
}

.game-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.game-card p {
  margin: 0 0 16px;
  flex: 1;
  color: var(--muted);
  font-size: 0.95rem;
}

.card-meta {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-card.suggested .card-meta {
  color: var(--coral);
}

.game-card .btn {
  align-self: stretch;
  text-align: center;
}

.game-card.coming-soon {
  cursor: default;
  opacity: 0.9;
}

.game-card.playable:hover {
  box-shadow: 0 6px 16px rgba(26, 107, 115, 0.12);
}

.game-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-bar strong {
  font-size: 0.95rem;
}

.game-bar a {
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
}

.game-bar a:hover {
  text-decoration: underline;
}

.game-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.screen {
  display: none;
  width: min(720px, 100%);
  text-align: center;
}

.screen.active {
  display: block;
}

.screen p {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem !important;
}

.digit {
  margin: 0;
  font-size: 5.5rem;
  font-weight: 700;
  line-height: 1;
  min-height: 1.2em;
}

.anti-stage {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 140px;
  margin-bottom: 28px;
}

.anti-side,
.anti-center {
  display: flex;
  justify-content: center;
  min-height: 1.2em;
}

.anti-stim,
.anti-fix {
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1;
  min-height: 1.2em;
}

.letter-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.letter-buttons[hidden] {
  display: none !important;
}

.letter-btn {
  appearance: none;
  width: 72px;
  height: 72px;
  border: 2px solid var(--teal);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 1.8rem;
  font-weight: 700;
  cursor: pointer;
}

.letter-btn:hover {
  border-color: var(--coral);
  background: #fff7f4;
}

.feedback {
  font-size: 2rem;
  font-weight: 700;
}

.feedback.correct {
  color: var(--correct);
}

.feedback.wrong {
  color: var(--wrong);
}

.btn {
  appearance: none;
  display: inline-block;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  background: var(--coral);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  background: var(--coral-hover);
}

.btn-teal {
  background: var(--teal);
  pointer-events: none;
}

.btn-teal:hover {
  background: var(--teal);
}

.btn-outline-on-teal {
  background: transparent;
  background: var(--teal);
}

.btn-outline-on-teal:hover {
  background: var(--teal-hover);
}

.text-btn {
  appearance: none;
  border: 0;
  padding: 8px 4px;
  background: none;
  color: var(--teal);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.text-btn:hover {
  text-decoration: underline;
}

.text-btn-on-teal {
  color: #fff;
}

.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 43, 45, 0.45);
  z-index: 20;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.modal-card h2 {
  margin: 0 0 16px;
  font-family: Georgia, "Times New Roman", serif;
}

.field {
  display: block;
  margin-bottom: 12px;
  text-align: left;
  font-size: 0.95rem;
}

.field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: var(--panel);
}

.field-required {
  font-weight: 600;
  color: var(--ink);
}

.profile-modal-card {
  width: min(720px, 100%);
  max-height: min(90vh, 880px);
  overflow-y: auto;
}

.profile-lede {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.profile-optional-heading {
  margin: 20px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.profile-location {
  margin: 0;
  padding: 0;
  border: none;
}

.profile-location legend {
  padding: 0;
  margin-bottom: 4px;
}

.modal-blocking .modal-card {
  pointer-events: auto;
}

.auth-error {
  min-height: 1.4em;
  margin: 0 0 8px;
  color: var(--wrong);
  font-size: 0.95rem;
}

.auth-switch {
  display: block;
  width: 100%;
  margin-top: 12px;
  text-align: center;
}

body.auth-checking .game-shell {
  visibility: hidden;
}

.summary-list {
  list-style: none;
  margin: 24px auto;
  padding: 0;
  width: min(420px, 100%);
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.summary-list li:last-child {
  border-bottom: 0;
}

.save-status {
  margin: 0 auto 16px;
  max-width: 420px;
  color: #9b2c2c;
  font-size: 0.95rem;
}

.sq-trial-screen {
  width: min(760px, 100%);
}

.sq-hud {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}

.sq-timer {
  flex: 1;
  height: 18px;
  overflow: hidden;
  background: #d7e4e2;
  border-radius: 999px;
}

.sq-bar {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: #2e9d64;
}

.sq-score {
  min-width: 2ch;
  color: var(--teal);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}

.sq-play {
  min-height: 220px;
}

.sq-stim-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.sq-stim-wrap[hidden],
.sq-simon[hidden],
.sq-choices[hidden] {
  display: none !important;
}

.sq-stim-wrap.boxed {
  margin-left: auto;
  margin-right: auto;
  width: fit-content;
  padding: 14px 18px;
  border: 2px solid #c62828;
  border-radius: 6px;
  background: #1c2b2d;
}

.sq-stim {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.sq-arrows {
  font-family: "Courier New", ui-monospace, monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.sq-stim-wrap.boxed .sq-stim {
  color: #fff;
}

.ink-red {
  color: #c62828;
}

.ink-blue {
  color: #1565c0;
}

.sq-simon {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 88px;
  margin-bottom: 28px;
}

.sq-simon-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  font-size: 4.4rem;
  line-height: 1;
}

.sq-choices {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.sq-choice {
  appearance: none;
  min-width: 160px;
  min-height: 64px;
  padding: 12px 18px;
  border: 2px solid #2b6cb0;
  border-radius: 8px;
  background: #1c2b2d;
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.sq-choice.ink-red,
.sq-choice.ink-blue {
  background: #1c2b2d;
}

.sq-choice:hover {
  filter: brightness(1.12);
}

.sq-choice-static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.sq-demo {
  margin: 8px 0 24px;
}

.sq-demo .sq-stim-box {
  display: inline-flex;
  justify-content: center;
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 2px solid #c62828;
  border-radius: 6px;
  background: #1c2b2d;
  color: #fff;
}

.sw-cue {
  width: 56px;
  height: 56px;
  margin: 48px auto;
  border-radius: 6px;
}

.sw-cue.red {
  background: #c62828;
}

.sw-cue.blue {
  background: #1565c0;
}

.sw-cue[hidden],
.sw-fix[hidden],
.sw-stim[hidden] {
  display: none !important;
}

.sw-fix {
  margin: 48px 0;
  font-size: 2.4rem;
  font-weight: 700;
}

.sw-stim {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
  min-height: 140px;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 4.4rem;
  font-weight: 700;
  line-height: 1;
}

.sw-stim span {
  min-width: 1ch;
  text-align: center;
}

.sw-plus {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 2rem;
}

.feedback.zero {
  color: var(--ink);
}

.sw-result {
  white-space: pre-line;
}

.results {
  margin-top: 48px;
}

.results h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.6rem;
}

.results-empty {
  margin: 0;
  color: var(--muted);
}

.result-row {
  margin-top: 24px;
}

.result-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.result-row h3 {
  margin: 0;
  font-size: 1.05rem;
}

.graph-modal-card {
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow-y: auto;
}

.graph-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.graph-modal-head h2 {
  margin: 0;
}

.graph-charts {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.graph-chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px 18px;
  box-shadow: 0 1px 2px rgba(28, 43, 45, 0.04);
}

.graph-chart-card h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.graph-chart-caption {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 36em;
}

.graph-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.graph-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.graph-chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.graph-chart-legend-dot--primary {
  background: #2a5160;
}

.graph-chart-legend-dot--latest {
  background: #d5866d;
}

.graph-chart-canvas-wrap {
  width: 100%;
  margin-top: 16px;
  overflow-x: auto;
}

.graph-chart-canvas-wrap canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.result-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.result-card {
  flex: 0 0 380px;
  margin: 0;
}

.result-when {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-card .summary-list {
  width: 100%;
  margin: 12px 0 0;
}

@media (max-width: 700px) {
  .top-bar,
  .game-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .page {
    padding: 28px 16px 56px;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .digit {
    font-size: 4rem;
  }
}
