:root {
  --saizeriya-red: #e60012;
  --saizeriya-red-dark: #c4000f;
  --saizeriya-cream: #fff8f0;
  --saizeriya-green: #008c3a;
  --gold: #f5b400;
  --text: #222;
  --muted: #777;
  --border: #e5e0d8;
  --correct: #2d8f2d;
  --correct-bg: #e8f5e8;
  --wrong: #d23e3e;
  --wrong-bg: #fceaea;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--saizeriya-cream);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s ease; }
.screen.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  align-items: center; justify-content: center;
}
.screen.overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ Start screen ============ */
header { text-align: center; margin-bottom: 22px; }
.badge {
  display: inline-block;
  background: var(--gold);
  color: white;
  font-weight: bold;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
  box-shadow: 0 2px 6px rgba(245,180,0,0.4);
}
header h1 {
  color: var(--saizeriya-red);
  font-size: 1.85rem;
  margin: 0;
  letter-spacing: 0.02em;
}
header h1 .accent {
  background: linear-gradient(transparent 60%, #ffe566 60%);
  padding: 0 4px;
}
header .tag {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 8px 0 0;
}

.start-stats {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 22px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
}
.start-stats .stat {
  display: inline-block;
  margin: 4px 12px;
}
.start-stats .stat-value {
  color: var(--saizeriya-red);
  font-weight: bold;
  font-size: 1.2rem;
  margin-left: 4px;
}

button.primary {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--saizeriya-red);
  color: white;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
button.primary:hover { background: var(--saizeriya-red-dark); }
button.primary:active { transform: scale(0.98); }
button.primary.big {
  font-size: 1.3rem;
  padding: 18px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(230,0,18,0.3);
}

.start-foot {
  text-align: center;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.primary-link {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--saizeriya-red);
  color: white;
  padding: 12px;
  border-radius: 10px;
  font-weight: bold;
  margin-top: 14px;
}
.secondary-link {
  display: block;
  text-align: center;
  text-decoration: none;
  background: white;
  border: 2px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  margin-top: 12px;
}

/* ============ Lock screen ============ */
.lock-card {
  background: white;
  border-radius: 18px;
  padding: 32px 22px;
  text-align: center;
  border: 2px solid var(--border);
  margin-top: 32px;
}
.lock-icon { font-size: 4rem; margin-bottom: 8px; }
.lock-card h2 { margin: 0 0 6px; color: var(--saizeriya-red); }
.lock-tag { color: var(--muted); margin: 0 0 20px; font-size: 0.95rem; }
.lock-checklist {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  text-align: left;
  display: inline-block;
}
.lock-checklist li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.95rem;
}
.lock-checklist li:last-child { border-bottom: none; }
.lock-checklist li.done { color: var(--correct); }
.lock-checklist li.todo { color: var(--muted); }
.lock-hint {
  margin-top: 22px;
  font-size: 0.75rem;
  color: var(--muted);
}
.lock-hint code {
  background: #f3eee5;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ============ Celebration ============ */
.celebrate-card {
  background: white;
  border-radius: 22px;
  padding: 36px 28px;
  text-align: center;
  max-width: 420px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.celebrate-card h2 {
  color: var(--saizeriya-red);
  font-size: 1.6rem;
  margin: 8px 0 12px;
  position: relative; z-index: 2;
}
.celebrate-sub {
  font-size: 1.05rem;
  margin: 0 0 6px;
  font-weight: bold;
  position: relative; z-index: 2;
}
.celebrate-line {
  color: var(--muted);
  margin: 0 0 22px;
  position: relative; z-index: 2;
}
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.confetti span {
  position: absolute;
  top: -10px;
  width: 8px; height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(420px) rotate(720deg); opacity: 0.4; }
}

/* ============ Quiz screen ============ */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: white;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: var(--muted);
  border: 1px solid var(--border);
}
#progress { font-weight: bold; color: var(--text); }
#score-display { color: var(--saizeriya-red); font-weight: bold; }
#combo-display {
  color: var(--gold);
  font-weight: bold;
  min-width: 0;
  transition: transform 0.2s ease;
}
#combo-display.pop {
  animation: comboPop 0.4s ease;
}
@keyframes comboPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); color: #ff7700; }
  100% { transform: scale(1); }
}

.prompt {
  background: white;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
  border: 1px solid var(--border);
}
.prompt img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  display: block;
  margin: 0 auto 10px;
}
.prompt .question-text {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: bold;
  margin-top: 4px;
}
.prompt .item-name {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.choices {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.choice {
  background: white;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  min-height: 56px;
  letter-spacing: 0.02em;
}
.choice:hover:not(:disabled) {
  border-color: var(--saizeriya-red);
  background: #fff5f5;
  transform: translateY(-1px);
}
.choice:active:not(:disabled) { transform: scale(0.98); }
.choice:disabled { cursor: default; }
.choice small {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.78rem;
  font-weight: normal;
  color: var(--muted);
  letter-spacing: 0;
}
.choice.correct small { color: var(--correct); opacity: 0.8; }
.choice.wrong small   { color: var(--wrong);   opacity: 0.8; }
.choice.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  animation: correctFlash 0.5s ease;
}
.choice.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
  animation: wrongShake 0.4s ease;
}
@keyframes correctFlash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

.feedback {
  text-align: center;
  font-size: 1rem;
  min-height: 48px;
  font-weight: bold;
  line-height: 1.4;
}
.feedback.correct { color: var(--correct); }
.feedback.wrong { color: var(--wrong); }
.feedback .pop-msg {
  display: inline-block;
  animation: popUp 0.4s ease;
}
@keyframes popUp {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.feedback .small {
  display: block;
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--muted);
  margin-top: 4px;
}

/* ============ Result screen ============ */
#result-screen { text-align: center; padding-top: 12px; }
#result-screen h2 {
  font-size: 1.4rem;
  color: var(--saizeriya-red);
  margin: 8px 0 18px;
}

.title-banner {
  background: linear-gradient(135deg, #fff 0%, #fff8e0 100%);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 18px 14px;
  margin-bottom: 20px;
  font-weight: bold;
}
.title-banner .title-name {
  font-size: 1.7rem;
  color: var(--saizeriya-red);
  margin-bottom: 4px;
}
.title-banner .title-comment {
  color: var(--text);
  font-size: 0.95rem;
}
.title-banner .title-bonus {
  display: inline-block;
  margin-top: 8px;
  background: var(--gold);
  color: white;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.result-cell {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 6px;
}
.cell-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.cell-value {
  font-size: 1.6rem;
  font-weight: bold;
  color: var(--saizeriya-red);
}
.cell-unit {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 2px;
}

.best-line {
  background: white;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--muted);
}
.best-line.new-record {
  border-color: var(--gold);
  background: #fffbe8;
  color: #b87b00;
  font-weight: bold;
  animation: pulseRecord 1s ease infinite;
}
@keyframes pulseRecord {
  0%, 100% { box-shadow: 0 0 0 rgba(245,180,0,0); }
  50%      { box-shadow: 0 0 14px rgba(245,180,0,0.5); }
}

.trivia {
  background: #fff5f5;
  border-left: 4px solid var(--saizeriya-red);
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 22px;
  line-height: 1.6;
}
.trivia .trivia-label {
  display: block;
  font-weight: bold;
  color: var(--saizeriya-red);
  margin-bottom: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  margin: 0 auto;
}

/* ============ Initial state ============ */
/* No screen is .active by default; JS will activate the right one */
