:root {
  color-scheme: light;
  --ink: #17372f;
  --muted: #71827c;
  --green: #16624e;
  --green-dark: #103f34;
  --green-soft: #e6f0ec;
  --cream: #f5f2e9;
  --paper: #fffef9;
  --line: #dce3de;
  --orange: #dc783d;
  --red: #bb554e;
  --shadow: 0 14px 36px rgba(22, 62, 51, 0.09);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 5%, rgba(255, 255, 255, 0.85), transparent 27rem),
    var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; -webkit-tap-highlight-color: transparent; }

.app-header {
  padding: calc(18px + env(safe-area-inset-top)) 20px 24px;
  color: #fff;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.04), transparent 45%),
    var(--green-dark);
}

.header-inner {
  display: flex;
  align-items: center;
  max-width: 680px;
  margin: 0 auto;
  gap: 14px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 11px);
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.brand-mark span {
  width: 10px;
  height: 10px;
  border: 1.5px solid #fff;
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 2px;
  color: #b8d3ca;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 600;
  letter-spacing: 0.03em;
}

main {
  width: min(calc(100% - 28px), 680px);
  margin: 0 auto;
  padding: 20px 0 calc(48px + env(safe-area-inset-bottom));
}

.card {
  padding: 22px 18px;
  border: 1px solid rgba(22, 98, 78, 0.08);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.section-number {
  margin: 0 0 2px;
  color: var(--orange);
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h2 {
  margin: 0;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.section-note,
.record-count {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.score-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  gap: 9px;
}

.score-button {
  display: grid;
  min-width: 0;
  min-height: 68px;
  padding: 9px 6px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  box-shadow: 0 8px 18px rgba(22, 62, 51, 0.14);
  place-content: center;
  gap: 5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: filter 0.15s, transform 0.1s;
}

.score-button:active {
  transform: translateY(2px) scale(0.98);
}

.score-button:focus-visible,
.undo-button:focus-visible {
  outline: 3px solid rgba(22, 98, 78, 0.25);
  outline-offset: 3px;
}

.score-button.score-perfect { background: var(--green); }
.score-button.score-clear { background: var(--orange); }
.score-button.score-miss { background: var(--red); }

.score-button .score-symbol {
  font-family: Georgia, serif;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 0.85;
}

.score-button .score-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.today-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.today-counts div {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  gap: 9px;
}

.today-counts div + div { border-left: 1px solid var(--line); }
.today-counts span { font-family: Georgia, serif; font-size: 18px; }
.today-counts strong { font-size: 16px; }
.today-counts .perfect span { color: var(--green); }
.today-counts .clear span { color: var(--orange); }
.today-counts .miss span { color: var(--red); }

.live-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 12px 0 0;
  padding: 14px 6px;
  border-radius: 13px;
  background: var(--green-soft);
}

.live-summary div { padding: 0 6px; text-align: center; }
.live-summary div + div { border-left: 1px solid rgba(22, 98, 78, 0.16); }
.live-summary span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}
.live-summary strong {
  color: var(--green-dark);
  font-family: Georgia, serif;
  font-size: 18px;
}
.live-summary small { margin-left: 2px; font-family: sans-serif; font-size: 9px; }

.entry-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  margin-top: 14px;
  gap: 12px;
}

.entry-actions p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.undo-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.undo-button:disabled { cursor: default; opacity: 0.38; }

.records-section { margin-top: 32px; }
.records-heading { margin-bottom: 15px; padding: 0 4px; }
.record-count {
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(22, 98, 78, 0.08);
  color: var(--green);
  font-weight: 700;
}
.records-list { display: grid; gap: 13px; }
.record-card {
  padding: 16px;
  border: 1px solid rgba(22, 98, 78, 0.09);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 7px 20px rgba(22, 62, 51, 0.055);
}
.record-top { display: flex; align-items: center; justify-content: space-between; }
.record-date {
  font-family: Georgia, "Yu Mincho", serif;
  font-size: 16px;
  font-weight: 600;
}
.delete-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 9px;
  border: 0;
  border-radius: 50%;
  color: #8f9c97;
  background: transparent;
  place-items: center;
  cursor: pointer;
}
.delete-button:active { color: var(--red); background: #f7e9e7; }
.delete-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}
.record-scores {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.record-score {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 9px;
}
.record-score + .record-score { border-left: 1px solid var(--line); }
.record-score span { font-family: Georgia, serif; font-size: 18px; }
.record-score strong { font-size: 16px; }
.record-score.perfect span { color: var(--green); }
.record-score.clear span { color: var(--orange); }
.record-score.miss span { color: var(--red); }
.record-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
.record-stats div { text-align: center; }
.record-stats div + div { border-left: 1px solid var(--line); }
.record-stats span { display: block; color: var(--muted); font-size: 9px; }
.record-stats strong {
  display: block;
  margin-top: 3px;
  font-family: Georgia, serif;
  font-size: 15px;
}
.record-memo {
  margin: 13px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: #53645e;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.record-memo:empty { display: none; }
.empty-state {
  padding: 42px 20px;
  border: 1px dashed #bdcac5;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}
.empty-state[hidden] { display: none; }
.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border: 1px solid #c5d2cd;
  border-radius: 50%;
  color: var(--green);
  background: rgba(255, 255, 255, 0.45);
  font-family: Georgia, serif;
  font-size: 22px;
  place-items: center;
}
.empty-state p { margin: 0 0 5px; color: var(--ink); font-size: 14px; font-weight: 700; }
.empty-state span { font-size: 11px; }
.toast {
  position: fixed;
  z-index: 10;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 20px;
  max-width: 400px;
  margin: auto;
  padding: 13px 18px;
  border-radius: 12px;
  color: #fff;
  background: #183c33;
  box-shadow: 0 10px 28px rgba(16, 63, 52, 0.25);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (min-width: 560px) {
  .card { padding: 28px; }
  .score-buttons { gap: 13px; }
  .score-button { min-height: 78px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
