:root {
  --bg: #0b0d0a;
  --panel: rgba(16, 18, 15, 0.92);
  --panel2: rgba(30, 33, 28, 0.95);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8e4d8;
  --dim: #a9a594;
  --accent: #c8402e;
  --good: #7fb069;
  --warn: #e0a83a;
  --bad: #d9534f;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  /* The text size setting (main.js comfort), and the scale each font size uses (--ts). */
  --text-scale: 1;
  --ts: 1;
}
/* Text in the menus, messages and labels grows with the setting; the big round buttons don't. */
#menu, #toasts, #hint, #note, #ctxmenu, #progress, #death, #create, #topbar, #carhud, #downed, #buildbar, #map-bar, #map-pick,
#partners, #pauseveil, #sleepveil, #join, #signals, #watchbar { --ts: var(--text-scale); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Our own icons (client/icons.js), sized like the emoji they stand in for. The emoji stays in
   the text, hidden, for screen readers. */
.icw { display: inline-block; position: relative; line-height: 0; vertical-align: -0.2em; }
.ic { width: 1.2em; height: 1.2em; overflow: visible; }
.ic-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ------------------------------------------------------------ HUD */

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud #ctxmenu, #hud canvas { pointer-events: auto; }

#vignette {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(170, 0, 0, 0.75) 100%);
  transition: opacity 0.4s;
}
/* Hurt: stains at the edges (the picture is drawn by ui.js), beating with the heart below 25. */
#bloodedge, #panicedge { position: absolute; inset: 0; opacity: 0; transition: opacity 0.8s; pointer-events: none; }
#bloodedge { background-size: 100% 100%; }
#bloodedge.beat { animation: bloodbeat 1.1s infinite; }
@keyframes bloodbeat { 0%, 100% { transform: scale(1); } 10% { transform: scale(0.985); } 22% { transform: scale(1); } 32% { transform: scale(0.99); } }
#panicedge { background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.85) 100%); }

#sleepveil {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 10, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(22px * var(--ts));
  gap: 6px;
}
#sleepveil small { color: var(--dim); font-size: calc(14px * var(--ts)); }

#topbar {
  position: absolute;
  top: calc(6px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.45);
  border-radius: 14px;
  padding: 4px 12px;
  font-size: calc(14px * var(--ts));
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}
#weather { margin-left: 8px; opacity: 0.9; }
#tab-health .wear { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: calc(14px * var(--ts)); }
#tab-health .wear .wslot { width: 62px; flex: none; color: var(--dim); font-size: calc(13px * var(--ts)); }
#tab-health .wear .none { color: var(--dim); }
#clock-ff { color: var(--warn); font-weight: 700; }

#status {
  position: absolute;
  top: calc(8px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#hpbar {
  width: 120px;
  height: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
#hpfill { height: 100%; width: 100%; background: var(--good); transition: width 0.3s, background 0.3s; }
#moodles { display: flex; flex-wrap: wrap; gap: 4px; max-width: 170px; pointer-events: auto; }
.moodle {
  position: relative;
  width: 30px;
  height: 32px;
  padding-bottom: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--emoji);
  font-size: calc(17px * var(--ts));
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #f0e442;
}
/* Tap a moodle: what it means and what fixes it (client/cures.js). */
#moodle-pop {
  --ts: var(--text-scale);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 260px;
  padding: 6px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  pointer-events: auto;
  z-index: 6;
}
#moodle-pop .tip { padding: 2px 4px; font-size: calc(13px * var(--ts)); color: var(--dim); }
#moodle-pop button { padding: 9px 12px; border-radius: 10px; background: var(--panel2); text-align: left; font-size: calc(14px * var(--ts)); font-weight: 600; }
#moodle-pop button:active { background: rgba(224, 168, 58, 0.5); }
/* How bad it is shows in the colour (Okabe-Ito: yellow, orange, vermilion) and in the marks. */
.moodle.l2 { border-color: #e69f00; }
.moodle.lgood { border-color: var(--good); }
.moodle.lgood::after { display: none; }
.moodle.l3 { border-color: #d55e00; animation: pulse 1s infinite; }
.moodle::after { content: ''; position: absolute; bottom: 2px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: #fff; }
.moodle.l2::after { background: transparent; box-shadow: -3px 0 0 #fff, 3px 0 0 #fff; }
.moodle.l3::after { box-shadow: -5px 0 0 #fff, 5px 0 0 #fff; }
@keyframes pulse { 50% { transform: scale(1.12); } }

#partners { display: flex; flex-direction: column; gap: 4px; }
.partner {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: calc(12px * var(--ts));
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 2px 6px 2px 4px;
  width: max-content;
  border: 1px solid transparent;
}
.partner .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; }
.partner .hp { width: 44px; height: 5px; background: rgba(255, 255, 255, 0.15); border-radius: 3px; overflow: hidden; }
.partner .hp div { height: 100%; }
.partner .ico { font-family: var(--emoji); font-size: calc(13px * var(--ts)); }
.partner.alert { border-color: var(--bad); animation: pulse 1s infinite; }
.partner.gone { color: var(--dim); }

#topright {
  position: absolute;
  top: calc(8px + var(--safe-t));
  right: calc(10px + var(--safe-r));
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
#minimap {
  width: 92px;
  height: 92px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: #0b0d0a;
  touch-action: none;
}
#btn-shout {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  font-family: var(--emoji);
  font-size: calc(20px * var(--ts));
}
#btn-shout:active { transform: scale(0.94); background: rgba(224, 168, 58, 0.6); }
/* 📢: shout, or a quiet signal for your partner (server/closer.js). Under the button. */
#signals {
  position: absolute;
  top: calc(58px + var(--safe-t));
  right: calc(110px + var(--safe-r));
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
#signals button { padding: 9px 14px; border-radius: 10px; background: var(--panel2); text-align: left; font-size: calc(15px * var(--ts)); font-weight: 600; white-space: nowrap; }
#signals button:active { background: rgba(224, 168, 58, 0.5); }
#signals small { display: block; font-size: calc(11px * var(--ts)); font-weight: 400; color: var(--dim); }
/* Dead: no controls, a bar saying whose eyes you see through (ui.js updateWatch). */
#hud.watching #controls, #hud.watching #joy-base, #hud.watching #btn-shout, #hud.watching #signals,
#hud.watching #hpbar, #hud.watching #moodles, #hud.watching #moodle-pop, #hud.watching #loot, #hud.watching #progress { display: none !important; }
#watchbar {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 14px;
  background: rgba(20, 8, 8, 0.82);
  border: 1px solid rgba(224, 90, 70, 0.5);
  font-size: calc(14px * var(--ts));
}
#watchbar button { flex: none; padding: 9px 14px; border-radius: 10px; background: var(--panel2); font-size: calc(14px * var(--ts)); font-weight: 600; }
#watch-start { background: var(--accent) !important; color: #fff; }

#downed {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(46vw, 420px);
  background: rgba(60, 0, 0, 0.8);
  border: 2px solid var(--bad);
  border-radius: 14px;
  padding: 10px 16px;
  text-align: center;
  font-size: calc(17px * var(--ts));
  font-weight: 700;
}
/* Only the words pulse: the Give up button stays still under your thumb. */
#downed-text { animation: pulse 1.2s infinite; }
#downed small { display: block; font-size: calc(13px * var(--ts)); font-weight: 400; color: #ffcfc8; margin-top: 3px; }

