:root {
  --ink: #f2efe6;
  --dim: #a49e8f;
  --bg: #0d0f12;
  --accent: #ffcf4a;
  --accent2: #6fd3ff;
}

* { box-sizing: border-box; }

/* the hidden attribute loses to any display rule, and #handle-row has one */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }
/* a finger on the canvas is a look, never a scroll, a zoom, a selection or a callout */
#app canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

#crosshair {
  position: fixed; left: 50%; top: 50%; width: 6px; height: 6px;
  margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255,255,255,.55); box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
body.playing #crosshair { opacity: 1; }
/* pointing at someone: the dot opens into a ring; holding: it fills amber */
#crosshair.can-grab {
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,.85), 0 0 0 1px rgba(0,0,0,.4);
}
#crosshair.holding {
  width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: #ffcf4a; box-shadow: 0 0 0 2px rgba(0,0,0,.5);
}

/* a small pill above the bottom edge: "E  sit down", "click to look around" */
#prompt {
  position: fixed; left: 50%; bottom: 16%; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: var(--ink); font-size: 13px; letter-spacing: .06em;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12);
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
body.playing #prompt.on { opacity: 1; }
/* the first prompt of the game is the tutorial: make it read from across the room */
#prompt .key { color: var(--accent); font-weight: 700; margin-right: .45em; }
#prompt.big { font-size: 24px; padding: 14px 28px; bottom: 22%; letter-spacing: .1em; font-weight: 600; box-shadow: 0 0 0 2px var(--accent); }

/* the black between the menu camera's shots (menucam.js drives the opacity) */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 5; }

/* while you're holding someone: the two things you can do with them */
#holdkeys {
  position: fixed; left: calc(50% + 22px); top: 50%; transform: translateY(-50%);
  font-size: 12px; letter-spacing: .05em; color: var(--ink); text-shadow: 0 1px 4px #000;
  pointer-events: none; opacity: 0; transition: opacity .15s; line-height: 1.7;
}
body.playing #holdkeys.on { opacity: 1; }
#holdkeys .key {
  display: inline-block; min-width: 18px; text-align: center; margin-right: 6px;
  padding: 0 5px; border-radius: 4px; background: rgba(0,0,0,.6); color: var(--accent);
  font-weight: 700; box-shadow: 0 0 0 1px rgba(255,255,255,.25);
}
#holdkeys.nopost div:first-child { opacity: .35; }

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

#hud {
  position: fixed; left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); pointer-events: none;
  font-size: 12px; letter-spacing: .04em; text-transform: lowercase;
  color: var(--dim); text-shadow: 0 1px 3px rgba(0,0,0,.8);
  opacity: 0; transition: opacity .3s;
}
body.playing #hud { opacity: 1; }
#hud b { color: var(--ink); font-size: 15px; }
#hud .stat { margin-bottom: 2px; }
#s-status { color: var(--accent2); }
#s-status.down { color: #ff6b6b; }

/* ---------- touch mode: the chair edition (touch.js) ---------- */

/* the gear: only on touch, only in the game (the menu has its own way back) */
#btn-menu {
  display: none; position: fixed; z-index: 6;
  right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top));
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  align-items: center; justify-content: center;
  color: var(--ink); background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.18);
  -webkit-tap-highlight-color: transparent;
}
#btn-menu:active { background: rgba(255,255,255,.2); }
body.touch.playing #btn-menu { display: flex; }
/* nothing to aim, nothing to hold */
body.touch #crosshair, body.touch #holdkeys { display: none; }

/* the thumbstick: a ring bottom-left with a knob that follows the thumb (stick.js) */
#stick {
  display: none; position: fixed; z-index: 6;
  left: max(22px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(0,0,0,.28); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  transition: opacity .2s;
}
#stick .knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%; background: rgba(255,255,255,.35); box-shadow: 0 0 0 1px rgba(0,0,0,.35);
  pointer-events: none;
}
#stick.active .knob { background: rgba(255,207,74,.75); }
#stick.off { opacity: 0; pointer-events: none; }
body.touch.playing #stick { display: block; }

