/* ============================================================
   Cappy's Workbook — styles
   Designed touch-first for iPad: big targets (≥56px), no hover-
   dependent UI, tap-highlight off, generous type sizes.
   ============================================================ */

/* Self-hosted latin subsets (was Google Fonts — two extra origins, render-blocking) */
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/fredoka-latin-var.woff2") format("woff2");
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/andika-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Andika";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/andika-latin-700.woff2") format("woff2");
}
@font-face {
  font-family: "Patrick Hand";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/patrick-hand-latin-400.woff2") format("woff2");
}

:root {
  --cream: #FFF6E9;
  --cream-2: #FFFDF6;
  --brown: #4A3728;
  --brown-soft: #7A6350;
  --capy: #A97C50;
  --capy-dark: #8A6240;
  --orange: #F59E2D;
  --orange-dark: #D9820F;
  --green: #6FA65A;
  --green-dark: #57874A;
  --teal: #4E9FBB;
  --teal-light: #7CC7E0;
  --pink: #E8A08A;
  --card: #FFFFFF;
  --shadow: 0 6px 0 rgba(111, 78, 51, 0.18);
  --radius: 22px;
  --font-ui: "Fredoka", -apple-system, "SF Pro Rounded", sans-serif;
  --font-read: "Andika", "Comic Sans MS", sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--brown);
  background:
    radial-gradient(circle at 12% 18%, rgba(111, 166, 90, 0.10) 0 44px, transparent 45px),
    radial-gradient(circle at 85% 30%, rgba(245, 158, 45, 0.10) 0 56px, transparent 57px),
    radial-gradient(circle at 70% 85%, rgba(124, 199, 224, 0.12) 0 60px, transparent 61px),
    radial-gradient(circle at 25% 78%, rgba(232, 160, 138, 0.10) 0 40px, transparent 41px),
    var(--cream);
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

button {
  font-family: var(--font-ui);
  color: var(--brown);
  border: none; cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(0.96); }

/* ---------------- top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--cream-2);
  border-bottom: 3px solid rgba(169, 124, 80, 0.25);
  flex: 0 0 auto;
  z-index: 5;
}
#topbar-title {
  flex: 1; text-align: center;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 56px; height: 56px;
  font-size: 28px; line-height: 1;
  background: #fff; border-radius: 18px;
  box-shadow: var(--shadow);
}
#yuzu-chip {
  font-size: 22px; font-weight: 700;
  background: #FFEFD2; border-radius: 18px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}
#player-chip {
  font-size: 19px; font-weight: 700;
  background: #E5F4E0; border-radius: 18px;
  padding: 10px 16px;
  min-height: 56px;
  box-shadow: var(--shadow);
}
#player-name {
  display: inline-block;
  max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}

/* ---------------- main screen ---------------- */
#screen {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px clamp(14px, 4vw, 44px) 40px;
}
.fade-in { animation: fadeUp 0.35s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

#confetti {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none; z-index: 60;
}

/* ---------------- home ---------------- */
.home { max-width: 1100px; margin: 0 auto; }
.hero {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(8px, 3vw, 40px);
  flex-wrap: wrap;
  padding: 8px 0 18px;
}
.hero-capy svg { display: block; }
.bob { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero-text h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  color: var(--capy-dark);
}
.tagline { margin: 6px 0 14px; font-size: clamp(17px, 2.4vw, 22px); color: var(--brown-soft); }
.bubble {
  display: inline-block;
  background: #fff; border-radius: 20px;
  padding: 12px 20px; margin: 0;
  font-size: clamp(16px, 2.2vw, 20px);
  box-shadow: var(--shadow);
  position: relative;
}
.bubble::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  border: 10px solid transparent; border-right-color: #fff;
  transform: translateY(-50%);
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(14px, 2.5vw, 26px);
}
.subject-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: clamp(22px, 3.5vw, 36px) 18px;
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-bottom: 6px solid;
  transition: transform 0.15s ease;
}
.subject-emoji { font-size: clamp(46px, 7vw, 66px); }
.subject-name { font-size: clamp(26px, 3.6vw, 34px); font-weight: 700; }
.subject-blurb { font-size: clamp(15px, 2vw, 18px); color: var(--brown-soft); }
.subject-stars {
  margin-top: 8px; font-size: 18px; font-weight: 600;
  background: var(--cream); padding: 8px 16px; border-radius: 14px;
}
.sub-writing { border-color: var(--orange); }
.sub-reading { border-color: var(--teal); }
.sub-math    { border-color: var(--green); }
.home-tip {
  text-align: center; margin-top: 26px;
  font-size: clamp(15px, 2vw, 18px); color: var(--brown-soft);
}

