/* ================= Kota Ceria — Harvest Moon pixel theme ================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/PixelifySans.woff2") format("woff2");
}

/* ANGKA: glyph 1/2/5/7 di font piksel ambigu untuk anak (5 mirip S).
   Font ini HANYA meng-cover U+0030–0039, jadi semua digit di seluruh
   game dialihkan ke font sistem yang jelas; huruf tetap piksel.
   size-adjust menyamakan tinggi supaya campurannya tidak lompat. */
@font-face {
  font-family: "KC Angka";
  font-style: normal;
  font-weight: 400 700;
  src: local("Comic Sans MS"), local("Trebuchet MS"), local("Verdana"),
       local("DejaVu Sans"), local("Arial");
  unicode-range: U+0030-0039;
  size-adjust: 86%;
}

:root {
  --tile: min(5.6vw, 6.4vh, 52px);
  --mw: 15;
  --mh: 11;

  /* sky */
  --c-sky1: #8ecbe8;
  --c-sky2: #d8ecc8;

  /* rustic palette */
  --c-parch:  #f6e7c1;   /* parchment panel */
  --c-parch2: #efd9a8;   /* darker parchment */
  --c-wood:   #8b5e3c;   /* mid wood */
  --c-wood-d: #5a3a22;   /* dark wood border */
  --c-wood-l: #c89b62;   /* light wood bevel */
  --c-gold:   #e8a33d;   /* gold accent */
  --c-gold-d: #a86a1c;
  --c-good:   #5a9e3c;
  --c-good-d: #3c6e26;
  --c-text:   #3a2417;

  --c-card: var(--c-parch);
  --c-primary: var(--c-gold);
  --c-primary-dark: var(--c-gold-d);

  --radius: 6px;
  --font: "KC Angka", "Pixelify Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  --depth: 0 8px 0 rgba(40, 24, 10, .35);

  /* reusable pixel frame: dark outline + light inner bevel */
  --frame:
    inset 0 0 0 2px #fff6dd,
    inset 0 0 0 5px var(--c-wood-l),
    0 6px 0 rgba(40, 24, 10, .3);
}

#app[data-period="siang"] { --c-sky1: #7cc4e4; --c-sky2: #f2e6b4; }
#app[data-period="sore"]  { --c-sky1: #e08a4e; --c-sky2: #f0c48a; }
#app[data-period="malam"] { --c-sky1: #1d2a4a; --c-sky2: #101830; }

/* Teks terang HANYA untuk layar yang isinya menempel langsung di
   langit malam. Dulu warna ini dipasang di #app, jadi menetes ke
   SEMUA panel — teks dialog/toast jadi putih di atas parchment
   dan praktis hilang. Panel punya latar sendiri, jadi tintanya
   tetap gelap sepanjang hari. */
#app[data-period="malam"] #screen-quiz,
#app[data-period="malam"] #screen-build { color: #eef3ff; }

/* Sabuk pengaman: permukaan parchment selalu bertinta gelap,
   apa pun periodenya. Panel/kartu baru WAJIB masuk daftar ini
   kalau latarnya terang. */
.title-card, .dialog-box, .panel-box, .celebrate-box, .toast,
.mat-chip, .bag-item, .shop-row, .help-row, #dialog-face {
  color: var(--c-text);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--c-text);
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, var(--c-sky1), var(--c-sky2) 55%, #97c26a 100%);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#app { height: 100%; position: relative; }
#app[data-period="malam"] {
  background:
    radial-gradient(circle at 75% 12%, rgba(255,255,200,.18), transparent 22%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.03) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, var(--c-sky1), var(--c-sky2));
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  color: var(--c-text);
}

