/* German Grammar Trainer — mobile-first */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --black:  #1a1a1a;
  --red:    #cc0000;
  --gold:   #f5a800;
  --white:  #ffffff;
  --grey0:  #f5f5f5;
  --grey1:  #e8e8e8;
  --grey2:  #999;
  --green:  #1a9954;
  --green-bg: #e6f4ec;
  --red-bg: #fdecea;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --max: 480px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--grey0);
  color: var(--black);
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

/* ── Layout ─────────────────────────────────────────────── */

.screen {
  width: 100%;
  max-width: var(--max);
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100dvh;
}

/* ── App header strip ────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header .flag {
  display: flex;
  flex-direction: column;
  width: 28px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.app-header .flag span { flex: 1; display: block; }
.app-header .flag .f1 { background: var(--black); }
.app-header .flag .f2 { background: var(--red); }
.app-header .flag .f3 { background: var(--gold); }

.app-header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.01em;
}

/* ── Name screen ─────────────────────────────────────────── */

#screen-name {
  justify-content: center;
  gap: 28px;
}

#screen-name h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

#screen-name p.sub {
  text-align: center;
  color: var(--grey2);
  font-size: 0.95rem;
  margin-top: -12px;
}

#name-input {
  width: 100%;
  font-size: 1.25rem;
  padding: 14px 16px;
  border: 2px solid var(--grey1);
  border-radius: var(--radius);
  outline: none;
  text-align: center;
  background: var(--white);
  transition: border-color 0.15s;
}
#name-input:focus { border-color: var(--gold); }

/* ── Home screen ─────────────────────────────────────────── */

#home-greeting {
  font-size: 1.5rem;
  font-weight: 700;
}

.today-card {
  background: var(--black);
  color: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.today-card .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 600;
}
.today-card h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey2);
  font-weight: 600;
}

.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.type-btn {
  background: var(--white);
  border: 2px solid var(--grey1);
  border-radius: var(--radius);
  padding: 14px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--black);
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition: border-color 0.15s, background 0.15s;
}
.type-btn:active { background: var(--grey1); }
.type-btn .type-en {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--grey2);
  margin-top: 2px;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--gold);
  color: var(--black);
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-primary:active { filter: brightness(0.92); }

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: var(--white);
  color: var(--black);
  border: 2px solid var(--grey1);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:active { background: var(--grey1); }

.btn-link {
  background: none;
  border: none;
  color: var(--grey2);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
  text-align: center;
  width: 100%;
}

/* ── Exercise screen ─────────────────────────────────────── */

.ex-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ex-type-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--grey2);
}
#ex-counter {
  font-size: 0.85rem;
  color: var(--grey2);
  font-weight: 500;
}

.progress-track {
  height: 6px;
  background: var(--grey1);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* English translation hint */
.ex-en {
  font-size: 0.9rem;
  color: var(--grey2);
  font-style: italic;
  text-align: center;
}

/* Big noun for article exercise */
.ex-noun {
  font-size: 2.8rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
  color: var(--black);
  padding: 8px 0;
}

/* Sentence for case/possessive */
.ex-sentence {
  font-size: 1.4rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
}
.blank {
  display: inline-block;
  border-bottom: 3px solid var(--gold);
  min-width: 60px;
  padding: 0 4px;
  color: var(--gold);
  font-weight: 700;
}

.ex-hint-label {
  font-size: 0.88rem;
  color: var(--grey2);
  text-align: center;
}

/* ── Choice buttons ──────────────────────────────────────── */

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.article-choices {
  grid-template-columns: 1fr 1fr 1fr;
}

.choice-btn {
  padding: 18px 8px;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid var(--grey1);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  color: var(--black);
}
.choice-btn:active:not(:disabled) { background: var(--grey1); }
.choice-btn:disabled { cursor: default; opacity: 0.7; }
.choice-btn.correct {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
  opacity: 1;
}
.choice-btn.wrong {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
  opacity: 1;
}

/* ── Word order chips ────────────────────────────────────── */

.word-answer-area,
.word-pool-area {
  min-height: 52px;
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.word-answer-area {
  background: var(--white);
  border: 2px solid var(--gold);
}
.word-pool-area {
  background: var(--grey1);
  border: 2px solid transparent;
}

.placeholder {
  color: var(--grey2);
  font-size: 1rem;
  padding: 4px;
}

.word-chip {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter 0.1s;
}
.word-chip:active { filter: brightness(0.9); }
.pool-chip {
  background: var(--white);
  color: var(--black);
  border: 2px solid var(--grey1);
}
.answer-chip {
  background: var(--black);
  color: var(--white);
}
.word-chip:disabled { opacity: 0.6; cursor: default; }

.btn-check {
  width: 100%;
  padding: 16px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-check:disabled { opacity: 0.4; cursor: default; }

/* ── Feedback ─────────────────────────────────────────────── */

.feedback {
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.92rem;
  line-height: 1.6;
}
.feedback-correct {
  background: var(--green-bg);
  color: var(--green);
  border: 1.5px solid var(--green);
}
.feedback-wrong {
  background: var(--red-bg);
  color: var(--red);
  border: 1.5px solid var(--red);
}
.fb-icon { font-size: 1.1rem; }
.fb-correct {
  color: var(--black);
  display: block;
  margin-top: 4px;
}
.fb-rule {
  color: var(--black);
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  font-style: italic;
  opacity: 0.8;
}

/* ── Summary screen ──────────────────────────────────────── */

#screen-summary {
  justify-content: center;
  text-align: center;
  gap: 24px;
}
#screen-summary h2 {
  font-size: 1.4rem;
  font-weight: 700;
}
.summary-score-big {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--black);
}
.summary-pct {
  font-size: 1.3rem;
  color: var(--grey2);
  margin-top: -8px;
}
.summary-grade {
  font-size: 1.4rem;
  font-weight: 600;
}
.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* ── Stats screen ─────────────────────────────────────────── */

#stats-name { font-size: 1.3rem; font-weight: 700; }

/* Period tabs */
.stats-tabs {
  display: flex;
  gap: 6px;
  background: var(--grey1);
  border-radius: var(--radius);
  padding: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px 6px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--grey2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn.tab-active {
  background: var(--white);
  color: var(--black);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.tab-btn:active:not(.tab-active) { background: var(--grey1); }

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.stat-label { font-weight: 600; font-size: 0.95rem; }
.stat-pct   { font-weight: 700; font-size: 1.1rem; color: var(--gold); }
.stat-bar-bg {
  height: 8px;
  background: var(--grey1);
  border-radius: 999px;
  overflow: hidden;
}
.stat-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.stat-sub { font-size: 0.8rem; color: var(--grey2); }

.stats-overall-line {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--grey2);
  text-align: center;
}

/* ── Admin / Leaderboard screen ───────────────────────────── */

.admin-title { font-size: 1.4rem; font-weight: 700; }

.admin-loading,
.admin-empty  { color: var(--grey2); font-size: 0.95rem; text-align: center; padding: 20px 0; }

.lb-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey2);
  margin-bottom: 8px;
}
.lb-sub {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--grey1);
}
.lb-row:last-child { border-bottom: none; }
.lb-row.lb-first .lb-name { color: var(--gold); }

.lb-rank {
  font-size: 1.4rem;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.lb-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.lb-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-detail {
  font-size: 0.8rem;
  color: var(--grey2);
}
.lb-empty {
  font-size: 0.88rem;
  color: var(--grey2);
  font-style: italic;
  padding: 8px 0;
}