/* Fills while a finger is held still, then the ping is sent. */
#hold-ring {
  position: absolute;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffe9a8;
  animation: hold 0.35s linear forwards;
}
@keyframes hold { from { transform: rotate(0) scale(0.6); } to { transform: rotate(360deg) scale(1); border-color: #ffe9a8; } }

#toasts {
  position: absolute;
  top: calc(40px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(70vw, 460px);
}
.toast {
  background: rgba(0, 0, 0, 0.7);
  border-radius: 10px;
  padding: 5px 12px;
  font-size: calc(14px * var(--ts));
  text-align: center;
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.5s;
}
.toast.bad, .toast.hurt { color: #ffb3a8; border: 1px solid rgba(217, 83, 79, 0.6); }
.toast.good { color: #d4f0c0; border: 1px solid rgba(127, 176, 105, 0.6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

#joy-base {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.4);
}
#joy-base.run #joy-knob { background: rgba(224, 168, 58, 0.55); }
/* Stamina round the stick (client/main.js sets --en, 0-100): it empties as you run and swing. */
#joy-base::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(var(--stam, #7fb069) calc(var(--en, 100) * 1%), rgba(255, 255, 255, 0.1) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
}
#joy-base.run.winded #joy-knob { background: rgba(217, 83, 79, 0.6); }

#progress {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  text-align: center;
  font-size: calc(13px * var(--ts));
  text-shadow: 0 1px 2px #000;
}
#progress-bar { width: 120px; height: 6px; background: rgba(0, 0, 0, 0.6); border-radius: 3px; overflow: hidden; margin-top: 3px; }
#progress-fill { height: 100%; width: 0; background: var(--warn); }

/* In a car: the gas gauge, a brake instead of the weapon, and no sneaking. */
/* Phase 17: what's on the TV or the radio, under the clock (client/ui.js showAir). Messages move down under it. */
#airbar {
  position: absolute;
  left: 50%;
  top: calc(44px + var(--safe-t));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(calc(100vw - 340px), 560px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border-radius: 12px;
  background: rgba(10, 12, 14, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: calc(13px * var(--ts));
  line-height: 1.3;
  transition: opacity 0.8s;
}
#airbar:not(.hidden) ~ #toasts { top: calc(104px + var(--safe-t)); }
#airbar .air-words { display: flex; flex-direction: column; min-width: 0; }
#airbar.fade { opacity: 0.45; }
#air-st { color: var(--warn); font-weight: 700; font-size: calc(11px * var(--ts)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#air-text { font-style: italic; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#airbar button { flex: none; min-height: 30px; padding: 2px 9px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); }
#airbar:not(.ctl) button { display: none; }
#tab-diary .diary-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
#tab-diary .diary-tabs button { padding: 6px 12px; border-radius: 10px; background: var(--panel2); display: inline-flex; align-items: center; gap: 6px; }
#tab-diary .diary-tabs button.on { background: var(--accent); color: #fff; }
#tab-diary .diary-tabs .dot { width: 10px; height: 10px; border-radius: 50%; }
#tab-diary .day { padding: 6px 2px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
#tab-diary .day h4 { margin: 0 0 4px; color: var(--warn); font-size: calc(14px * var(--ts)); }
#tab-diary .day p { margin: 3px 0; font-family: Georgia, 'Times New Roman', serif; font-size: calc(15px * var(--ts)); line-height: 1.4; }

#carhud {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 14px;
  background: rgba(10, 12, 10, 0.6);
  font-size: calc(13px * var(--ts));
  text-shadow: 0 1px 2px #000;
}
/* On a bicycle (Phase 23) there's no fuel to show. */
#carhud.pedal #carfuel, #carhud.pedal .fuelico { display: none; }
#carfuel { width: 70px; height: 7px; background: rgba(0, 0, 0, 0.6); border-radius: 4px; overflow: hidden; }
#carfuel-fill { height: 100%; width: 0; background: var(--good); }
#carfuel-fill.low { background: var(--bad); }
#car-cond { opacity: 0.85; font-size: calc(12px * var(--ts)); }
body.in-car #btn-sneak, body.in-car #btn-reload { display: none !important; }

#controls {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(12px + var(--safe-b));
  width: 230px;
  height: 230px;
}
#btn-attack {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(200, 64, 46, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#btn-attack .ico { font-family: var(--emoji); font-size: calc(34px * var(--ts)); line-height: 1; }
#btn-attack .sub { font-size: calc(11px * var(--ts)); margin-top: 2px; font-variant-numeric: tabular-nums; }
#btn-attack.held { background: rgba(230, 80, 60, 0.8); transform: scale(0.95); }

#act-row {
  position: absolute;
  right: 100px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-direction: row-reverse;
}
#btn-act {
  min-width: 78px;
  max-width: 132px;
  height: 66px;
  border-radius: 16px;
  background: rgba(40, 90, 120, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
}
#btn-act .ico { font-family: var(--emoji); font-size: calc(24px * var(--ts)); line-height: 1.1; }
#btn-act .lbl { font-size: calc(11px * var(--ts)); line-height: 1.15; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#btn-act:active { transform: scale(0.95); }
#btn-more {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-size: calc(20px * var(--ts));
  line-height: 1;
}