/* ================= screens ================= */
.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ================= shared buttons ================= */
.btn-big {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 700;
  padding: 14px 34px;
  min-height: 64px;
  border-radius: var(--radius);
  border: 4px solid var(--c-wood-d);
  background: linear-gradient(180deg, #f5c169 0 50%, var(--c-gold) 50%);
  color: #4a2c12;
  text-shadow: 0 2px 0 rgba(255,255,255,.35);
  box-shadow:
    inset 0 0 0 2px #ffe2a8,
    0 6px 0 var(--c-gold-d),
    0 8px 0 rgba(40,24,10,.3);
  transition: transform .08s;
}
.btn-big:active {
  transform: translateY(5px);
  box-shadow: inset 0 0 0 2px #ffe2a8, 0 1px 0 var(--c-gold-d);
}

.btn-ghost {
  font-size: clamp(15px, 2.6vw, 19px);
  font-weight: 700;
  padding: 10px 22px;
  min-height: 48px;
  border-radius: var(--radius);
  background: var(--c-parch);
  border: 3px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 2px #fff6dd, 0 4px 0 rgba(40,24,10,.25);
}
.btn-ghost:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px #fff6dd; }

/* ================= title screen ================= */
.title-card {
  position: relative;
  background:
    repeating-linear-gradient(90deg, rgba(90,58,34,.06) 0 3px, transparent 3px 26px),
    var(--c-parch);
  border: 5px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: clamp(18px, 4vh, 40px) clamp(24px, 6vw, 60px);
  text-align: center;
  box-shadow: var(--frame);
  max-width: 92vw;
}
/* hanging-sign nails */
.title-card::before, .title-card::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 10px; height: 10px;
  background: var(--c-wood-d);
  box-shadow: inset 2px 2px 0 var(--c-wood-l);
}
.title-card::before { left: 12px; }
.title-card::after  { right: 12px; }

.title-logo { font-size: clamp(56px, 12vh, 100px); animation: bob 2s ease-in-out infinite; }
.title-card h1 {
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 700;
  color: var(--c-gold);
  text-shadow:
    -2px 0 0 var(--c-wood-d), 2px 0 0 var(--c-wood-d),
    0 -2px 0 var(--c-wood-d), 0 2px 0 var(--c-wood-d),
    0 5px 0 var(--c-wood-d);
  letter-spacing: 2px;
}
.subtitle { font-size: clamp(16px, 3vw, 22px); margin: 6px 0 18px; }
.pick-label { font-size: clamp(16px, 3vw, 20px); margin-bottom: 8px; }

#avatar-pick { display: flex; gap: 14px; justify-content: center; margin-bottom: 14px; }
.avatar-btn {
  font-size: 40px;
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  background: var(--c-parch2);
  border: 4px solid var(--c-wood);
  box-shadow: inset 0 0 0 2px rgba(255,246,221,.7);
  transition: transform .1s;
}
.avatar-btn.selected {
  border-color: var(--c-gold-d);
  background: #ffe2a8;
  box-shadow: inset 0 0 0 2px #fff6dd, 0 0 0 2px var(--c-gold);
  transform: scale(1.12);
}

#name-input {
  font-family: var(--font);
  font-size: 20px;
  text-align: center;
  padding: 10px 14px;
  border: 3px solid var(--c-wood-d);
  border-radius: var(--radius);
  margin-bottom: 16px;
  width: min(280px, 70vw);
  outline: none;
  background: #fff9e8;
  color: var(--c-text);
  box-shadow: inset 0 3px 0 rgba(90,58,34,.15);
}
#name-input:focus { border-color: var(--c-gold-d); box-shadow: inset 0 3px 0 rgba(90,58,34,.15), 0 0 0 2px var(--c-gold); }

#title-new, #title-continue { display: flex; flex-direction: column; gap: 12px; align-items: center; }
#title-new[hidden], #title-continue[hidden] { display: none; }
#name-input { margin-bottom: 0; }

