/* Jelly Pop. The jars fill the screen behind everything; the menu sits on a card at
   the bottom, and while playing the controls run along the bottom edge. */
:root {
  --kGlow1: rgba(0, 0, 0, .6);
  --kGlow2: rgba(0, 0, 0, .65);
  --kGlow3: rgba(0, 0, 0, .7);

  /* R-C40: colours that were written out in rules, as tokens (theme-derive.py) */
  --kBg1: #231a25;
  --kBg10: rgba(0, 0, 0, .18);
  --kBg11: #2c2130;
  --kBg12: #46364a;
  --kBg13: rgba(36, 26, 38, .78);
  --kBg14: rgba(36, 26, 38, .85);
  --kBg15: rgba(36, 26, 38, .2);
  --kBg16: rgba(36, 26, 38, .92);
  --kBg17: rgba(255, 255, 255, .14);
  --kBg18: rgba(255, 255, 255, .3);
  --kBg19: rgba(0, 0, 0, .55);
  --kBg2: #3a2c3c;
  --kBg20: rgba(20, 12, 22, .45);
  --kBg3: #4c3a4f;
  --kBg4: #e7ddcd;
  --kBg5: rgba(32, 23, 34, .95);
  --kBg6: rgba(36, 26, 38, .62);
  --kBg7: rgba(36, 26, 38, .25);
  --kBg8: #4a3a48;
  --kBg9: #31243a;
  --kInk1: #ffffff;
  --kInk2: #ffe27a;
  --kInk3: #99ff99;
  --kLine1: #3a2c3c;
  --kLine2: #ffd27a;

  --hotInk: #3a2204;
  --bg: #2a1f2c;
  --ink: #fbf6f9;
  --dim: #d9cdd8;
  --card: rgba(36, 26, 38, .88);
  --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, .65);
  --kGlow3: rgba(255, 255, 255, .7);

  --kBg1: #c3bcc5;
  --kBg10: rgba(247, 247, 247, .18);
  --kBg11: #bcb3bf;
  --kBg12: #a99dac;
  --kBg13: rgba(195, 187, 197, .78);
  --kBg14: rgba(195, 187, 197, .85);
  --kBg15: rgba(195, 187, 197, .2);
  --kBg16: rgba(195, 187, 197, .92);
  --kBg17: rgba(31, 31, 31, .14);
  --kBg18: rgba(31, 31, 31, .3);
  --kBg19: rgba(247, 247, 247, .55);
  --kBg2: #b2a8b4;
  --kBg20: rgba(210, 203, 212, .45);
  --kBg3: #a699a8;
  --kBg4: #353029;
  --kBg5: rgba(198, 191, 200, .95);
  --kBg6: rgba(195, 187, 197, .62);
  --kBg7: rgba(195, 187, 197, .25);
  --kBg8: #a69ba5;
  --kBg9: #b8aebf;
  --kInk1: #5d5d5d;
  --kInk2: #0b0000;
  --kInk3: #000700;
  --kLine1: #b2a8b4;
  --kLine2: #453000;

  --hotInk: #ffffff;
  --bg: #fcf3fe;
  --ink: #211e20;
  --dim: #403b40;
  --card: rgba(250, 242, 252, .88);
  --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); }

#main { position: relative; flex: 1; min-height: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; background: var(--kBg4); }
#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 *, #pad, #pad *, #btnHint { pointer-events: auto; }
#scr-how { background: var(--kBg5); }
#scr-how > * { max-width: 640px; margin-left: auto; margin-right: auto; }

/* the menu: words at the top, a card at the bottom, the match playing between */
#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(--kBg6), var(--kBg7)); text-shadow: 0 1px 3px var(--kGlow1); }
h1 { font-size: 34px; margin: 4px 0 4px; }
.sub { color: var(--kInk1); font-size: 15px; line-height: 1.4; margin-bottom: 4px; 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; }
.goal { color: var(--ink); font-size: 14px; margin: 6px 2px 2px; min-height: 18px; }
.big { display: block; width: 100%; min-height: 52px; margin: 8px 0; border: 1px solid var(--line); border-radius: 14px;
       background: var(--kBg2); color: var(--ink); font-size: 17px; font-weight: 600; cursor: pointer; }
