:root {
  color-scheme: light;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  color: #202124;
  background: #f5f5f3;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  min-height: 100svh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background: #f5f5f3;
}

button, input { font: inherit; }

.app {
  width: min(100%, 520px);
  padding: clamp(24px, 6vw, 42px);
  border: 1px solid #deded9;
  border-radius: 18px;
  background: #fff;
}

header { margin-bottom: 30px; }
h1 { margin: 0; font-size: clamp(30px, 8vw, 42px); line-height: 1.1; letter-spacing: -.045em; }
.intro { margin: 12px 0 0; color: #686a64; line-height: 1.55; }

.setup {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid #e3e3df;
  border-radius: 12px;
  background: #f7f7f5;
}

.setup > label, legend { font-size: 14px; font-weight: 700; }
.score-input { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.score-input input {
  width: 80px;
  padding: 8px 10px;
  border: 1px solid #cbc7bd;
  border-radius: 10px;
  background: #fff;
  text-align: right;
  font-weight: 800;
}

fieldset { display: contents; }
legend { padding: 0; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 9px; background: #e5e5e1; }
.mode-switch label { cursor: pointer; }
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch span { display: block; min-width: 64px; padding: 7px 12px; border-radius: 8px; color: #666761; text-align: center; font-size: 13px; font-weight: 800; }
.mode-switch input:checked + span { color: #202124; background: #fff; }
.mode-switch input:focus-visible + span { outline: 3px solid rgba(35, 95, 170, .25); }

.result { padding: 34px 4px 30px; }
.result p { margin: 0 0 5px; color: #777870; font-size: 14px; font-weight: 700; }
.score { display: flex; align-items: baseline; gap: 8px; }
.score strong { font-size: clamp(64px, 18vw, 88px); line-height: 1; letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.score span { color: #777870; font-size: 18px; font-weight: 700; }
.progress { height: 7px; margin-top: 20px; overflow: hidden; border-radius: 99px; background: #e5e2da; }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: #235faa; transition: width .18s ease; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.actions button {
  min-height: 92px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: #303236;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: background .12s ease;
}
.actions button:hover { background: #235faa; }
.actions button:active { background: #1c4f90; }
.actions button:focus-visible, .secondary-actions button:focus-visible, input:focus-visible { outline: 3px solid rgba(35, 95, 170, .25); outline-offset: 3px; }
.actions button span { display: block; margin-bottom: 3px; font-size: 34px; line-height: 1; }
.actions button small { display: block; margin-top: 9px; color: #c8c9cc; font-size: 12px; font-weight: 600; }
.actions button small b { color: #fff; }

.secondary-actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.secondary-actions button { display: inline-grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 0; border-radius: 8px; color: #6a6b65; background: transparent; cursor: pointer; }
.secondary-actions svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.secondary-actions button:hover:not(:disabled) { color: #202124; }
.secondary-actions button:disabled { color: #b8b8b3; cursor: default; }
.hint { margin: 4px 0 0; color: #96968f; text-align: center; font-size: 12px; }

@media (max-width: 410px) {
  .setup { grid-template-columns: 1fr; }
  .score-input, .mode-switch { justify-self: stretch; }
  .score-input input { flex: 1; }
  .actions button { min-height: 82px; }
}

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