/* Shared UI kit for both games. Each game sets the theme variables in its own index.html. */
:root {
  --z: 1;   /* tablets and desktops scale the whole interface up. core.js sets this. */
  --sat: calc(max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px)) / var(--z));
  --sab: calc(max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px)) / var(--z));
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--ink); overscroll-behavior: none; }
body {
  font-family: var(--font-t); font-weight: 500; color: var(--text);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
}
canvas#c { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
#safeProbe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding-top: var(--sat); padding-bottom: var(--sab); }

/* ---------- layers ---------- */
#hud { position: fixed; left: 0; top: 0; width: calc(100% / var(--z)); height: calc(100% / var(--z)); transform: scale(var(--z)); transform-origin: 0 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar { position: absolute; left: 12px; right: 12px; top: calc(var(--sat) + 10px); display: flex; align-items: center; gap: 8px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
#topbar .spacer { flex: 1; pointer-events: none; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px 0 8px; border: 0;
  border-radius: 19px; background: rgba(10, 6, 30, 0.55); color: #fff; font-family: var(--font-d); font-size: 16px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}
.pill svg { width: 24px; height: 24px; flex: none; }
.pill .plus { margin-left: 2px; width: 20px; height: 20px; border-radius: 10px; background: var(--go); color: #05240f;
  display: grid; place-items: center; font-size: 15px; line-height: 1; }
.pill.bump { animation: bump 0.32s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }
.iconbtn {
  width: 40px; height: 40px; border: 0; border-radius: 14px; background: rgba(10, 6, 30, 0.55); color: #fff;
  display: grid; place-items: center; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}
.iconbtn svg { width: 22px; height: 22px; }
.getapp { height: 38px; padding: 0 14px; border: 0; border-radius: 19px; background: var(--gold); color: #1d1400;
  font-family: var(--font-d); font-size: 14px; box-shadow: 0 3px 0 var(--gold-d); }