/* ================= HUD ================= */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  z-index: 20;
}
.hud-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hud-row2 { opacity: .98; }
.hud-chip {
  background: var(--c-parch);
  border: 3px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: clamp(12px, 2.2vw, 17px);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px #fff6dd, inset 0 -3px 0 rgba(90,58,34,.18), 0 3px 0 rgba(40,24,10,.3);
  color: var(--c-text);
}
.tool-chip { background: #ffe2a8; border-color: var(--c-gold-d); }
.quest-chip { background: #e2eecb; border-color: var(--c-good-d); font-size: clamp(11px, 2vw, 14px); max-width: 96vw; }
.hud-spacer { flex: 1; }
.hud-btn {
  font-size: 22px;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--c-parch) 0 50%, var(--c-parch2) 50%);
  border: 3px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 1px #fff6dd, 0 4px 0 rgba(40,24,10,.3);
}
.hud-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px #fff6dd; }

/* ================= map ================= */
#screen-map { justify-content: center; padding-top: 96px; }

#map-wrap {
  position: relative;
  width: min(96vw, 1100px);
  height: min(calc(100vh - 200px), 660px);
  border: 6px solid var(--c-wood-d);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px var(--c-wood-l),
    0 0 0 6px var(--c-wood-d),
    0 10px 0 rgba(40, 24, 10, .35);
  background: #4a9a3a;
}
#canvas3d { display: block; width: 100%; height: 100%; }
/* lapisan DOM lama tidak dipakai lagi — dunia digambar di canvas 3D */
#map-wrap #map-grid, #map-wrap #map-entities, #map-wrap #player { display: none; }
#map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255,246,221,.25);
  z-index: 30;
}
#map-wrap[data-weather="hujan"]::before,
#map-wrap[data-weather="badai"]::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  background: repeating-linear-gradient(
    -20deg,
    transparent 0 10px,
    rgba(180,210,255,.16) 10px 13px
  );
  animation: rainmove .7s linear infinite;
  opacity: .8;
}
@keyframes rainmove { to { background-position: 20px 40px; } }

#map-grid {
  display: grid;
  grid-template-columns: repeat(var(--mw), var(--tile));
  grid-template-rows: repeat(var(--mh), var(--tile));
}
.tile {
  position: relative;
  width: var(--tile);
  height: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--tile) * 0.72);
  line-height: 1;
  overflow: hidden;
}
.tile-em {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.25));
  transform: translateY(-4%);
}
.tile-shadow {
  position: absolute;
  bottom: 10%;
  width: 55%;
  height: 18%;
  background: rgba(0,0,0,.18);
  border-radius: 50%;
  z-index: 1;
}
.tree-em { font-size: calc(var(--tile) * 0.88); transform: translateY(-8%); }