/* Quick slots: up to three things to use with one tap (ui.js renderQuick). */
#quick {
  position: absolute;
  right: 0;
  bottom: 162px;
  display: flex;
  gap: 8px;
  flex-direction: row-reverse;
}
#quick .qslot {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  font-size: 22px;
}
#quick .qslot.on { background: rgba(224, 168, 58, 0.6); border-color: rgba(255, 230, 160, 0.8); }
#quick .qslot.empty { opacity: 0.45; }
#quick .n { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
body.in-car #quick { display: none; }

/* Big buttons: the controls a fifth bigger. */
body.big-buttons #controls { transform: scale(1.2); transform-origin: bottom right; }
/* Left-handed: the controls on the left, the stick on the right (input.js). */
body.lefty #controls { right: auto; left: calc(12px + var(--safe-l)); }
body.lefty.big-buttons #controls { transform-origin: bottom left; }
body.lefty #btn-attack { right: auto; left: 0; }
body.lefty #act-row { right: auto; left: 100px; flex-direction: row; }
body.lefty #smallbtns, body.lefty #quick { right: auto; left: 0; flex-direction: row; }
body.lefty #ctxmenu { right: auto; left: calc(110px + var(--safe-l)); }

#smallbtns {
  position: absolute;
  right: 0;
  bottom: 104px;
  display: flex;
  gap: 8px;
  flex-direction: row-reverse;
}
#smallbtns button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.25);
  font-family: var(--emoji);
  font-size: calc(22px * var(--ts));
}
#smallbtns button.on { background: rgba(224, 168, 58, 0.6); border-color: rgba(255, 230, 160, 0.8); }
#smallbtns #btn-shove { background: rgba(160, 50, 40, 0.6); border-color: rgba(255, 180, 160, 0.5); }
#smallbtns #btn-shove.on { background: rgba(230, 80, 60, 0.85); }

#ctxmenu {
  position: absolute;
  right: calc(110px + var(--safe-r));
  bottom: calc(96px + var(--safe-b));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  max-height: 70vh;
  overflow-y: auto;
}
#ctxmenu button {
  text-align: left;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  font-size: calc(15px * var(--ts));
}
#ctxmenu button .ico { font-family: var(--emoji); margin-right: 8px; }

/* The loot strip (client/loot.js): what you found, beside the buttons, the world still in view. */
#loot {
  position: absolute;
  left: calc(10px + var(--safe-l));
  right: calc(252px + var(--safe-r));
  bottom: calc(10px + var(--safe-b));
  max-width: 600px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px 6px 6px;
  --ts: var(--text-scale);
}
body.big-buttons #loot { right: calc(298px + var(--safe-r)); }
body.lefty #loot { left: auto; right: calc(10px + var(--safe-r)); width: calc(100% - 262px - var(--safe-l) - var(--safe-r)); }
body.lefty.big-buttons #loot { width: calc(100% - 308px - var(--safe-l) - var(--safe-r)); }
.loot-head { display: flex; align-items: center; gap: 8px; padding: 0 2px 4px; font-size: calc(13px * var(--ts)); min-width: 0; }
.loot-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#loot-w { color: var(--dim); white-space: nowrap; margin-right: auto; font-size: calc(12px * var(--ts)); }
.loot-head button { padding: 4px 10px; min-height: 30px; border-radius: 8px; background: var(--panel2); white-space: nowrap; font-size: calc(13px * var(--ts)); }
#loot-close { min-width: 34px; }
#loot-room small { color: var(--dim); font-size: 0.85em; }
/* What we have (ui.js stockHTML): by kind, with where each thing is. */
.stock-kind { padding: 8px 6px 3px; font-size: calc(12px * var(--ts)); color: var(--warn); font-weight: 600; letter-spacing: 0.02em; }
.row.stock { cursor: default; }
.row.stock .name small { display: block; color: var(--dim); font-size: calc(11px * var(--ts)); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#put-away { background: rgba(127, 176, 105, 0.45); }
#put-away + #inv-sort { margin-left: 6px; }
.loot-body { display: flex; gap: 6px; align-items: stretch; }
#loot-tiles { flex: 1; min-width: 0; display: flex; gap: 5px; overflow-x: auto; overscroll-behavior: contain; scrollbar-width: none; }
#loot-tiles::-webkit-scrollbar { display: none; }
#loot-tiles .empty { align-self: center; color: var(--dim); padding: 0 8px; font-size: calc(13px * var(--ts)); }
#loot-tiles .tile {
  position: relative;
  flex: 0 0 auto;
  width: 64px;
  height: 70px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 3px 3px;
}
#loot-tiles .tile:active { background: rgba(127, 176, 105, 0.35); }
#loot-tiles .ico { font-size: 28px; line-height: 1; height: 32px; }
#loot-tiles .nm { font-size: calc(10px * var(--ts)); line-height: 1.1; text-align: center; color: var(--dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
#loot-tiles .n { position: absolute; left: 4px; top: 2px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.cmp { font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.cmp.up { color: #8fdc6c; }
.cmp.down { color: #ff8a80; }
#loot-tiles .cmp { position: absolute; right: 4px; top: 2px; }
.loot-take { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; width: 92px; }
#loot-all { min-height: 34px; border-radius: 9px; background: rgba(127, 176, 105, 0.55); font-weight: 600; font-size: calc(13px * var(--ts)); }
#loot-kinds { display: flex; gap: 4px; }
#loot-kinds button { flex: 0 0 28px; height: 32px; border-radius: 8px; background: var(--panel2); font-size: 17px; padding: 0; }

#buildbar {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--panel);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}
#buildbar button { padding: 10px 16px; border-radius: 10px; background: var(--panel2); font-weight: 600; }
#build-place { background: rgba(127, 176, 105, 0.6) !important; }
#build-name { padding: 0 6px; font-size: calc(14px * var(--ts)); }

/* ------------------------------------------------------------ menu */

#menu {
  position: fixed;
  inset: 0;
  padding: calc(6px + var(--safe-t)) calc(8px + var(--safe-r)) calc(6px + var(--safe-b)) calc(8px + var(--safe-l));
  background: rgba(8, 10, 8, 0.82);
  display: flex;
  flex-direction: column;
  touch-action: pan-y;
}
/* Too many tabs for a small phone: the bar scrolls sideways, with ✕ always at the right. */
#menu-tabs { display: flex; gap: 6px; margin-bottom: 6px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
#menu-tabs::-webkit-scrollbar { display: none; }
#menu-tabs button { flex: none; }
#menu-tabs button {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel2);
  font-size: calc(14px * var(--ts));
  color: var(--dim);
}
#menu-tabs button.on { color: var(--text); background: rgba(70, 80, 60, 0.95); }
#menu-close { margin-left: auto; color: var(--text) !important; width: 44px; position: sticky; right: 0; box-shadow: -8px 0 8px var(--bg); }
/* Our plans (ui.js renderPlans). */
#tab-plans { display: flex; gap: 8px; overflow: hidden; }
.row.plan, .row.idea { align-items: center; cursor: default; }
.row.plan .name, .row.idea .name { white-space: normal; line-height: 1.3; }
.row.plan .tick { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--dim); background: transparent; color: var(--good); font-size: calc(18px * var(--ts)); font-weight: 700; line-height: 1; }
.row.plan.done .tick { border-color: var(--good); }
.row.plan.done .name { color: var(--dim); text-decoration: line-through; }
.row.plan .name small, .row.idea .name small { display: block; color: var(--dim); font-size: calc(11px * var(--ts)); text-decoration: none; }
.row.plan .del { flex: none; margin-left: auto; width: 30px; height: 30px; border-radius: 8px; background: var(--panel2); color: var(--dim); }
.row.idea button { flex: none; margin-left: auto; width: 36px; height: 32px; border-radius: 8px; background: rgba(70, 90, 60, 0.9); }
/* Phase 26: the big ones you know of, over the ideas. */
.row.idea.big { background: rgba(90, 30, 26, 0.35); border-left: 3px solid #b8392e; }
.row.idea.big .ico { flex: none; width: 26px; margin-right: 6px; }
.plan-add { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line); }
.plan-add input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font-size: 16px; }
.plan-add button { padding: 8px 14px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.tab { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
#tab-inv { display: flex; gap: 8px; overflow: hidden; }
.col { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--panel); border-radius: 12px; border: 1px solid var(--line); }
.colhead {
  padding: 8px 10px;
  font-size: calc(13px * var(--ts));
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.colhead b { color: var(--text); }
.colhead .over { color: var(--bad); }
.colhead button { margin-left: auto; padding: 5px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.1); font-size: calc(12px * var(--ts)); color: var(--text); }
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 4px; }
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  min-height: 44px;
  border-radius: 8px;
  font-size: calc(14px * var(--ts));
}
.row.sel { background: rgba(224, 168, 58, 0.25); }
.row .ico { font-family: var(--emoji); font-size: calc(20px * var(--ts)); width: 26px; text-align: center; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .w { color: var(--dim); font-size: calc(12px * var(--ts)); font-variant-numeric: tabular-nums; }
.row .tag { font-size: calc(10px * var(--ts)); padding: 2px 5px; border-radius: 5px; background: rgba(127, 176, 105, 0.35); }
.empty { color: var(--dim); font-size: calc(13px * var(--ts)); padding: 12px; text-align: center; }

#itembar {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--panel);
  border-radius: 12px;
  padding: 6px;
}
#itembar button { padding: 9px 12px; border-radius: 9px; background: var(--panel2); font-size: calc(14px * var(--ts)); }
#itembar .title { align-self: center; padding: 0 6px; font-size: calc(13px * var(--ts)); color: var(--dim); }
#itembar button.give { background: rgba(58, 154, 165, 0.45); }
.colhead .label-edit { margin-left: 0; padding: 3px 7px; }
/* 16px stops iOS Safari from zooming in when the box gets focus. */
#label-input { flex: 1; min-width: 0; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: 16px var(--ui); }

