/* Chop Hop. The course fills the screen behind everything; the menu sits on a
   card at the bottom so the level picked shows above it. */
:root {
  --kGlow1: rgba(0, 0, 0, .6);
  --kGlow2: rgba(0, 0, 0, .55);
  --kGlow3: rgba(0, 0, 0, .45);
  --kGlow4: rgba(0, 0, 0, .35);

  /* R-C40: colours that were written out in rules, as tokens (theme-derive.py) */
  --kBg1: #18211a;
  --kBg10: #3a3420;
  --kBg11: rgba(0, 0, 0, .18);
  --kBg12: #222c24;
  --kBg13: #34433a;
  --kBg14: #253027;
  --kBg15: rgba(20, 26, 22, .7);
  --kBg16: rgba(20, 26, 22, .82);
  --kBg17: #ffd76a;
  --kBg18: rgba(255, 255, 255, .2);
  --kBg19: rgba(20, 26, 22, .85);
  --kBg2: #2a3a2c;
  --kBg20: rgba(0, 0, 0, .55);
  --kBg21: rgba(10, 14, 12, .45);
  --kBg22: #1a221c;
  --kBg3: #3a503d;
  --kBg4: #3a2f12;
  --kBg5: #5d7f9c;
  --kBg6: rgba(20, 26, 22, .94);
  --kBg7: rgba(20, 26, 22, .5);
  --kBg8: rgba(20, 26, 22, .2);
  --kBg9: #2f3d31;
  --kInk1: #ffd76a;
  --kInk2: #ffffff;
  --kInk3: #ffe27a;
  --kInk4: #99ff99;
  --kLine1: #2c3a2e;
  --kLine2: #ffd27a;

  --hotInk: #3a2204;
  --bg: #1d2a1f;
  --ink: #fbf7ef;
  --dim: #d6cdbd;
  --card: rgba(28, 33, 30, .86);
  --line: rgba(255, 255, 255, .16);
  --hot: #ffb338;
  --good: #57d68d;
  --bad: #ff6b5b;
}

/* R-C40: the light look. This product's own is dark; the other is chosen with the switch beside Home. */
:root[data-theme="light"] {
  --kGlow1: rgba(255, 255, 255, .6);
  --kGlow2: rgba(255, 255, 255, .55);
  --kGlow3: rgba(255, 255, 255, .45);
  --kGlow4: rgba(255, 255, 255, .35);

  --kBg1: #b9c0bb;
  --kBg10: #aea99c;
  --kBg11: rgba(247, 247, 247, .18);
  --kBg12: #afb6b0;
  --kBg13: #99a39d;
  --kBg14: #abb3ac;
  --kBg15: rgba(193, 198, 194, .7);
  --kBg16: rgba(193, 198, 194, .82);
  --kBg17: #795d00;
  --kBg18: rgba(31, 31, 31, .2);
  --kBg19: rgba(193, 198, 194, .85);
  --kBg2: #a1aca2;
  --kBg20: rgba(247, 247, 247, .55);
  --kBg21: rgba(206, 209, 208, .45);
  --kBg22: #b8bfba;
  --kBg3: #8d9c8f;
  --kBg4: #b4ac99;
  --kBg5: #607384;
  --kBg6: rgba(193, 198, 194, .94);
  --kBg7: rgba(193, 198, 194, .5);
  --kBg8: rgba(193, 198, 194, .2);
  --kBg9: #9fa8a0;
  --kInk1: #150000;
  --kInk2: #000000;
  --kInk3: #0b0000;
  --kInk4: #000700;
  --kLine1: #a1aba2;
  --kLine2: #453000;

  --hotInk: #ffffff;
  --bg: #f0faf1;
  --ink: #211f1c;
  --dim: #443f37;
  --card: rgba(242, 246, 244, .86);
  --line: rgba(13, 13, 13, .16);
  --hot: #a26a00;
  --good: #02a25d;
  --bad: #ef6051;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none;
}
#app { display: flex; flex-direction: column; height: 100%; }