.big.primary { background: var(--hot); border-color: var(--kLine2); color: var(--hotInk); }

.pickRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 2px 0 6px; }
.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(--kBg8); }
.modeRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 4px 0 6px; }
.mode { min-height: 46px; border-radius: 12px; border: 2px solid transparent; background: var(--kBg9); color: var(--dim); font-size: 14px; font-weight: 700; cursor: pointer; }
.mode.sel { border-color: var(--hot); color: var(--kInk1); background: var(--kBg8); }

/* the ladder of creatures: a grid that wraps, never a row that scrolls sideways */
#ladder { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 4px 0 0; }
.rung { min-height: 58px; min-width: 0; border-radius: 12px; border: 2px solid transparent; background: var(--kBg9); color: var(--ink);
        cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; }
.rung .em { font-size: 22px; }
.rung small { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rung.sel { border-color: var(--hot); background: var(--kBg8); }
.rung.beat { box-shadow: inset 0 -3px 0 var(--good); }
.rung.locked { opacity: .45; cursor: default; }
#pzNav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0; }
#pzName { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 18px; }
#pzName 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(--kBg10); }
#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(--kBg11); color: var(--dim); font-size: 13px; cursor: pointer; }
.knobBtn.on { background: var(--kBg12); color: var(--ink); border: 2px solid var(--hot); font-weight: 700; }

.card { background: var(--kBg9); 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: 6px; left: 8px; right: 8px; height: 40px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.chip { background: var(--kBg13); color: var(--kInk1); border-radius: 14px; padding: 4px 10px; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#chipWho { flex: 0 1 auto; }
.chip.score { font-size: 20px; padding: 3px 12px; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.chipBtn { min-width: 44px; min-height: 44px; border-radius: 14px; border: 0; background: var(--kBg14); font-size: 20px; cursor: pointer; margin-left: auto; }
#hint { position: absolute; left: 12px; right: 12px; bottom: 132px; text-align: center; font-size: 19px; font-weight: 800; color: var(--kInk1);
        text-shadow: 0 2px 6px var(--kGlow2); pointer-events: none; }
/* the controls: big, along the bottom, under the thumbs */
#pad { position: absolute; left: 0; right: 0; bottom: 0; height: 118px; display: flex; gap: 8px; align-items: center; justify-content: center;
       padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 10px); background: linear-gradient(var(--kBg15), var(--kBg16)); }
.padBtn { flex: 1 1 0; max-width: 96px; min-width: 52px; height: 84px; border-radius: 20px; border: 1px solid rgba(255, 255, 255, .22);
          background: var(--kBg17); color: var(--kInk1); font-size: 32px; font-weight: 800; cursor: pointer; touch-action: none; }
.padBtn:active { background: var(--kBg18); }
.padBtn.turn { box-shadow: inset 0 0 0 2px rgba(255, 179, 56, .7); }
.padBtn.drop { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
#pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; color: var(--kInk1); font-size: 30px; text-shadow: 0 2px 4px var(--kGlow3);
       animation: rise 1.2s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 40px; color: var(--kInk2); }
@keyframes rise { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -70px; } }
#fpsNow { position: absolute; left: 8px; top: 52px; background: var(--kBg19); color: var(--kInk3); 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(--kBg20); padding: 12px; z-index: 10; }
.ovl.on { display: flex; }
.ovlCard { width: min(420px, 100%); margin: auto; background: var(--kBg9); 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; }
.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 */
@media (max-height: 480px) {
  .ovlCard { padding: 10px 12px; }
  .ovlCard h2 { font-size: 19px; margin: 2px 0; }
  #over .big, #paused .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 { width: calc(50% - 8px); }
  #menuTop .sub { display: none; }
  h1 { font-size: 24px; }
  #pad { height: 96px; }
  .padBtn { height: 70px; }
}
