.hint-card[hidden], .sheet[hidden], .modal[hidden] { display: none; }

:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ink: #3f2414;
  --ink-soft: #6b4a2a;
  --cream: #fff1cd;
  --cream2: #fbead2;
  --parchment: #fff3d7;
  --wheat: #e8c985;
  --amber: #e8954a;
  --orange: #cf6b2d;
  --grass: #8fbf70;
  --grass-deep: #547b41;
  --water: #80c9d9;
  --pool: #a8dded;
  --font: "Comic Sans MS", "Chalkboard SE", "Marker Felt", "Segoe Print", "PingFang SC", "Microsoft YaHei", cursive, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; touch-action: manipulation; }
body {
  font-family: var(--font);
  background: #7cac62;
  color: var(--ink);
  overscroll-behavior: none;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: none;
}

/* ---------- storybook overlays ---------- */
#grainOverlay {
  position: fixed;
  inset: -20%;
  z-index: 20;
  opacity: .22;
  mix-blend-mode: multiply;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}
#warmGlow {
  position: fixed;
  inset: 0;
  z-index: 19;
  pointer-events: none;
  background:
    radial-gradient(circle at 76% 14%, rgba(232,149,74,.26), transparent 34%),
    radial-gradient(circle at 12% 10%, rgba(26,18,8,.20), transparent 46%),
    linear-gradient(180deg, rgba(26,18,8,.20), transparent 24%, rgba(26,18,8,.14));
  mix-blend-mode: multiply;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
}
#hud > * { pointer-events: auto; }

#strip {
  position: absolute;
  top: var(--eazo-safe-area-top);
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 7px;
  border: 3px solid var(--ink);
  border-radius: 23px 19px 24px 18px;
  background: linear-gradient(180deg, #fff2ce, #e7c985);
  box-shadow: 0 7px 0 rgba(63,36,20,.20), inset 0 0 0 2px rgba(255,255,255,.40);
  transform: rotate(-.5deg);
  z-index: 30;
}
#strip::before, #strip::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 48px;
  height: 18px;
  background: rgba(248,199,114,.78);
  border: 2px solid rgba(63,36,20,.45);
  box-shadow: 0 2px 0 rgba(63,36,20,.15);
  pointer-events: none;
}
#strip::before { left: 26px; transform: rotate(-8deg); }
#strip::after { right: 28px; transform: rotate(7deg); }

.strip-left, .strip-right { display: flex; align-items: center; gap: 5px; min-width: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff8df; border: 2.5px solid var(--ink);
  border-radius: 999px; padding: 4px 8px;
  font-family: var(--font); font-weight: 900; font-size: 13px; color: var(--ink);
  box-shadow: 0 3px 0 rgba(63,36,20,.22);
  cursor: pointer; white-space: nowrap;
}
.chip:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(63,36,20,.22); }
.chip .ic { width: 17px; height: 17px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 14px;
  background: #fff8df; border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 rgba(63,36,20,.22);
  cursor: pointer; padding: 0; flex: 0 0 auto;
}
.icon-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(63,36,20,.22); }
.icon-btn .ic { width: 20px; height: 20px; }
.tab {
  font-family: var(--font); font-weight: 900; font-size: 12px;
  color: var(--cream); background: #5a3422;
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 6px 10px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 3px 0 rgba(63,36,20,.26);
}
.tab:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(63,36,20,.26); }
.lang-sel {
  font-family: var(--font); font-weight: 900; font-size: 12px;
  color: var(--ink); background: var(--cream2);
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 5px 6px; cursor: pointer; flex: 0 0 auto;
  box-shadow: 0 3px 0 rgba(63,36,20,.22);
}

/* Narrow screens: compact the HUD chips so the strip stays a single tight row,
   and drop the toast tray below it in case the strip wraps to two rows. */
@media (max-width: 414px) {
  #strip { padding: 4px 6px; gap: 5px; }
  .strip-left, .strip-right { gap: 4px; }
  .chip { gap: 3px; padding: 3px 5px; font-size: 12px; }
  .chip .ic { width: 16px; height: 16px; }
  .icon-btn { width: 33px; height: 33px; }
  .icon-btn .ic { width: 19px; height: 19px; }
  .tab { font-size: 11px; padding: 5px 8px; }
  .lang-sel { font-size: 11px; padding: 4px 5px; }
}
@media (max-width: 355px) {
  #hud #toasts { top: calc(var(--eazo-safe-area-top) + 116px); }
}

/* ---------- Hint & toasts ---------- */
.hint-card {
  position: absolute;
  left: 14px; right: 14px;
  bottom: calc(var(--eazo-safe-area-bottom) + 12px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 13px;
  border: 3px solid var(--ink);
  border-radius: 22px 18px 24px 20px;
  background: linear-gradient(180deg, #fff7dd, #f5dfad);
  box-shadow: 0 8px 0 rgba(63,36,20,.22);
  transform: rotate(-.4deg);
  z-index: 25;
}
.hint-card p { margin: 0; font-size: 13px; line-height: 1.3; flex: 1; font-weight: 700; }
.brown-btn {
  font-family: var(--font); font-weight: 900; font-size: 14px;
  color: var(--cream); background: #5a3422;
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 9px 17px; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 0 rgba(63,36,20,.30);
}
.brown-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(63,36,20,.30); }
.brown-btn.ghost { background: #fff8df; color: var(--ink); }
.brown-btn.small { font-size: 12px; padding: 6px 14px; }

#toasts {
  position: absolute;
  top: calc(var(--eazo-safe-area-top) + 64px);
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 40; pointer-events: none;
}
.toast {
  background: linear-gradient(180deg, #fff3d7, #f5d99d);
  border: 2.5px solid var(--ink);
  border-radius: 16px 13px 17px 12px;
  padding: 7px 15px;
  font-size: 13px; font-weight: 900; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 5px 0 rgba(63,36,20,.20);
  transform: rotate(-.3deg);
  animation: toastIn .25s ease-out;
}
.toast .t-ic { width: 20px; height: 20px; flex: 0 0 auto; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) rotate(.5deg); } to { opacity: 1; transform: rotate(-.3deg); } }
.toast.out { transition: opacity .3s; opacity: 0; }