/* sit down / stand up: where the E pill would be */
#btn-seat {
  position: fixed; z-index: 6; left: 50%; bottom: max(34px, calc(env(safe-area-inset-bottom) + 20px));
  transform: translateX(-50%);
  padding: 12px 22px; border-radius: 999px; font-size: 14px; font-weight: 600; letter-spacing: .08em;
  text-transform: lowercase; color: var(--ink); background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.25); -webkit-tap-highlight-color: transparent;
}
#btn-seat:active { background: rgba(255,255,255,.2); }
/* the first one is the tutorial: make it read from across the room */
#btn-seat.big { font-size: 18px; padding: 16px 30px; box-shadow: 0 0 0 2px var(--accent); }
body:not(.touch) #btn-seat, body:not(.playing) #btn-seat { display: none; }
/* the controls line for the device you're on */
.controls.touch { display: none; }
body.touch .controls:not(.touch) { display: none; }
body.touch .controls.touch { display: block; }


/* ---------- overlay: title / setup / options / paused ---------- */

#overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 10;
  /* the menu camera is behind this: a vignette, not a wall */
  background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,.08) 30%, rgba(0,0,0,.62) 100%);
}
#overlay.visible { display: flex; }
/* the pause menu covers a live crowd: darker, and softened */
#overlay[data-screen=paused] {
  background: radial-gradient(circle at 50% 40%, rgba(20,24,30,.82), rgba(6,7,9,.94));
  backdrop-filter: blur(3px);
}

.screen { display: none; }
.screen.on { display: block; }

.panel {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 24px 28px 18px; border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; background: rgba(12,14,18,.84);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.panel h2 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--dim); font-weight: 600;
}
.panel h2 + .tiles { margin-bottom: 18px; }

