/* ロシア語文法クイズ — ブランドカラー（白・紺・赤） */

:root {
  --rl-bg: #FFFFFF;
  --rl-bg-soft: #F6F4EF;
  --rl-ink: #1B1B1B;
  --rl-ink-soft: #4A4A4A;
  --rl-navy: #0B2A59;
  --rl-navy-dk: #061834;
  --rl-red: #C1272D;
  --rl-red-dk: #8E1B20;
  --rl-rule: #E2E4EA;
  --rl-success: #1F7A3A;
  --rl-success-bg: #E8F5EE;
  --rl-error-bg: #FBEAEB;

  --font-sans-jp: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-serif-jp: "Noto Serif JP", "Yu Mincho", serif;
  --font-ru: "PT Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--rl-bg);
  color: var(--rl-ink);
  font-family: var(--font-sans-jp);
  font-size: 16px;
  line-height: 1.7;
}

a { color: var(--rl-navy); text-decoration: none; }
a:hover { color: var(--rl-red); }

/* Header */
.site-header {
  background: var(--rl-navy-dk);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.brand:hover { color: #fff; opacity: 0.9; }
.brand-text {
  font-family: var(--font-serif-jp);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.flag {
  display: inline-block;
  width: 22px; height: 16px;
  background: linear-gradient(to bottom, #fff 0 33.3%, var(--rl-navy) 33.3% 66.6%, var(--rl-red) 66.6% 100%);
  border: 1px solid rgba(255,255,255,0.4);
}
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-nav a {
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
}
.site-nav a:hover { color: #fff; }
.site-nav a[aria-current="page"] {
  color: #fff;
  border-bottom: 2px solid var(--rl-red);
  padding-bottom: 2px;
}

/* Layout */
#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.screen { display: block; }
.screen[hidden] { display: none; }

/* Home */
.hero h1 {
  font-family: var(--font-serif-jp);
  font-size: 2rem;
  color: var(--rl-navy);
  margin: 0 0 8px;
}
.hero .lead {
  color: var(--rl-ink-soft);
  margin: 0 0 32px;
}

.setup fieldset {
  border: 1px solid var(--rl-rule);
  border-radius: 6px;
  padding: 18px 20px;
  margin: 0 0 20px;
}
.setup legend {
  font-weight: 700;
  color: var(--rl-navy);
  padding: 0 8px;
}
.setup label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 14px 4px 0;
  cursor: pointer;
}
.setup label input { accent-color: var(--rl-navy); }

.actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.btn-primary, .btn-secondary, .btn-link {
  font-family: var(--font-sans-jp);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary {
  background: var(--rl-red);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 4px;
  font-weight: 700;
}
.btn-primary:hover { background: var(--rl-red-dk); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { background: #c0c4cc; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--rl-navy);
  border: 2px solid var(--rl-navy);
  padding: 10px 24px;
  border-radius: 4px;
  font-weight: 700;
}
.btn-secondary:hover { background: var(--rl-navy); color: #fff; }
.btn-link {
  background: none;
  border: none;
  color: var(--rl-ink-soft);
  text-decoration: underline;
  padding: 4px 0;
  font-size: 0.9rem;
}
.btn-link:hover { color: var(--rl-red); }

.muted { color: var(--rl-ink-soft); font-size: 0.9rem; margin: 0; }

.stats {
  margin-top: 40px;
  padding: 20px;
  background: var(--rl-bg-soft);
  border-radius: 6px;
}
.stats h3 { margin: 0 0 8px; color: var(--rl-navy); }

/* Quiz */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--rl-rule);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--rl-navy);
  width: 5%;
  transition: width 0.3s;
}
.progress-text {
  color: var(--rl-ink-soft);
  font-size: 0.9rem;
  white-space: nowrap;
}

.question-area {
  background: var(--rl-bg-soft);
  padding: 28px 24px;
  border-radius: 6px;
  margin-bottom: 20px;
}
.q-tags {
  font-size: 0.8rem;
  color: var(--rl-ink-soft);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.q-prompt {
  font-family: var(--font-serif-jp);
  font-size: 1.25rem;
  margin: 0 0 20px;
  color: var(--rl-ink);
  line-height: 1.5;
}
.q-prompt .ru {
  font-family: var(--font-ru);
  font-style: italic;
}

/* MCQ */
.mcq-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.mcq-choices button {
  font-family: var(--font-ru);
  font-size: 1.15rem;
  background: #fff;
  border: 2px solid var(--rl-rule);
  border-radius: 4px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.mcq-choices button:hover {
  border-color: var(--rl-navy);
}
.mcq-choices button.selected {
  border-color: var(--rl-navy);
  background: rgba(11, 42, 89, 0.06);
  font-weight: 700;
}
.mcq-choices button.correct {
  border-color: var(--rl-success);
  background: var(--rl-success-bg);
}
.mcq-choices button.incorrect {
  border-color: var(--rl-red);
  background: var(--rl-error-bg);
}
@media (max-width: 540px) {
  .mcq-choices { grid-template-columns: 1fr; }
}

/* Typing */
.typing-input {
  width: 100%;
  font-family: var(--font-ru);
  font-size: 1.3rem;
  padding: 12px 14px;
  border: 2px solid var(--rl-rule);
  border-radius: 4px;
  background: #fff;
}
.typing-input:focus {
  outline: none;
  border-color: var(--rl-navy);
}
.kb-hint {
  font-size: 0.85rem;
  color: var(--rl-ink-soft);
  margin-top: 8px;
}

/* Conjugation table */
.conj-table {
  width: 100%;
  border-collapse: collapse;
}
.conj-table th, .conj-table td {
  border: 1px solid var(--rl-rule);
  padding: 8px;
  text-align: center;
}
.conj-table th {
  background: #fff;
  color: var(--rl-navy);
  font-weight: 700;
}
.conj-table input {
  width: 100%;
  font-family: var(--font-ru);
  font-size: 1.05rem;
  border: none;
  background: transparent;
  text-align: center;
  padding: 6px;
}
.conj-table input:focus {
  outline: 2px solid var(--rl-navy);
  outline-offset: -2px;
  background: #fff;
}
.conj-table td.correct { background: var(--rl-success-bg); }
.conj-table td.incorrect { background: var(--rl-error-bg); }

/* Feedback */
.feedback {
  padding: 16px 20px;
  border-radius: 6px;
  margin-top: 16px;
}
.feedback.correct {
  background: var(--rl-success-bg);
  border-left: 4px solid var(--rl-success);
}
.feedback.incorrect {
  background: var(--rl-error-bg);
  border-left: 4px solid var(--rl-red);
}
.feedback h4 { margin: 0 0 6px; }
.feedback .correct-answer {
  font-family: var(--font-ru);
  font-weight: 700;
}
.feedback .explanation {
  margin-top: 6px;
  color: var(--rl-ink-soft);
  font-size: 0.95rem;
}

.quiz-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  gap: 12px;
}

/* Result */
.result-summary {
  text-align: center;
  margin-bottom: 32px;
}
.result-summary h2 {
  font-family: var(--font-serif-jp);
  color: var(--rl-navy);
  margin: 0 0 16px;
}
.score {
  font-size: 3rem;
  font-weight: 700;
  color: var(--rl-navy);
  font-family: var(--font-serif-jp);
}
.score .pct { color: var(--rl-red); }

.missed { margin: 32px 0; }
.missed h3 { color: var(--rl-navy); }
.missed ul {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
.missed li {
  background: var(--rl-bg-soft);
  border-left: 3px solid var(--rl-red);
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: 0 4px 4px 0;
}
.missed .miss-prompt { font-weight: 500; }
.missed .miss-answer { color: var(--rl-success); font-family: var(--font-ru); }
.missed .miss-yours { color: var(--rl-red); font-family: var(--font-ru); }

/* Footer */
.site-footer {
  text-align: center;
  padding: 24px;
  background: var(--rl-bg-soft);
  color: var(--rl-ink-soft);
  font-size: 0.85rem;
}

/* Cyrillic keyboard helper */
.cyrillic-keyboard {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 4px;
  max-width: 100%;
}
.cyrillic-keyboard button {
  font-family: var(--font-ru);
  background: #fff;
  border: 1px solid var(--rl-rule);
  padding: 8px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
}
.cyrillic-keyboard button:hover {
  background: var(--rl-bg-soft);
  border-color: var(--rl-navy);
}
@media (max-width: 540px) {
  .cyrillic-keyboard { grid-template-columns: repeat(8, 1fr); font-size: 0.85rem; }
}
