/* Roman Numeral Trainer — styles */
:root {
  --bg: #14181d;
  --bg-glow: #1d242d;
  --ink: #f2ede3;
  --ink-dim: #9aa5b1;
  --gold: #e6c76a;
  --gold-deep: #c9a227;
  --good: #6fbf73;
  --bad: #e07a5f;
  --card: #1b2129;
  --line: #2c3540;
}

html {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
/* Ensure the `hidden` attribute always wins over display overrides */
[hidden] {
  display: none !important;
}


body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(60rem 30rem at 50% -10rem, var(--bg-glow), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: Georgia, "Palatino Linotype", "Times New Roman", serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Skip link (a11y) */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background-color: var(--gold);
  color: #1a1508;
  padding: 0.6rem 1rem;
  border-radius: 0 0 0.5rem 0;
  font-size: 0.9rem;
  font-family: inherit;
}
.skip-link:focus-visible {
  left: 1rem;
}

.shell {
  max-width: 42rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 5rem;
}

.screen {
  animation: screen-in 0.25s ease-out;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  color: var(--gold);
  letter-spacing: 0.03em;
  margin: 0.25rem 0 1rem;
  text-wrap: balance;
}
h2 {
  font-size: 1.5rem;
  margin: 0 0 1rem;
  text-wrap: balance;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.35em;
  font-size: 0.75rem;
  color: var(--ink-dim);
  margin: 0 0 1rem;
}
.lede {
  color: var(--ink-dim);
  line-height: 1.6;
  margin: 0 0 1.5rem;
}
.best-note {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
  min-height: 1.2rem;
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Difficulty & direction pickers */
.difficulty, .mode {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.25rem;
  margin: 0 0 1rem;
}
.difficulty legend, .mode legend {
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding: 0.5rem 0.75rem 0.25rem;
}
.difficulty label, .mode label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.difficulty label:hover, .mode label:hover {
  border-color: var(--gold);
  background-color: rgba(230, 199, 106, 0.06);
}
.difficulty input, .mode input {
  accent-color: var(--gold);
  width: 1rem;
  height: 1rem;
}
.difficulty small, .mode small {
  margin-left: auto;
  color: var(--ink-dim);
}
/* Buttons */
.btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.8rem 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background-color: var(--card);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover {
  border-color: var(--gold);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn-primary {
  background-color: var(--gold);
  border-color: var(--gold-deep);
  color: #1a1508;
  font-weight: 700;
}
.btn-primary:hover {
  background-color: #f0d78c;
}
.btn-ghost {
  background-color: transparent;
}
.btn-ghost:hover {
  background-color: rgba(230, 199, 106, 0.08);
}

.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s;
}
.icon-btn:hover {
  border-color: var(--gold);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Game HUD */
#game-title {
  font-size: 1.1rem;
  color: var(--ink-dim);
  margin: 0 0 0.75rem;
}
.game-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 0 0 0.75rem;
}
.hud-stat {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.hud-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
#hud-time,
#hud-score,
#hud-streak,
#hud-multiplier {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.timerbar {
  height: 0.4rem;
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
  margin: 0 0 1.5rem;
}
#timerbar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  transform-origin: left center;
  transition: transform 0.25s linear;
}

/* Question card */
.question {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.75rem 1.5rem;
}
.question-label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.72rem;
  color: var(--ink-dim);
  margin: 0 0 1rem;
}
.question-roman {
  font-size: clamp(2.4rem, 9vw, 4rem);
  color: var(--gold);
  letter-spacing: 0.08em;
  font-weight: 700;
  text-align: center;
  margin: 0 0 1.25rem;
}
.answer-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.answer-form label {
  font-size: 0.85rem;
  color: var(--ink-dim);
  margin: 0;
}
#answer-input {
  font-family: inherit;
  font-size: 1.25rem;
  padding: 0.7rem 1rem;
  background-color: #12161b;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
#answer-input::placeholder {
  color: #5d6a78;
}
#answer-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.feedback {
  min-height: 1.4rem;
  margin: 0.5rem 0 0;
  font-size: 1rem;
}
.feedback.is-good { color: var(--good); }
.feedback.is-bad { color: var(--bad); }
.game-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}
/* Reference modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(8, 10, 13, 0.72);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}
.modal {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.5rem;
  max-width: 26rem;
  width: 100%;
  max-height: 80dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.ref-table th,
.ref-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
}
.ref-table th {
  text-align: left;
  color: var(--ink-dim);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.ref-table td:first-child {
  color: var(--gold);
  font-weight: 700;
}
.ref-table td {
  font-variant-numeric: tabular-nums;
}
.ref-note {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}
.modal .btn {
  width: 100%;
}

/* Results */
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 0 0 1.5rem;
}
.result-stat {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.8rem;
}
.stat-value {
  display: block;
  font-size: 1.5rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.2rem;
}
.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.new-best {
  color: var(--gold);
  font-weight: 700;
  margin: 0 0 1rem;
}

/* Confetti canvas */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* Wrong-answer shake */
@keyframes shake-x {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}
.shake {
  animation: shake-x 0.35s ease-in-out;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .screen,
  .modal {
    animation: none;
  }
  #timerbar-fill {
    transition: none;
  }
  .shake {
    animation: none;
  }
}

/* Small screens */
@media (max-width: 480px) {
  .game-hud {
    grid-template-columns: repeat(2, 1fr);
  }
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


