/* Bramble Dash. Portrait layout: banner slot, then menu (header, panel, tabs) or game (HUD, stage, controls). */
:root {
  --banner-h: 60px;
  --bg: #12221c;
  --surface: #1b3128;
  --surface-2: #264636;
  --ink: #eefaf1;
  --ink-soft: #9fc2ae;
  --line: #2f5642;
  --accent: #ff9a3c;
  --accent-ink: #2b1500;
  --gold: #ffc940;
  --gold-d: #d9a21c;
  --bad: #ff7b6b;
  --good: #4fdc9c;
  --ph: #172b22;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
body[data-theme='light'] {
  --bg: #eaf6e3;
  --surface: #ffffff;
  --surface-2: #dcefd2;
  --ink: #17301f;
  --ink-soft: #587a62;
  --line: #bfdcb3;
  --accent: #f0771d;
  --accent-ink: #fff;
  --gold: #e8a91c;
  --gold-d: #b97d08;
  --bad: #c93a2a;
  --good: #1f9a6a;
  --ph: #dcefd2;
  --shadow: 0 2px 10px rgba(30, 80, 40, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; }

#app {
  position: fixed;
  inset: 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- the one banner slot ---- */
.banner {
  flex: 0 0 var(--banner-h);
  height: var(--banner-h);
  margin: 0 0 6px;
  background: var(--ph);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.banner.collapsed { display: none; margin: 0; }
.banner-ph { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); opacity: 0.7; }
.banner.filled .banner-ph { display: none; }

.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---- menu ---- */
.top { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 4px 14px 8px; }
.ttl { font-size: 22px; font-weight: 800; letter-spacing: 0.01em; }
.ttl span { color: var(--accent); }
.pill { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; }
.coin { display: inline-block; width: 15px; height: 15px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold) 55%, var(--gold-d)); box-shadow: inset 0 0 0 2px rgba(120, 80, 0, 0.35); vertical-align: -2px; margin-right: 4px; }
.pill .coin { margin: 0; }

.panel { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 14px 16px; -webkit-overflow-scrolling: touch; }
.panel h2 { font-size: 17px; margin: 18px 2px 6px; }
.panel h2:first-child { margin-top: 6px; }
.note { color: var(--ink-soft); font-size: 13px; margin: 2px 2px 10px; line-height: 1.4; text-align: center; margin-top: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; }
.rinfo { flex: 1; min-width: 0; }
.rinfo h3 { margin: 0 0 3px; font-size: 15px; }
.rinfo p { margin: 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.how p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.4; }
.how p:last-child { margin: 0; }
.ico { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 26px; }
.ico img { width: 34px; height: 34px; object-fit: contain; }