/* pixel-dither grass: 2-tone checker */
.tile-grass, .tile-grass2, .tile-flower, .tile-tree {
  background:
    conic-gradient(#74c455 25%, #68b849 0 50%, #74c455 0 75%, #68b849 0)
    0 0 / calc(var(--tile) / 6) calc(var(--tile) / 6);
}
.tile-grass2 {
  background:
    conic-gradient(#68b849 25%, #5cab3e 0 50%, #68b849 0 75%, #5cab3e 0)
    0 0 / calc(var(--tile) / 6) calc(var(--tile) / 6);
}
.grass-tuft {
  position: absolute;
  bottom: 18%;
  width: 26%;
  height: 20%;
  background:
    linear-gradient(90deg, #4d9c30 0 30%, #86d95e 30% 45%, #4d9c30 45% 70%, #86d95e 70% 85%, #4d9c30 85%);
  clip-path: polygon(0 100%, 15% 20%, 30% 100%, 45% 0, 60% 100%, 78% 25%, 100% 100%);
  opacity: .7;
}

/* pixel water: banded stripes + shimmer */
.tile-water {
  background:
    repeating-linear-gradient(180deg,
      #4aa8e8 0 calc(var(--tile) / 6),
      #3d92d4 calc(var(--tile) / 6) calc(var(--tile) / 3),
      #3584c4 calc(var(--tile) / 3) calc(var(--tile) / 2));
  animation: shimmer 3s ease-in-out infinite;
}
.water-shine {
  position: absolute;
  width: 45%;
  height: 12%;
  top: 22%;
  left: 15%;
  background:
    linear-gradient(90deg, transparent 0 10%, #bfe6ff 10% 55%, transparent 55% 65%, #bfe6ff 65% 90%, transparent 90%);
}

/* sandy pixel path */
.tile-road {
  background:
    conic-gradient(#dcb886 25%, #d0a970 0 50%, #dcb886 0 75%, #d0a970 0)
    0 0 / calc(var(--tile) / 5) calc(var(--tile) / 5);
  box-shadow: inset 0 0 0 1px rgba(120,80,40,.18);
}
.road-line {
  width: 16%;
  height: 60%;
  background: rgba(255,244,214,.4);
}

/* farm plot: dark furrowed soil */
.tile-plot {
  background:
    conic-gradient(#7c4e26 25%, #6e4320 0 50%, #7c4e26 0 75%, #6e4320 0)
    0 0 / calc(var(--tile) / 5) calc(var(--tile) / 5);
  box-shadow: inset 0 0 0 2px #4c2c12;
}
.plot-soil {
  position: absolute;
  inset: 12%;
  border-radius: 3px;
  background:
    repeating-linear-gradient(180deg,
      #a06a38 0 calc(var(--tile) / 8),
      #7c4e22 calc(var(--tile) / 8) calc(var(--tile) / 4));
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.15),
    inset 0 -3px 0 rgba(0,0,0,.3),
    0 2px 0 rgba(0,0,0,.2);
  z-index: 1;
}
.tile-plot.needs-water .plot-soil { box-shadow: inset 0 0 0 2px #5dade2, inset 0 -3px 0 rgba(0,0,0,.3); }
.tile-plot.is-watered .plot-soil {
  background:
    repeating-linear-gradient(180deg,
      #6e5028 0 calc(var(--tile) / 8),
      #4a3010 calc(var(--tile) / 8) calc(var(--tile) / 4));
}
.tile-plot.is-wilted .plot-soil { filter: grayscale(.4) brightness(.85); }
.crop-em {
  z-index: 3;
  font-size: calc(var(--tile) * 0.7);
  animation: cropbob 2.4s ease-in-out infinite;
}
@keyframes cropbob { 0%,100% { transform: translateY(-6%); } 50% { transform: translateY(-12%); } }

/* indoor / building floor tiles: plank wood */
.tile-bed, .tile-coop, .tile-barn, .tile-shop, .tile-door, .tile-stove {
  background:
    repeating-linear-gradient(90deg, rgba(90,58,34,.14) 0 2px, transparent 2px calc(var(--tile) / 2)),
    repeating-linear-gradient(180deg, #e8c98a 0 calc(var(--tile) / 3), #dcba74 calc(var(--tile) / 3) calc(var(--tile) / 1.5));
  box-shadow: inset 0 0 0 2px #b8905a;
}

@keyframes shimmer { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }

#map-entities { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.entity, #player {
  position: absolute;
  left: 0; top: 0;
  width: var(--tile);
  height: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--tile) * 0.82);
  line-height: 1;
  transform: translate(calc(var(--px) * var(--tile)), calc(var(--py) * var(--tile)));
  z-index: 8;
}
.entity { pointer-events: auto; cursor: pointer; filter: drop-shadow(0 3px 2px rgba(0,0,0,.28)); }
.player-shadow {
  position: absolute;
  bottom: 8%;
  width: 46%;
  height: 16%;
  background: rgba(0,0,0,.22);
  border-radius: 50%;
  z-index: 1;
}
.player-em {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.3));
}
.heart-badge {
  position: absolute;
  top: -4px; right: -6px;
  font-size: calc(var(--tile) * 0.32);
  background: var(--c-parch);
  border: 2px solid var(--c-wood-d);
  border-radius: 4px;
  padding: 0 3px;
  line-height: 1.2;
}
.animal-ent { z-index: 6; }

#player {
  z-index: 10;
  transition: transform .17s linear;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.3));
}
#player.walking { animation: hop .17s linear infinite; }
@keyframes hop { 0%,100% { padding-bottom: 0; } 50% { padding-bottom: 6px; } }

/* the next site to build sparkles */
.entity.site-next { animation: pulse 1.1s ease-in-out infinite; }
.entity.site-next::after {
  content: "✨";
  position: absolute;
  top: -6px; right: -4px;
  font-size: calc(var(--tile) * 0.44);
  animation: bob 1.4s ease-in-out infinite;
}
.entity.site-locked { filter: grayscale(.9) opacity(.55); }

@keyframes pulse { 0%,100% { transform: translate(calc(var(--px) * var(--tile)), calc(var(--py) * var(--tile))) scale(1); }
                   50%     { transform: translate(calc(var(--px) * var(--tile)), calc(var(--py) * var(--tile))) scale(1.14); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* ================= d-pad (touch devices) ================= */
#dpad {
  display: none;
  position: absolute;
  right: 14px;
  bottom: 14px;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 58px);
  gap: 6px;
  z-index: 20;
}
.dpad-btn {
  font-size: 24px;
  border-radius: var(--radius);
  background: var(--c-parch);
  border: 3px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 1px #fff6dd, 0 4px 0 rgba(40,24,10,.3);
  opacity: .92;
}
.dpad-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1px #fff6dd; }
#dpad-up    { grid-column: 2; grid-row: 1; }
#dpad-left  { grid-column: 1; grid-row: 2; }
#dpad-down  { grid-column: 2; grid-row: 2; }
#dpad-right { grid-column: 3; grid-row: 2; }

@media (pointer: coarse) { #dpad { display: grid; } }

/* soal belajar: seluruh teksnya (bukan cuma angka) pakai font bulat
   yang gampang dibaca anak — angka global sudah diurus "KC Angka" */
#quiz-question, #quiz-visual, #quiz-choices button, #quiz-progress, .quiz-streak {
  font-family: "Comic Sans MS", "Segoe UI", "Arial Rounded MT Bold", sans-serif;
}

/* ================= buku koleksi ================= */
#collection-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.coll-tab { font-size: 15px; padding: 6px 10px; width: auto; }
.coll-tab.selected { background: var(--c-wood-d, #6e451e); color: #fff6dd; }
#collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.coll-item { cursor: default; }
.coll-unknown { opacity: .55; filter: grayscale(1); }

/* ================= tombol konteks (ramah anak) ================= */
#btn-ctx {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 22;
  font-family: inherit;
  font-size: 20px;
  padding: 12px 26px;
  border-radius: 999px;
  background: var(--c-parch);
  border: 4px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 1px #fff6dd, 0 5px 0 rgba(40,24,10,.35);
  cursor: pointer;
  animation: ctxpop .18s ease-out;
}
#btn-ctx:active { transform: translateX(-50%) translateY(3px); box-shadow: inset 0 0 0 1px #fff6dd; }
#btn-ctx[hidden] { display: none; }
@keyframes ctxpop { from { transform: translateX(-50%) scale(.7); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* ================= overlay tidur otomatis ================= */
.overlay-sleep { background: rgba(8, 10, 30, .85); transition: opacity .4s; }
.sleep-box { text-align: center; color: #fff6dd; font-size: 20px; }
.sleep-emoji { font-size: 72px; animation: bob 1.6s ease-in-out infinite; }

/* ================= overlays / dialog ================= */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 30, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay[hidden] { display: none; }

/* classic HM: dialog sits at the bottom of the screen */
#dialog { align-items: flex-end; padding-bottom: 16px; }

.dialog-box {
  background: var(--c-parch);
  border: 5px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 18px 22px;
  width: min(560px, 94vw);
  box-shadow: var(--frame);
  animation: popin .22s ease-out;
}
@keyframes popin { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
#dialog-face {
  font-size: 40px;
  width: 64px;
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff9e8;
  border: 4px solid var(--c-wood);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px #fff6dd;
}
#dialog-name {
  font-weight: 700;
  font-size: 20px;
  flex: 1;
  align-self: flex-start;
  display: inline-block;
  background: var(--c-wood-d);
  color: #ffe9bd;
  padding: 4px 14px;
  border-radius: 4px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.3), 0 2px 0 rgba(40,24,10,.3);
  max-width: max-content;
}
#dialog-text { font-size: clamp(17px, 3vw, 22px); margin-bottom: 12px; }

#dialog-materials { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mat-chip {
  font-size: 18px;
  font-weight: 700;
  background: #fff9e8;
  border: 3px solid var(--c-wood-l);
  border-radius: var(--radius);
  padding: 6px 12px;
}
.mat-chip.mat-ok { background: #e2eecb; border-color: var(--c-good-d); }

#dialog-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#dialog-buttons .btn-big { font-size: clamp(17px, 3vw, 22px); padding: 12px 22px; }

/* ================= quiz ================= */
#screen-quiz {
  background:
    repeating-linear-gradient(0deg, rgba(90,58,34,.04) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, #f0dcae, #f8eed4);
  gap: 10px;
}

#quiz-catpick, #quiz-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
#quiz-catpick[hidden], #quiz-play[hidden], #quiz-done[hidden] { display: none; }

#quiz-catpick h2, #quiz-done h2 {
  font-size: clamp(24px, 5vw, 36px);
  text-shadow: 0 3px 0 rgba(90,58,34,.2);
}

#quiz-categories { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: clamp(110px, 24vw, 150px);
  padding: 18px 10px;
  border-radius: var(--radius);
  background: var(--c-parch);
  border: 4px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 2px #fff6dd, 0 6px 0 rgba(40,24,10,.3);
  transition: transform .08s;
}
.cat-btn:active { transform: translateY(4px); box-shadow: inset 0 0 0 2px #fff6dd, 0 2px 0 rgba(40,24,10,.3); }
.cat-icon { font-size: clamp(40px, 9vw, 60px); }
.cat-label { font-size: clamp(16px, 3vw, 20px); font-weight: 700; }
.cat-meta { font-size: 12px; opacity: .75; }
.quiz-streak {
  min-height: 22px;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 700;
  color: var(--c-gold-d);
}

#quiz-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 12px;
}
#quiz-progress { display: flex; gap: 10px; }
.qdot {
  width: 16px; height: 16px;
  border-radius: 3px;
  background: var(--c-parch2);
  border: 2px solid var(--c-wood-d);
}
.qdot.done { background: var(--c-good); }
.qdot.now { background: var(--c-gold); transform: scale(1.3); }

#quiz-visual {
  font-size: clamp(34px, 8vw, 60px);
  min-height: clamp(44px, 10vw, 74px);
  text-align: center;
  letter-spacing: 4px;
  max-width: 92vw;
}
.quiz-qrow { display: flex; align-items: center; gap: 12px; max-width: 92vw; }
#quiz-question { font-size: clamp(20px, 4.4vw, 32px); font-weight: 700; text-align: center; }

#quiz-choices { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.choice-btn {
  min-width: clamp(90px, 20vw, 130px);
  min-height: clamp(90px, 20vw, 130px);
  font-size: clamp(44px, 10vw, 64px);
  border-radius: var(--radius);
  background: var(--c-parch);
  border: 4px solid var(--c-wood-d);
  box-shadow: inset 0 0 0 2px #fff6dd, 0 6px 0 rgba(40,24,10,.3);
  transition: transform .08s;
  line-height: 1.15;
}
.choice-btn.choice-long { font-size: clamp(22px, 5vw, 34px); padding: 8px; }
.choice-btn:active { transform: translateY(4px); }
.choice-btn.wrong { animation: shake .4s; background: #f0c2ae; opacity: .55; pointer-events: none; }
.choice-btn.right { background: #d2e8ad; border-color: var(--c-good-d); animation: cheer .5s; }
/* dikunci setelah dijawab benar — jangan dipudarkan browser */
.choice-btn:disabled { opacity: 1; }
.choice-btn.wrong:disabled { opacity: .55; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
@keyframes cheer { 0% { transform: scale(1); } 40% { transform: scale(1.2); } 100% { transform: scale(1); } }

#quiz-done-emoji { font-size: clamp(64px, 16vw, 110px); animation: bob 1s ease-in-out infinite; }

/* ================= build ================= */
#screen-build {
  background:
    repeating-linear-gradient(0deg, rgba(90,58,34,.04) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, #bcd8e8, #e6eed8);
  gap: 18px;
}
#build-title { font-size: clamp(24px, 5vw, 38px); text-shadow: 0 3px 0 rgba(90,58,34,.2); }
#build-visual {
  font-size: clamp(90px, 24vh, 170px);
  line-height: 1;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.2));
}
#build-visual.bump { animation: bump .18s; }
@keyframes bump { 0% { transform: scale(1) rotate(0); } 40% { transform: scale(1.08) rotate(-3deg); } 100% { transform: scale(1); } }
#build-visual.grow { animation: grow .45s ease-out; }
@keyframes grow { 0% { transform: scale(.4) translateY(40px); opacity: .3; } 100% { transform: scale(1) translateY(0); opacity: 1; } }

