:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f6f7f9;
  color: #1f2328;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: #f6f7f9;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="number"] {
  border: 1px solid #d0d7de;
  border-radius: 10px;
  background: #fff;
  color: inherit;
}

select,
input[type="number"] {
  min-height: 44px;
  padding: 0 12px;
}

.app-shell {
  min-height: 100vh;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 48px 24px;
}

.screen--active {
  display: flex;
}

#setup-screen,
#result-screen {
  align-items: center;
  justify-content: center;
}

.panel {
  width: min(760px, 100%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 22px;
  box-shadow: 0 16px 48px rgba(31, 35, 40, 0.08);
}

.setup-panel,
.result-panel {
  padding: 42px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #656d76;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.lead {
  margin-bottom: 34px;
  color: #656d76;
  line-height: 1.8;
}

.field-group {
  margin-top: 26px;
}

.field-group > label,
.field-group legend {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

#pack-select {
  width: 100%;
}

.muted {
  margin: 10px 0 0;
  color: #656d76;
  line-height: 1.7;
}

.meta {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: #8c959f;
}

.mode-group {
  padding: 0;
  border: 0;
}

.mode-group label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 22px;
  font-weight: 500;
  cursor: pointer;
}

.inline-setting {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-setting label {
  margin: 0;
}

#question-count {
  width: 92px;
}

.long-notice {
  margin-top: 28px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f6f8fa;
  color: #57606a;
}

.start-hint,
.result-hint {
  margin: 38px 0 0;
  text-align: center;
  color: #57606a;
  font-size: 0.95rem;
}

kbd {
  display: inline-block;
  min-width: 2.2em;
  padding: 3px 7px;
  border: 1px solid #d0d7de;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #f6f8fa;
  font-size: 0.8em;
  font-family: inherit;
  font-weight: 700;
}

.setup-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}

.button--secondary {
  border: 1px solid #d0d7de;
  background: #fff;
}

.error-box {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid #ffb8b8;
  border-radius: 10px;
  background: #fff1f1;
  color: #b42318;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#play-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding-top: 84px;
}

.play-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: 0 26px;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(246, 247, 249, 0.94);
  backdrop-filter: blur(8px);
  color: #656d76;
  font-size: 0.9rem;
}

#play-progress {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

#endurance-end {
  justify-self: end;
}

.text-button {
  border: 0;
  background: transparent;
  color: #57606a;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.typing-card {
  width: min(1100px, 100%);
  padding: 44px 24px;
  text-align: center;
  border-radius: 18px;
}

.question-display {
  font-size: clamp(1.45rem, 2.9vw, 2.45rem);
  font-weight: 700;
  line-height: 1.9;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.romaji-display {
  margin-top: 24px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.9;
  letter-spacing: 0.03em;
  overflow-wrap: anywhere;
}

.romaji-typed {
  color: #0969da;
  font-weight: 700;
}

.romaji-remaining {
  color: #9ca3af;
}

.typing-card--miss {
  animation: miss-flash 120ms ease-out;
}

@keyframes miss-flash {
  0% { background: rgba(207, 34, 46, 0.12); }
  100% { background: transparent; }
}

.scores {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.score-item {
  padding: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fbfcfd;
}

.score-label {
  display: block;
  color: #656d76;
  font-size: 0.9rem;
}

.score-value {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  font-variant-numeric: tabular-nums;
}

.review-block {
  margin-top: 38px;
  padding-top: 30px;
  border-top: 1px solid #e5e7eb;
}

.review-block h2 {
  font-size: 1.05rem;
}

.review-list {
  margin: 20px 0 0;
  padding-left: 1.7em;
}

.review-list li {
  margin-bottom: 14px;
  padding-left: 8px;
  line-height: 1.8;
}

@media (max-width: 640px) {
  .screen {
    padding: 24px 16px;
  }

  .setup-panel,
  .result-panel {
    padding: 28px 22px;
  }

  .scores {
    grid-template-columns: 1fr;
  }

  .play-topbar {
    padding: 0 14px;
    grid-template-columns: 1fr auto auto;
  }

  .typing-card {
    padding-inline: 4px;
  }
}
