:root {
  --sea: #0d5eaf;
  --sea-2: #1f8fd6;
  --sand: #f7f0e3;
  --ink: #14233b;
  --muted: #5b6b82;
  --card: #ffffff;
  --tile: #f7f0e3;
  --ok: #1d8a4a;
  --ok-bg: #e3f6ea;
  --bad: #c0392b;
  --bad-bg: #fde7e4;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(13, 94, 175, 0.12);
  --chrome: 185px; /* header + controls, used to fit the deck in the viewport */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sand: #0f1a2b; --ink: #e8eef8; --muted: #a9b8cd; --card: #17263e; --tile: #0f1a2b;
    --ok-bg: #173d2a; --bad-bg: #4a1d1a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --sand: #0f1a2b; --ink: #e8eef8; --muted: #a9b8cd; --card: #17263e; --tile: #0f1a2b;
  --ok-bg: #173d2a; --bad-bg: #4a1d1a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Base size grows with the screen: ~18px on phones, up to 24px on big screens */
html { font-size: clamp(18px, 0.55vw + 14px, 24px); -webkit-text-size-adjust: 100%; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Assistant", "Heebo", "Arial", system-ui, sans-serif;
  background: var(--sand);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ---------- Header ---------- */
.topbar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between;
  padding: 10px clamp(12px, 2vw, 28px);
  background: var(--sea); color: #fff;
}
.brand { font-weight: 800; font-size: 1.15rem; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  font: inherit; font-size: 1rem; border: 0; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; min-height: 44px;
  background: rgba(255,255,255,0.15); color: #fff;
}
.tab.is-active { background: #fff; color: var(--sea); font-weight: 700; }

main {
  flex: 1; width: 100%; max-width: 1500px; margin: 0 auto;
  padding: clamp(8px, 1.5vw, 20px) clamp(10px, 2vw, 28px);
}
.view { display: none; }
.view.is-active { display: block; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  padding: 12px 22px; min-height: 48px; border-radius: 14px; border: 0;
  background: var(--sea); color: #fff; font-size: 1.05rem;
}
.btn:disabled { opacity: .35; cursor: default; }
.btn.ghost { background: transparent; color: var(--sea); border: 2px solid var(--sea); }
.btn.small { padding: 6px 14px; min-height: 40px; font-size: .95rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.ghost { color: #8cc4f5; border-color: #8cc4f5; }
}

/* ---------- Deck: always 16:9 and always fits the screen ---------- */
.deck {
  position: relative;
  width: min(100%, calc((100svh - var(--chrome)) * 16 / 9));
  min-width: min(100%, 320px);
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.deck:fullscreen { width: 100vw; border-radius: 0; aspect-ratio: auto; display: flex; align-items: center; }
.slide { display: none; margin: 0; width: 100%; height: 100%; position: relative; animation: fade .35s ease; }
.slide.is-active { display: block; }
.slide img { width: 100%; height: 100%; object-fit: contain; display: block; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.slide-cta {
  position: absolute; bottom: 4%; left: 50%; transform: translateX(-50%);
  font-size: clamp(.85rem, 2.2vw, 1.5rem); padding: .6em 1.3em; min-height: 0;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  animation: pulse 1.8s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.06); } }

.deck-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: min(100%, calc((100svh - var(--chrome)) * 16 / 9));
  min-width: min(100%, 320px);
  margin: 12px auto 0;
}
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 0; padding: 0; background: var(--muted); opacity: .35; cursor: pointer;
}
.dot.is-active { opacity: 1; background: var(--sea); transform: scale(1.25); }
.deck-tools { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.counter { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; margin-inline-end: 6px; }
.notes {
  max-width: 900px; margin: 10px auto 0;
  background: var(--card); border-radius: 12px; padding: 12px 16px; line-height: 1.6;
}
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

/* ---------- Cards (quiz + game) ---------- */
.card {
  max-width: 980px; margin: 0 auto;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 40px);
}
.muted { color: var(--muted); }

/* ---------- Quiz ---------- */
.progress { height: 10px; background: var(--sand); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--sea), var(--sea-2)); width: 0; transition: width .3s; }
.q-count { color: var(--muted); }
.q-text { font-size: clamp(1.4rem, 3.2vw, 2.1rem); font-weight: 800; margin: 6px 0 20px; line-height: 1.35; }
.options { display: grid; gap: 12px; }
.opt {
  font: inherit; text-align: right; cursor: pointer;
  padding: 16px 20px; min-height: 60px; border-radius: 16px;
  border: 3px solid transparent; background: var(--tile); color: var(--ink);
  font-size: clamp(1.15rem, 2.4vw, 1.5rem); font-weight: 700;
}
.opt:hover:not(:disabled) { border-color: var(--sea-2); }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); }
.opt:disabled { cursor: default; }
.feedback { min-height: 34px; margin: 16px 0 6px; font-weight: 800; font-size: 1.3rem; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }
.explain { font-size: 1.1rem; line-height: 1.55; }
.quiz-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 22px; flex-wrap: wrap; }
.result { text-align: center; padding: 20px 0; }
.result .score { font-size: clamp(3rem, 8vw, 4.5rem); font-weight: 800; color: var(--sea); }
.result p { font-size: 1.35rem; }