.sec { background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 10px 12px; margin-bottom: 8px; }
.sec h3 { margin: 0 0 8px; font-size: calc(14px * var(--ts)); color: var(--dim); font-weight: 600; }
.statrow { display: flex; align-items: center; gap: 10px; font-size: calc(13px * var(--ts)); margin: 5px 0; }
.statrow span:first-child { width: 90px; }
.meter { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.meter div { height: 100%; }
.wound { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; font-size: calc(14px * var(--ts)); border-top: 1px solid var(--line); }
.wound:first-of-type { border-top: none; }
/* A wound with several things to do about it: the words take the line, the buttons wrap under them. */
.wound span { flex: 1 1 12em; text-align: left; }
.wound button, .recipe button, .sec button.wide { padding: 8px 12px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); }
.recipe { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.recipe:first-of-type { border-top: none; }
.recipe .ico { font-family: var(--emoji); font-size: calc(24px * var(--ts)); }
.recipe .info { flex: 1; font-size: calc(14px * var(--ts)); }
.recipe .req { font-size: calc(12px * var(--ts)); color: var(--dim); }
.recipe .req .ok { color: var(--good); }
.recipe .req .no { color: var(--bad); }
.recipe button:disabled { opacity: 0.4; }
.recipe.locked .ico, .recipe.locked .info { opacity: 0.6; }
.who { font-size: calc(14px * var(--ts)); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: calc(12px * var(--ts)); padding: 4px 8px; border-radius: 999px; background: var(--panel2); }
.chip.good { border: 1px solid rgba(127, 176, 105, 0.6); }
.chip.bad { border: 1px solid rgba(217, 83, 79, 0.6); }
.skill { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.skill .ico { font-family: var(--emoji); font-size: calc(22px * var(--ts)); width: 28px; text-align: center; }
.skill .info { flex: 1; font-size: calc(14px * var(--ts)); }
.skill .top { display: flex; align-items: baseline; gap: 6px; }
.skill .lv { margin-left: auto; font-weight: 700; font-size: calc(16px * var(--ts)); }
.skill .fast { font-size: calc(11px * var(--ts)); color: var(--good); }
.skill .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); margin: 4px 0; overflow: hidden; }
.skill .bar div { height: 100%; background: var(--good); }
.skill .req { font-size: calc(12px * var(--ts)); color: var(--dim); }
.hint { font-size: calc(13px * var(--ts)); color: var(--dim); line-height: 1.4; }

