:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #11141b;
  color: #eef1f7;
  --border: #303544;
  --accent: #a9e978;
  --muted: #aeb7c8;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
.shell { max-width: 76rem; margin: 0 auto; padding: clamp(1rem, 4vw, 3rem); }
header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0 0 1.25rem; }
.brand { margin: 0 0 .4rem; color: var(--accent); font-size: .875rem; font-weight: 700; }
h1 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.35rem); letter-spacing: -.035em; }
.status { flex-shrink: 0; margin: 0; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .5rem; color: var(--muted); font-size: .85rem; }
.status[data-state="connected"] { color: var(--accent); }
.status[data-state="ended"] { color: #f5b09d; }
.keytime { flex-shrink: 0; margin: 0; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .5rem; color: var(--muted); font-size: .85rem; }
.keytime[data-warn="true"] { color: #f5b09d; border-color: #f5b09d; font-weight: 700; }
.join { border: 1px solid var(--border); border-radius: .8rem; background: #181c25; padding: 1rem; margin: 0 0 1.25rem; }
.join label { display: block; margin: 0 0 .5rem; font-weight: 600; }
.join-row { display: flex; gap: .6rem; }
.join-row input { flex: 1; min-width: 0; min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid var(--border); border-radius: .55rem; background: #090b10; color: inherit; font: inherit; }
.join-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.join-error { margin: .6rem 0 0; color: #f5b09d; }
.join-error:empty { display: none; }
.workspace { border: 1px solid var(--border); border-radius: .8rem; overflow: hidden; background: #181c25; }
.display { position: relative; display: grid; place-items: center; height: min(72dvh, 54rem); min-height: 15rem; background: #090b10; touch-action: none; }
.display video, .display img { width: 100%; height: 100%; min-height: 0; object-fit: contain; user-select: none; }
.display[data-controlling="true"] { cursor: default; }
/* In fullscreen the display must fill the screen: the author height
   (72dvh) would otherwise override the UA's fullscreen sizing and
   leave the picture boxed in the middle of a black screen. */
.display:fullscreen, .display:-webkit-full-screen { width: 100%; height: 100%; }
.stage:fullscreen, .stage:-webkit-full-screen { width: 100%; height: 100%; overflow-y: auto; }
.stage[data-mode="list"]:fullscreen iframe, .stage[data-mode="list"]:fullscreen .open-tile, .stage[data-mode="list"]:fullscreen .watch-tile { height: 100%; }
/* The single-machine fullscreen target is the whole workspace, so
   the control buttons stay reachable in fullscreen too; the display
   flexes to fill whatever the buttons leave. */
.workspace:fullscreen, .workspace:-webkit-full-screen { display: flex; flex-direction: column; width: 100%; height: 100%; background: #181c25; }
.workspace:fullscreen .display { flex: 1; height: auto; min-height: 0; }
/* iPhone fallback when no fullscreen API exists at all: a fixed
   fill that keeps the touch surface and the buttons on screen. */
.workspace.pseudo-fullscreen { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; width: 100%; height: 100dvh; background: #181c25; }
.workspace.pseudo-fullscreen .display { flex: 1; height: auto; min-height: 0; }
/* In fullscreen the buttons float over the picture's bottom edge
   instead of taking a row of their own, so the game gets the full
   height of the screen — and they auto-hide after a few seconds,
   because the game's own navigation sits on that same edge. A
   small pill at the top centre (the least UI-dense spot) brings
   them back. */
.workspace:fullscreen .controls, .workspace:-webkit-full-screen .controls, .workspace.pseudo-fullscreen .controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; border-top: 0; background: rgba(24, 28, 37, .92); padding-bottom: calc(.7rem + env(safe-area-inset-bottom)); transition: opacity .25s ease, transform .25s ease; }
.workspace:fullscreen[data-controls="hidden"] .controls, .workspace:-webkit-full-screen[data-controls="hidden"] .controls, .workspace.pseudo-fullscreen[data-controls="hidden"] .controls { opacity: 0; pointer-events: none; transform: translateY(30%); }
#fs-menu { display: none; }
.workspace:fullscreen #fs-menu, .workspace:-webkit-full-screen #fs-menu, .workspace.pseudo-fullscreen #fs-menu { display: block; position: absolute; top: calc(.5rem + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 6; min-height: 2rem; padding: .2rem .95rem; border-radius: 999px; background: rgba(24, 28, 37, .55); letter-spacing: .15em; }
.notice { position: absolute; max-width: 28rem; margin: 1rem; padding: .75rem 1rem; border-radius: .5rem; background: #191f2b; color: var(--muted); line-height: 1.4; text-align: center; pointer-events: none; }
.controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding: .7rem; border-top: 1px solid var(--border); }
.xep-gach { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .75rem; }
#xep-gach-status { color: var(--muted); font-size: .85rem; }
#xep-gach-status[data-state="on"] { color: var(--accent); }
button { min-height: 2.75rem; padding: .55rem .95rem; border: 1px solid var(--border); border-radius: .55rem; background: #222837; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
button:hover:enabled { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { color: #788095; cursor: default; }
[hidden] { display: none !important; }

.machines { border: 1px solid var(--border); border-radius: .8rem; overflow: hidden; background: #181c25; }
.machines-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; padding: .6rem .7rem; border-bottom: 1px solid var(--border); }
.machine-tabs { display: flex; flex-wrap: wrap; gap: .45rem; }
.machine-tab { min-height: 2.4rem; display: inline-flex; align-items: center; gap: .45rem; }
.machine-tab[data-active="true"] { border-color: var(--accent); color: var(--accent); }
.dot { width: .55rem; height: .55rem; border-radius: 50%; background: #788095; flex-shrink: 0; }
.dot[data-live="true"] { background: var(--accent); }
.dot[data-busy="true"] { background: #f5b09d; }
.machines-actions { display: flex; gap: .45rem; }
.machines-actions button[data-active="true"] { border-color: var(--accent); color: var(--accent); }
.stage { background: #090b10; }
.stage iframe { display: block; width: 100%; border: 0; background: #090b10; }
.stage[data-mode="list"] iframe, .stage[data-mode="list"] .open-tile, .stage[data-mode="list"] .watch-tile { height: min(74dvh, 56rem); }
.stage[data-mode="grid"] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 2px; }
.stage[data-mode="grid"] iframe, .stage[data-mode="grid"] .open-tile, .stage[data-mode="grid"] .watch-tile { height: min(52dvh, 34rem); }
.open-tile { display: grid; place-items: center; align-content: center; gap: .8rem; padding: 1rem; background: #090b10; color: var(--muted); text-align: center; }
.open-tile p { margin: 0; line-height: 1.45; }
.watch-tile { position: relative; display: grid; place-items: center; background: #090b10; color: var(--muted); text-align: center; overflow: hidden; }
.watch-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.watch-tile p { position: relative; margin: 0; padding: .4rem .6rem; background: rgba(9, 11, 16, .72); line-height: 1.45; }
.watch-tile button { position: relative; margin-top: .5rem; }

body.embed .shell { max-width: none; padding: 0; }
body.embed header, body.embed .join, body.embed .machines { display: none; }
body.embed .workspace { display: flex; flex-direction: column; height: 100dvh; border: 0; border-radius: 0; }
body.embed .display { flex: 1; height: auto; min-height: 0; }

@media (max-width: 32rem) {
  header { align-items: start; flex-direction: column; gap: .6rem; }
  .display { height: 67dvh; }
  body.embed .display { height: auto; }
}

/* Seamless keyboard: the catcher is never seen — it only holds
   focus so the buyer's own keyboard (or phone keyboard, after a
   long press on the picture) types straight into the game. */
.kb-hint { margin: .35rem 0 0; font-size: .8rem; color: var(--muted, #aeb7c8); }
#kb-catcher { position: fixed; left: 4px; bottom: 4px; width: 8px; height: 8px; opacity: 0; border: 0; padding: 0; pointer-events: none; }
.keyrenew { flex-shrink: 0; margin: 0; font-size: .85rem; }
.keyrenew a { color: #f5b09d; font-weight: 700; }
.lang-toggle { float: right; min-height: 2rem; padding: .3rem .7rem; }