#build-bar-wrap {
  width: min(420px, 80vw);
  height: 28px;
  border-radius: 4px;
  background: #fff9e8;
  border: 4px solid var(--c-wood-d);
  box-shadow: inset 0 3px 0 rgba(90,58,34,.2);
  overflow: hidden;
}
#build-bar {
  height: 100%;
  width: 0%;
  background:
    repeating-linear-gradient(90deg, transparent 0 10px, rgba(255,255,255,.25) 10px 14px),
    linear-gradient(180deg, #f5c169, var(--c-gold));
  transition: width .15s;
}
#btn-hammer { font-size: clamp(26px, 6vw, 40px); padding: 20px 50px; }

/* ================= celebration ================= */
.celebrate-box {
  background: var(--c-parch);
  border: 5px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 30px 40px;
  text-align: center;
  box-shadow: var(--frame);
  animation: popin .3s ease-out;
  z-index: 2;
  max-width: 90vw;
}
#celebrate-emoji { font-size: clamp(70px, 18vh, 130px); animation: bob 1.2s ease-in-out infinite; }
#celebrate-title {
  font-size: clamp(28px, 6vw, 44px);
  color: var(--c-gold);
  text-shadow:
    -2px 0 0 var(--c-wood-d), 2px 0 0 var(--c-wood-d),
    0 -2px 0 var(--c-wood-d), 0 2px 0 var(--c-wood-d);
}
#celebrate-text { font-size: clamp(17px, 3.4vw, 24px); margin: 8px 0 18px; }

#confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti {
  position: absolute;
  top: -20px;
  width: 10px; height: 10px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ================= bag / shop panels ================= */
.panel-box {
  background: var(--c-parch);
  border: 5px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 16px 18px;
  width: min(560px, 94vw);
  max-height: 85vh;
  overflow: auto;
  box-shadow: var(--frame);
  color: var(--c-text);
  animation: popin .22s ease-out;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-head h2 { flex: 1; font-size: clamp(20px, 4vw, 28px); text-shadow: 0 2px 0 rgba(90,58,34,.18); }
.panel-hint { font-size: 14px; margin-bottom: 10px; opacity: .8; }
#bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.bag-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius);
  background: #fff9e8;
  border: 3px solid var(--c-wood-l);
  box-shadow: inset 0 -3px 0 rgba(90,58,34,.12);
  min-height: 90px;
}
.bag-item.selected { border-color: var(--c-gold-d); background: #ffe2a8; box-shadow: inset 0 0 0 2px var(--c-gold); }
.bag-emoji { font-size: 28px; }
.bag-name { font-size: 13px; font-weight: 700; text-align: center; }
.bag-count { font-size: 14px; }

.shop-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.shop-cols h3 { margin-bottom: 8px; font-size: 18px; }
.shop-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: #fff9e8;
  border: 3px solid var(--c-wood-l);
  box-shadow: inset 0 -3px 0 rgba(90,58,34,.12);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}