#hdr {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: var(--kBg1); border-bottom: 1px solid var(--kLine1); position: relative; z-index: 5;
}
#hdrTitle { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; font-size: 15px; }
@media (max-width: 380px) { #hdrTitle { visibility: hidden; } }
/* R-C26: [hidden] loses to any display of our own */
[hidden] { display: none !important; }
.pill { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer; }
.pill:active { background: var(--kBg3); }
.coins { display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: 16px; background: var(--kBg4); color: var(--kInk1); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

#main { position: relative; flex: 1; min-height: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; background: var(--kBg5); }
#cvs { display: block; width: 100%; height: 100%; touch-action: none; }
#glFail { position: absolute; inset: 20% 12% auto; padding: 14px; border-radius: 12px; z-index: 30; background: var(--kBg1); color: var(--ink); font-size: 14px; line-height: 1.5; }

.scr { display: none; position: absolute; inset: 0; overflow-y: auto; padding: 12px; }
.scr.on { display: block; }
#scr-play { padding: 0; overflow: hidden; pointer-events: none; }
#scr-play .ovl, #scr-play .ovl * { pointer-events: auto; }
#scr-shop, #scr-how { background: var(--kBg6); }
#scr-shop > *, #scr-how > * { max-width: 640px; margin-left: auto; margin-right: auto; }

/* the menu: words over the sky, a card at the bottom */
#scr-menu { display: none; flex-direction: column; justify-content: space-between; }
#scr-menu.on { display: flex; }
#menuTop { max-width: 560px; width: 100%; margin: 0 auto; padding: 4px 10px 8px; border-radius: 16px; background: linear-gradient(var(--kBg7), var(--kBg8)); text-shadow: 0 1px 3px var(--kGlow1); }
h1 { font-size: 34px; margin: 4px 0 4px; }
.sub { color: var(--kInk2); font-size: 15px; line-height: 1.4; margin-bottom: 8px; max-width: 30em; }
#menuCard { max-width: 560px; width: 100%; margin: 12px auto 0; background: var(--card); border: 1px solid var(--line);
            border-radius: 18px; padding: 10px 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.stat { color: var(--dim); font-size: 13px; margin: 6px 2px 0; }
.big { display: block; width: 100%; min-height: 52px; margin: 8px 0; border: 1px solid var(--line); border-radius: 14px;
       background: var(--kBg9); color: var(--ink); font-size: 17px; font-weight: 600; cursor: pointer; }
.big.primary { background: var(--hot); border-color: var(--kLine2); color: var(--hotInk); }
.big:disabled { opacity: .45; cursor: default; }
.twoBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.twoBtns .big { margin: 0; }

.pickRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 2px 0 4px; }
.pick { min-width: 0; min-height: 66px; background: var(--kBg2); color: var(--ink); border: 2px solid transparent; border-radius: 14px;
        padding: 6px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.pick .te { font-size: 22px; }
.pick b { font-size: 14px; }
.pick small { color: var(--dim); font-size: 11px; }
.pick.sel { border-color: var(--hot); background: var(--kBg10); }

#lvlNav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 0; }
#lvlName { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 18px; }
#lvlName small { color: var(--dim); font-size: 12px; min-height: 15px; }
.setBtn { min-width: 52px; min-height: 48px; border-radius: 12px; border: 0; background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer; }
.setBtn:disabled { opacity: .3; cursor: default; }

#custom { margin: 8px 0 0; border: 1px solid var(--line); border-radius: 14px; background: var(--kBg11); }
#custom > summary { list-style: none; }
#custom > summary::-webkit-details-marker { display: none; }
#custom > summary::after { content: "▾"; margin-left: auto; color: var(--dim); }
#custom[open] > summary::after { content: "▴"; }
summary { min-height: 48px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; font-weight: 600; }
.setBody { padding: 4px 12px 12px; }
.setRow { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.setLbl { flex: 1 1 120px; font-size: 14px; }
.setNote { color: var(--dim); font-size: 12px; line-height: 1.4; }
.knob { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.knobBtn { min-height: 44px; min-width: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg12); color: var(--dim); font-size: 13px; cursor: pointer; }
.knobBtn.on { background: var(--kBg13); color: var(--ink); border: 2px solid var(--hot); font-weight: 700; }

.card { background: var(--kBg14); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 8px 0; font-size: 14px; line-height: 1.5; }
.card h2 { font-size: 17px; margin: 0 0 4px; }

/* ---- playing ----------------------------------------------------------------------- */
#hud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; pointer-events: none; }
.chip { background: var(--kBg15); color: var(--kInk2); border-radius: 14px; padding: 4px 10px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.score { font-size: 22px; padding: 4px 14px; }
#hint { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font-size: 26px; font-weight: 800; color: var(--kInk2);
        text-shadow: 0 2px 6px var(--kGlow2); pointer-events: none; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
#colScore { position: absolute; left: 10px; top: 58px; max-width: 46%; background: var(--kBg16); color: var(--kInk2); border-radius: 16px;
            padding: 8px 16px; font-size: 18px; text-align: center; pointer-events: none; }
#colScore b { font-size: 26px; color: var(--kInk1); }
#colScore small { display: block; font-size: 13px; color: var(--dim); }
#waitRing { position: absolute; right: 16px; top: 58px; width: 44px; height: 44px; border-radius: 50%; background: conic-gradient(var(--kBg17) var(--p, 0%), var(--kBg18) 0); pointer-events: none; }
#waitRing i { position: absolute; inset: 7px; border-radius: 50%; background: var(--kBg19); }

#labels, #pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.band { position: absolute; transform: translate(-50%, -50%); font-weight: 900; color: var(--kInk2); font-size: 22px; letter-spacing: .5px;
        text-shadow: 0 2px 0 var(--kGlow3), 0 0 6px var(--kGlow4); white-space: nowrap; }
.band.now { color: var(--kInk3); transform: translate(-50%, -50%) scale(1.25); }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; color: var(--kInk2); font-size: 20px; text-shadow: 0 2px 3px var(--kGlow1);
       animation: rise .9s ease-out forwards; white-space: nowrap; }
.pop.praise { font-size: 30px; color: var(--kInk3); animation-duration: 1.3s; }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -60px; } }
#fpsNow { position: absolute; left: 8px; bottom: 8px; background: var(--kBg20); color: var(--kInk4); font: 12px ui-monospace, monospace; padding: 3px 6px; border-radius: 6px; pointer-events: none; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; background: var(--kBg21); padding: 12px; z-index: 10; }
.ovl.on { display: flex; }
.ovlCard { width: min(420px, 100%); margin: auto; background: var(--kBg14); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; text-align: center; }
.ovlCard.small { width: auto; }
.ovlCard h2 { margin: 4px 0 8px; font-size: 24px; }
.ovlCard p { color: var(--dim); font-size: 15px; line-height: 1.45; margin: 6px 0; }
#doneSum { font-size: 30px; font-weight: 900; margin: 6px 0; font-variant-numeric: tabular-nums; }
#doneSum small { display: block; font-size: 14px; font-weight: 600; color: var(--dim); }
#doneCoins { font-size: 22px; font-weight: 800; color: var(--kInk1); margin: 6px 0 10px; }

