/* Hızlı Okuma — literary-but-energetic theme.
   Violet = focus/primary, coral = energy accent, warm paper ground.
   Serif headings (Georgia) for a booky feel; system sans for UI + reading. */

:root {
  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f7f3ec;
  --bg-tint: #efe8fb;         /* violet wash for ambient glow */
  --surface: #ffffff;
  --surface-2: #f4f0fb;       /* soft violet tint for chips/secondary */
  --ink: #221c33;
  --muted: #6e6580;
  --border: #e9e2d6;
  --border-strong: #ddd4e6;

  --primary: #6a4be0;
  --primary-strong: #5636c4;
  --spark: #ff6a3d;           /* coral: streaks, progress energy, celebration */
  --spark-strong: #e8501f;
  --success: #22a06b;
  --gold: #caa23a;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px rgba(52, 34, 92, 0.08);
  --shadow-hover: 0 12px 32px rgba(52, 34, 92, 0.14);
  --ring: 0 0 0 3px rgba(106, 75, 224, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17121f;
    --bg-tint: #241a3a;
    --surface: #221b30;
    --surface-2: #2c2340;
    --ink: #f2edf7;
    --muted: #a99eb8;
    --border: #352a49;
    --border-strong: #40324f;

    --primary: #8f74f7;
    --primary-strong: #a98cff;
    --spark: #ff845f;
    --spark-strong: #ff9a79;
    --success: #38c489;
    --gold: #e0be5a;

    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.45);
    --ring: 0 0 0 3px rgba(143, 116, 247, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 50% -12%, var(--bg-tint), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 760px; margin: 0 auto; padding: 22px 20px 48px; }

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .3s ease; }

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

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}
.center-card { max-width: 440px; margin: 9vh auto 0; text-align: center; }

/* ---------- Type ---------- */
h1 { font-family: var(--font-display); margin: 0 0 6px; font-size: 34px; letter-spacing: -0.01em; }
h2 { font-family: var(--font-display); margin: 0 0 6px; font-size: 24px; }
.subtitle { color: var(--muted); margin-top: 0; font-size: 15px; }

/* Login hero mark */
.brand-mark {
  width: 78px; height: 78px; margin: 0 auto 14px;
  display: grid; place-items: center;
  font-size: 38px; border-radius: 22px;
  background: linear-gradient(150deg, var(--primary), var(--spark));
  box-shadow: 0 10px 26px rgba(106, 75, 224, 0.35);
  transform: rotate(-4deg);
}

/* ---------- Inputs ---------- */
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin: 18px 0;
}
input[type="text"]:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
  color: #fff; width: 100%;
  box-shadow: 0 6px 16px rgba(106, 75, 224, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(106, 75, 224, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { background: var(--border-strong); color: var(--muted); box-shadow: none; cursor: not-allowed; transform: none; }

.btn-secondary { background: var(--surface-2); color: var(--primary-strong); }
.btn-secondary:hover { background: var(--border-strong); }
.btn-secondary:disabled { color: var(--muted); cursor: not-allowed; opacity: .7; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ---------- Top bar + stats ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.greeting { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.stats-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 999px;
  font-size: 13px; color: var(--muted); box-shadow: var(--shadow);
}
.stat b { color: var(--ink); font-size: 15px; }

/* ---------- Badges ---------- */
.badges-row { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 26px; }
.badge {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--gold);
  padding: 7px 13px; border-radius: 999px;
  font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
}

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex; gap: 4px; margin-bottom: 20px;
  background: var(--surface-2); padding: 4px; border-radius: 999px;
}
.tab-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 9px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow); }

.section-title { font-family: var(--font-display); font-size: 20px; margin: 0 0 14px; }

/* ---------- Passage list ---------- */
.passage-list { display: flex; flex-direction: column; gap: 12px; }
.passage-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.passage-card:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.passage-card.locked { opacity: 0.55; }
.passage-card .btn-secondary { flex: 0 0 auto; }

.passage-info .p-title { font-weight: 700; font-size: 16px; }
.passage-info .p-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.tier-pill {
  font-size: 11px; font-weight: 800; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--primary-strong);
  margin-right: 8px; text-transform: uppercase;
}

.games-note {
  font-size: 13px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 16px;
}

