@import url("https://fonts.googleapis.com/css2?family=Klee+One:wght@400;600&family=Noto+Serif+JP:wght@400;600;700&family=Zen+Maru+Gothic:wght@400;500;700&display=swap");

:root {
  --bg: #f5efe4;
  --paper: #fffaf2;
  --ink: #1b1b17;
  --muted: #6a5f53;
  --accent: #c83d2d;
  --accent-dark: #8d2d22;
  --accent-soft: #f1d2c4;
  --indigo: #1d3153;
  --sage: #7c8b74;
  --gold: #c9a66b;
  --line: #dccbb4;
  --shadow: rgba(18, 14, 10, 0.16);
  --success: #1f6b46;
  --danger: #9c3a2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Serif JP", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(29, 49, 83, 0.08) 0 22px, transparent 23px),
    radial-gradient(circle at 36px 36px, rgba(29, 49, 83, 0.08) 0 22px, transparent 23px),
    radial-gradient(circle at 50% 10%, rgba(201, 166, 107, 0.22), transparent 55%),
    radial-gradient(circle at 10% 75%, rgba(29, 49, 83, 0.1), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0 10px, rgba(240, 232, 220, 0.5) 10px 20px),
    var(--bg);
  background-size: 72px 72px, 72px 72px, auto, auto, auto, auto;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -20vh;
  background:
    repeating-radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(90deg, rgba(226, 212, 194, 0.35) 0 1px, transparent 1px 8px);
  opacity: 0.32;
  z-index: -1;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 52px;
  position: relative;
}

.page::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 24px;
  right: clamp(12px, 3vw, 32px);
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(201, 166, 107, 0.65), transparent);
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  position: relative;
}

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

.hero-ornaments {
  position: absolute;
  right: 18px;
  top: -8px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  pointer-events: none;
}

.tategaki {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "Klee One", cursive;
  font-size: 1.1rem;
  letter-spacing: 0.3em;
  color: rgba(29, 49, 83, 0.65);
  border-left: 1px solid rgba(29, 49, 83, 0.25);
  padding-left: 10px;
}

.seal {
  width: 52px;
  height: 52px;
  background: linear-gradient(145deg, #d44a38, #b03527);
  color: #fff7ee;
  display: grid;
  place-items: center;
  font-family: "Klee One", cursive;
  font-size: 1.4rem;
  border-radius: 10px;
  box-shadow: 0 12px 20px rgba(156, 58, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  color: var(--indigo);
  margin: 0 0 8px;
}

h1 {
  font-size: clamp(2.5rem, 4vw, 3.6rem);
  margin: 0 0 8px;
  font-family: "Klee One", cursive;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 2.2fr;
  gap: 24px;
  position: relative;
}

.layout.controls-collapsed {
  grid-template-columns: 1fr;
}

.layout.controls-collapsed .controls {
  display: none;
}

.controls,
.game-card {
  background: var(--paper);
  border-radius: 22px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 44px var(--shadow);
}

.controls {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.controls::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 40%),
    repeating-linear-gradient(45deg, rgba(223, 210, 193, 0.3) 0 10px, transparent 10px 20px);
  opacity: 0.5;
  pointer-events: none;
}

.panel-header h2 {
  margin: 0 0 6px;
  font-family: "Klee One", cursive;
}

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

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: "Zen Maru Gothic", sans-serif;
  color: var(--muted);
}

input,
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: inherit;
  background: #fbf6ec;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.range-row {
  display: flex;
  justify-content: flex-end;
}

.voice-row select {
  flex: 1;
}

.control-actions {
  display: flex;
  gap: 12px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #fdf7ed;
  border-radius: 14px;
  padding: 14px;
  border: 1px dashed var(--line);
}

.stats.stats-srs {
  grid-template-columns: repeat(4, 1fr);
}

.stats.hidden {
  display: none;
}

.app-version {
  font-size: 0.85rem;
}

.app-commit {
  font-size: 0.8rem;
  opacity: 0.8;
}

.retention-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.retention-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(29, 49, 83, 0.12);
  border-radius: 10px;
  font-size: 0.9rem;
}

.retention-list .retention-kana {
  font-weight: 600;
}

.retention-list .retention-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.srs-only {
  display: none;
}

body.srs-enabled .srs-only {
  display: flex;
  flex-direction: column;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.game {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  padding: 16px;
  background: linear-gradient(160deg, rgba(255, 250, 242, 0.9), rgba(245, 235, 221, 0.6));
  border-radius: 24px;
  border: 1px solid rgba(29, 49, 83, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.game::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(29, 49, 83, 0.35), transparent);
}

.game-card {
  padding: 28px;
  position: relative;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(29, 49, 83, 0.12);
  border-radius: 18px;
  pointer-events: none;
}

.feedback-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: "Zen Maru Gothic", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translate(-50%, -6px);
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.feedback-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.feedback-toast.correct {
  background: rgba(31, 107, 70, 0.12);
  color: var(--success);
  border: 1px solid rgba(31, 107, 70, 0.35);
}

.feedback-toast.incorrect {
  background: rgba(156, 58, 42, 0.12);
  color: var(--danger);
  border: 1px solid rgba(156, 58, 42, 0.35);
}

.game-card.flash-correct {
  animation: flashCorrect 0.5s ease;
  border-color: rgba(31, 107, 70, 0.45);
}

.game-card.flash-incorrect {
  animation: flashIncorrect 0.5s ease;
  border-color: rgba(156, 58, 42, 0.45);
}

@keyframes flashCorrect {
  0% {
    box-shadow: 0 0 0 rgba(31, 107, 70, 0.0);
  }
  40% {
    box-shadow: 0 0 0 8px rgba(31, 107, 70, 0.15);
  }
  100% {
    box-shadow: 0 0 0 rgba(31, 107, 70, 0.0);
  }
}

@keyframes flashIncorrect {
  0% {
    box-shadow: 0 0 0 rgba(156, 58, 42, 0.0);
  }
  40% {
    box-shadow: 0 0 0 8px rgba(156, 58, 42, 0.15);
  }
  100% {
    box-shadow: 0 0 0 rgba(156, 58, 42, 0.0);
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Zen Maru Gothic", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.card-body h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  margin: 4px 0 12px;
  font-family: "Klee One", cursive;
}

.card-body h3 {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  margin: 4px 0 0;
  color: var(--accent-dark);
  font-family: "Noto Serif JP", serif;
}

.card-meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: 0;
  font-family: "Zen Maru Gothic", sans-serif;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(29, 49, 83, 0.25), transparent);
  margin: 16px 0;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.game-hint {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line);
}

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: "Zen Maru Gothic", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #e18a59);
  color: #fff;
  box-shadow: 0 10px 24px rgba(197, 75, 55, 0.28);
}

.btn.ghost {
  background: #f7efe2;
  color: var(--ink);
}

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

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

.btn.warning {
  background: #b07a32;
  color: #fff;
}

#stopBtn {
  display: none;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px var(--shadow);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fbf6ed;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.hidden {
  visibility: hidden;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .layout.controls-collapsed .controls {
    display: none;
  }

  .hero-ornaments {
    position: static;
    margin-left: auto;
  }

  .page::after {
    display: none;
  }

  .game::before {
    display: none;
  }

  .stats.stats-srs {
    grid-template-columns: repeat(2, 1fr);
  }
}