/* ---------------- subject page ---------------- */
.subject-page { max-width: 1100px; margin: 0 auto; }
.subject-banner {
  display: flex; align-items: center; gap: 18px;
  background: var(--card);
  border-radius: var(--radius);
  border-left: 10px solid;
  padding: 14px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.subject-banner h2 { margin: 0; font-size: clamp(24px, 3.4vw, 32px); }
.subject-banner p { margin: 2px 0 0; color: var(--brown-soft); }
.banner-emoji { font-size: clamp(36px, 5vw, 52px); }
.banner-capy { margin-left: auto; }
.banner-capy svg { display: block; }

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: clamp(12px, 2vw, 22px);
}
.activity-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  padding: 20px 22px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-bottom: 5px solid;
  min-height: 150px;
}
.act-emoji { font-size: 38px; }
.act-title { font-size: clamp(20px, 2.6vw, 24px); font-weight: 700; }
.act-blurb { font-size: 15px; color: var(--brown-soft); }
.act-meta { display: flex; align-items: center; gap: 12px; margin-top: auto; padding-top: 8px; }
.act-stars { color: var(--orange); font-size: 20px; letter-spacing: 2px; }
.act-level {
  font-size: 14px; font-weight: 600;
  background: var(--cream); border-radius: 12px; padding: 5px 10px;
}

/* ---------------- round / engine ---------------- */
.round { max-width: 880px; margin: 0 auto; }
.round-head {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.round-emoji { font-size: 40px; }
.round-titles h2 { margin: 0; font-size: clamp(20px, 3vw, 26px); }
.qdots { margin-left: auto; display: flex; gap: 7px; flex-wrap: wrap; }
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #E4D5BF; border: 2px solid #D3BFA1;
}
.dot.now { background: var(--orange); border-color: var(--orange-dark); transform: scale(1.25); }
.dot.good { background: var(--green); border-color: var(--green-dark); }
.dot.miss { background: var(--pink); border-color: #C97F68; }

.qcard {
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 32px);
  min-height: 340px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.shake-it { animation: shake 0.45s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px); } 40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(4px); }
}

.prompt-bar {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 600;
  text-align: center;
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
}
.hint-line { margin: -6px 0 0; color: var(--brown-soft); font-size: clamp(14px, 2vw, 17px); text-align: center; }
.target-word {
  font-family: var(--font-read);
  background: var(--cream);
  border-radius: 14px; padding: 4px 16px;
  font-size: clamp(24px, 3.6vw, 32px); font-weight: 700;
  color: var(--capy-dark);
}
.speaker-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--teal-light);
  font-size: 24px;
  box-shadow: 0 4px 0 rgba(78, 159, 187, 0.5);
}
.speaker-btn.big { width: 60px; height: 60px; font-size: 28px; }

