/* Loopdale. The park fills the screen; everything else floats over it and
   stays out of the middle, where the building happens. */
:root {
  --kGlow1: rgba(0, 0, 0, .7);

  /* R-C40: colours that were written out in rules, as tokens (theme-derive.py) */
  --kBg1: #154a70;
  --kBg10: #0c2b44;
  --kBg11: rgba(10, 36, 58, .92);
  --kBg12: rgba(10, 36, 58, .75);
  --kBg13: rgba(255, 255, 255, .08);
  --kBg14: rgba(255, 214, 90, .14);
  --kBg15: #ffffff;
  --kBg16: rgba(12, 42, 66, .95);
  --kBg17: #1a5680;
  --kBg18: #22648f;
  --kBg19: #7d8b96;
  --kBg2: #1f5f8e;
  --kBg20: rgba(6, 24, 40, .7);
  --kBg3: #2a70a3;
  --kBg4: #184f78;
  --kBg5: #123e60;
  --kBg6: #5aa9dd;
  --kBg7: #0f3452;
  --kBg8: rgba(255, 255, 255, .88);
  --kBg9: #ffd9d4;
  --kInk1: #ffe38a;
  --kInk2: #10263a;
  --kInk3: #0b2d18;
  --kInk4: #ffffff;
  --kLine1: #2a6c9c;
  --kLine2: #ffd27a;

  --hotInk: #3a2204;
  --sky: #1d5e8c;
  --ink: #f4f8fb;
  --dim: #b9cfe0;
  --card: #174c73;
  --line: #2d74a6;
  --hot: #ffb338;
  --good: #57d68d;
  --bad: #ff6b5b;
  --glass: rgba(10, 36, 58, .82);
}

/* 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, .7);

  --kBg1: #a3c1dc;
  --kBg10: #cde2f6;
  --kBg11: rgba(216, 234, 252, .92);
  --kBg12: rgba(216, 234, 252, .75);
  --kBg13: rgba(31, 31, 31, .08);
  --kBg14: rgba(110, 84, 0, .14);
  --kBg15: #1f1f1f;
  --kBg16: rgba(207, 227, 246, .95);
  --kBg17: #94b6d2;
  --kBg18: #84a9c5;
  --kBg19: #747c83;
  --kBg2: #89accb;
  --kBg20: rgba(234, 249, 255, .7);
  --kBg3: #769cbc;
  --kBg4: #9cbcd8;
  --kBg5: #b2cde6;
  --kBg6: #426c88;
  --kBg7: #c0d8ef;
  --kBg8: rgba(31, 31, 31, .88);
  --kBg9: #3f2d2b;
  --kInk1: #0a0000;
  --kInk2: #94aec7;
  --kInk3: #001403;
  --kInk4: #000000;
  --kLine1: #7ba0bf;
  --kLine2: #4b3501;

  --hotInk: #ffffff;
  --sky: #bce2ff;
  --ink: #1e1f21;
  --dim: #414c55;
  --card: #dbfbff;
  --line: #9bc4e4;
  --hot: #a26a00;
  --good: #008f4c;
  --bad: #da4c3f;
  --glass: rgba(229, 248, 255, .82);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--sky); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
#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);
}
/* flex-basis 0: the title takes only what the pills leave */
#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 */
#hdrPause[hidden], #btnResume[hidden], #placeBar[hidden], #sheet[hidden], #goalChip[hidden], #glFail[hidden], #rideBar[hidden] { display: none; }
.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); }

.scr { display: none; flex: 1; overflow-y: auto; padding: 12px; }
.scr.on { display: block; }
#scr-play.on { display: flex; padding: 0; }

h1 { font-size: 28px; margin: 8px 0 4px; }
.sub { color: var(--dim); font-size: 14px; line-height: 1.45; margin-bottom: 12px; }
.stat { color: var(--dim); font-size: 13px; }
.goal { color: var(--ink); font-size: 14px; line-height: 1.45; margin: 4px 2px 8px; min-height: 20px; }

.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); }

details { margin: 10px 0; border: 1px solid var(--kLine1); border-radius: 14px; background: var(--kBg4); }
#custom { margin: 10px 0; border: 1px solid var(--kLine1); border-radius: 14px; background: var(--kBg4); }
#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: 10px 12px 14px; }
.setRow { display: flex; align-items: center; gap: 10px; margin: 10px 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(--kBg5); color: var(--dim);
  font-size: 13px; cursor: pointer;
}
.knobBtn.on { background: var(--hot); color: var(--hotInk); border-color: var(--kLine2); font-weight: 700; }

