@font-face {
  font-family: Jua;
  src: url("assets/jua-title.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #352b24;
  --muted: #6e5748;
  --orange: #ab3f22;
  --cream: #fffdfa;
  --outline: #e5cc9e;
  --round-font: Jua, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: #fff7e7;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background-image: radial-gradient(#d9b77e63 .8px, transparent .8px), radial-gradient(ellipse at top, #ffedc1, #fff8ed 72%);
  background-size: 19px 19px, 100% 100%;
}

h1, h2, p, ol { margin: 0; }
button, input { font: inherit; }
button:focus-visible, .choice input:focus-visible + .tile { outline: 3px solid #803218; outline-offset: 3px; }
[hidden] { display: none !important; }

.book { width: min(100% - 3rem, 960px); margin: auto; padding: 45px 0 30px; }
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  align-items: center;
  min-height: 247px;
  margin-bottom: 25px;
  padding: 23px 47px 27px;
  border: 1px solid #ecd09e;
  border-radius: 32px;
  background: linear-gradient(116deg, #fffdf6 5%, #fff6db 68%, #ffe9aa 100%);
  box-shadow: 0 7px 0 #edcc914d;
}

.hero-name { color: #8a4628; font: 400 clamp(26px, 4vw, 38px)/1.05 var(--round-font); }
.hero h1 { font: 400 clamp(46px, 8.2vw, 93px)/1 var(--round-font); letter-spacing: -.045em; margin: 5px 0 12px; }
.hero h1 span { color: var(--orange); }
.hero-line { color: #684b38; font-size: clamp(14px, 2.2vw, 19px); font-weight: 720; }

.hero-art { position: relative; height: 198px; min-width: 0; }
.hero-art img { position: absolute; height: auto; filter: drop-shadow(0 6px 6px #7d4b2526); }
.hero-star { width: min(52%, 190px); left: 25%; top: 2%; transform: rotate(-12deg); z-index: 1; }
.hero-rainbow { width: min(32%, 115px); left: 6%; bottom: 1%; transform: rotate(-13deg); z-index: 2; }
.hero-berry { width: min(30%, 108px); right: 1%; bottom: 0; transform: rotate(16deg); z-index: 2; }
.sparkle { position: absolute; color: #ac5f32; line-height: 1; }
.sparkle-top { right: 12%; top: 6%; font-size: 29px; }
.sparkle-left { left: 11%; top: 14%; font-size: 35px; }
.sparkle-right { right: 20%; bottom: -1%; color: #a94941; font-size: 18px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.26fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { position: relative; min-width: 0; padding: 24px; border: 1px solid var(--outline); border-radius: 26px; }
.board { background: var(--cream); box-shadow: 0 5px 0 #e2bd7f42; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card h2 { font: 400 clamp(25px, 4.8vw, 32px)/1.1 var(--round-font); }
.count { display: flex; align-items: baseline; gap: 4px; padding: 5px 12px; border-radius: 999px; background: #faecd5; color: #694330; font-size: 13px; white-space: nowrap; }
.count strong { color: #943a22; font-size: 20px; line-height: 1; }

progress { display: block; width: 100%; height: 9px; border: 0; border-radius: 999px; appearance: none; margin: 13px 0 19px; background: #f3e6d0; overflow: hidden; }
progress::-webkit-progress-bar { background: #f3e6d0; }
progress::-webkit-progress-value { background: #e3804f; border-radius: 999px; transition: width .24s ease-out; }
progress::-moz-progress-bar { background: #e3804f; border-radius: 999px; }

.slots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; padding: 0; list-style: none; }
.slot {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid #eedbb8;
  border-radius: clamp(10px, 2.2vw, 18px);
  background: #faf2e4;
  color: #775a43;
  font-weight: 750;
  font-size: clamp(12px, 2.6vw, 17px);
  font-variant-numeric: tabular-nums;
}
.slot.next { border: 1.5px dashed #bd7145; background: #fff0cf; color: #a34d2d; }
.slot.next .slot-icon { font-size: 1.35em; }
.slot.filled { background: #fff7e6; }
.slot.filled:nth-child(4n + 2) { background: #fff1ee; }
.slot.filled:nth-child(4n + 3) { background: #eef4ff; }
.slot.filled:nth-child(4n) { background: #f0f3e8; }
.slot img { width: 90%; height: auto; filter: drop-shadow(0 2px 1px #60402126); transform: rotate(-6deg); }
.slot:nth-child(even) img { transform: rotate(7deg); }
.slot.new img { animation: stamp .38s cubic-bezier(.23, 1.57, .5, 1) both; }

.board-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 43px; margin-top: 8px; }
#message { font-size: clamp(13px, 2.8vw, 15px); font-weight: 690; color: var(--muted); }
.board.complete #message { color: #8b3520; }
.undo { min-height: 43px; padding: 5px 2px 5px 6px; background: transparent; color: #74574a; border: 0; border-radius: 8px; white-space: nowrap; cursor: pointer; font-size: 13px; }
.undo:hover { text-decoration: underline; }

.tray { background: #f1f3e5; border-color: #d1d7b9; box-shadow: 0 5px 0 #bdc69d4a; }
.tray h2 { color: #35402d; }
.tray-hint { margin: 5px 0 13px; color: #525f46; font-size: 14px; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; border: 0; min-inline-size: 0; margin: 0; padding: 0; }
.choice { cursor: pointer; }
.choice input, .sr-only { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tile { display: grid; justify-items: center; align-content: center; gap: 2px; height: 100%; padding: 2px 2px 5px; border: 1px solid #dce0c9; border-radius: 13px; background: #fffef7; color: #46513b; font-size: 12px; font-weight: 710; transition: background .18s, transform .18s; }
.tile img { width: min(100%, 54px); height: auto; display: block; filter: drop-shadow(0 2px 1px #70533118); }
.choice input:checked + .tile { background: #fff0c5; border-color: #a64c2f; color: #71381f; box-shadow: inset 0 0 0 1px #a64c2f; }
.choice input:disabled + .tile { opacity: .72; cursor: default; }
@media (hover: hover) { .choice:hover .tile { transform: translateY(-2px); } }

.add {
  width: 100%;
  min-height: 49px;
  margin-top: 13px;
  padding: 9px 12px;
  border: 1px solid #9b3d24;
  border-radius: 14px;
  background: #b64b2a;
  color: #fffdf6;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 #84361e;
}
.add span { font-size: 19px; margin-right: 2px; vertical-align: -1px; }
.add:hover:not(:disabled) { background: #a84022; }
.add:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #84361e; }
.add:disabled { color: #695c48; background: #eae1c9; border-color: #d8caac; box-shadow: none; cursor: default; }
.save-note { color: #6e5747; font-size: 12px; text-align: center; margin: 19px 0 0; }

.confetti { position: absolute; overflow: hidden; inset: 0; border-radius: inherit; pointer-events: none; }
.piece { position: absolute; top: 30%; left: 50%; width: 8px; height: 12px; border-radius: 3px; background: var(--piece); animation: confetti .95s ease-out both; }
@keyframes stamp { from { scale: .62; opacity: .55; } 65% { scale: 1.12; } to { scale: 1; } }
@keyframes confetti {
  from { transform: translate(-50%, -60%) rotate(0); opacity: 1; }
  65% { opacity: 1; }
  to { transform: translate(var(--x), var(--y)) rotate(var(--spin)); opacity: 0; }
}

@media (max-width: 720px) {
  .book { width: min(100% - 28px, 500px); padding: 19px 0 24px; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, .72fr); min-height: 154px; padding: 14px 18px; margin-bottom: 16px; border-radius: 24px; }
  .hero h1 { font-size: clamp(32px, 10.2vw, 56px); margin: 4px 0 6px; }
  .hero-name { font-size: clamp(23px, 6vw, 30px); }
  .hero-line { font-size: clamp(11px, 3.35vw, 15px); }
  .hero-art { height: clamp(87px, 28vw, 138px); }
  .hero-star { width: 76%; left: 13%; top: 5%; }
  .hero-rainbow { width: 50%; left: -4%; bottom: 1%; }
  .hero-berry { width: 39%; right: -1%; bottom: 1%; }
  .sparkle-top { right: 3%; top: 2%; font-size: 18px; }
  .sparkle-left { left: 1%; top: 12%; font-size: 20px; }
  .sparkle-right { bottom: -3%; font-size: 12px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .card { padding: 14px; border-radius: 21px; }
  progress { margin: 9px 0 11px; height: 8px; }
  .slots { gap: 6px; }
  .board-foot { min-height: 34px; margin-top: 4px; }
  .undo { min-height: 34px; }
  .tray-hint { margin-top: 3px; margin-bottom: 8px; font-size: 13px; }
  .choices { gap: 6px; }
  .tile img { width: min(100%, 48px); }
  .add { margin-top: 9px; }
  .save-note { margin-top: 14px; }
}

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