.hero { position: relative; border-radius: 18px; overflow: hidden; margin-bottom: 10px; box-shadow: var(--shadow); aspect-ratio: 2 / 1; background: #2e6a47 center / cover no-repeat; }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 55%); }
.hero .best { position: absolute; left: 14px; bottom: 10px; color: #fff; font-weight: 800; font-size: 16px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.hero .biome { position: absolute; right: 12px; bottom: 10px; color: #fff; font-size: 12px; opacity: 0.9; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }

.skins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.skin { background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 6px 1px 5px; text-align: center; cursor: pointer; min-width: 0; }
.skin.sel { border-color: var(--accent); }
.skin img { width: 100%; height: 40px; object-fit: contain; }
.skin.locked img { opacity: 0.5; }
.skin b { display: block; font-size: 10.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skin small { display: block; font-size: 9.5px; letter-spacing: -0.1px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skin small.mx { color: var(--accent); font-weight: 800; }
.skin small.rq { color: var(--bad); font-weight: 700; }
.mline { margin: 8px 2px 4px; font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.mline b { color: var(--accent); }
.rb { margin-top: 12px; }
.rb h3 { margin: 0 0 4px; font-size: 15px; }
.rb p { margin: 0 0 6px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.rb .bar i { background: var(--gold); }
.rb .btn { width: 100%; margin-top: 4px; }
.over .sc { font-size: 17px; font-weight: 800; margin: -2px 0 6px; font-variant-numeric: tabular-nums; }
.over .sc small { color: var(--accent); font-size: 13px; margin-left: 4px; }
.over .sc .nbs { display: block; color: var(--accent); font-size: 13px; animation: pulse 0.6s infinite alternate; }

.btn { border: 0; background: var(--surface-2); color: var(--ink); padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer; min-height: 44px; }
.btn:active { transform: translateY(1px); filter: brightness(0.92); }
.btn.go { background: linear-gradient(180deg, #ffbe6a, var(--accent)); color: var(--accent-ink); }
.btn.big { width: 100%; font-size: 20px; padding: 15px; margin-top: 4px; border-radius: 14px; letter-spacing: 0.06em; }
.btn.sm { min-width: 74px; padding: 8px 12px; min-height: 40px; }
.btn.buy { min-width: 92px; }
.btn.buy.can { background: linear-gradient(180deg, #ffbe6a, var(--accent)); color: var(--accent-ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); margin-top: 16px; width: 100%; }

.pips { display: flex; gap: 3px; margin-top: 7px; flex-wrap: wrap; }
.pip { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.pip.on { background: var(--accent); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; background: var(--good); border-radius: 4px; }

.gift { border-color: var(--accent); }
.awards { display: grid; grid-template-columns: 1fr; gap: 6px; }
.award { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; opacity: 0.55; }
.award i { font-style: normal; font-size: 22px; filter: grayscale(1); }
.award span { flex: 1; }
.award b { color: var(--gold); font-size: 12px; }
.award.on { opacity: 1; border-color: var(--gold-d); }
.award.on i { filter: none; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px; font-size: 14px; }
.sw { width: 46px; height: 26px; border-radius: 13px; background: var(--line); position: relative; border: 0; cursor: pointer; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.sw.on { background: var(--good); }
.sw.on::after { left: 23px; }
select { font: inherit; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; }
.stats b { text-align: right; }

.tabs { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); }
.tabs button { position: relative; background: none; border: 0; padding: 8px 2px 7px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--ink-soft); cursor: pointer; }
.tabs button svg { width: 24px; height: 24px; fill: currentColor; }
.tabs button.active { color: var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); box-sizing: content-box; }

/* ---- game ---- */
.hud { flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 2px 10px 6px; gap: 8px; }
.hl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; min-width: 0; }
.hl .hd { display: flex; align-items: baseline; gap: 4px; }
.hs { font-size: 12.5px; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hs u { text-decoration: none; color: var(--accent); margin-left: 6px; }
.hl b { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hl small { color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.hc { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 60px; }
#h-hearts { font-size: 15px; letter-spacing: 2px; color: #ff5c6c; min-height: 18px; }
#h-pu { display: flex; gap: 6px; min-height: 22px; }
.pu { position: relative; width: 24px; height: 24px; }
.pu img { width: 24px; height: 24px; object-fit: contain; }
.pu i { position: absolute; left: 0; right: 0; bottom: -4px; height: 3px; border-radius: 2px; background: var(--accent); }
.hr { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 800; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }

.stage { flex: 1 1 auto; min-height: 0; position: relative; background: #7ac7a0; border-radius: 12px; margin: 0 6px; overflow: hidden; touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.msg { position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: 30px; font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 170, 60, 0.9); pointer-events: none; animation: pop 0.35s ease-out; padding: 0 12px; }
.tut { position: absolute; left: 10%; right: 10%; top: 40%; text-align: center; font-size: 20px; font-weight: 800; color: #fff; background: rgba(0, 0, 0, 0.45); padding: 10px; border-radius: 14px; pointer-events: none; }

.ctl { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; padding: 8px 6px 6px; height: 84px; }
.cbtn { border: 0; border-radius: 16px; background: var(--surface-2); color: var(--ink); font-weight: 800; font-size: 17px; letter-spacing: 0.05em; cursor: pointer; touch-action: none; }
.cbtn.jump { background: linear-gradient(180deg, #ffbe6a, var(--accent)); color: var(--accent-ink); }
.cbtn:active, .cbtn.down { filter: brightness(0.88); transform: translateY(1px); }

/* ---- toast / modal ---- */
.toast { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; z-index: 30; max-width: 92%; text-align: center; }
.toast.gold { border-color: var(--gold); color: var(--gold); }
.modal { position: absolute; inset: 0; background: rgba(5, 15, 10, 0.66); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 20; }
.modal-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); max-height: 92%; overflow-y: auto; }
.modal-card h2 { margin: 0 0 12px; font-size: 20px; text-align: center; }
.modal-card p { line-height: 1.4; }
.mrow { display: flex; gap: 10px; margin-top: 14px; }
.mrow .btn { flex: 1; }
.over { text-align: center; }
.over .big { font-size: 44px; font-weight: 900; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.over .nb { color: var(--accent); font-weight: 800; margin-bottom: 4px; animation: pulse 0.6s infinite alternate; }
.over .why { color: var(--ink-soft); font-size: 13px; margin-bottom: 8px; }
.orow { display: flex; justify-content: space-between; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); font-size: 14px; }
.orow span { color: var(--ink-soft); }

@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.25); } }

@media (max-height: 560px) {
  .hl b { font-size: 22px; }
  .ctl { height: 60px; }
  .banner { margin-bottom: 2px; }
}
@media (min-width: 520px) and (min-height: 760px) {
  .panel { padding: 6px 22px 18px; }
}

/* music volume slider (settings) */
input.vol { width: 130px; max-width: 45vw; accent-color: var(--accent); }
.set .np-title { font-size: 12px; color: var(--ink-soft); max-width: 55vw; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .msg, .over .nb { animation: none; }
  .sw::after { transition: none; }
}

/* fox on the home screen: sits and blinks (colour skins) or runs on the spot (costumes) */
.hero .hero-fox { position: absolute; right: 7%; bottom: 10%; height: 70%; animation: heroBob 2.8s ease-in-out infinite; transform-origin: 50% 100%; }
.hero .hero-fox.run { height: 56%; bottom: 13%; animation: none; }
@keyframes heroBob { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.02, 0.98); } }
/* cheering fox on a new best */
.over .cheer { display: block; height: 96px; margin: -6px auto 2px; animation: cheer 0.55s ease-in-out infinite alternate; }
.over .cheer.costume { height: 80px; }
@keyframes cheer { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-8px) rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .hero .hero-fox, .over .cheer { animation: none; } }