/* choices */
.choice-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  width: 100%; max-width: 640px;
}
.choice-btn {
  min-height: 72px;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 600;
  font-family: var(--font-read);
  background: var(--cream);
  border: 3px solid #E2D2B8;
  border-radius: 20px;
  padding: 12px;
  transition: background 0.15s ease;
}
.choice-btn.big { min-height: 86px; font-size: clamp(26px, 4vw, 36px); }
.choice-btn.correct { background: #DDF0CE; border-color: var(--green); animation: popIn 0.3s ease; }
.choice-btn.wrong { background: #FBE3DA; border-color: var(--pink); opacity: 0.65; }
.choice-btn:disabled { cursor: default; }

.lily-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.lily-grid .choice-btn {
  background: #E5F4E0;
  border-color: #A9CF9B;
  border-radius: 50px;
  min-height: 78px;
}
.lily-grid .choice-btn.correct { background: #C8E8B8; border-color: var(--green-dark); }

.pic-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); max-width: 560px; }
.pic-emoji { font-size: clamp(44px, 6vw, 60px); line-height: 1; }
.word-grid .choice-btn { font-size: clamp(22px, 3.4vw, 30px); }
.num-grid { max-width: 520px; }
.sign-grid { grid-template-columns: repeat(3, 1fr); max-width: 420px; }
.sign-grid .choice-btn { font-size: 40px; font-family: var(--font-ui); }

.read-word {
  font-family: var(--font-read);
  font-size: clamp(40px, 7vw, 60px);
  font-weight: 700;
  color: var(--capy-dark);
  display: flex; align-items: center; gap: 14px;
}

/* praise float */
.praise-float {
  position: absolute;
  left: 50%; top: 26%;
  transform: translateX(-50%);
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 700;
  color: var(--orange-dark);
  pointer-events: none;
  animation: floatUp 1.15s ease forwards;
  text-shadow: 0 2px 0 #fff;
  z-index: 20;
}
.qcard { position: relative; }
@keyframes floatUp {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.8); }
  25% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.06); }
  to { opacity: 0; transform: translateX(-50%) translateY(-46px) scale(1); }
}

