:root {
  --paper: #f6f2e9;
  --ink: #1d1d1f;
  --muted: #7a776f;
  --gold: #b8975a;
  --red: #e5484d;
  --green: #2fa36b;
  --blue: #0f6fd6;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--sans); }
body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }

/* HUD */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.back {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; color: #4f4c45; text-decoration: none; white-space: nowrap;
  background: rgba(255,253,248,.82); border: 1px solid #e4dccb; border-radius: 999px; padding: 7px 12px;
}
.back:hover { color: var(--ink); border-color: var(--ink); }
.crumbs {
  display: flex; align-items: center; gap: 5px; padding: 5px 11px 5px 8px; border-radius: 999px;
  background: rgba(255,253,248,.85); border: 1px solid #e4dccb;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.crumbs svg { width: 18px; height: 18px; display: block; }
.crumbs.bump { animation: bump .3s ease-out; }
@keyframes bump { 40% { transform: scale(1.15); background: #fff3c4; } }
.score {
  display: flex; align-items: baseline; gap: 5px; font-family: var(--serif); white-space: nowrap;
  background: rgba(255,253,248,.85); border: 1px solid #e4dccb; border-radius: 999px; padding: 1px 14px 3px;
}
.score b { font-size: 28px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }
.score span { font-size: 14px; color: var(--muted); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid #d8d2c4; background: rgba(255,255,255,.85);
  display: grid; place-items: center; padding: 0;
}
.icon-btn:hover { border-color: var(--ink); }

.status {
  position: fixed; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 50px); transform: translateX(-50%); z-index: 10;
  display: flex; gap: 8px; pointer-events: none;
}
.chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(60,50,30,.14);
}
.chip.bee { background: #f7c21b; color: var(--ink); border: 1.5px solid var(--ink); }
.chip.wings { background: var(--blue); color: #fff; border: 1.5px solid #0a4f9a; }
.chip i { display: block; width: 52px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.18); overflow: hidden; }
.chip i u { display: block; height: 100%; background: currentColor; }

/* overlays */
.overlay {
  position: fixed; inset: 0; z-index: 30; display: none; place-items: center; padding: 16px;
  background: rgba(246,242,233,.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  touch-action: pan-y;
}
.overlay.open { display: grid; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; } }
.overlay .card {
  width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: #fffdf8; border: 1px solid #e4dccb; border-radius: 14px; padding: 30px 30px 26px;
  box-shadow: 0 30px 80px rgba(60,50,30,.22);
}
.overlay .card.small { width: min(420px, 100%); }
.eyebrow { font-size: 11.5px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--gold); margin: 0 0 10px; }
.eyebrow.alert { color: var(--red); }
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(36px, 8vw, 50px); }
h2 { font-size: clamp(30px, 6vw, 40px); }
.lede { color: #55524b; font-size: 15.5px; line-height: 1.55; margin: 12px 0 0; }
.howto { margin: 16px 0 0; padding: 0 0 0 18px; color: #55524b; font-size: 14.5px; line-height: 1.6; }
.howto li + li { margin-top: 3px; }
.howto b { color: var(--ink); font-weight: 600; }
.actions { display: flex; align-items: center; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--ink); background: var(--ink); color: #fff; padding: 11px 22px; border-radius: 999px;
  font-size: 13px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; text-decoration: none;
  transition: transform .08s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: #cfc7b6; }
.best { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); margin: 16px 0 0; }

.results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.results div { background: var(--paper); border-radius: 10px; padding: 12px 6px; text-align: center; }
.results b { display: block; font-family: var(--serif); font-size: 30px; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; }
.results span { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }

#toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toast-in .2s ease-out; max-width: calc(100vw - 32px); text-align: center; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 560px) {
  .hud { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .hud-right { gap: 6px; }
  .back { padding: 6px 10px; font-size: 11px; }
  .score span { display: none; }
  .score b { font-size: 24px; }
  .score { padding: 1px 11px 2px; }
  .crumbs { padding: 4px 9px 4px 7px; font-size: 12px; }
  .icon-btn { width: 34px; height: 34px; }
  .overlay .card { padding: 24px 20px 20px; }
  .howto { font-size: 14px; }
  .results { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .back span { display: none; }
}