/* R-C12b: the parks, as a segmented row that wraps to two by two */
.pickRow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin: 6px 0 4px; }
@media (min-width: 560px) { .pickRow { grid-template-columns: repeat(4, 1fr); } }
.pick {
  min-width: 0; min-height: 72px;
  background: var(--kBg2); color: var(--ink); border: 2px solid transparent;
  border-radius: 14px; padding: 8px 4px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
}
.pick .te { font-size: 24px; }
.pick b { font-size: 14px; }
.pick small { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.pick.sel { border-color: var(--hot); background: var(--card); }

/* ---- the park -------------------------------------------------------------- */
#stage { position: relative; flex: 1; width: 100%; overflow: hidden; touch-action: none; background: var(--kBg6); }
#cvs { display: block; width: 100%; height: 100%; touch-action: none; }
#glFail {
  position: absolute; inset: 20% 12% auto; padding: 14px; border-radius: 12px;
  background: var(--kBg7); color: var(--ink); font-size: 14px; line-height: 1.5;
}
#signs { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sign {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  font-size: 22px; line-height: 1; padding: 3px 5px; border-radius: 10px;
  background: var(--kBg8); box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  white-space: nowrap; will-change: transform;
}
.sign.broken { background: var(--kBg9); }
.sign.shut { opacity: .6; }
.sign.small { font-size: 16px; padding: 2px 4px; }
/* R7.2: money as it comes in, rising and fading where it was taken */
.cashpop {
  position: absolute; transform: translate(-50%, -100%); font-size: 15px; font-weight: 800;
  color: var(--kInk1); text-shadow: 0 1px 3px var(--kGlow1); animation: cashup 1.1s ease-out forwards;
}
@keyframes cashup { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -34px; } }
@media (prefers-reduced-motion: reduce) { .cashpop { animation: none; opacity: .9; } }

#hud {
  position: absolute; top: 6px; left: 6px; right: 6px; pointer-events: none;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; justify-content: space-between;
}
#hudRow { display: flex; flex-wrap: wrap; gap: 4px; pointer-events: auto; }
.chip {
  background: var(--glass); border-radius: 10px; padding: 6px 8px; font-size: 13px;
  white-space: nowrap; font-variant-numeric: tabular-nums; min-height: 32px; display: inline-flex; align-items: center; gap: 3px;
}
.chip b { font-weight: 700; }
.chip.low b { color: var(--bad); }
#speedRow { display: flex; gap: 3px; pointer-events: auto; background: var(--glass); border-radius: 12px; padding: 2px; }
.spd { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; padding: 0 4px; }
.spd[data-speed="0"] { font-size: 18px; font-weight: 400; }
/* text on the amber is the dark ink, as on Play: the pale ink was 1.7:1 on it (the game-ui-colour standard asks 4.5) */
.spd.on { background: var(--hot); color: var(--hotInk); }
/* R2.2: folded, the row is the one button with the speed on it */
.spdNow { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: var(--hot); color: var(--hotInk); font-size: 15px; font-weight: 700; cursor: pointer; padding: 0 6px; }
.spdNow[data-speed="0"] { font-size: 18px; font-weight: 400; }
#speedRow.closed .spd { display: none; }
#speedRow:not(.closed) .spdNow { background: transparent; opacity: 0.8; }
#goalChip {
  flex-basis: 100%; pointer-events: auto; text-align: left; min-height: 44px;
  background: var(--glass); color: var(--ink); border: 0; border-radius: 10px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; max-width: 360px;
}
#goalChip .bar { display: inline-block; width: 54px; height: 7px; border-radius: 4px; background: var(--kBg10); vertical-align: middle; margin: 0 4px; overflow: hidden; }
#goalChip .bar i { display: block; height: 100%; background: var(--good); }

#viewBtns { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; }
/* A PHONE: the time buttons stand in a column on the right, under the money
   and guests, so the heads-up display is two short rows and not three. */
@media (max-width: 560px) {
  #hud { padding-right: 52px; }
  #speedRow { position: absolute; right: 0; top: 0; flex-direction: column; padding: 2px; }
  .chip { padding: 5px 6px; font-size: 12px; }
}
/* ON A PHONE, upright or on its side, the view buttons are a row above the
   toolbar (v1.7.0). A column met the five time buttons on a 667 px tall
   phone, and reached the toolbar on one 375 px tall on its side. */
@media (max-width: 560px), (max-height: 480px) {
  #viewBtns { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); transform: none; flex-direction: row; }
}
.vb { width: 46px; height: 46px; border: 0; border-radius: 12px; background: var(--glass); color: var(--ink); font-size: 18px; cursor: pointer; }

#tools {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 4px; overflow-x: auto; padding: 6px 6px calc(env(safe-area-inset-bottom, 0px) + 6px);
  background: linear-gradient(to top, var(--kBg11), var(--kBg12));
  scrollbar-width: none;
}
#tools::-webkit-scrollbar { display: none; }
.tool {
  flex: 0 0 auto; min-width: 62px; min-height: 56px; border: 0; border-radius: 12px;
  background: var(--kBg13); color: var(--ink); font-size: 11px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 6px;
}
.tool span { font-size: 22px; line-height: 1; }
.tool.on { background: var(--hot); color: var(--hotInk); }
/* R1.2: there is a next step; the Park panel says what it is */
.tool.hint { position: relative; }
.tool.hint::after { content: '💡'; position: absolute; top: -4px; right: -2px; font-size: 14px; }
.row.next { background: var(--kBg14); border-radius: 12px; padding: 6px 8px; }
.row.next .lbl { flex: 1 1 160px; }
.nameIn {
  flex: 1 1 140px; min-height: 44px; min-width: 0; border: 0; border-radius: 10px; padding: 0 10px;
  font: inherit; font-size: 16px; background: var(--kBg15); color: var(--kInk2);
}