/* ---------- Cipher game ---------- */
.game-title { font-size: clamp(1.5rem, 3.4vw, 2.3rem); margin: 0 0 8px; color: var(--sea); }
.game-intro { font-size: 1.15rem; margin: 0 0 6px; }
.game-steps { margin: 0 0 18px; padding-inline-start: 1.4em; font-size: 1.05rem; }
.game-steps li { margin-bottom: 2px; }

.cipher {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: clamp(14px, 3vw, 40px) clamp(18px, 4vw, 48px);
  background: var(--tile); border-radius: 16px;
  padding: clamp(14px, 2.5vw, 28px) clamp(8px, 2vw, 24px);
}
.cipher-word { display: flex; gap: clamp(4px, .8vw, 10px); }
.slot-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.greek-letter {
  font-size: clamp(1.7rem, 4.2vw, 3rem); font-weight: 800; color: var(--sea);
  font-family: "Arial", "Helvetica", sans-serif; line-height: 1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .greek-letter, :root:not([data-theme="light"]) .key-greek { color: #8cc4f5; }
}
.slot {
  font: inherit; font-weight: 800; cursor: pointer;
  width: clamp(34px, 5.6vw, 66px); height: clamp(42px, 6.2vw, 70px);
  font-size: clamp(.8rem, 1.9vw, 1.35rem); line-height: 1.1;
  border-radius: 10px; border: 3px dashed var(--muted);
  background: var(--card); color: var(--ink); padding: 0 2px;
}
.slot.is-selected { border: 3px solid var(--sea-2); box-shadow: 0 0 0 4px rgba(31,143,214,.25); }
.slot.is-done { border: 3px solid var(--ok); background: var(--ok-bg); cursor: default; }
.slot.is-wrong { border: 3px solid var(--bad); background: var(--bad-bg); animation: shake .35s; }

.game-status {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 14px 0 6px;
}
.progress-text { font-weight: 800; font-size: 1.1rem; }
.game-buttons { display: flex; gap: 8px; }

.key-title { margin: 18px 0 2px; font-size: 1.4rem; }
.key-grid {
  display: grid; gap: clamp(6px, 1vw, 12px); margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(clamp(72px, 9.5vw, 112px), 1fr));
}
.key-card {
  font: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 10px 12px; min-height: 60px; border-radius: 12px;
  border: 2px solid transparent; background: var(--tile); color: var(--ink);
}
.key-card:hover { border-color: var(--sea-2); }
.key-card:active { transform: scale(.96); }
.key-greek { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; color: var(--sea); font-family: "Arial", sans-serif; }
.key-he { font-size: clamp(1rem, 1.9vw, 1.3rem); font-weight: 700; }
.key-card.shake { animation: shake .35s; border-color: var(--bad); }
.key-card.pop { border-color: var(--ok); background: var(--ok-bg); }
.small-note { font-size: .95rem; margin-top: 12px; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.reveal {
  margin-top: 22px; text-align: center;
  border: 3px solid var(--sea); border-radius: 18px; padding: clamp(16px, 3vw, 32px);
}
.reveal-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; color: var(--ok); }
.reveal-greek { font-size: clamp(1.4rem, 3.6vw, 2.4rem); font-weight: 800; color: var(--sea); font-family: "Arial", sans-serif; margin: 8px 0; }
.reveal-read { font-size: 1.25rem; }
.reveal-meaning { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 800; margin: 10px 0; }
.syllables { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 12px 0; }
.syl { padding: 8px 14px; border-radius: 10px; font-weight: 800; font-size: 1.25rem; }
.syl.blue { background: var(--sea); color: #fff; }
.syl.white { background: #fff; color: var(--sea); border: 2px solid var(--sea); }
.reveal-fact { font-size: 1.25rem; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti span { position: absolute; top: -40px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 12px; }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  :root { --chrome: 260px; }
  .brand { font-size: 1rem; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 6px; font-size: .95rem; }
  .deck { border-radius: 12px; }
  .btn { padding: 10px 14px; }
  .hint { display: none; }
}
/* Phone held sideways: give the slide the whole height */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --chrome: 120px; }
  .topbar { padding: 4px 12px; }
  .hint, .footer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
