*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f0f23;
  --surface: #1a1a2e;
  --accent: #e94560;
  --text: #eeeeee;
  --text-dim: #888888;
  --success: #4caf50;
  --hidden: #444444;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Hiragino Kaku Gothic Pro', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100%;
  max-width: 560px;
  padding: 2.5rem 2rem;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ── Menu ── */
.title {
  font-size: 2.6rem;
  font-weight: bold;
  line-height: 1.4;
  margin-bottom: 3rem;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

/* ── Buttons ── */
.btn {
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
  width: 220px;
}

.btn:hover { opacity: 0.85; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #444;
}

.btn-text {
  background: transparent;
  color: var(--text-dim);
  width: auto;
  margin-top: 1.5rem;
  font-size: 0.95rem;
  border: none;
}

/* ── Stage Select ── */
h2 {
  font-size: 1.4rem;
  margin-bottom: 1.8rem;
  font-weight: normal;
}

.stage-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.stage-card {
  background: var(--surface);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s;
}

.stage-card:hover {
  border-color: var(--accent);
}

/* ── Level Select ── */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.btn-level {
  background: var(--surface);
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0.9rem 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s;
  color: var(--text);
}

.btn-level:hover {
  border-color: var(--accent);
}

.level-name {
  font-weight: bold;
  font-size: 1rem;
  width: 3.2rem;
  text-align: left;
  color: var(--accent);
  flex-shrink: 0;
}

.level-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  flex: 1;
  text-align: left;
}

.level-example {
  font-family: 'Hiragino Mincho Pro', 'Noto Serif JP', 'Yu Mincho', serif;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  color: var(--text);
  flex-shrink: 0;
}

/* ── Game Screen ── */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.game-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.2rem;
}

.meaning-text {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text);
  max-width: 440px;
}

.idiom-display {
  display: flex;
  gap: 0.4rem;
}

.kanji-char {
  font-family: 'Hiragino Mincho Pro', 'Noto Serif JP', 'Yu Mincho', serif;
  font-size: 3rem;
  width: 3.6rem;
  height: 3.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 8px;
  color: #ffffff;
  border: 1px solid #333;
}

.kanji-char.hidden-char {
  color: var(--hidden);
}

.input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.romaji-display {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 2rem;
  color: var(--text);
  min-height: 2.6rem;
  min-width: 240px;
  text-align: center;
  letter-spacing: 0.08em;
}

.romaji-display::after {
  content: '|';
  animation: blink 0.9s step-end infinite;
  color: var(--accent);
  margin-left: 1px;
}

.romaji-display.correct-flash {
  color: var(--success);
}

.romaji-display.shake {
  animation: shake 0.28s ease-out;
  color: var(--accent);
}

.hint-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── Result Screen ── */
.result-title {
  font-size: 2rem;
  margin-bottom: 2.5rem;
  color: var(--text);
}

.result-stats {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.stat-value {
  font-size: 2.2rem;
  font-weight: bold;
  color: var(--text);
  line-height: 1.1;
}

.stat-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.2rem;
}

.stat-unit {
  font-size: 1rem;
  color: var(--text-dim);
}

.result-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* ── Animations ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
