:root {
  --ink: #202124;
  --muted: #667085;
  --paper: #faf7f0;
  --panel: #fffdf8;
  --line: #ded7cc;
  --red: #c84b47;
  --green: #217c63;
  --blue: #2f5f8f;
  --gold: #c99328;
  --shadow: 0 18px 50px rgba(47, 42, 35, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(200, 75, 71, 0.16), transparent 34rem),
    linear-gradient(135deg, #f8f1e4 0%, #eef4f1 55%, #f7eee8 100%);
}

button {
  font: inherit;
}

input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: stretch;
}

.game-panel,
.side-panel {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid rgba(222, 215, 204, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.game-panel {
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-panel {
  border-radius: 8px;
  padding: 20px;
  overflow: auto;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.start-button {
  min-width: 120px;
  min-height: 48px;
  border: 1px solid rgba(32, 33, 36, 0.18);
  border-radius: 8px;
  background: var(--green);
  color: #fffdf8;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  transition: transform 140ms ease, background 140ms ease;
}

.start-button:hover,
.start-button:focus-visible {
  background: #1a6752;
  transform: translateY(-2px);
  outline: none;
}

.start-button:disabled {
  background: #d8d1c7;
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
}

h2 {
  font-size: 1.12rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
}

.mode-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.mode-button.is-active {
  border-color: rgba(33, 124, 99, 0.58);
  background: #effaf5;
  color: var(--ink);
}

.training-section {
  display: grid;
  gap: 8px;
}

.section-title {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
}

.group-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.group-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.group-button:hover,
.group-button:focus-visible {
  border-color: var(--blue);
  transform: translateY(-1px);
  outline: none;
}

.group-button.is-active {
  color: var(--ink);
  border-color: rgba(33, 124, 99, 0.58);
  background: #effaf5;
  box-shadow: 0 1px 8px rgba(50, 45, 38, 0.1);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.8rem;
  line-height: 1;
}

.timer-shell {
  display: grid;
  gap: 8px;
}

.timer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.timer-track {
  height: 14px;
  border-radius: 999px;
  background: #e5ddd1;
  overflow: hidden;
}

.timer-fill {
  width: 100%;
  height: 100%;
  background: var(--green);
  transition: width 80ms linear;
}

.arena {
  flex: 1;
  min-height: 420px;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(260px, 1fr) auto;
  gap: 14px;
  align-items: stretch;
}

.practice-card {
  position: relative;
  min-height: 300px;
  border-radius: 8px;
  border: 1px solid #d7c4a4;
  background: #fff8eb;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.practice-card::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 6px;
  pointer-events: none;
}

.practice-card.is-correct {
  border-color: var(--green);
  background: #e9f7f1;
}

.practice-card.is-wrong {
  border-color: var(--red);
  background: #fff0ef;
}

.card-hint {
  position: absolute;
  top: 18px;
  left: 18px;
  color: var(--muted);
  font-weight: 700;
}

.kana {
  font-family: "UD Digi Kyokasho N-R", "Yu Gothic", "Meiryo", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: clamp(8rem, 18vw, 13rem);
  font-weight: 500;
  line-height: 1;
  max-width: calc(100% - 56px);
  color: #1f1d1a;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
  text-align: center;
  text-shadow: 0 10px 24px rgba(60, 45, 32, 0.15);
}

.kana.is-word {
  font-size: clamp(3.2rem, 8vw, 7rem);
  line-height: 1.08;
}

.kana.is-long-word {
  font-size: clamp(2.4rem, 5.4vw, 4.6rem);
  line-height: 1.14;
}

.kana.is-very-long-word {
  font-size: clamp(1.7rem, 3.7vw, 3.2rem);
  line-height: 1.2;
}

.kana.is-extra-long-word {
  font-size: clamp(1.25rem, 2.7vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0;
}

.romaji-preview {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 54px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
  font-weight: 900;
}

.typing-panel {
  min-height: 154px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.76);
  display: flex;
  flex-direction: column;
  justify-content: end;
  gap: 12px;
  padding: 24px;
}

.input-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.romaji-input {
  width: 100%;
  min-height: 84px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0;
  padding: 12px 16px;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease;
}

.romaji-input:focus {
  border-color: var(--blue);
}

.submit-button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf8;
  font-size: 1rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.submit-button:hover,
.submit-button:focus-visible {
  background: #343537;
  transform: translateY(-2px);
  outline: none;
}

.submit-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.kana-map {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.map-tile {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.map-tile strong {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
  line-height: 1;
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .practice-card {
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .game-panel,
  .side-panel {
    padding: 14px;
  }

  .top-bar {
    flex-direction: column;
  }

  .start-button {
    width: 100%;
  }

  .group-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .typing-panel {
    min-height: 142px;
    padding: 16px;
  }

  .romaji-input {
    min-height: 70px;
    font-size: 1.6rem;
  }
}