.fb { display: flex; gap: 10px; min-height: 100%; }
.fb-main { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fb-kinds { flex-wrap: wrap; }
/* 16px stops iOS Safari from zooming in when the box gets focus. */
#fb-text {
  flex: 1; min-height: 110px; resize: none; padding: 8px 10px; border-radius: 10px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); font: 16px/1.35 var(--ui);
}
.fb-side { width: 34%; display: flex; flex-direction: column; gap: 8px; }
#fb-send { background: rgba(127, 176, 105, 0.6) !important; font-weight: 700; font-size: calc(15px * var(--ts)) !important; padding: 10px !important; }
#fb-send:disabled { opacity: 0.6; }
.fb-check { font-size: calc(13px * var(--ts)); color: var(--dim); display: flex; align-items: center; gap: 6px; }
#fb-shot { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
/* Your reports and Claude's answers (Phase 20). */
.fb-list { margin-top: 12px; }
.fb-head { font-weight: 700; font-size: calc(15px * var(--ts)); margin: 4px 0 6px; }
.fb-rep { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.fb-rep.new { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); }
.fb-top { display: flex; gap: 6px; align-items: baseline; font-size: calc(13px * var(--ts)); color: var(--dim); }
.fb-said { flex: 1; min-width: 0; font-style: italic; overflow-wrap: anywhere; }
.fb-date { flex: none; }
.fb-ans { margin-top: 4px; font-size: calc(14px * var(--ts)); line-height: 1.35; }
.fb-ans b { margin-right: 2px; white-space: nowrap; }
.fb-ans.wait { color: var(--dim); }
/* Something new behind this button: a red dot in its corner. */
.news { position: relative; }
.news::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 10px; height: 10px; border-radius: 50%;
  background: #e0453a; border: 1.5px solid #fff; pointer-events: none;
}
.setrow { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: calc(14px * var(--ts)); }
.setrow input[type=range] { flex: 1; }
.seg { display: flex; gap: 4px; }
.seg button { min-height: 40px; padding: 7px 12px; border-radius: 8px; background: var(--panel2); font-size: calc(13px * var(--ts)); color: var(--dim); }
.seg button.on { color: var(--text); background: rgba(70, 80, 60, 0.95); }

/* ------------------------------------------------------------ map */

#mapview { position: fixed; inset: 0; background: #0b0d0a; touch-action: none; }
#mapcanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#map-bar {
  position: absolute;
  top: calc(6px + var(--safe-t));
  left: calc(8px + var(--safe-l));
  right: calc(8px + var(--safe-r));
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
#map-bar .hint { background: rgba(0, 0, 0, 0.55); border-radius: 10px; padding: 6px 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#map-bar button { pointer-events: auto; padding: 9px 14px; border-radius: 10px; background: var(--panel2); font-size: calc(15px * var(--ts)); }
#map-me { margin-left: auto; }
#map-in, #map-out { min-width: 44px; font-weight: 700; }
#map-out { margin-left: auto; }
#map-out ~ #map-me { margin-left: 0; }
/* Phase 21: the name of the area you walk into, for a few seconds (client/map.js placeNameTick). */
#placename {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  font: italic 600 calc(24px * var(--ts)) Georgia, 'Times New Roman', serif;
  letter-spacing: 0.05em;
  color: #f3ead6;
  text-shadow: 0 2px 6px #000, 0 0 2px #000;
  opacity: 0;
  transition: opacity 1.2s;
}
#placename.show { opacity: 0.95; transition: opacity 0.6s; }
/* Phase 22: the street you step onto, on a street sign; the house you walk into, on its number plate. */
#streetname {
  position: absolute;
  left: 50%;
  top: calc(34% + 40px * var(--ts));
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
  font: 700 calc(14px * var(--ts)) system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: #f4f6f2;
  background: #1f5a34;
  border: 2px solid #e8efe6;
  border-radius: 5px;
  padding: 2px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 1s;
}
#streetname.house { background: #f1ead6; color: #2a2620; border-color: #6b5a3e; }
#streetname.show { opacity: 0.92; transition: opacity 0.5s; }
#map-pick {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  max-width: min(360px, 92vw);
}
.pick-title { font-size: calc(14px * var(--ts)); color: var(--dim); margin: 2px 4px 8px; }
.pick-title .ico, #map-pick .ico { font-family: var(--emoji); }
.pick-kinds { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pick-kinds button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--panel2); font-size: calc(12px * var(--ts)); }
.pick-kinds .ico { font-size: calc(22px * var(--ts)); }
#pick-del { width: 100%; padding: 10px; border-radius: 10px; background: rgba(217, 83, 79, 0.5); font-size: calc(14px * var(--ts)); }

/* ------------------------------------------------------------ overlays */

#death, #join, #conn, #rotate {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(10px + var(--safe-t)) calc(16px + var(--safe-r)) calc(10px + var(--safe-b)) calc(16px + var(--safe-l));
}
#death { background: rgba(40, 0, 0, 0.7); animation: fadein 2s; flex-direction: row; flex-wrap: wrap; align-content: center; gap: 8px 28px; overflow-y: auto; }
.death-sum { display: flex; flex-direction: column; align-items: center; max-width: min(92vw, 560px); }
@media (min-width: 600px) {
  /* Side by side on a phone held sideways. */
  #death { flex-wrap: nowrap; }
  .death-sum { max-width: 50vw; }
  #death-what { width: min(44vw, 400px); }
}
#death-what {
  width: min(92vw, 400px);
  max-height: 86vh;
  overflow-y: auto;
  text-align: left;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
}
#death-what h3 { margin: 0 0 6px; font-size: calc(14px * var(--ts)); color: #f2b8ad; }
#death-what .wh { display: flex; gap: 8px; padding: 3px 0; font-size: calc(13px * var(--ts)); border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
#death-what .when { flex: 0 0 74px; color: var(--dim); font-variant-numeric: tabular-nums; }
#death-what .tip { margin-bottom: 8px; font-size: calc(13px * var(--ts)); color: #ffe9a8; line-height: 1.4; }
@keyframes fadein { from { opacity: 0; } }
#death h1 { font-size: calc(44px * var(--ts)); letter-spacing: 6px; text-transform: uppercase; color: #e05a46; margin: 0; }
#death .sub { font-style: italic; color: var(--dim); }
#death p { font-size: calc(16px * var(--ts)); }
#death button, #btn-play {
  margin-top: 10px;
  padding: 13px 28px;
  font-size: calc(17px * var(--ts));
  font-weight: 700;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
}
#death button.quiet { background: var(--panel2); color: var(--text); font-size: calc(15px * var(--ts)); font-weight: 600; }
.death-actions { display: flex; flex-wrap: wrap; gap: 0 12px; justify-content: center; align-items: center; }
@media (max-height: 420px) {
  #death h1 { font-size: calc(32px * var(--ts)); }
  #death p { font-size: calc(14px * var(--ts)); margin: 6px 0; }
}

