:root {
  color-scheme: light;
  --ink: #181713;
  --paper: #f3eddf;
  --red: #e4472f;
  --yellow: #f2c94c;
  --muted: #746e63;
  --line: #27251f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(24,23,19,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24,23,19,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { color: inherit; }

.app {
  width: min(100%, 760px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px clamp(18px, 5vw, 42px) 18px;
  display: flex;
  flex-direction: column;
}

.topbar, .progress-strip, footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--ink);
  color: var(--paper);
  font-size: 25px;
  font-weight: 800;
  transform: rotate(-3deg);
}

h1 { margin: 0; font-size: 21px; letter-spacing: .08em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.icon-button {
  width: 46px;
  height: 46px;
  border: 2px solid var(--line);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--line);
}
.icon-button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }

.progress-strip {
  margin-top: 24px;
  padding: 13px 16px;
  border-block: 2px solid var(--line);
}
.progress-strip > div { display: flex; align-items: baseline; gap: 12px; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.progress-strip strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.progress-strip small { font-size: 13px; font-weight: 600; color: var(--muted); }
.today-block { text-align: right; }

.settings {
  margin-top: 14px;
  padding: 18px;
  border: 2px solid var(--line);
  background: #fffaf0;
  box-shadow: 6px 6px 0 var(--yellow);
  z-index: 2;
}
.settings[hidden] { display: none; }
.field { display: grid; grid-template-columns: 1fr 180px; align-items: center; gap: 14px; margin-bottom: 13px; }
.field label { font-size: 13px; font-weight: 800; }
.number-control { display: grid; grid-template-columns: 40px 1fr 40px; border: 2px solid var(--line); }
.number-control button { border: 0; background: var(--paper); cursor: pointer; font-size: 20px; font-weight: 800; }
.number-control input { width: 100%; min-width: 0; padding: 7px 4px; border: 0; border-inline: 2px solid var(--line); background: white; text-align: center; font-weight: 800; }
.number-control input::-webkit-inner-spin-button { appearance: none; }
.feedback-toggles { display: flex; gap: 10px; }
.feedback-toggles label { cursor: pointer; }
.feedback-toggles input { position: absolute; opacity: 0; }
.feedback-toggles span { display: inline-block; padding: 7px 13px; border: 2px solid var(--line); font-size: 12px; font-weight: 800; }
.feedback-toggles input:checked + span { background: var(--ink); color: white; }
.setting-hint { margin: 12px 0 0; color: var(--muted); font-size: 11px; }

.stage {
  flex: 1;
  min-height: 410px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 24px 0;
}

.counter {
  position: relative;
  isolation: isolate;
  width: min(67vw, 390px);
  aspect-ratio: 1;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--red);
  color: white;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 12px 14px 0 var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
}
.counter::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 50%;
}
.counter:active, .counter.is-tapped { transform: translate(7px, 8px) scale(.985); box-shadow: 5px 6px 0 var(--line); }
.counter-label { font-size: 14px; font-weight: 800; letter-spacing: .18em; }
.count { line-height: 1; margin: 20px 0 18px; font-size: clamp(74px, 18vw, 126px); font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.08em; }
.count small { font-size: 18px; letter-spacing: 0; opacity: .8; }
.tap-note { font-size: 11px; letter-spacing: .14em; opacity: .75; }
.progress-ring { position: absolute; z-index: -1; inset: 0; background: conic-gradient(var(--yellow) var(--progress, 0%), transparent 0); opacity: .35; }

.rest-card, .finish-card {
  width: min(86vw, 420px);
  min-height: 360px;
  border: 3px solid var(--line);
  background: var(--yellow);
  box-shadow: 12px 14px 0 var(--line);
  padding: 34px;
  text-align: center;
}
.rest-card[hidden], .finish-card[hidden] { display: none; }
.rest-kanji, .finish-mark { display: block; font-family: serif; font-size: 72px; font-weight: 900; line-height: 1; }
.rest-card p, .finish-card p { margin: 18px 0 8px; font-weight: 900; letter-spacing: .15em; }
.rest-card strong { display: block; font-size: 72px; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.rest-card > span:last-of-type { display: block; color: #5e552f; font-size: 12px; }
.rest-card button, .finish-card button { margin-top: 28px; padding: 12px 24px; border: 2px solid var(--line); background: white; font-weight: 900; cursor: pointer; box-shadow: 5px 5px 0 var(--line); }
.finish-card { background: #fffaf0; }
.finish-mark { width: 108px; height: 108px; margin: 0 auto; padding-top: 16px; border: 5px solid var(--red); border-radius: 50%; color: var(--red); transform: rotate(-8deg); }
.finish-card strong { display: block; margin-top: 30px; font-size: 24px; }

footer { min-height: 42px; gap: 14px; color: var(--muted); font-size: 12px; }
.reset-button { padding: 7px 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--muted); cursor: pointer; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

button:focus-visible, input:focus-visible { outline: 4px solid #315cff; outline-offset: 3px; }

@media (max-width: 520px) {
  .app { padding-top: 16px; }
  .progress-strip { margin-top: 18px; }
  .progress-strip > div { display: block; }
  .eyebrow { display: block; margin-bottom: 2px; }
  .stage { min-height: 390px; padding-block: 20px; }
  .counter { width: min(76vw, 340px); box-shadow: 8px 10px 0 var(--line); }
  .field { grid-template-columns: 1fr; gap: 6px; }
  .settings { max-height: 52dvh; overflow: auto; }
  .rest-card, .finish-card { min-height: 330px; padding: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