/* ---- the shop -------------------------------------------------------------------- */
.shopHead { display: flex; align-items: center; justify-content: space-between; }
.shopHead h2 { margin: 6px 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px auto; }
.tab { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg12); color: var(--dim); font-size: 15px; font-weight: 600; cursor: pointer; }
.tab.on { background: var(--kBg10); color: var(--kInk2); border-color: var(--hot); }
#shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 8px auto; }
.item { background: var(--kBg14); border: 2px solid transparent; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; min-width: 0; }
.item.using { border-color: var(--good); }
.item .thumb { width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; background: var(--kBg22); display: flex; align-items: center; justify-content: center; font-size: 36px; overflow: hidden; }
.item .thumb canvas { width: 100%; height: 100%; display: block; }
.item b { font-size: 14px; }
.item small { color: var(--dim); font-size: 12px; min-height: 30px; line-height: 1.25; }
.item button { width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg9); color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; }
.item button.buy { background: var(--hot); color: var(--hotInk); border-color: var(--kLine2); }
.item button:disabled { opacity: .5; cursor: default; }

.toast-host { position: fixed; left: 0; right: 0; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
/* a phone on its side: the cards put their buttons in a row so they fit without scrolling */
@media (max-height: 480px) {
  .ovlCard { padding: 10px 12px; }
  .ovlCard h2 { font-size: 19px; margin: 2px 0; }
  #doneSum { font-size: 24px; margin: 2px 0; }
  #doneCoins { margin: 2px 0 4px; }
  #done .big, #paused .big, #lost .big { display: inline-block; width: calc(33% - 8px); min-width: 120px; min-height: 46px; margin: 4px 2px; padding: 0 8px; font-size: 15px; }
  #paused .big, #lost .big { width: calc(50% - 8px); }
  #menuTop .sub { display: none; }
  h1 { font-size: 24px; }
}