#join {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(120, 30, 20, 0.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(40, 70, 30, 0.35), transparent 60%),
    var(--bg);
  overflow-y: auto;
  touch-action: pan-y;
  justify-content: safe center;
}
.join-card { width: min(440px, 100%); text-align: left; }
.join-card h1 { font-size: calc(38px * var(--ts)); letter-spacing: 5px; margin: 0; text-align: center; font-weight: 900; }
.hazard { color: var(--accent); }
.tag { text-align: center; color: var(--dim); margin: 4px 0 14px; font-size: calc(14px * var(--ts)); }
.join-card label { font-size: calc(13px * var(--ts)); color: var(--dim); }
#room-msg { font-size: calc(14px * var(--ts)); color: var(--warn); margin: 4px 0 8px; }
#name, #room {
  width: 100%;
  margin: 4px 0 10px;
  padding: 11px 12px;
  font-size: calc(17px * var(--ts));
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  -webkit-user-select: text;
  user-select: text;
}
#swatches { display: flex; gap: 10px; margin-bottom: 6px; justify-content: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.swatch.on { border-color: #fff; }
#btn-play { width: 100%; }
/* ⚙️ Frame rate: Show. Bottom middle, between the stick and the buttons, out of the way. */
#fps {
  position: fixed;
  left: 50%;
  bottom: calc(4px + var(--safe-b));
  transform: translateX(-50%);
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.8);
  font: 12px ui-monospace, Menlo, Consolas, monospace;
  pointer-events: none;
  z-index: 5;
}
#btn-install { width: 100%; margin-top: 8px; padding: 10px; border-radius: 12px; background: var(--panel2); color: var(--text); font-size: calc(15px * var(--ts)); font-weight: 600; }
#install-tip { font-size: calc(12px * var(--ts)); color: var(--warn); text-align: center; min-height: 1em; }
details { font-size: calc(13px * var(--ts)); color: var(--dim); margin-top: 6px; }
details ul { padding-left: 18px; line-height: 1.5; }
summary { cursor: pointer; }

/* Who were you? Occupations on the left, traits on the right, each column scrolling on its own. */
#create {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: calc(6px + var(--safe-t)) calc(10px + var(--safe-r)) calc(6px + var(--safe-b)) calc(10px + var(--safe-l));
  background: var(--bg);
}
.create-head { display: flex; align-items: center; gap: 10px; }
.create-titles { flex: 1; min-width: 0; }
.create-head h2 { margin: 0; font-size: calc(19px * var(--ts)); }
#create-sub { font-size: calc(12px * var(--ts)); color: var(--dim); }
#create-pts { font-size: calc(14px * var(--ts)); font-weight: 700; color: var(--good); white-space: nowrap; }
#create-pts.bad { color: var(--bad); }
#create-go { padding: 11px 22px; border-radius: 12px; background: var(--accent); color: #fff; font-size: calc(16px * var(--ts)); font-weight: 700; }
#create-go:disabled { opacity: 0.4; }
#create-back { width: 40px; height: 40px; border-radius: 10px; background: var(--panel2); font-size: calc(22px * var(--ts)); }
.create-cols { flex: 1; min-height: 0; display: flex; gap: 8px; }
.create-col { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; display: flex; flex-direction: column; gap: 5px; }
.create-col h4 { margin: 4px 2px 0; font-size: calc(12px * var(--ts)); color: var(--dim); font-weight: 600; }
.pick { display: flex; align-items: center; gap: 9px; text-align: left; padding: 7px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.pick.on { background: rgba(70, 90, 60, 0.9); border-color: var(--good); }
.pick:disabled { opacity: 0.35; }
.pick .ico { font-family: var(--emoji); font-size: calc(22px * var(--ts)); }
.pick b { display: block; font-size: calc(14px * var(--ts)); }
.pick small { display: block; font-size: calc(11.5px * var(--ts)); color: var(--dim); }
.pick .cost { margin-left: auto; font-weight: 700; font-size: calc(14px * var(--ts)); }
.pick .cost.good { color: var(--warn); }
.pick .cost.bad { color: var(--good); }
#create-note { font-size: calc(13px * var(--ts)); min-height: 1.3em; color: var(--text); }
/* After a death the world shows through, following your partner (client/create.js). */
#create.over-world { background: rgba(11, 13, 10, 0.86); }
#create-where { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#create-where .lbl { font-size: calc(13px * var(--ts)); color: var(--dim); margin-right: 2px; }
#create-where button { padding: 7px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: calc(14px * var(--ts)); font-weight: 600; }
#create-where button.on { background: rgba(70, 90, 60, 0.9); border-color: var(--good); }
#create-where button:disabled { opacity: 0.5; }
#create-where small { display: block; font-size: calc(11px * var(--ts)); font-weight: 400; color: var(--warn); }

#conn { background: rgba(0, 0, 0, 0.8); gap: 8px; font-size: calc(18px * var(--ts)); }
#conn small { color: var(--dim); font-size: calc(13px * var(--ts)); max-width: 420px; }

#rotate { display: none; background: var(--bg); font-size: calc(18px * var(--ts)); gap: 10px; z-index: 50; }
#rotate .big { font-size: calc(64px * var(--ts)); }
@media (orientation: portrait) {
  body.playing #rotate { display: flex; }
}

/* ------------------------------------------------------------ pause and hints */

#btn-pause, #btn-fs { font-size: calc(15px * var(--ts)); min-width: 36px; min-height: 32px; padding: 2px 4px; margin-left: 2px; opacity: 0.9; background: transparent; border: none; }
#btn-fs { color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
#pauseveil {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: calc(20px * var(--ts));
  pointer-events: auto;
}
#pauseveil .big { font-size: calc(54px * var(--ts)); }
.pause-actions { display: flex; gap: 12px; margin-top: 8px; }
.pause-actions button { padding: 13px 26px; border-radius: 12px; background: var(--accent); color: #fff; font-size: calc(17px * var(--ts)); font-weight: 700; }
.pause-actions button.quiet { background: var(--panel2); color: var(--text); font-weight: 600; }

#hint {
  position: absolute;
  top: calc(40px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  width: min(52vw, 480px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20, 26, 18, 0.94);
  border: 1px solid rgba(224, 168, 58, 0.55);
  border-radius: 12px;
  padding: 6px 8px 6px 10px;
  font-size: calc(13px * var(--ts));
  line-height: 1.3;
  animation: toast-in 0.25s ease-out;
}
#hint-text { flex: 1; }
#hint-text::before { content: "💡 "; }
.hint-btns { display: flex; flex-direction: column; gap: 4px; }
.hint-btns button { padding: 5px 10px; border-radius: 8px; background: var(--panel2); font-size: calc(12px * var(--ts)); white-space: nowrap; }
#hint-ok { background: rgba(70, 80, 60, 0.95); font-weight: 600; }
body { --hint-h: 0px; }
#toasts { top: calc(40px + var(--safe-t) + var(--hint-h)); }

/* ------------------------------------------------------------ a note */

#note {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: calc(10px + var(--safe-t)) 16px 10px;
}
#note .paper {
  width: min(92vw, 560px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #e9e1cb;
  color: #2b2620;
  border-radius: 4px;
  padding: 14px 18px 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  transform: rotate(-0.6deg);
}
#note h3 { margin: 0 0 8px; font-size: calc(14px * var(--ts)); color: #6b5a3e; font-weight: 600; }
#note-text { white-space: pre-line; font-family: "Segoe Print", "Bradley Hand", "Marker Felt", cursive; font-size: calc(15px * var(--ts)); line-height: 1.45; overflow-y: auto; min-height: 0; }
#note-ok { flex-shrink: 0; align-self: flex-start; margin-top: 10px; padding: 8px 18px; border-radius: 10px; background: #6b5a3e; color: #fff; font-weight: 600; }
@media (max-height: 480px) { #note-text { font-size: calc(13px * var(--ts)); line-height: 1.35; } }

/* ------------------------------------------------------------ world tab */

#tab-world { max-width: 760px; }
#tab-world h4 { margin: 10px 0 4px; font-size: calc(13px * var(--ts)); color: var(--dim); font-weight: 600; }
.seg.wrap { flex-wrap: wrap; }
.seg button:disabled { opacity: 0.45; }
.seg button.on:disabled { opacity: 1; }
.optrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 7px 0 2px; font-size: calc(14px * var(--ts)); }
.optrow .lbl { flex: 0 1 190px; }
.optrow .seg { justify-content: flex-end; }
.hint.note { font-size: calc(12px * var(--ts)); margin: 0 0 6px; }
.custom { align-self: center; font-size: calc(12px * var(--ts)); color: var(--warn); padding: 0 4px; }
.numrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: calc(13px * var(--ts)); border-bottom: 1px solid var(--line); }
.numrow .vals { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.numrow .dot { color: var(--warn); }
.field, .num {
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font: 16px var(--ui);
  -webkit-user-select: text;
  user-select: text;
}
.field { flex: 1; min-width: 0; }
.field.pin { flex: 0 0 110px; letter-spacing: 6px; text-align: center; }
.num { width: 84px; text-align: right; }
.err { color: #ffb3a8; font-size: calc(13px * var(--ts)); margin-top: 4px; }
.slot { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.slot .info { flex: 1; min-width: 0; }
.slot .acts { display: flex; gap: 6px; }
.slot button { padding: 8px 12px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); }
.slot .tag { font-size: calc(11px * var(--ts)); color: var(--good); border: 1px solid rgba(127, 176, 105, 0.5); border-radius: 6px; padding: 1px 5px; }
.sec button.wide.go { background: rgba(127, 176, 105, 0.45); font-weight: 600; }
#set-hints-again { padding: 7px 12px; border-radius: 8px; background: var(--panel2); font-size: calc(13px * var(--ts)); }

/* ------------------------------------------------------------ down, and giving up */

#downed #btn-giveup {
  margin-top: 8px;
  padding: 6px 14px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 207, 200, 0.5);
  color: #ffcfc8;
  font-size: calc(13px * var(--ts));
  font-weight: 600;
}
#downed #btn-giveup.sure { background: var(--bad); color: #fff; border-color: #fff; }