/* ---------- dock ---------- */
#dock { position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 16px); display: flex; justify-content: center; gap: 9px; padding: 0 10px; pointer-events: none; }
.dockbtn {
  position: relative; pointer-events: auto; flex: 0 1 68px; min-width: 0; height: 64px; border: 0; border-radius: 18px;
  background: var(--slab); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--font-t); font-weight: 600; font-size: 11.5px; letter-spacing: 0.1px;
  box-shadow: inset 0 0 0 2px var(--edge), 0 5px 0 rgba(0, 0, 0, 0.3);
}
.dockbtn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--edge), 0 2px 0 rgba(0, 0, 0, 0.3); }
.dockbtn svg { width: 26px; height: 26px; }
.dockbtn .badge {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--red); color: #fff; font-family: var(--font-d); font-size: 12px; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--ink);
}
.dockbtn .badge.fire { background: var(--gold); color: #2a1a00; }

/* ---------- buttons ---------- */
.btn {
  --bg: var(--gold); --lip: var(--gold-d); --fg: #221700;
  display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 52px; padding: 10px 16px;
  border: 0; border-radius: 17px; background: var(--bg); color: var(--fg); font-family: var(--font-d); font-size: 17px; line-height: 1.1;
  box-shadow: 0 5px 0 var(--lip), 0 10px 16px rgba(0, 0, 0, 0.25); transition: transform 0.05s, box-shadow 0.05s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--lip), 0 3px 6px rgba(0, 0, 0, 0.25); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.go { --bg: var(--go); --lip: var(--go-d); --fg: #04260f; }
.btn.blue { --bg: var(--blue); --lip: var(--blue-d); --fg: #04163a; }
.btn.quiet { --bg: rgba(255, 255, 255, 0.11); --lip: rgba(0, 0, 0, 0.28); --fg: #fff; box-shadow: 0 4px 0 var(--lip); min-height: 46px; font-size: 15px; }
.btn.small { min-height: 40px; font-size: 14px; border-radius: 13px; padding: 6px 12px; width: auto; box-shadow: 0 4px 0 var(--lip); }
.btn[disabled] { filter: saturate(0.25) brightness(0.75); pointer-events: none; }
.btn .sub { font-family: var(--font-t); font-weight: 600; font-size: 12px; opacity: 0.8; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 11px; }
.linkbtn { background: none; border: 0; color: var(--mute); font-family: var(--font-t); font-weight: 600; font-size: 14px; padding: 10px; width: 100%; }

/* ---------- sheets (modal panels) ---------- */
#scrim { position: absolute; inset: 0; background: rgba(8, 4, 24, 0.66); display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sat) + 12px) 14px calc(var(--sab) + 12px); }
.sheet {
  position: relative; width: min(100%, 384px); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--slab); border: 3px solid var(--edge); border-radius: 28px; padding: 22px 18px 18px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.3); text-align: center; animation: pop 0.16s cubic-bezier(0.2, 1.3, 0.5, 1);
  touch-action: pan-y;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sheet h2 { font-family: var(--font-d); font-weight: 400; font-size: 24px; line-height: 1.15; color: #fff; }
.sheet h2.gold { color: var(--gold); } .sheet h2.red { color: var(--red); } .sheet h2.green { color: var(--go); }
.sheet p { color: var(--mute); font-size: 14.5px; line-height: 1.4; margin-top: 6px; }
.sheet .close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.1); color: #fff; display: grid; place-items: center; }
.sheet .close svg { width: 18px; height: 18px; }
.bignum { font-family: var(--font-d); font-size: 64px; line-height: 1; color: #fff; margin-top: 6px; }
.meta { display: flex; justify-content: center; gap: 14px; margin-top: 8px; font-weight: 600; font-size: 14.5px; color: var(--mute); }
.meta b { color: #fff; font-family: var(--font-d); font-weight: 400; }
.meta .coin { display: inline-flex; align-items: center; gap: 5px; color: var(--gold); }
.meta svg { width: 18px; height: 18px; }
.note { margin-top: 10px; font-weight: 600; font-size: 14px; color: var(--gold); }
.note.green { color: var(--go); }

/* progress */
.goal { margin-top: 14px; padding: 11px 12px; border-radius: 16px; background: rgba(0, 0, 0, 0.22); text-align: left; }
.goal .top { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 13.5px; color: #fff; }
.goal .top span:last-child { color: var(--mute); }
.bar { margin-top: 8px; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--gold); transition: width 0.5s ease-out; }
.bar.green i { background: var(--go); }

/* ring countdown */
.ring { width: 96px; height: 96px; margin: 14px auto 4px; position: relative; }
.ring svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.ring .n { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-d); font-size: 38px; color: #fff; }

/* tabs */
.tabs { display: flex; gap: 6px; margin: 14px 0 10px; padding: 4px; border-radius: 15px; background: rgba(0, 0, 0, 0.25); }
.tab { flex: 1; height: 36px; border: 0; border-radius: 11px; background: none; color: var(--mute); font-family: var(--font-d); font-size: 13.5px; }
.tab.on { background: var(--gold); color: #221700; }

/* lists */
.list { list-style: none; text-align: left; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 13px; font-weight: 600; font-size: 15px; }
.list li:nth-child(odd) { background: rgba(255, 255, 255, 0.05); }
.list li.me { box-shadow: inset 0 0 0 2px var(--gold); background: rgba(255, 196, 46, 0.1); }
.list .rk { width: 26px; text-align: right; color: var(--mute); font-family: var(--font-d); font-size: 14px; }
.list .fl { width: 24px; text-align: center; }
.list .nm { flex: 1; font-family: var(--font-d); letter-spacing: 2px; }
.list .sc { color: var(--gold); font-family: var(--font-d); }
.empty { padding: 22px 6px; color: var(--mute); font-size: 14.5px; line-height: 1.4; }

/* inputs */
.field { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; font-weight: 600; font-size: 14px; color: var(--mute); }
.field input {
  width: 96px; height: 46px; border-radius: 13px; border: 2px solid var(--edge); background: rgba(0, 0, 0, 0.3); color: #fff;
  font-family: var(--font-d); font-size: 20px; letter-spacing: 5px; text-align: center; text-transform: uppercase; outline: none;
  -webkit-user-select: text; user-select: text;
}
.field input.wide { width: 190px; letter-spacing: 8px; }
.field input:focus { border-color: var(--gold); }

/* shop */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 4px; }
.skin { position: relative; border: 0; border-radius: 16px; padding: 8px 6px 9px; background: rgba(0, 0, 0, 0.24); color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08); }
.skin.on { box-shadow: inset 0 0 0 3px var(--gold); }
.skin canvas { width: 100%; aspect-ratio: 1 / 0.82; border-radius: 10px; display: block; }
.skin .nm { margin-top: 6px; font-family: var(--font-d); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skin .pr { margin-top: 3px; display: flex; align-items: center; justify-content: center; gap: 4px; font-weight: 600; font-size: 12.5px; color: var(--gold); min-height: 18px; }
.skin .pr svg { width: 14px; height: 14px; }
.skin .pr.own { color: var(--go); } .skin .pr.lock { color: var(--mute); }
.offer { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; border-radius: 18px; background: rgba(0, 0, 0, 0.24); margin-top: 10px; }
.offer .ic { width: 46px; height: 46px; flex: none; border-radius: 14px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.08); }
.offer .ic svg { width: 28px; height: 28px; }
.offer .tx { flex: 1; min-width: 0; }
.offer .tx b { display: block; font-family: var(--font-d); font-weight: 400; font-size: 15px; color: #fff; }
.offer .tx span { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.3; color: var(--mute); }
.offer.hero { background: linear-gradient(135deg, rgba(255, 196, 46, 0.22), rgba(255, 196, 46, 0.06)); box-shadow: inset 0 0 0 2px rgba(255, 196, 46, 0.5); }

/* daily calendar */
.days { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.day { border-radius: 14px; padding: 8px 4px; background: rgba(0, 0, 0, 0.24); font-weight: 600; font-size: 12px; color: var(--mute); }
.day b { display: block; margin-top: 4px; font-family: var(--font-d); font-weight: 400; font-size: 15px; color: #fff; }
.day svg { width: 22px; height: 22px; margin-top: 4px; }
.day.done { opacity: 0.45; }
.day.now { background: rgba(255, 196, 46, 0.18); box-shadow: inset 0 0 0 2px var(--gold); color: var(--gold); }
.day.big { grid-column: span 2; }

/* missions */
.mission { display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px; border-radius: 16px; background: rgba(0, 0, 0, 0.24); margin-top: 9px; }
.mission .tx { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; color: #fff; }
.mission .tx .bar { height: 9px; margin-top: 7px; }
.mission .tx small { display: block; margin-top: 5px; font-size: 12px; color: var(--mute); font-weight: 600; }
.mission.done .tx { color: var(--go); }
.mission .rw { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-d); font-size: 14px; color: var(--gold); }
.mission .rw svg { width: 16px; height: 16px; }

/* settings */
.set { display: flex; align-items: center; justify-content: space-between; padding: 12px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-weight: 600; font-size: 15px; color: #fff; text-align: left; }
.set:last-of-type { border-bottom: 0; }
.switch { width: 54px; height: 32px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, 0.16); position: relative; transition: background 0.15s; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform 0.15s; }
.switch.on { background: var(--go); }
.switch.on::after { transform: translateX(22px); }
.fine { margin-top: 12px; font-size: 12px; color: var(--mute); line-height: 1.45; }
.fine a { color: var(--mute); }

/* promo */
.promo { display: flex; align-items: center; gap: 11px; margin-top: 12px; padding: 9px 11px; border: 0; width: 100%; border-radius: 16px; background: rgba(0, 0, 0, 0.24); color: #fff; text-align: left; }
.promo img { width: 42px; height: 42px; border-radius: 11px; flex: none; }
.promo b { display: block; font-family: var(--font-d); font-weight: 400; font-size: 14px; }
.promo span { display: block; font-size: 12px; color: var(--mute); font-weight: 600; }
.promo .go { margin-left: auto; font-family: var(--font-d); font-size: 13px; color: var(--gold); }

/* toast + curtain */
#toast {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 104px); transform: translate(-50%, 16px); max-width: calc(86vw / var(--z));
  padding: 11px 16px; border-radius: 15px; background: rgba(10, 6, 30, 0.92); color: #fff; font-weight: 600; font-size: 14px; text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14); opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none !important; z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#curtain { position: absolute; inset: 0; z-index: 60; background: rgba(8, 4, 24, 0.82); display: grid; place-items: center; font-family: var(--font-d); font-size: 18px; color: #fff; }
.fly { position: absolute; z-index: 50; width: 22px; height: 22px; pointer-events: none !important; transition: transform 0.55s cubic-bezier(0.5, -0.2, 0.7, 1), opacity 0.55s; }
.fly svg { width: 22px; height: 22px; }

@media (max-height: 640px) {
  .bignum { font-size: 50px; }
  .btn { min-height: 46px; }
  .sheet { padding: 18px 16px 14px; }
}
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .pill.bump { animation: none; } }

/* in-app document (privacy policy) and small helper lines */
.doc { display: block; width: 100%; height: calc(62vh / var(--z)); border: 0; border-radius: 14px; background: #fff; margin-top: 26px; }
.hintline { margin: 10px 2px 0; font-size: 13px; color: var(--mute); text-align: left; }