/* ---------------- tiles & slots (scramble / spell) ---------------- */
.slot-row {
  min-height: 84px;
  width: 100%; max-width: 720px;
  background: var(--cream);
  border: 3px dashed #D8C6A8;
  border-radius: 18px;
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: center;
  padding: 12px;
}
.tile-tray {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: center;
  padding: 6px;
  min-height: 70px;
}
.word-tile {
  font-family: var(--font-read);
  font-size: clamp(20px, 3vw, 27px);
  font-weight: 700;
  background: #fff;
  border: 3px solid var(--teal-light);
  border-radius: 16px;
  padding: 12px 18px;
  min-height: 58px;
  box-shadow: 0 4px 0 rgba(78, 159, 187, 0.35);
}
.word-tile.tile-good { background: #DDF0CE; border-color: var(--green); box-shadow: none; }
.letter-tile { min-width: 62px; text-transform: lowercase; }
.letter-tile.used { opacity: 0.25; pointer-events: none; }
.spell-pic { font-size: clamp(60px, 9vw, 92px); line-height: 1; }
.spell-slots { max-width: 560px; }
.letter-slot {
  width: 62px; height: 66px;
  background: #fff;
  border: 3px solid #E2D2B8;
  border-bottom-width: 6px;
  border-radius: 14px;
  font-family: var(--font-read);
  font-size: 30px; font-weight: 700;
  text-transform: lowercase;
}
.letter-slot.slot-good { background: #DDF0CE; border-color: var(--green); }

/* ---------------- fix the sentence ---------------- */
.fix-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: center;
  font-family: var(--font-read);
  padding: 4px;
}
.fix-word {
  font-family: var(--font-read);
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 700;
  background: var(--cream);
  border: 3px solid #E2D2B8;
  border-radius: 14px;
  padding: 10px 14px;
  min-height: 58px;
}
.fix-word.capped { background: #FFF0D6; border-color: var(--orange); }
.fix-word.locked { background: #F1E9DB; color: var(--brown-soft); }
.end-slot {
  font-size: 34px; font-weight: 700;
  width: 54px; height: 58px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 3px dashed #D8C6A8; border-radius: 12px;
}
.end-slot.filled { border-style: solid; border-color: var(--orange); }
.mark-row { display: flex; gap: 14px; }
.mark-btn {
  width: 74px; height: 74px;
  font-size: 40px; font-weight: 700;
  background: #fff;
  border: 3px solid var(--teal-light);
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(78, 159, 187, 0.35);
}
.mark-btn.on { background: #FFF0D6; border-color: var(--orange); }
.check-btn { margin-top: 4px; }
.fixed-sentence {
  font-family: var(--font-read);
  font-size: clamp(24px, 3.6vw, 32px);
  font-weight: 700;
  color: var(--green-dark);
  background: #DDF0CE;
  padding: 12px 22px; border-radius: 16px;
}

/* ---------------- story ---------------- */
.story-card {
  background: var(--cream);
  border-radius: 20px;
  padding: 18px 22px;
  width: 100%; max-width: 760px;
}
.story-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.story-head h3 { margin: 0; font-size: clamp(20px, 3vw, 26px); flex: 1; }
.story-art { font-size: 34px; }
.story-text {
  font-family: var(--font-read);
  font-size: clamp(18px, 2.6vw, 23px);
  line-height: 1.75;
  margin: 6px 0 0;
}
.answers { max-width: 720px; }

/* ---------------- math ---------------- */
.count-field {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: center;
  max-width: 700px;
  background: var(--cream);
  border-radius: 20px;
  padding: 16px;
}
.count-emoji { font-size: 44px; line-height: 1; }
.count-capy svg { display: block; }

/* ten-frames (5x2 counting grids) */
.tf-wrap {
  display: flex; flex-wrap: wrap; gap: clamp(14px, 3vw, 26px);
  justify-content: center;
}
.ten-frame {
  display: grid;
  grid-template-columns: repeat(5, clamp(46px, 8.5vw, 64px));
  grid-auto-rows: clamp(46px, 8.5vw, 64px);
  background: #fff;
  border: 3px solid var(--capy-dark);
  border-radius: 10px;
  overflow: hidden;
}
.tf-cell {
  border: 1.5px solid #DCCBAD;
  display: flex; align-items: center; justify-content: center;
}
.tf-cell .count-emoji { font-size: clamp(26px, 5vw, 38px); }
.tf-cell .count-capy svg { width: 90%; height: auto; }

.chip-scene {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap; justify-content: center;
}
.chip-box {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-width: 300px;
  padding: 14px;
  background: var(--cream);
  border-radius: 18px;
  justify-content: center;
}
.chip {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
}
.chip.teal { background: var(--teal-light); border: 3px solid var(--teal); }
.chip.orange { background: #FFC163; border: 3px solid var(--orange-dark); }
.chip-out { opacity: 0.35; }
.op-sign { font-size: 44px; font-weight: 700; color: var(--brown-soft); }

.equation {
  font-size: clamp(34px, 5.5vw, 48px);
  font-weight: 700;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; justify-content: center;
}
.num-display {
  min-width: 90px; min-height: 68px;
  background: var(--cream);
  border: 3px solid #E2D2B8;
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 700;
  padding: 4px 14px;
}
.num-display.good { background: #DDF0CE; border-color: var(--green); }
.eq-box.mystery { border-style: dashed; border-color: var(--orange); }

.numpad-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 10px;
}
.pad-key {
  height: 66px;
  font-size: 28px; font-weight: 700;
  background: #fff;
  border: 3px solid #E2D2B8;
  border-radius: 16px;
  box-shadow: 0 4px 0 rgba(111, 78, 51, 0.12);
}
.pad-go { background: #DDF0CE; border-color: var(--green); }
.pad-del { background: #FBE3DA; border-color: var(--pink); }

.compare-row {
  display: flex; align-items: center; gap: 20px;
}
.num-card {
  font-size: clamp(46px, 8vw, 72px);
  font-weight: 700;
  background: var(--cream);
  border: 4px solid #E2D2B8;
  border-radius: 22px;
  padding: 10px 26px;
  min-width: 110px; text-align: center;
}
.compare-slot {
  font-size: clamp(40px, 7vw, 60px);
  font-weight: 700;
  color: var(--orange-dark);
  width: 70px; text-align: center;
}

.blocks-wrap { display: flex; justify-content: center; }
.blocks-svg { max-width: min(90%, 440px); height: auto; max-height: 240px; }
.blk-label { font-family: var(--font-ui); font-size: 17px; fill: var(--brown-soft); font-weight: 600; }

.clock-wrap { display: flex; justify-content: center; }
.clock-num { font-family: var(--font-ui); font-size: 19px; font-weight: 700; fill: var(--brown); }

/* ---------------- tracing ---------------- */
.trace-page { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.trace-tabs { display: flex; gap: 10px; justify-content: center; }
.tab-btn {
  font-size: 22px; font-weight: 700;
  padding: 12px 26px;
  min-height: 56px;
  border-radius: 18px;
  background: #fff;
  border: 3px solid #E2D2B8;
  box-shadow: var(--shadow);
}
.tab-btn.on { background: var(--orange); border-color: var(--orange-dark); color: #fff; }

.letter-strip {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.letter-chip {
  position: relative;
  flex: 0 0 auto;
  width: 54px; height: 54px;
  font-family: var(--font-read);
  font-size: 24px; font-weight: 700;
  background: #fff;
  border: 3px solid #E2D2B8;
  border-radius: 14px;
}
.letter-chip.on { border-color: var(--orange); background: #FFF0D6; }
.letter-chip.chip-done { background: #EAF5E2; border-color: #A9CF9B; }
.chip-check {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px;
  background: var(--green); color: #fff;
  border-radius: 50%;
  font-size: 13px; line-height: 22px;
}
.trace-prompt {
  text-align: center;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.trace-target {
  font-family: var(--font-read);
  font-size: clamp(30px, 4.4vw, 40px);
  color: var(--orange-dark);
  background: var(--cream);
  border-radius: 12px; padding: 0 14px;
}
.canvas-wrap {
  position: relative;
  background: var(--cream-2);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
#trace-canvas {
  display: block;
  width: 100%;
  touch-action: none; /* finger/Pencil draws; page must not scroll */
}
.trace-flash {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 90px;
  opacity: 0; pointer-events: none;
}
.trace-flash.go { animation: sparkle 1s ease; }
@keyframes sparkle {
  0% { opacity: 0; transform: scale(0.4); }
  35% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.5); }
}
.trace-meter {
  height: 16px;
  background: #EFE3CC;
  border-radius: 10px;
  overflow: hidden;
}
.trace-meter-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--orange), #FFC163);
  border-radius: 10px;
  transition: width 0.35s ease;
}
.trace-btns { display: flex; gap: 12px; justify-content: center; }

/* ---------------- buttons ---------------- */
.big-btn {
  font-size: clamp(19px, 2.6vw, 23px);
  font-weight: 700;
  padding: 14px 26px;
  min-height: 60px;
  border-radius: 20px;
  color: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
}
.big-btn.orange { background: var(--orange); }
.big-btn.green  { background: var(--green); }
.big-btn.tan    { background: var(--capy); }

/* ---------------- celebration ---------------- */
#overlay {
  position: fixed; inset: 0;
  background: rgba(74, 55, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
#overlay[hidden] { display: none; }
.celebrate-card {
  background: var(--cream-2);
  border-radius: 30px;
  padding: clamp(22px, 4vw, 40px);
  text-align: center;
  max-width: 480px; width: 100%;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
}
.celebrate-card h2 { margin: 8px 0 4px; font-size: clamp(28px, 4.4vw, 38px); color: var(--capy-dark); }
.star-row { font-size: 0; margin: 8px 0; }
.big-star {
  display: inline-block;
  font-size: clamp(44px, 7vw, 60px);
  color: #E0D3BC;
  margin: 0 6px;
}
.big-star.lit {
  color: var(--orange);
  animation: starPop 0.5s ease both;
  text-shadow: 0 3px 0 rgba(217, 130, 15, 0.35);
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}
.score-line { font-size: clamp(18px, 2.6vw, 22px); margin: 6px 0; }
.yuzu-line { font-size: clamp(17px, 2.4vw, 20px); color: var(--orange-dark); font-weight: 700; margin: 2px 0 16px; }
.celebrate-btns { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.pop-in { animation: popIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.toast {
  position: fixed;
  top: 96px; left: 50%;
  transform: translateX(-50%);
  background: var(--cream-2);
  border-radius: 20px;
  border: 3px solid var(--orange);
  padding: 14px 26px;
  font-size: clamp(18px, 2.6vw, 22px);
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  z-index: 70;
}

/* ---------------- player picker ---------------- */
.players-page {
  max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding-top: 8px;
}
.players-hero svg { display: block; }
.players-title {
  margin: 0;
  font-size: clamp(28px, 4.6vw, 42px);
  color: var(--capy-dark);
  text-align: center;
}
.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  width: 100%;
}
.player-card-wrap { position: relative; }
.player-card {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card);
  border-radius: 24px;
  border-bottom: 5px solid var(--green);
  box-shadow: var(--shadow);
  padding: 18px 14px 16px;
}
.player-label {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.player-stats {
  font-size: 15px; font-weight: 600;
  background: var(--cream);
  border-radius: 12px; padding: 5px 12px;
}
.player-del {
  position: absolute; top: -8px; right: -8px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #FBE3DA; color: #A25540;
  font-size: 16px; font-weight: 700;
  box-shadow: var(--shadow);
}
.add-player {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center; align-items: stretch;
  width: 100%;
}
#player-input {
  font-family: var(--font-ui);
  font-size: 22px; font-weight: 600;
  color: var(--brown);
  background: #fff;
  border: 3px solid #E2D2B8;
  border-radius: 20px;
  padding: 12px 20px;
  min-height: 60px;
  width: min(340px, 100%);
  outline: none;
  -webkit-user-select: text; user-select: text;
}
#player-input:focus { border-color: var(--orange); }

/* ---------------- Cappy's Pond ---------------- */
#yuzu-chip { cursor: pointer; }
#yuzu-chip:active { transform: scale(0.96); }
.pond-page {
  max-width: 760px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pond-stats { display: flex; gap: 14px; }
.pond-stat {
  font-size: clamp(18px, 2.6vw, 22px); font-weight: 700;
  background: var(--card); border-radius: 16px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
}
.pond-scene {
  position: relative;
  width: 100%;
  display: flex; justify-content: center;
  background: linear-gradient(180deg, #EAF6EC 0%, #D6EFF7 100%);
  border-radius: 28px;
  padding: 26px 10px 14px;
  box-shadow: var(--shadow);
  overflow: visible;
}
.pond-hint { margin: 0; color: var(--brown-soft); font-weight: 600; font-size: clamp(15px, 2.2vw, 18px); min-height: 20px; }
.feed-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; align-items: center;
  min-height: 64px;
}
.feed-yuzu {
  font-size: 40px; line-height: 1;
  background: var(--card);
  border-radius: 50%;
  width: 62px; height: 62px;
  box-shadow: var(--shadow);
  will-change: transform, opacity;
}
.feed-more { font-size: 22px; font-weight: 700; color: var(--brown-soft); }
.heart-meter { width: min(480px, 100%); display: flex; flex-direction: column; gap: 8px; }
.heart-meter-text { text-align: center; font-weight: 600; font-size: clamp(15px, 2.2vw, 18px); }
.heart-fill { background: linear-gradient(90deg, #E85D75, #F2A0C0); }
.heart-pop {
  position: absolute;
  bottom: 40%;
  font-size: 30px;
  pointer-events: none;
  animation: heartUp 1.3s ease forwards;
  z-index: 30;
}
@keyframes heartUp {
  from { opacity: 0; transform: translateY(10px) scale(0.6); }
  25% { opacity: 1; transform: translateY(-8px) scale(1.1); }
  to { opacity: 0; transform: translateY(-70px) scale(1); }
}
.wardrobe-title { margin: 8px 0 0; font-size: clamp(19px, 2.8vw, 24px); color: var(--capy-dark); }
.wardrobe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 12px;
  width: 100%;
}
.hat-chip {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card);
  border: 3px solid #E2D2B8;
  border-radius: 18px;
  padding: 12px 8px;
  min-height: 96px;
}
.hat-chip .hat-emoji { font-size: 32px; line-height: 1; }
.hat-chip .hat-name { font-weight: 700; font-size: 14px; }
.hat-chip .hat-req { font-size: 12px; color: var(--brown-soft); font-weight: 600; }
.hat-chip.worn { border-color: var(--orange); background: #FFF0D6; }
.hat-chip.worn .hat-req { color: var(--orange-dark); }
.hat-chip.locked { opacity: 0.55; }

/* ---------------- tap-to-talk mascot ---------------- */
.capy-tap {
  position: relative;
  background: none;
  padding: 0;
  display: inline-block;
  line-height: 0;
}
.capy-tap svg { display: block; }
.capy-speech {
  position: absolute;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(280px, 78vw);
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 18px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: clamp(15px, 2.2vw, 18px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--brown);
  text-align: center;
  white-space: normal;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 40;
  animation: popIn 0.25s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.capy-speech::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--orange);
}
/* flipped variant: bubble sits under the capy when the header would clip it */
.capy-speech.below {
  bottom: auto;
  top: calc(100% + 8px);
}
.capy-speech.below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--orange);
}
.capy-wiggle { animation: wiggle 0.5s ease; transform-origin: 50% 80%; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  50% { transform: rotate(4deg); }
  75% { transform: rotate(-2deg); }
}

/* ---------------- family sync ---------------- */
.sync-link {
  background: none;
  font-size: 17px; font-weight: 600;
  color: var(--teal);
  text-decoration: underline;
  padding: 12px 18px;
  min-height: 48px;
}
.sync-lead {
  font-size: clamp(16px, 2.3vw, 20px);
  color: var(--brown-soft);
  text-align: center;
  max-width: 560px;
  margin: 0;
  line-height: 1.55;
}
.family-code {
  font-family: var(--font-read);
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--capy-dark);
  background: #fff;
  border: 4px dashed var(--orange);
  border-radius: 22px;
  padding: 14px 30px;
  user-select: text; -webkit-user-select: text;
}
.sync-status { font-size: 16px; font-weight: 600; color: var(--brown-soft); margin: 0; min-height: 22px; }
.sync-choice { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.sync-or { color: var(--brown-soft); font-weight: 600; }
#sync-input {
  font-family: var(--font-read);
  font-size: 24px; font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--brown);
  background: #fff;
  border: 3px solid #E2D2B8;
  border-radius: 20px;
  padding: 12px 20px;
  min-height: 60px;
  width: min(280px, 100%);
  text-align: center;
  outline: none;
  -webkit-user-select: text; user-select: text;
}
#sync-input:focus { border-color: var(--orange); }

/* ---------------- report card ---------------- */
.home-actions { display: flex; justify-content: center; margin-top: 24px; }
.report-page {
  max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 18px;
}
.report-head {
  display: flex; align-items: center; gap: 18px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 22px;
}
.report-head h2 { margin: 0; font-size: clamp(22px, 3.4vw, 30px); color: var(--capy-dark); }
.report-totals { margin: 4px 0 0; font-size: clamp(17px, 2.4vw, 21px); font-weight: 600; }
.report-section {
  background: var(--card);
  border-radius: var(--radius);
  border-left: 8px solid;
  box-shadow: var(--shadow);
  padding: 14px 20px;
}
.report-section h3 { margin: 2px 0 10px; font-size: clamp(19px, 2.8vw, 24px); }
.report-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  grid-template-areas: "emoji title stars" "emoji info stars";
  align-items: center;
  column-gap: 10px;
  padding: 9px 0;
  border-top: 2px solid var(--cream);
}
.report-emoji { grid-area: emoji; font-size: 28px; }
.report-title { grid-area: title; font-weight: 700; font-size: clamp(16px, 2.3vw, 19px); }
.report-info { grid-area: info; color: var(--brown-soft); font-size: clamp(13px, 1.9vw, 15px); }
.report-stars { grid-area: stars; color: var(--orange); font-size: 22px; letter-spacing: 2px; }

/* ---------------- small screens (phone / narrow portrait) ---------------- */
@media (max-width: 560px) {
  .icon-btn { width: 48px; height: 48px; font-size: 24px; }
  #yuzu-chip { font-size: 18px; padding: 8px 12px; }
  #player-chip { font-size: 16px; padding: 8px 10px; min-height: 48px; }
  #player-name { max-width: 64px; }
  .numpad { grid-template-columns: repeat(3, 72px); }
  .pad-key { height: 58px; }
  .qcard { padding: 16px 12px; }
  .banner-capy { display: none; }
  .qdots { width: 100%; margin-left: 0; }
}