/* ------------------------------------------------------------ surprise eggs (client/eggs.js) */

#egg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  padding: calc(10px + var(--safe-t)) 16px 10px;
}
.egg-card {
  position: relative;
  width: min(86vw, 380px);
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(#2b2f3a, #1d2028);
  border: 2px solid rgba(255, 233, 168, 0.5);
  border-radius: 18px;
  padding: 14px 16px 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: egg-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.egg-burst {
  position: absolute;
  left: 50%;
  top: 64px;
  width: 260px;
  height: 260px;
  margin: -130px 0 0 -130px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 233, 168, 0.16) 0 10deg, transparent 10deg 20deg);
  -webkit-mask: radial-gradient(closest-side, #000 30%, transparent);
  mask: radial-gradient(closest-side, #000 30%, transparent);
  animation: egg-spin 9s linear infinite;
  pointer-events: none;
}
#egg-fig { position: relative; font-size: 76px; line-height: 1; margin: 6px 0 2px; animation: egg-rise 0.7s 0.1s both cubic-bezier(0.2, 1.5, 0.4, 1); }
#egg h3 { position: relative; margin: 6px 0 2px; font-size: calc(19px * var(--ts)); color: #ffe9a8; }
#egg-line { position: relative; font-style: italic; color: var(--dim); font-size: calc(14px * var(--ts)); }
#egg-count { position: relative; margin-top: 8px; font-size: calc(14px * var(--ts)); font-weight: 600; }
#egg.fresh #egg-count { color: var(--good); }
#egg-letter {
  position: relative;
  margin-top: 10px;
  padding: 10px 12px;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-line;
  text-align: left;
  background: #f4ead0;
  color: #3a2f20;
  border-radius: 6px;
  font-family: "Segoe Print", "Bradley Hand", "Marker Felt", cursive;
  font-size: calc(14px * var(--ts));
  line-height: 1.45;
}
#egg-ok { position: relative; flex-shrink: 0; margin-top: 12px; padding: 9px 26px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 700; font-size: calc(15px * var(--ts)); }
#egg.golden .egg-card { background: linear-gradient(#5a4512, #2e230a); border-color: #f2ca4b; }
#egg.golden .egg-burst { background: repeating-conic-gradient(rgba(242, 202, 75, 0.3) 0 10deg, transparent 10deg 20deg); }
@media (max-height: 420px) {
  #egg-fig { font-size: 54px; }
  .egg-burst { top: 50px; }
}
@keyframes egg-pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes egg-rise { from { transform: translateY(30px) scale(0.3); opacity: 0; } }
@keyframes egg-spin { to { transform: rotate(360deg); } }

#confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
#confetti i {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: both;
}
@keyframes confetti-fall { to { transform: translateY(105vh) rotate(var(--spin)); } }