/* ---------- Reader: the focus lens ---------- */
.reader-stage {
  position: relative;
  background:
    radial-gradient(420px 260px at 50% 42%, var(--bg-tint), transparent 72%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 24px; min-height: 280px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; margin-top: 12px; overflow: hidden;
  box-shadow: var(--shadow);
}
/* fixation guides above/below the word line */
.reader-stage::before, .reader-stage::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  width: 2px; height: 22px; background: var(--primary); opacity: .25; border-radius: 2px;
}
.reader-stage::before { top: 34px; }
.reader-stage::after { bottom: 34px; }
.game-stage::before, .game-stage::after { display: none; }

#reader-title { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.reader-display {
  font-size: 40px; font-weight: 800; line-height: 1.25; letter-spacing: -0.01em;
  min-height: 96px; display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}

.speed-control { text-align: right; font-size: 13px; color: var(--muted); }
.speed-control label { font-weight: 600; }
.speed-control input[type="range"] {
  width: 170px; vertical-align: middle; margin-left: 10px; accent-color: var(--primary);
}

.reader-controls { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }
.reader-controls button { flex: 0 0 auto; width: auto; }

.progress-bar-wrap {
  height: 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; margin-top: 18px; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--spark));
  transition: width .1s linear;
}

/* ---------- Quiz ---------- */
.quiz-q { margin-bottom: 24px; counter-reset: choice; }
.quiz-q .q-text { font-weight: 700; margin-bottom: 12px; font-size: 16px; }
.quiz-choice {
  position: relative; display: block; width: 100%; text-align: left;
  padding: 12px 14px 12px 46px; margin-bottom: 9px;
  border: 2px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font-size: 15px; font-family: inherit;
  transition: border-color .12s, background .12s;
}
.quiz-choice::before {
  counter-increment: choice; content: counter(choice, upper-alpha);
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 800;
}
.quiz-choice:hover { border-color: var(--primary); }
.quiz-choice.selected { border-color: var(--primary); background: var(--surface-2); }
.quiz-choice.selected::before { background: var(--primary); color: #fff; }

/* ---------- Results ---------- */
#results-headline { font-size: 30px; }
.results-grid { display: flex; gap: 14px; justify-content: center; margin: 22px 0; }
.result-box {
  flex: 1; max-width: 180px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 18px;
}
.result-num { font-family: var(--font-display); font-size: 34px; font-weight: 800; color: var(--primary-strong); }
.result-label { font-size: 13px; color: var(--muted); margin-top: 6px; }
#results-message { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- Games ---------- */
.game-stage { gap: 20px; }
#flash-instructions, #schulte-instructions { color: var(--muted); font-size: 14px; max-width: 440px; }

.flash-zone {
  display: flex; align-items: center; justify-content: center;
  gap: 64px; min-height: 84px; width: 100%;
}
.flash-word { font-size: 30px; font-weight: 800; min-width: 120px; text-align: center; visibility: hidden; color: var(--ink); }
.fixation-dot { font-size: 20px; color: var(--primary); }

.flash-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
.flash-option {
  padding: 9px 17px; border-radius: 999px;
  border: 2px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 14px; font-weight: 700; font-family: inherit;
  transition: border-color .12s, background .12s;
}
.flash-option:hover { border-color: var(--primary); }
.flash-option.selected { border-color: var(--primary); background: var(--surface-2); }

.game-score { text-align: center; font-weight: 700; margin-top: 16px; min-height: 24px; }

.schulte-grid {
  display: grid; grid-template-columns: repeat(4, 66px); grid-template-rows: repeat(4, 66px);
  gap: 8px; justify-content: center;
}
.schulte-cell {
  background: var(--surface); border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 21px; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none;
  transition: transform .1s, border-color .1s;
}
.schulte-cell:hover { border-color: var(--primary); transform: translateY(-1px); }
.schulte-cell.done { background: var(--success); color: #fff; border-color: var(--success); opacity: 0.55; }
.schulte-cell.wrong { animation: shake .2s; border-color: var(--spark); }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  h1 { font-size: 28px; }
  .reader-display { font-size: 30px; }
  .reader-stage { padding: 40px 16px; }
  .schulte-grid { grid-template-columns: repeat(4, 60px); grid-template-rows: repeat(4, 60px); }
  .flash-zone { gap: 40px; }
  .card { padding: 22px; }
}

/* ---------- A11y: respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, .screen.active { animation: none !important; transition: none !important; }
}