.shop-row:active { background: #ffe2a8; }
@media (max-width: 560px) {
  .shop-cols { grid-template-columns: 1fr; }
}

/* ================= toasts ================= */
#toast-layer {
  position: absolute;
  top: 18%;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 90;
}
.toast {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 700;
  background: var(--c-parch);
  border: 3px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 8px 22px;
  box-shadow: inset 0 0 0 2px #fff6dd, 0 5px 0 rgba(40,24,10,.3);
  animation: toastup 1.4s ease-out forwards;
}
@keyframes toastup {
  0% { transform: translateY(16px) scale(.8); opacity: 0; }
  20% { transform: translateY(0) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translateY(-30px); opacity: 0; }
}

/* small screens: shrink hud a bit */
@media (max-width: 560px) {
  .hud-chip { padding: 4px 8px; }
  #avatar-pick .avatar-btn { width: 60px; height: 60px; font-size: 32px; }
}

/* ================= navigasi keyboard (KC.uinav) ================= */
/* Fokus asli disembunyikan hanya kalau BUKAN dari keyboard; cincin
   besar ".kb-focus" dipasang KC.uinav supaya anak gampang melihat
   pilihan yang sedang aktif. */
#app :focus:not(:focus-visible) { outline: none; }

.kb-focus {
  outline: 3px solid #fff6dd !important;
  outline-offset: 2px;
  box-shadow:
    inset 0 0 0 2px #fff6dd,
    0 0 0 6px var(--c-gold),
    0 0 0 9px var(--c-wood-d) !important;
  position: relative;
  z-index: 6;
  animation: kbpulse 1.1s ease-in-out infinite;
}
@keyframes kbpulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.14); }
}
#name-input.kb-focus { animation: none; }