.album .figs { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; margin: 8px 0 4px; }
.album .fig {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 4px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 30px;
}
.album .fig .nm { font-size: calc(11px * var(--ts)); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Not found yet: only the shape, in the dark. */
.album .fig:not(.got) .icw { filter: brightness(0); opacity: 0.35; }
.album .fig.got .nm { color: var(--text); }
.album .fig.rare { border-color: rgba(176, 140, 230, 0.7); }
.album .fig.rare.got { background: linear-gradient(rgba(125, 88, 179, 0.35), var(--panel2)); }
.album .fig.gold { border-color: #f2ca4b; background: linear-gradient(rgba(214, 163, 50, 0.4), var(--panel2)); }
.album .fig.gold.wrapped .icw { filter: brightness(0.6); }
.album .gold-note { color: #f2ca4b; }

/* ------------------------------------------------------------ 📖 Guide (client/guide.js) */

#tab-guide { display: flex; gap: 10px; align-items: flex-start; }
#tab-guide.hidden { display: none; }
.guide-list { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; }
.guide-list button { display: flex; align-items: center; gap: 6px; text-align: left; padding: 7px 10px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); white-space: nowrap; }
.guide-list button.on { background: rgba(224, 168, 58, 0.45); }
.guide-page { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.guide-page h3 { margin: 0 0 6px; font-size: calc(16px * var(--ts)); color: #ffe9a8; }
.guide-page p { margin: 0 0 8px; font-size: calc(14px * var(--ts)); line-height: 1.45; }
.guide-page b { color: #fff; }

/* 🏆 Our story (client/story.js): milestones, the memorial, the evenings. */
.story-top { display: flex; align-items: center; gap: 10px; font-size: calc(14px * var(--ts)); }
.story-top > div { flex: 1; }
.story-top button.wide { width: auto; flex: none; margin: 0; }
.ms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.ms { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: var(--panel2); opacity: 0.55; }
.ms.got { opacity: 1; border: 1px solid rgba(214, 163, 50, 0.6); }
.ms .ico { flex: none; width: 28px; height: 28px; font-size: 24px; display: flex; align-items: center; justify-content: center; filter: grayscale(1); }
.ms.got .ico { filter: none; }
.ms b { display: block; font-size: calc(13px * var(--ts)); }
.ms small { display: block; color: var(--dim); font-size: calc(11px * var(--ts)); line-height: 1.25; }
.dead { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: calc(14px * var(--ts)); }
.dead .dot { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.4); }
.dead .who { flex: 1; min-width: 0; }
.dead small { display: block; color: var(--dim); font-size: calc(12px * var(--ts)); }
.dead button { flex: none; padding: 7px 10px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); }
.dead button small { font-size: calc(10px * var(--ts)); }
.dead .buried { flex: none; color: var(--dim); font-size: calc(13px * var(--ts)); }
.night { display: block; width: 100%; text-align: left; padding: 8px 10px; margin-bottom: 4px; border-radius: 9px; background: var(--panel2); font-size: calc(13px * var(--ts)); line-height: 1.35; }
/* A milestone reached: across the top of the screen, on both phones. */
#ms-banner {
  --ts: var(--text-scale);
  position: absolute;
  top: calc(44px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 12px;
  border-radius: 14px;
  background: linear-gradient(#5a4512, #2e230a);
  border: 2px solid #f2ca4b;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
#ms-banner.go { animation: egg-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1); }
#ms-banner .ico { width: 34px; height: 34px; font-size: 30px; display: flex; align-items: center; justify-content: center; }
#ms-banner small { display: block; color: #f2ca4b; font-size: calc(11px * var(--ts)); font-weight: 600; }
#ms-banner b { display: block; color: #fff6dc; font-size: calc(17px * var(--ts)); }
/* An evening's recap. */
#recap {
  --ts: var(--text-scale);
  position: fixed;
  inset: 0;
  z-index: 44;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(5, 8, 20, 0.78);
}
.recap-card {
  width: min(90vw, 440px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px;
  border-radius: 18px;
  background: linear-gradient(#232a44, #151a2c);
  border: 2px solid rgba(166, 212, 242, 0.45);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: egg-pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.recap-card h3 { margin: 0; font-size: calc(19px * var(--ts)); color: #e8eeff; }
#recap-who { color: var(--dim); font-size: calc(13px * var(--ts)); margin-bottom: 8px; }
#recap-lines { overflow-y: auto; min-height: 0; touch-action: pan-y; }
#recap-lines .line { padding: 4px 0; font-size: calc(14px * var(--ts)); line-height: 1.35; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
#recap-lines .line.bad { color: #f0a090; }
#recap-lines .line.good { color: var(--good); }
#recap-ok { flex-shrink: 0; align-self: center; margin-top: 12px; padding: 9px 26px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 700; font-size: calc(15px * var(--ts)); }
/* The evacuation (server/evac.js): the line in 🏆 Story, and the end of the story. */
.evac-line { display: flex; align-items: center; gap: 10px; font-size: calc(14px * var(--ts)); line-height: 1.35; }
.evac-line .ico { flex: none; font-size: 22px; }
.evac-line .txt { flex: 1; }
.evac-line button.wide { width: auto; flex: none; margin: 0 0 0 auto; }
#death.out { background: rgba(10, 24, 40, 0.82); }
#death.out h1 { color: #a6d4f2; }
.ep-head { font-style: italic; color: var(--dim); font-size: calc(13px * var(--ts)); line-height: 1.4; margin-bottom: 6px; }
#recap-lines h4, #death-what h4 { margin: 10px 0 4px; font-size: calc(13px * var(--ts)); color: var(--dim); font-weight: 600; }
.ep-mss { display: flex; flex-wrap: wrap; gap: 4px; }
.ep-ms { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 8px; background: rgba(214, 163, 50, 0.18); font-size: calc(12px * var(--ts)); }
.ep-ms .ico { width: 16px; height: 16px; font-size: 14px; }
.ep-lost { font-size: calc(13px * var(--ts)); line-height: 1.4; }
.ep-foot { margin-top: 10px; font-size: calc(14px * var(--ts)); font-weight: 600; }
