/* ===========================================================
   Makan Quiz — stylesheet (light/warm theme)

   Palette: warm paper background, deep navy ink, a muted teal
   accent (toned down from the logo's neon for readability on a
   light surface), plus a five-color difficulty scale that all
   pass WCAG AA as text on the paper background.

   Type: Fraunces (a characterful, high-contrast display serif)
   for headlines and identity moments; Manrope for everything
   functional; Space Grotesk reserved specifically for numbers —
   the score, the timer, stat values — since a scoring quiz game
   is fundamentally about numbers, that's the one place a little
   typographic personality earns its keep. All three are bundled
   locally as woff2 so the game works fully offline once wrapped
   into an APK.
=========================================================== */

@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../assets/fonts/manrope-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../assets/fonts/manrope-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../assets/fonts/manrope-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("../assets/fonts/manrope-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../assets/fonts/space-grotesk-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("../assets/fonts/space-grotesk-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* surfaces */
  --bg: #f7f3ec;
  --bg-panel: #ffffff;
  --bg-panel-alt: #efe9dc;
  --bg-plaque: #12203a;   /* dark navy — houses the logo artwork as-is */
  --border: #e4ddcb;
  --shadow: 0 1px 2px rgba(27, 42, 61, 0.05), 0 6px 20px rgba(27, 42, 61, 0.06);
  --shadow-sm: 0 1px 2px rgba(27, 42, 61, 0.06);

  /* ink */
  --ink: #1b2a3d;
  --ink-muted: #54607a;

  /* brand accent (muted teal — echoes the logo, tuned for light bg) */
  --accent: #0e7c6b;
  --accent-strong: #0b6358;
  --accent-soft: #e1f1ec;
  --accent-ink: #ffffff;

  /* semantic */
  --correct: #177a46;
  --correct-soft: #e4f4ea;
  --wrong: #bb3a44;
  --wrong-soft: #fbe9ea;
  --warn: #82590e;

  /* difficulty scale — all pass 4.5:1 as text on --bg */
  --tier-rookie: #177a46;
  --tier-amateur: #0e7c6b;
  --tier-pro: #9c6b14;
  --tier-expert: #a34a17;
  --tier-legendary: #bb3a44;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-numeric: "Space Grotesk", var(--font-body);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

h1, h2, h3 { margin: 0; font-family: var(--font-display); }
p { margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select { font-family: inherit; }

img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  padding: 18px 18px 28px;
  animation: fade-in 0.22s ease;
}
.screen.active { display: flex; }

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

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

/* ---------------- shared bits ---------------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.8rem;
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--bg-panel-alt); color: var(--ink); }

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 1.02rem;
  box-shadow: 0 4px 14px rgba(14, 124, 107, 0.28);
  transition: background 0.15s ease, transform 0.1s ease;
}
.primary-btn:hover { background: var(--accent-strong); }
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 18px;
  border-radius: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease;
}
.secondary-btn:hover { background: var(--bg-panel-alt); }
.secondary-btn:active { transform: scale(0.98); }

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.footer-credit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  padding: 22px 0 6px;
}
.footer-credit .logo-plaque {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
}
.footer-credit img { height: 22px; width: auto; display: block; }

.logo-plaque {
  background: var(--bg-plaque);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.top-bar .spacer { flex: 1; }

.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------- start screen ---------------- */

.logo-banner {
  display: block;
  margin: 6px auto 4px;
  max-width: 320px;
  width: 78%;
  border-radius: 12px;
}

.tagline {
  text-align: center;
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 22px;
}

.field-label {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--ink);
  margin-bottom: 8px;
  display: block;
}

.text-input {
  width: 100%;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0 14px;
  font-size: 0.95rem;
}
.text-input::placeholder { color: var(--ink-muted); }
.text-input:focus { border-color: var(--accent); }