/* ================= panel bantuan tombol ================= */
#help-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  max-height: 56vh;
  overflow-y: auto;
}
.help-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffaf0;
  border: 3px solid var(--c-wood-d);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: inset 0 0 0 1px #fff6dd;
}
.help-key {
  flex: 0 0 auto;
  min-width: 96px;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--c-parch2);
  border: 2px solid var(--c-wood-d);
  box-shadow: 0 3px 0 rgba(40,24,10,.3);
}
.help-what { font-size: 17px; }

/* ================= hewan peliharaan ================= */
.pet-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.pet-hearts { font-size: 22px; letter-spacing: 2px; }

.kb-hint {
  margin-top: 16px;
  font-size: clamp(13px, 2.2vw, 16px);
  opacity: .75;
}

/* ================= lempar gelang (minigame pasar malam) ================= */
.panel-lempar { text-align: center; max-width: 560px; }
#lempar-rings {
  font-size: 34px;
  letter-spacing: 8px;
  margin: 6px 0 14px;
}
#lempar-bar {
  position: relative;
  height: 62px;
  margin: 0 auto 12px;
  background: linear-gradient(180deg, #6a4a2a 0 50%, #5a3a22 50%);
  border: 4px solid var(--c-wood-d);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px #c89b62;
  overflow: hidden;
}
#lempar-target {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 26%;
  transform: translateX(-50%);
  background: repeating-linear-gradient(90deg, #5a9e3c 0 10px, #6fb54a 10px 20px);
  box-shadow: inset 0 0 0 2px #d2e8ad;
  transition: background .12s;
}
#lempar-target.lempar-kena { background: #ffd23e; }
#lempar-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 2px 0 rgba(40,24,10,.5));
  will-change: left;
}
#lempar-score { font-size: 18px; margin-bottom: 14px; min-height: 24px; }
#lempar-throw { width: min(320px, 80%); }