#toast {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%);
  max-width: min(92%, 420px); background: var(--glass); border-radius: 12px; padding: 8px 12px;
  font-size: 14px; line-height: 1.35; opacity: 0; transition: opacity .3s ease; pointer-events: none; text-align: center;
}
#toast.on { opacity: 1; pointer-events: auto; cursor: pointer; }

#placeBar {
  position: absolute; left: 6px; right: 6px; bottom: calc(env(safe-area-inset-bottom, 0px) + 74px);
  background: var(--glass); border-radius: 14px; padding: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
#placeWhat { font-weight: 700; font-size: 14px; flex: 1 1 140px; }
#placeWhy { flex-basis: 100%; font-size: 13px; color: var(--hot); min-height: 0; order: 3; }
#placeWhy:empty { display: none; }
#placeBtns { display: flex; gap: 6px; }
.pb {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: var(--kBg2); color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer; padding: 0 12px;
}
.pb.go { background: var(--good); color: var(--kInk3); }
.pb.warn { background: var(--bad); color: var(--kInk4); }
.pb.on { background: var(--hot); color: var(--hotInk); }
.pb:disabled { opacity: .4; }

/* RIDING (R16.12): the building tools, signs and view buttons step aside;
   the money and guests stay, with a way off at the bottom. */
#rideBar {
  position: absolute; left: 6px; right: 6px; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: var(--glass); border-radius: 14px; padding: 8px; display: flex; align-items: center; gap: 8px;
}
#rideWhat { flex: 1 1 auto; display: flex; flex-direction: column; font-size: 13px; }
#rideWhat b { font-size: 15px; }
.riding #tools, .riding #viewBtns, .riding #signs, .riding #goalChip, .riding #placeBar, .riding #sheet { display: none; }

#sheet {
  position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
  max-height: 58%; display: flex; flex-direction: column;
  background: var(--kBg16); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, .3);
}
#sheetHead { display: flex; align-items: center; gap: 8px; padding: 8px 8px 4px 12px; }
#sheetTitle { flex: 1; font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sheetBody { overflow-y: auto; padding: 4px 10px 12px; overscroll-behavior: contain; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.card2 {
  min-height: 84px; border: 1px solid var(--line); border-radius: 12px; background: var(--kBg17); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px;
  cursor: pointer; font-size: 12px; text-align: center;
}
.card2 .em { font-size: 28px; line-height: 1.1; }
.card2 .cost { color: var(--hot); font-weight: 700; font-variant-numeric: tabular-nums; }
.card2.locked { opacity: .45; }
.card2.sel { border-color: var(--hot); background: var(--kBg18); }
.row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.row .lbl { flex: 1 1 120px; font-size: 14px; }
.meter { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 5px 0; }
.meter .name { width: 88px; color: var(--dim); }
.meter .bar { flex: 1; height: 10px; border-radius: 5px; background: var(--kBg10); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 5px; }
.meter .val { width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.thought { font-size: 14px; margin: 4px 0; }
.small { font-size: 12px; color: var(--dim); line-height: 1.4; }
.pillrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.tag.open { background: var(--good); color: var(--kInk3); }
.tag.shut { background: var(--kBg19); color: var(--kInk4); }
.tag.broken { background: var(--bad); color: var(--kInk4); }
.tag.building { background: var(--hot); color: var(--hotInk); }
.news { font-size: 13px; margin: 6px 0; line-height: 1.35; cursor: pointer; }
.fin { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin: 6px 0; }
.fin i { flex: 1; display: block; border-radius: 3px 3px 0 0; min-height: 2px; }

/* the coaster builder: big arrows a thumb can find */
.bgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0; }
.bbtn {
  min-height: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--kBg17); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.bbtn b { font-size: 22px; }
.bbtn.on { background: var(--hot); color: var(--hotInk); border-color: var(--kLine2); }
.bbtn:disabled { opacity: .35; }

/* R-C15a: an overlay is a SCROLL REGION, not a centring box */
.ovl {
  position: absolute; inset: 0; display: none;
  align-items: flex-start; justify-content: center; overflow-y: auto;
  background: var(--kBg20); padding: 16px; overscroll-behavior: contain; z-index: 5;
}
.ovl.on { display: flex; }
.ovlCard {
  width: 100%; max-width: 340px; margin: auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 16px; text-align: center;
}
.ovlCard h2 { margin: 4px 0 8px; font-size: 20px; }
.ovlCard p { color: var(--dim); font-size: 14px; line-height: 1.45; }

.card {
  background: var(--kBg4); border: 1px solid var(--kLine1); border-radius: 14px;
  padding: 12px; margin-bottom: 10px; font-size: 14px; line-height: 1.5; color: var(--dim);
}
.card h2 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }

footer { padding: 6px 10px calc(env(safe-area-inset-bottom, 0px) + 6px); text-align: center; }
.toast-host { position: fixed; left: 0; right: 0; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
