/* Polytopia — base theme & shell */
:root {
  --bg0: #0b0e14;
  --bg1: #11141d;
  --bg2: #181c28;
  --bg3: #202537;
  --line: #2a3046;
  --tx0: #eef1f8;
  --tx1: #b9c0d4;
  --tx2: #7d86a0;
  --acc: #62b6f0;
  --acc2: #f0a35e;
  --good: #8fd18a;
  --bad: #ef7f8a;
  --gold: #e8d477;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overscroll-behavior: none; }
/* pan-x pan-y (not `none`): allows any future scroll containers while REFUSING
   the browser's own pinch-zoom gesture — the second zoom layer that could scale
   the whole UI out from under the exhibits' pinch handlers on iPad. Elements
   with their own touch-action (canvas: none) still win locally. */
html { touch-action: pan-x pan-y; }
/* kill iOS double-tap zoom on controls while keeping fast taps */
button, select, input, label, a, nav { touch-action: manipulation; }
/* game surfaces own their gestures completely: no scroll, no callout, no selection */
canvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lp-pulse { animation: lp-pulse .22s ease-out; }
@keyframes lp-pulse { 0% { filter: brightness(1); } 40% { filter: brightness(1.6); } 100% { filter: brightness(1); } }
body {
  background: radial-gradient(1200px 700px at 70% -10%, #1a2030 0%, var(--bg0) 55%);
  color: var(--tx0);
  font: 15px/1.45 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}
button, select, input {
  font: inherit; color: var(--tx0);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
button { cursor: pointer; transition: background .15s, border-color .15s, transform .05s; }
button:hover { background: var(--bg3); border-color: #3a4260; }
button:active { transform: translateY(1px); }
button.on { background: #24406030; border-color: var(--acc); color: #cfe8ff; box-shadow: 0 0 0 1px #62b6f033 inset; }
button:disabled { opacity: .35; cursor: default; }
select { cursor: pointer; }
input[type="range"] { accent-color: var(--acc); padding: 0; height: 26px; }
input[type="search"] { background: var(--bg1); }

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 18px;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(16px + env(safe-area-inset-right, 0px)) 0 calc(16px + env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, #141826f2, #10131df2);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
#logo { font-size: 17px; letter-spacing: 1px; color: var(--tx0); white-space: nowrap; }
#logo b { color: var(--acc); font-weight: 700; }
.logo-sub { color: var(--tx2); font-size: 11.5px; letter-spacing: 2px; text-transform: uppercase; margin-left: 6px; }
#topbar nav { display: flex; gap: 6px; flex: 1; }
/* position:relative so the .nav-dot ::after has an anchor box */
#topbar nav button { background: transparent; border-color: transparent; color: var(--tx1); padding: 7px 14px; position: relative; }
#topbar nav button:hover { background: var(--bg2); }
#topbar nav button.on { background: var(--bg3); border-color: var(--line); color: var(--tx0); }
/* a quiet gold dot meaning "something in here is new and you haven't opened it";
   wonders.js toggles the class, and it clears itself as exhibits get visited */
#topbar nav button.nav-dot::after {
  content: ''; position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 6px var(--gold);
}
#btn-mute { background: transparent; border-color: transparent; font-size: 17px; }
#sound-panel {
  position: fixed; top: calc(50px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 60;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 12px 30px #0009;
}
#sound-panel.hidden { display: none; }
#sound-panel label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--tx1); }
#sound-panel input[type="range"] { width: 130px; }

main { height: calc(100% - 52px - env(safe-area-inset-top, 0px)); position: relative; }

/* ---- touch ergonomics: finger-first sizing on coarse pointers ---- */
@media (pointer: coarse) {
  button, select { min-height: 44px; padding: 9px 14px; }
  #topbar nav button { padding: 9px 16px; }
  input[type="range"] { height: 44px; }
  input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; }
  .wx-controls { gap: 12px; }
  .wx-wingtab { min-height: 44px; }
  main { padding-bottom: env(safe-area-inset-bottom, 0px); }
}
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* toasts */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1c2233ee; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 20px; opacity: 0; transition: all .35s; z-index: 100;
  box-shadow: 0 10px 30px #0009; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: var(--bad); }
.toast.egg { border-color: var(--gold); background: #2a2410ee; font-size: 16px; }

/* splash */
#splash {
  position: fixed; inset: 0; z-index: 50; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 600px at 50% 35%, #1c2438, var(--bg0) 70%);
  transition: opacity .6s;
}
#splash.gone { opacity: 0; pointer-events: none; }
#splash-core { text-align: center; }
#splash-mark { font-size: 84px; color: var(--acc); text-shadow: 0 0 60px #62b6f088; animation: spin-mark 14s linear infinite; display: inline-block; }
@keyframes spin-mark { to { transform: rotateY(360deg) rotateZ(360deg); } }
#splash h1 { letter-spacing: 10px; font-size: 42px; margin-top: 8px; }
#splash .tag { color: var(--tx2); letter-spacing: 4px; text-transform: uppercase; font-size: 12px; margin-top: 6px; }
#splash-daily { margin: 26px auto 0; padding: 14px 22px; border: 1px solid var(--line); border-radius: 14px; background: #161b2a; max-width: 460px; }
#splash-daily .sd-label { display: block; color: var(--tx2); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
#splash-daily b { font-size: 17px; }
#splash-daily .sd-fact { display: block; color: var(--tx1); font-size: 13px; margin-top: 4px; }
#splash .enter { margin-top: 34px; color: var(--tx2); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* shared tool panels */
.tool-sec { color: var(--tx2); font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; margin: 14px 0 6px; }
.tool-sec:first-child { margin-top: 0; }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tool-row.center { justify-content: center; }
.tool-row button { flex: 1 1 auto; font-size: 13px; padding: 6px 8px; }
.tool-hint { color: var(--tx2); font-size: 12px; margin-top: 14px; line-height: 1.5; }
.tool-hint.big { font-size: 14px; color: var(--gold); min-height: 40px; margin-top: 6px; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12.5px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  color: var(--tx0); margin: 2px 2px 2px 0;
}
.hidden { display: none !important; }
