main {
  width: min(96vw, 920px);
  margin: 1.1rem auto 2rem;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 1rem + 1.2vw, 2rem);
}

h2 {
  margin: 0;
  font-size: clamp(1.4rem, 1.2rem + 1.4vw, 2.2rem);
}

.subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.45rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.55rem 0.45rem;
  text-align: center;
  background: linear-gradient(180deg, #fffefb 0%, #f9f5ed 100%);
}

.stat .k {
  color: var(--muted);
  font-size: 0.72rem;
  display: block;
  letter-spacing: 0.03em;
}

.stat .v {
  font-weight: 800;
  font-size: 1.08rem;
}

.strikes {
  display: inline-flex;
  gap: 0.2rem;
  margin-right: 0.25rem;
}

.strike-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid #c8ba9f;
  color: #7f7464;
  font-size: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f3ece0;
}

.strike-dot.is-on {
  border-color: #8f2d2d;
  background: #c84f4f;
  color: #fff5f5;
}

.play-area {
  position: relative;
  overflow: hidden;
}

.slots-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
  align-items: center;
}

.slot-btn,
.book-chip {
  border-radius: 10px;
  font: inherit;
}

.slot-btn {
  border: 1px solid #7a9eb5;
  background: linear-gradient(180deg, #eef8ff 0%, #cfe3f2 100%);
  color: #1f4258;
  padding: 0.45rem 0.55rem;
  min-width: 2.5rem;
  min-height: 2.7rem;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 0.2rem 0.45rem rgba(25, 59, 84, 0.16);
}

.book-chip {
  border: 1px solid #c6b08d;
  background: linear-gradient(180deg, #fffefb 0%, #f7efdf 100%);
  color: #3f301f;
  padding: 0.48rem 0.62rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 0.18rem 0.38rem rgba(57, 42, 23, 0.1);
}

button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.8rem;
  min-height: 2.85rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.actions button {
  white-space: nowrap;
  border: 1px solid #ccbca2;
  border-radius: 10px;
  padding: 0.62rem 0.8rem;
  min-height: 2.85rem;
  font-weight: 700;
  background: linear-gradient(180deg, #fff7ea 0%, #f1e6d2 100%);
  color: #47351f;
  box-shadow: 0 0.2rem 0.45rem rgba(53, 37, 20, 0.08);
}

.actions .start-action {
  margin-left: 0;
  order: -1;
}

.feedback {
  min-height: 1.35rem;
  margin: 0.75rem 0 0;
  font-weight: 700;
}

.feedback.good {
  color: var(--accent);
}

.feedback.bad {
  color: #b13f3f;
}

.miss-x {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(5rem, 22vw, 10rem);
  font-weight: 900;
  color: rgba(196, 37, 37, 0.96);
  text-shadow: 0 0 1.5rem rgba(128, 14, 14, 0.45);
  opacity: 0;
  pointer-events: none;
}

.miss-x.show {
  animation: miss-x-burst 420ms ease-out;
}

.play-area.flash-good {
  animation: flash-good 240ms ease;
}

.play-area.flash-bad {
  animation: flash-bad 240ms ease;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(26, 21, 14, 0.68);
  display: grid;
  place-items: center;
  padding: 1rem;
}

[hidden] {
  display: none !important;
}

.settings-card {
  width: min(92vw, 520px);
  max-height: min(86vh, 700px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  box-shadow: var(--shadow-deep);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.popup-close {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f0e4;
  color: #47351f;
  font: inherit;
  font-weight: 800;
  width: 1.9rem;
  height: 1.9rem;
}

.settings-grid {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.setting {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
  color: #4f4538;
}

.setting select {
  width: 100%;
}

.setting input[type="range"] {
  width: 100%;
}

.settings-subpanel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
  background: linear-gradient(180deg, #fffdf7 0%, #f8f3e8 100%);
}

.settings-subpanel h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: #5f5446;
}

#daily-status,
#daily-score,
#daily-best,
#daily-streak {
  margin: 0 0 0.35rem;
}

#review-empty {
  margin: 0 0 0.4rem;
}

.missed-list {
  margin: 0;
  padding-left: 1.2rem;
}

.missed-list li {
  margin-bottom: 0.25rem;
}

.summary-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(26, 21, 14, 0.62);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.summary-card {
  width: min(92vw, 460px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-deep);
}

.summary-card h2 {
  margin: 0 0 0.45rem;
}

.summary-card ul {
  margin: 0;
  padding-left: 1.1rem;
}

.summary-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.summary-actions button {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  font-weight: 700;
  background: #f6f0e4;
  color: #47351f;
}

#summary-play-again-btn {
  background: var(--start-bg);
  color: #f8fffb;
  border-color: var(--start-border);
}

@keyframes flash-good {
  0% {
    background-color: rgba(64, 158, 97, 0.22);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes flash-bad {
  0% {
    background-color: rgba(191, 72, 72, 0.2);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes miss-x-burst {
  0% {
    opacity: 0;
    transform: scale(0.65);
  }
  22% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

@media (max-width: 760px) {
  main {
    width: 100%;
    padding: 0 0.45rem 1rem;
  }

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

  .slot-btn,
  .book-chip {
    width: 100%;
  }

  .summary-actions {
    flex-direction: column;
  }
}
