@font-face {
  font-family: Fredoka;
  src: url("../fonts/Fredoka.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #fff4e6;
  --ink: #3c2a22;
  --coral: #ff6b4a;
  --sun: #ffc14d;
  --leaf: #21b888;
  --sky: #4aa3e8;
  --grape: #7d6ae8;
  --card: #fffdf8;
  color: var(--ink);
  font-family: Fredoka, "Trebuchet MS", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  background:
    radial-gradient(circle at 8% 12%, #ffe1c4 0 18%, transparent 19%),
    radial-gradient(circle at 92% 88%, #d9f3e4 0 16%, transparent 17%),
    radial-gradient(circle at 88% 8%, #ffe7a8 0 12%, transparent 13%),
    var(--paper);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

button svg { pointer-events: none; }

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 8px 12px 0;
}

.top.lone { justify-content: flex-end; }

.icon-btn, .tool, .mini {
  width: 76px;
  height: 76px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 0 #eadcc8;
  display: grid;
  place-items: center;
  color: var(--ink);
}

.icon-btn:active, .tool:active, .big-choice:active, .map-item:active, .tile:active, .sticker:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #eadcc8;
}

.ico { width: 54%; height: 54%; }

.side-pic {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 22px;
  padding: 4px 14px 4px 4px;
  box-shadow: 0 6px 0 #eadcc8;
  max-width: 42vw;
}

.side-pic .emoji, .side-pic .count { width: 64px; height: 64px; font-size: 52px; line-height: 64px; text-align: center; }
.word { font-size: 28px; font-weight: 650; }

.home {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 8px 24px 24px;
}

.big-choice {
  width: min(30vw, 280px);
  height: min(62vh, 340px);
  border-radius: 40px;
  background: var(--card);
  box-shadow: 0 10px 0 #eadcc8;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.big-choice.draw { background: #fff7df; }
.big-choice.find { background: #e7f6ff; }
.big-choice.album { background: #fff0ea; }

.choice-art { width: 78%; height: 70%; display: grid; place-items: center; }
.choice-art .glyph { width: 46%; }
.choice-art .ico { width: 70%; height: 70%; }

.abc { display: flex; gap: 2px; width: 92%; height: 64%; align-items: center; }
.abc .glyph { flex: 1; height: 100%; width: 30%; }
.nums { align-items: center; justify-content: center; font-size: 64px; font-weight: 700; color: var(--ink); gap: 10px; }
.nums b { background: #fff; border-radius: 18px; padding: 4px 10px; box-shadow: 0 4px 0 #eadcc8; }

.map-scroller, .album {
  flex: 1;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px 20px 24px;
  scroll-snap-type: x mandatory;
  touch-action: pan-x;
  align-items: center;
}

.map-item, .sticker {
  flex: 0 0 auto;
  scroll-snap-align: center;
  width: 150px;
  height: 190px;
  border-radius: 32px;
  background: var(--card);
  box-shadow: 0 8px 0 #eadcc8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
}

.map-item .glyph { width: 78%; height: 62%; }
.map-item.done { background: #fff6d4; }
.map-item.locked { opacity: 0.55; }
.lock { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; }

.stars { display: flex; gap: 2px; }
.star { width: 22px; height: 22px; fill: #eadfce; }
.star.on { fill: #ffc14d; }

.stage-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 4px 16px; }
.stage {
  position: relative;
  height: 100%;
  aspect-ratio: 1;
  max-width: 100%;
  background: #fff;
  border-radius: 36px;
  box-shadow: inset 0 0 0 6px #ffe0c2;
  overflow: hidden;
  touch-action: none;
}
.model, canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.model { padding: 6%; }
.model.lv1 { opacity: 0.95; }
.model.lv2 { opacity: 0.18; }
.model.lv3 { opacity: 0; }
.model.hint { opacity: 0.95; transition: opacity 0.25s linear; }
canvas { touch-action: none; background: transparent; }

.tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6px 16px 14px;
}
.tool.check {
  width: 104px;
  height: 104px;
  border-radius: 36px;
  background: var(--leaf);
  box-shadow: 0 8px 0 #14956c;
  color: white;
}
.tool.check:active { box-shadow: 0 3px 0 #14956c; }

.find-board {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 16px;
  padding: 8px 20px 8px;
  align-content: center;
  position: relative;
}
.find-board.n3 { grid-template-columns: repeat(3, 1fr); }
.find-board.n4 { grid-template-columns: repeat(4, 1fr); }
.find-board.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tile {
  height: min(34vh, 220px);
  border-radius: 32px;
  background: var(--card);
  box-shadow: 0 8px 0 #eadcc8;
  display: grid;
  place-items: center;
}
.tile .glyph { width: 70%; height: 70%; }
.tile.soft { transform: scale(0.96); opacity: 0.55; }
.tile.show-right { background: #e5fff4; box-shadow: 0 8px 0 #8ad8bc; }

.hint-pic { margin-left: auto; }
.hint-pic .emoji, .hint-pic .count { width: 72px; height: 72px; font-size: 60px; }

.album { flex-wrap: wrap; align-content: flex-start; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; }
.album-switch { display: flex; gap: 10px; padding: 0 16px; }
.mini.on { background: #ffe7a8; }
.sticker .glyph { width: 42%; height: 36%; }
.sticker .emoji, .sticker .count { width: 64px; height: 48px; font-size: 40px; }
.num { font-size: 40px; }
.empty-book { margin: auto; width: 180px; opacity: 0.85; }
.sticker.popped { transform: scale(1.06); }

.pop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(255, 248, 236, 0.2);
}
.pop-pic { font-size: 88px; width: 140px; height: 140px; display: grid; place-items: center; animation: pop 0.45s ease; }
.pop .stars { position: absolute; bottom: 12%; }
.burst i {
  position: absolute;
  left: 50%;
  top: 50%;
  font-style: normal;
  color: var(--sun);
  font-size: 28px;
  animation: fly 0.9s ease-out forwards;
  transform: rotate(calc(var(--i) * 30deg)) translateY(0);
}
@keyframes fly { to { transform: rotate(calc(var(--i) * 30deg)) translateY(-140px); opacity: 0; } }
@keyframes pop { from { transform: scale(0.4); } to { transform: scale(1); } }
.wiggle { animation: wiggle 0.45s ease; }
@keyframes wiggle { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

.turn {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--paper);
  z-index: 20;
  place-items: center;
}
.turn-svg { width: min(50vw, 240px); }
@media (orientation: portrait) {
  #app { display: none; }
  .turn { display: grid; }
}

@media (max-height: 500px) {
  .icon-btn, .tool, .mini { width: 60px; height: 60px; border-radius: 18px; }
  .tool.check { width: 84px; height: 84px; }
  .big-choice { height: min(70vh, 260px); }
  .map-item { width: 120px; height: 150px; }
}
