:root {
  --bg: #fff7dd;
  --paper: #fffefa;
  --ink: #473b31;
  --accent: #f5a623;
  --accent-dark: #db7e00;
  --pink: #f0778d;
  --mint: #68c9ae;
  --line: #ead9ae;
  --shadow: 0 10px 0 #e6c978;
  --radius: 28px;
  --font: 'Hiragino Maru Gothic ProN', 'BIZ UDPGothic', system-ui, sans-serif;
  --space: clamp(12px, 2vw, 28px);
  --title: clamp(28px, 4vw, 52px);
  --count: clamp(108px, 23vw, 240px);
}
* {
  box-sizing: border-box;
}
html,
body,
#app {
  min-height: 100%;
  margin: 0;
}
body {
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
}
button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}
#settings {
  position: fixed;
  top: var(--space);
  right: var(--space);
  z-index: 4;
  border: 0;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  background: var(--paper);
  box-shadow:
    0 3px 0 var(--line),
    0 0 0 0 var(--accent);
  font-size: 24px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#settings.holding {
  box-shadow:
    0 3px 0 var(--line),
    0 0 0 10px var(--accent);
  transition: box-shadow var(--hold-ms) linear;
}
.gear-hint {
  position: fixed;
  top: calc(var(--space) + 56px);
  right: var(--space);
  z-index: 4;
  margin: 0;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
}
.gear-hint[hidden] {
  display: none;
}
.screen {
  width: min(100%, 1100px);
  min-height: 100vh;
  margin: auto;
  padding: calc(var(--space) * 2) max(var(--space), env(safe-area-inset-left))
    calc(var(--space) * 2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: var(--space);
}
h1,
p {
  margin: 0;
}
h1 {
  font-size: var(--title);
  line-height: 1.25;
}
.label {
  color: #866f5d;
  font-size: clamp(16px, 2.5vw, 24px);
  font-weight: 700;
}
.count-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  color: var(--accent-dark);
  text-shadow: 0 4px 0 #fff;
}
.count-number {
  font-size: var(--count);
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 0.9;
}
.count-goal {
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 800;
}
.count-button:active .count-number {
  animation: pop 0.24s ease-out;
}
.progress {
  width: min(86vw, 650px);
  height: 28px;
  overflow: hidden;
  border: 4px solid var(--line);
  border-radius: 99px;
  background: var(--paper);
}
.progress span {
  display: block;
  height: 100%;
  width: calc(var(--progress) * 100%);
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), #9ae5b8);
  transition: width 0.18s ease-out;
}
.is-close .progress {
  animation: breathe 1.2s ease-in-out infinite;
}
.stars {
  width: min(92vw, 700px);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 6px;
  font-size: clamp(20px, 3vw, 34px);
  color: #d8c9a6;
}
.star.is-filled {
  color: var(--accent);
  animation: pop 0.3s ease-out;
}
.secondary,
.primary {
  min-width: 144px;
  min-height: 48px;
  border: 0;
  border-radius: 99px;
  padding: 10px 20px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--line);
}
.secondary {
  background: var(--paper);
}
.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 5px 0 var(--accent-dark);
  font-size: clamp(20px, 3vw, 30px);
}
.celebrate-screen,
.timeup-screen {
  width: 100vw;
  min-height: 100dvh;
}
.celebrate-screen {
  background: linear-gradient(135deg, #fff5b7, #ffd571);
}
.celebrate-message span,
.timeup-screen span {
  color: var(--accent-dark);
  font-size: clamp(90px, 16vw, 180px);
  display: block;
  animation: pop 0.6s ease-out;
}
.cards {
  width: min(94vw, 900px);
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: clamp(10px, 2vw, 20px);
}
.card {
  min-height: 145px;
  padding: 10px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 5px 0 var(--line);
  font-weight: 800;
  font-size: clamp(14px, 2vw, 20px);
}
.card.is-focused {
  outline: 5px solid var(--accent);
  transform: translateY(-4px);
}
.card-emoji {
  display: block;
  font-size: clamp(48px, 7vw, 76px);
}
.card-image,
.chosen-image {
  display: block;
  width: clamp(48px, 7vw, 76px);
  height: clamp(48px, 7vw, 76px);
  margin: 0 auto;
  border-radius: 18px;
  object-fit: cover;
}
.chosen-image {
  width: 120px;
  height: 120px;
}
.chosen-card {
  min-width: min(80vw, 440px);
  padding: 32px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chosen-card span {
  font-size: 120px;
}
.timer {
  color: var(--accent-dark);
  font-size: clamp(86px, 18vw, 190px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.timer.is-urgent,
.timeup-screen {
  animation: breathe 1.2s ease-in-out infinite;
}
.reward-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}
.reward-image {
  width: 40px;
  height: 40px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 50%;
  object-fit: cover;
}
.settings-panel {
  position: fixed;
  z-index: 10;
  inset: 0;
  padding: var(--space);
  overflow-y: auto;
  background: rgb(71 59 49 / 48%);
}
.settings-panel[hidden] {
  display: none;
}
.settings-dialog {
  width: min(100%, 760px);
  min-height: min-content;
  margin: auto;
  padding: clamp(20px, 4vw, 40px);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.settings-dialog h2,
.settings-dialog h3 {
  margin: 0 0 16px;
}
.settings-dialog label,
.settings-dialog fieldset {
  display: block;
  margin: 16px 0;
  font-weight: 800;
}
.settings-dialog input:not([type='checkbox']):not([type='file']) {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.settings-dialog fieldset {
  border: 2px solid var(--line);
  border-radius: 16px;
}
.settings-options,
.emoji-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-option {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  padding: 6px 12px;
  background: var(--bg);
  font-weight: 800;
}
.check-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.check-row input {
  width: 24px;
  height: 24px;
}
.settings-close {
  float: right;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--bg);
  font-size: 30px;
}
.settings-cards ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.settings-card-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) repeat(3, auto);
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  border-radius: 16px;
  background: var(--bg);
}
.settings-card-row .secondary {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
}
.settings-card-image {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
}
.card-form {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--line);
}
.settings-error {
  min-height: 1.5em;
  color: var(--accent-dark);
  font-weight: 800;
}
.settings-image-status {
  min-height: 1.25em;
}
.timeup-screen {
  background: linear-gradient(135deg, #ffdce3, #ffc36d);
  cursor: pointer;
}
.fx {
  position: fixed;
  z-index: 3;
  left: 50%;
  top: 50%;
  pointer-events: none;
}
.fx i {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  animation: fly 0.7s ease-out var(--delay) forwards;
}
.confetti i {
  width: 10px;
  height: 22px;
  border-radius: 3px;
  background: var(--pink);
}
.confetti i:nth-child(3n) {
  background: var(--mint);
}
.big i {
  width: 18px;
  height: 18px;
}
@keyframes pop {
  0% {
    transform: scale(0.65);
  }
  65% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes breathe {
  50% {
    transform: scale(1.025);
  }
}
@keyframes fly {
  to {
    transform: translate(var(--x), var(--y)) rotate(280deg);
    opacity: 0;
  }
}
@media (max-width: 600px) {
  .cards {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  .card {
    min-height: 120px;
  }
  .settings-card-row {
    grid-template-columns: 40px minmax(0, 1fr) repeat(2, auto);
  }
}
@media (max-height: 650px) and (min-width: 700px) {
  .screen {
    padding-block: 18px;
    gap: 12px;
  }
  .card {
    min-height: 104px;
  }
  .card-emoji {
    font-size: 46px;
  }
}