.select-wrap { position: relative; }
.select-input {
  width: 100%;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0 40px 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.form-card { margin-bottom: 14px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (min-width: 480px) {
  .two-col { grid-template-columns: 1fr 1fr; }
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 10px 0 10px;
}

.difficulty-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.difficulty-row::-webkit-scrollbar { height: 6px; }
.difficulty-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.diff-card {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 152px;
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
.diff-card.selected {
  box-shadow: 0 4px 16px rgba(27, 42, 61, 0.12);
  transform: translateY(-1px);
}
.diff-card .diff-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 2px;
}
.diff-card .diff-stars {
  font-size: 0.85rem;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.diff-card .diff-desc {
  color: var(--ink-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  margin-bottom: 10px;
  min-height: 46px;
}
.diff-card .diff-meta {
  font-family: var(--font-numeric);
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
@media (min-width: 480px) {
  .action-stack.row { flex-direction: row; }
  .action-stack.row > * { flex: 1; }
}

.status-line {
  min-height: 20px;
  color: var(--warn);
  font-size: 0.82rem;
  margin: 4px 0 4px;
}

/* ---------------- quiz screen ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.78rem;
}

.streak-pill {
  color: var(--warn);
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: 0.88rem;
}

.score-pill {
  margin-left: auto;
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}

.progress-label {
  text-align: center;
  font-family: var(--font-numeric);
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.bar-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-panel-alt);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.15s linear;
}

.timer-track { margin-top: 10px; height: 10px; }
.timer-fill { background: var(--correct); transition: width 0.06s linear, background 0.2s ease; }

.question-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: 18px 0;
  padding: 26px 18px;
  min-height: 320px;
}

.q-meta {
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.78rem;
  margin-bottom: 18px;
}

.q-text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 18px;
}

.q-feedback {
  min-height: 24px;
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 10px;
}

.answers-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.answer-btn {
  min-height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.98rem;
  padding: 12px 10px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
  line-height: 1.25;
}
.answer-btn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.answer-btn:active:not(:disabled) { transform: scale(0.97); }
.answer-btn:disabled { cursor: default; }
.answer-btn.correct { background: var(--correct); border-color: var(--correct); color: #ffffff; }
.answer-btn.wrong { background: var(--wrong); border-color: var(--wrong); color: #ffffff; }

.loading-note {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin-top: 12px;
}

/* ---------------- result screen ---------------- */

.result-headline {
  text-align: center;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-top: 6px;
}
.result-sub {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin: 6px 0 18px;
}
.result-score {
  text-align: center;
  font-family: var(--font-numeric);
  font-size: 3.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}
.result-score-label {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  margin: 6px 0 20px;
}

.tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 480px) {
  .tiles-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-tile {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  text-align: center;
  padding: 14px 6px;
}
.stat-tile .stat-value {
  font-family: var(--font-numeric);
  font-size: 1.4rem;
  font-weight: 700;
}
.stat-tile .stat-label {
  color: var(--ink-muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.save-status {
  text-align: center;
  color: var(--correct);
  font-size: 0.85rem;
  min-height: 20px;
  margin: 6px 0 16px;
}

/* ---------------- leaderboard ---------------- */

.filter-select { margin-left: auto; width: auto; min-width: 150px; }

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
}
.lb-rank {
  width: 38px;
  flex: 0 0 auto;
  text-align: center;
  font-family: var(--font-numeric);
  font-weight: 700;
  color: var(--accent-strong);
}
.lb-info { flex: 1; min-width: 0; }
.lb-name {
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-sub {
  color: var(--ink-muted);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-score {
  flex: 0 0 auto;
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--correct);
}

.empty-note {
  text-align: center;
  color: var(--ink-muted);
  padding: 40px 10px;
}

/* ---------------- about screen ---------------- */

.about-card { margin-bottom: 14px; }
.about-card h2 {
  color: var(--accent-strong);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.about-card ol, .about-card p {
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.6;
  padding-left: 18px;
}
.about-card p { padding-left: 0; margin-bottom: 10px; }
.about-card p:last-child { margin-bottom: 0; }

/* ---------------- misc ---------------- */

.center-col { display: flex; flex-direction: column; align-items: center; }

@media (min-width: 640px) {
  .screen { padding: 26px 30px 34px; }
}
