:root {
  --navy: #0a3161;        /* Old Glory Blue */
  --red: #b31942;         /* Old Glory Red */
  --navy-light: #1c4a8a;
  --bg: #f6f8fc;
  --card: #ffffff;
  --ink: #1a2233;
  --muted: #5d6b82;
  --line: #e3e8f0;
  --green: #1f8a4c;
  --gold: #d4af37;
  --shadow: 0 6px 24px rgba(10, 49, 97, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.flag { font-size: 40px; line-height: 1; }
.site-header h1 { margin: 0; font-size: 26px; letter-spacing: -0.3px; }
.tagline { margin: 2px 0 0; font-size: 14px; opacity: 0.85; }
.streak {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 10px 16px;
  border-radius: 999px;
  text-align: center;
}
.streak-num { font-size: 22px; font-weight: 800; color: var(--gold); }
.streak-label { font-size: 12px; opacity: 0.85; display: block; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tab {
  border: none;
  background: none;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--red); }

/* Views */
main { max-width: 820px; margin: 0 auto; padding: 28px 20px 60px; }
.view { display: none; animation: fade 0.25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 4px 14px rgba(179,25,66,0.3); }
.btn-primary:hover { background: #9c1638; }
.btn-ghost { background: #eef2f8; color: var(--navy); }
.btn-ghost:hover { background: #e0e7f2; }
.btn-small { padding: 8px 16px; font-size: 14px; }
.btn-known { background: var(--green); color: #fff; }
.btn-known:hover { filter: brightness(0.94); }
.btn-review { background: #f0e2c0; color: #6b5410; }
.btn-review:hover { filter: brightness(0.96); }
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }

/* Home */
.hero {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  text-align: center;
  border-top: 5px solid var(--red);
}
.hero h2 { margin: 0 0 10px; font-size: 27px; }
.hero p { color: var(--muted); margin: 0 auto 22px; max-width: 520px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.progress-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin: 20px 0;
}
.progress-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 10px; }
.bar { height: 12px; background: #e7ecf4; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), #36b06a); transition: width 0.4s ease; }
.progress-card .link-btn { margin-top: 12px; display: inline-block; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 20px; }
.info-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.info-card .ic { font-size: 34px; }
.info-card h3 { margin: 8px 0 6px; }
.info-card p { color: var(--muted); font-size: 14px; min-height: 60px; }

/* Flashcards */
.toolbar { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; flex-wrap: wrap; }
.counter { font-weight: 700; color: var(--muted); min-width: 70px; text-align: center; }

.flashcard { perspective: 1400px; cursor: pointer; margin: 0 auto; max-width: 560px; height: 320px; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform 0.55s; transform-style: preserve-3d; }
.flashcard.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.flash-front { background: var(--card); border-top: 5px solid var(--navy); }
.flash-back { background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: #fff; transform: rotateY(180deg); }
.flash-cat { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--red); font-weight: 800; margin-bottom: 14px; }
.flash-back .flash-cat { color: var(--gold); }
.flash-q { font-size: 21px; font-weight: 700; margin: 0; }
.flash-hint { margin-top: 18px; font-size: 13px; color: var(--muted); }
.flash-label { font-size: 13px; opacity: 0.85; margin-bottom: 10px; }
.flash-answers { list-style: none; padding: 0; margin: 0; text-align: center; }
.flash-answers li { font-size: 18px; font-weight: 600; padding: 4px 0; }
.flash-answers li::before { content: "★ "; color: var(--gold); }
.flash-note { margin-top: 14px; font-size: 13px; opacity: 0.9; font-style: italic; }
.flash-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }

/* Practice test */
.test-intro, .test-results { text-align: center; background: var(--card); border-radius: var(--radius); padding: 36px 28px; box-shadow: var(--shadow); }
.test-intro p { color: var(--muted); max-width: 480px; margin: 0 auto 22px; }
.test-progress { margin-bottom: 18px; }
.test-progress span { font-weight: 700; color: var(--muted); display: block; margin-bottom: 8px; }
.test-q-card { background: var(--card); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); border-top: 5px solid var(--red); }
.test-q { font-size: 22px; font-weight: 700; margin: 6px 0 22px; }
.test-answer-area { background: #f3f6fb; border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.test-answer-area .flash-answers li { color: var(--navy); }
.grade-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }
.result-emoji { font-size: 60px; }
.result-score { font-size: 28px; font-weight: 800; color: var(--navy); margin: 6px 0; }

/* Browse */
.browse-controls { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
#searchBox, #catFilter { padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; background: var(--card); }
#searchBox { flex: 1; min-width: 200px; }
.browse-list { display: flex; flex-direction: column; gap: 12px; }
.q-item { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.q-item summary { font-weight: 700; cursor: pointer; list-style: none; display: flex; gap: 10px; }
.q-item summary::-webkit-details-marker { display: none; }
.q-num { color: var(--red); font-weight: 800; flex-shrink: 0; }
.q-cat-tag { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-top: 10px; }
.q-answers { list-style: none; padding: 0; margin: 12px 0 0; }
.q-answers li { padding: 3px 0 3px 20px; position: relative; }
.q-answers li::before { content: "✓"; color: var(--green); position: absolute; left: 0; font-weight: 800; }
.q-note { display: block; margin-top: 8px; font-size: 13px; color: var(--red); font-style: italic; }

/* Resources */
.links-list { display: flex; flex-direction: column; gap: 12px; margin: 18px 0; }
.link-item { background: var(--card); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); display: block; text-decoration: none; color: var(--ink); border-left: 4px solid var(--navy); transition: transform 0.1s ease; }
.link-item:hover { transform: translateX(3px); border-left-color: var(--red); }
.link-item .lname { font-weight: 700; color: var(--navy); }
.link-item .lnote { font-size: 14px; color: var(--muted); margin-top: 4px; }
.disclaimer { background: #fff8e8; border: 1px solid #f0e0b0; border-radius: 12px; padding: 16px 20px; font-size: 14px; color: #6b5410; margin-top: 20px; }
.disclaimer a { color: var(--navy); }

/* Multiple choice */
.mc-lengths { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.mc-adaptive-note, .mc-excluded-note { font-size: 13px; max-width: 520px; margin: 6px auto 0; }
.mc-excluded-note { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.mc-scoreline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mc-score { color: var(--green); font-weight: 800; }
.mc-options { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.mc-option {
  text-align: left; background: #f3f6fb; border: 2px solid transparent; border-radius: 12px;
  padding: 14px 16px; font-size: 16px; font-weight: 600; color: var(--ink); cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease; display: flex; gap: 12px; align-items: center;
}
.mc-option:hover:not(:disabled) { border-color: var(--navy-light); background: #eaf0f8; }
.mc-option .mc-key {
  font-weight: 800; color: var(--navy); background: #fff; border-radius: 6px;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mc-option:disabled { cursor: default; }
.mc-option.correct { background: #e3f5ea; border-color: var(--green); color: #14622f; }
.mc-option.correct .mc-key { color: var(--green); }
.mc-option.wrong { background: #fbe3ea; border-color: var(--red); color: #8a132f; }
.mc-option.wrong .mc-key { color: var(--red); }
.mc-feedback { margin: 16px 0 4px; padding: 14px 16px; border-radius: 12px; font-size: 15px; }
.mc-feedback.ok { background: #e3f5ea; color: #14622f; }
.mc-feedback.no { background: #fbe3ea; color: #8a132f; }
.mc-feedback strong { display: block; margin-bottom: 3px; }
.mc-feedback .mc-ans { font-weight: 800; }
.mc-missed { text-align: left; margin: 18px 0; display: flex; flex-direction: column; gap: 10px; }
.mc-missed h3 { font-size: 16px; margin: 0 0 4px; }
.mc-missed .mm-item { background: #fff8f0; border-left: 4px solid var(--red); border-radius: 8px; padding: 12px 14px; }
.mc-missed .mm-q { font-weight: 700; font-size: 14px; }
.mc-missed .mm-a { font-size: 14px; color: var(--green); margin-top: 4px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Footer */
.site-footer { text-align: center; padding: 24px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 600px) {
  .site-header h1 { font-size: 22px; }
  .flashcard { height: 300px; }
  .flash-q, .test-q { font-size: 19px; }
}
