:root {
  --navy: #0b1f33;
  --navy-2: #12304a;
  --ink: #0e2436;
  --foam: #e8f4f2;
  --sea: #1a6b6b;
  --sea-2: #14807c;
  --gold: #d4a017;
  --gold-2: #f0c14b;
  --sand: #f6efe3;
  --coral: #c45c4a;
  --ok: #1e8a5a;
  --warn: #c47a12;
  --paper: #fffdf8;
  --muted: #5b6b78;
  --line: #d7e0e6;
  --shadow: 0 10px 30px rgba(11, 31, 51, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1c4d63 0%, transparent 50%),
    radial-gradient(900px 500px at 110% 0%, #0d3b4a 0%, transparent 45%),
    var(--navy);
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f4f7f6;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}
.logo {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(160deg, #f0c14b, #b8860b);
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(212,160,23,.35);
  flex-shrink: 0;
}
.logo svg { display: block; }
.brand h1 {
  font-size: 1.15rem;
  margin: 0;
  letter-spacing: .02em;
}
.brand p {
  margin: 0;
  font-size: .78rem;
  opacity: .75;
  font-family: system-ui, sans-serif;
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.lang-switch {
  display: flex;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.lang-btn {
  border: 0;
  background: transparent;
  color: #dce7e6;
  font-family: system-ui, sans-serif;
  font-weight: 750;
  font-size: .82rem;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn.active-lang {
  background: var(--gold-2);
  color: #2a1c00;
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: system-ui, sans-serif;
  font-weight: 650;
  font-size: .9rem;
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
}
.btn:hover { transform: translateY(-1px); }
.btn-gold { background: var(--gold-2); color: #2a1c00; }
.btn-sea { background: #1c8a86; color: white; }
.btn-ghost {
  background: transparent;
  color: #eaf3f2;
  border: 1px solid rgba(255,255,255,.28);
}
.btn-ink { background: var(--navy); color: white; }
.btn-ok { background: var(--ok); color: white; }
.btn-coral { background: var(--coral); color: white; }
.btn-wide { width: 100%; }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero {
  color: #f7faf9;
  padding: 8px 4px 22px;
}
.hero h2 {
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  margin: 0 0 8px;
}
.hero p { margin: 0; max-width: 62ch; opacity: .86; line-height: 1.5; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.stat {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #f3f7f6;
  border-radius: 16px;
  padding: 16px;
}
.stat b { display: block; font-size: 1.5rem; }
.stat span { opacity: .75; font-family: system-ui, sans-serif; font-size: .82rem; }

.topic {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 168px;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: transform .12s ease, box-shadow .12s;
}
.topic:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(11,31,51,.16); }
.topic .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  color: var(--muted);
}
.badge {
  background: #eaf4f3;
  color: var(--sea);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.progress {
  height: 8px;
  background: #ece7db;
  border-radius: 99px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #14807c, #d4a017);
  width: 0;
}
.topic h3 { margin: 0; font-size: 1.08rem; }
.topic p { margin: 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: .88rem; line-height: 1.4; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
}
.tab {
  background: #efe8d8;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: system-ui, sans-serif;
  font-weight: 650;
  cursor: pointer;
}
.tab.active { background: var(--navy); color: white; }

.learn h3 { margin-top: 1.4em; }
.learn h3:first-child { margin-top: 0; }
.learn p, .learn li { line-height: 1.55; }
.term {
  display: inline-block;
  background: #f3e6bf;
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 700;
}
.note {
  background: #eef6f5;
  border-left: 4px solid var(--sea);
  padding: 12px 14px;
  border-radius: 10px;
  font-family: system-ui, sans-serif;
  font-size: .92rem;
}
.warnbox {
  background: #fdeee9;
  border-left: 4px solid var(--coral);
  padding: 12px 14px;
  border-radius: 10px;
}

.q-card { margin-bottom: 8px; }
.q-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: system-ui, sans-serif;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 10px;
}
.q-text {
  font-size: 1.12rem;
  margin: 0 0 14px;
}
.options { display: grid; gap: 8px; }
.opt {
  text-align: left;
  background: #f7f1e6;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: .95rem;
}
.opt:hover { border-color: #c9b27a; }
.opt.selected { border-color: var(--sea); background: #e6f3f1; }
.opt.correct { border-color: var(--ok); background: #e5f6ec; }
.opt.wrong { border-color: var(--coral); background: #fdeceb; }
.explain {
  margin-top: 14px;
  padding: 12px 14px;
  background: #eef6f5;
  border-radius: 12px;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #12304a;
  color: #f0c14b;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.result-big { font-size: 2.2rem; margin: 0 0 6px; }
.pass { color: var(--ok); }
.fail { color: var(--coral); }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: system-ui, sans-serif;
  font-size: .92rem;
}
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 650; }

.hidden { display: none !important; }

.footer-note {
  color: rgba(255,255,255,.62);
  font-family: system-ui, sans-serif;
  font-size: .78rem;
  margin-top: 22px;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .brand h1 { font-size: 1rem; }
  .card { padding: 16px; }
}