/* the title: a wordmark and two buttons, no box */
#scr-title { text-align: center; }
.wordmark {
  margin: 0; font-size: clamp(56px, 12vw, 112px); letter-spacing: .24em; font-weight: 800; line-height: 1;
  color: var(--accent); text-shadow: 0 6px 40px rgba(0,0,0,.7), 0 0 60px rgba(255,207,74,.18);
  padding-left: .24em;   /* the tracking hangs off the last letter: recentre */
}
.wordmark.small { font-size: 28px; letter-spacing: .3em; padding-left: .3em; margin-bottom: 8px; text-shadow: none; }
.tag { margin: 6px 0 34px; font-size: 14px; letter-spacing: .3em; text-transform: lowercase; color: var(--ink); text-shadow: 0 1px 6px #000; }
.menu { display: flex; flex-direction: column; gap: 10px; width: 260px; margin: 0 auto; }
.menu .big { margin: 0; }
.nsfw {
  position: fixed; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center;
  font-size: 11px; letter-spacing: .08em; color: var(--dim); text-shadow: 0 1px 4px #000;
}

/* the two-by-two: source and size */
.tiles { display: flex; gap: 10px; }
.tile {
  flex: 1; min-width: 0; cursor: pointer; user-select: none;
  padding: 12px 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px;
  background: rgba(255,255,255,.03); font-size: 14px; transition: border-color .12s, background .12s;
}
.tile:hover { background: rgba(255,255,255,.07); }
.tile:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
.tile b { display: block; letter-spacing: .04em; }
.tile small { display: block; color: var(--dim); font-size: 11px; margin-top: 3px; }
.tile.selected {
  border-color: var(--accent); background: rgba(255,207,74,.09);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tile.selected b { color: var(--accent); }
#scale .tile b { letter-spacing: .16em; }
/* the follows tile opens up into the handle box when picked */
.tile-body { margin-top: 10px; cursor: auto; }
#handle {
  display: block; width: 100%; padding: 8px 10px;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px; color: var(--ink); font-size: 14px;
}
#handle:focus { outline: none; border-color: var(--accent); }
.tile-body .check { display: flex; gap: 6px; align-items: center; margin-top: 8px; font-size: 11px; color: var(--dim); text-transform: lowercase; cursor: pointer; }
.tile-body .check input { accent-color: var(--accent); margin: 0; }
.note { font-size: 11px; color: var(--dim); min-height: 14px; margin-top: 6px; }
.note.err { color: #ff8080; }
.note.ok { color: #8ce99a; }

button {
  font-family: inherit; cursor: pointer; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); color: var(--ink);
}
button:hover { background: rgba(255,255,255,.16); }
button.mini { padding: 8px 12px; font-size: 12px; }
button.big {
  width: 100%; margin-top: 8px; padding: 14px; font-size: 16px; font-weight: 700;
  letter-spacing: .16em; background: var(--accent); color: #14110a; border: none;
}
button.big:hover { background: #ffe08a; }
button.big:disabled { background: #4a4a4a; color: #8a8a8a; cursor: progress; }
button.ghost {
  padding: 12px; font-size: 14px; font-weight: 600; letter-spacing: .16em;
  background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.3);
}
button.ghost:hover { background: rgba(255,255,255,.12); }
button.link {
  display: block; padding: 6px 0; border: none; background: none; color: var(--dim);
  font-size: 12px; letter-spacing: .06em; text-transform: lowercase;
}
button.link:hover { color: var(--ink); background: none; }
button.back { margin: 6px auto 0; }

/* the numbers, wherever they're showing */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; padding: 8px 2px; font-size: 13px; }
.settings-grid label {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 2px 6px; font-size: 11px; color: var(--dim); text-transform: lowercase;
}
.settings-grid input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 0; }
.settings-grid output { font-size: 11px; color: var(--ink); }
.settings-grid label.check { grid-template-columns: auto 1fr; cursor: pointer; }
.settings-grid label.check input { accent-color: var(--accent); }
.settings-grid label.span { grid-column: 1 / -1; }
/* the pause menu has no business changing how fast people talk mid-post */
#scr-paused .settings-grid label.speed { display: none; }
#advanced { margin: 2px 0 6px; padding: 4px 8px 2px; border: 1px solid rgba(255,255,255,.08); border-radius: 6px; background: rgba(0,0,0,.25); }

.controls { margin: 12px 0 0; text-align: center; font-size: 11px; color: var(--dim); }
.controls b { color: var(--ink); }
.warn { margin: 8px 0 0; text-align: center; font-size: 11px; color: var(--dim); min-height: 14px; }
.warn.ready { color: #8ce99a; }
.warn.err { color: #ff8080; }

/* narrow screens: the tiles and the numbers stack instead of sitting side by side */
@media (max-width: 440px) {
  .tiles { flex-direction: column; }
  .settings-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px 14px; }
  .nsfw { bottom: max(12px, env(safe-area-inset-bottom)); padding: 0 16px; }
}

/* ---------- debug panel (backquote) ---------- */

#debug {
  position: fixed; right: 12px; top: 12px; bottom: 12px; width: 340px; overflow-y: auto; z-index: 20;
  padding: 10px 12px; border-radius: 8px; background: rgba(10,12,16,.92); border: 1px solid rgba(255,255,255,.14);
  font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
#debug .dbg-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
#debug .dbg-head b { color: var(--accent); letter-spacing: .12em; text-transform: uppercase; }
#debug .dbg-head span { color: var(--dim); }
#debug details { border-top: 1px solid rgba(255,255,255,.08); padding: 4px 0; }
#debug summary { cursor: pointer; color: var(--accent2); text-transform: lowercase; letter-spacing: .06em; padding: 3px 0; }
#debug .dbg-body { padding: 2px 0 4px; }
#debug .dbg-row { display: flex; justify-content: space-between; gap: 8px; color: var(--dim); }
#debug .dbg-row b { color: var(--ink); font-weight: 500; text-align: right; }
#debug .dbg-slider { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; margin: 4px 0; color: var(--dim); }
#debug .dbg-slider output { color: var(--ink); }
#debug .dbg-slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 0; height: 14px; }
#debug .dbg-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
#debug .dbg-buttons button { font: inherit; font-size: 10.5px; padding: 4px 7px; border-radius: 4px; }