/* ---------- Sheets (shop / badges / report) ---------- */
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: min(78vh, 620px);
  background: linear-gradient(180deg, #fff3d7, #f5d99d);
  border: 3px solid var(--ink); border-bottom: none;
  border-radius: 25px 19px 0 0;
  z-index: 50;
  padding: calc(var(--eazo-safe-area-top) * 0 + 18px) 16px calc(var(--eazo-safe-area-bottom) + 16px);
  overflow-y: auto;
  box-shadow: 0 -8px 0 rgba(63,36,20,.14), 0 -22px 45px rgba(40,23,13,.22);
  animation: sheetUp .25s ease-out;
}
.sheet::before, .sheet::after {
  content: "";
  position: absolute;
  top: -13px;
  width: 55px;
  height: 21px;
  background: rgba(255,210,123,.78);
  border: 2px solid rgba(63,36,20,.44);
  pointer-events: none;
}
.sheet::before { left: 20px; transform: rotate(-10deg); }
.sheet::after { right: 30px; transform: rotate(8deg); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { margin: 0; font-size: 21px; color: #5a3422; text-shadow: 0 2px 0 rgba(255,255,255,.45); }
.sheet-sub { margin: 4px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.sheet-sub.small { font-size: 12px; margin-bottom: 6px; }
.sheet .icon-btn.close { border-radius: 15px; }

.shop-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,249,224,.80);
  border: 2.5px solid var(--ink);
  border-radius: 19px 15px 21px 16px;
  padding: 10px; margin-bottom: 10px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.32);
}
.shop-item .s-ic { width: 46px; height: 46px; flex: 0 0 auto; }
.shop-item .s-info { flex: 1; min-width: 0; }
.shop-item .s-name { font-weight: 900; font-size: 15px; }
.shop-item .s-desc { font-size: 12px; color: var(--ink-soft); }
.shop-item .s-price { font-size: 12px; font-weight: 900; color: #cf6b2d; }
.shop-item .s-act { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.shop-item .s-btn {
  font-family: var(--font); font-weight: 900; font-size: 12px;
  border-radius: 999px; padding: 7px 13px; cursor: pointer;
  color: var(--cream); background: var(--orange); border: 2.5px solid var(--ink);
  box-shadow: 0 4px 0 #6b351e;
  white-space: nowrap;
}
.shop-item .s-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 #6b351e; }
.shop-item .s-btn.owned { background: #7aa864; color: #213819; box-shadow: 0 4px 0 #3f5c34; }
.shop-item .s-btn.worn { background: var(--amber); color: var(--ink); box-shadow: 0 4px 0 #7a4a22; }
.shop-item .s-btn:disabled { opacity: .55; cursor: default; box-shadow: none; transform: none; }

.badge-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,249,224,.80);
  border: 2.5px solid var(--ink);
  border-radius: 19px 15px 21px 16px;
  padding: 9px 11px; margin-bottom: 8px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.32);
}
.badge-row .b-ic { width: 40px; height: 40px; flex: 0 0 auto; opacity: .95; }
.badge-row.locked .b-ic { opacity: .45; filter: grayscale(1); }
.badge-row .b-info { flex: 1; min-width: 0; }
.badge-row .b-name { font-weight: 900; font-size: 14px; }
.badge-row .b-desc { font-size: 12px; color: var(--ink-soft); }
.badge-row .b-state { font-size: 11px; font-weight: 900; white-space: nowrap; }
.badge-row.locked .b-state { color: #9a7b55; }
.badge-row.earned .b-state { color: #2e7d32; }

/* ---------- Report card ---------- */
.report-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 10px;
}
.stat-box {
  background: rgba(255,249,224,.80);
  border: 2.5px solid var(--ink);
  border-radius: 17px 13px 19px 14px;
  padding: 8px 10px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.32);
}
.stat-box .st-label { font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.stat-box .st-val { font-weight: 900; font-size: 15px; margin-top: 2px; }
.stat-box.wide { grid-column: 1 / -1; }
.report-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.report-actions .brown-btn { flex: 1; }
.share-status { margin: -4px 0 10px; font-size: 12px; font-weight: 700; color: #cf6b2d; text-align: center; }
#reportBadges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rb { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.rb .rb-ic { width: 38px; height: 38px; }
.rb.locked .rb-ic { opacity: .35; filter: grayscale(1); }
.rb .rb-name { font-size: 10px; line-height: 1.2; color: var(--ink-soft); font-weight: 700; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(60,40,20,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
}
.modal-card {
  width: min(340px, 100%);
  background: linear-gradient(180deg, #fff3d7, #f5d99d);
  border: 3px solid var(--ink); border-radius: 24px 18px 26px 20px;
  padding: 18px; text-align: center;
  box-shadow: 0 10px 0 rgba(63,36,20,.22);
  transform: rotate(.4deg);
}
.modal-card h3 { margin: 0 0 6px; color: #5a3422; }
.modal-card p { margin: 0 0 14px; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.modal-actions { display: flex; gap: 8px; justify-content: center; }
.modal-actions .brown-btn { flex: 1; }

@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; transform: translateX(-50%); width: 520px; max-height: 640px; border-radius: 25px 19px 29px 20px; border-bottom: 3px solid var(--ink); }
  .sheet.up { animation: sheetUp .25s ease-out; }
}
