/* Styles for the login and controller (phone) pages. The TV page has its own, scoped host.css. Plain CSS, old-browser friendly. */
:root {
  --bg: #0b1020;
  --panel: #111a2e;
  --line: #24314d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #22c55e;
  --good: #4ade80;
  --ok: #facc15;
  --bad: #f87171;
  --me: #64748b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2 { margin: 0 0 8px; line-height: 1.15; }
a { color: #93c5fd; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.good { color: var(--good); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.dim { color: #475569; }
.error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: #052e16; border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; }
button.primary:disabled { background: #334155; color: #94a3b8; cursor: default; }
button.primary:focus-visible, .link-button:focus-visible { outline: 4px solid #93c5fd; outline-offset: 3px; }
button.big { font-size: 1.25em; padding: 16px 28px; width: 100%; }
button.secondary { background: #1e293b; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 20px; font-weight: 700; }
button.secondary:disabled { color: var(--muted); cursor: default; }
button.secondary:focus-visible { outline: 4px solid #93c5fd; outline-offset: 3px; }
.link-button { background: none; border: 0; color: #93c5fd; padding: 8px; text-decoration: underline; }
label { display: block; margin: 0 0 14px; color: var(--muted); }
input { display: block; width: 100%; margin-top: 6px; padding: 12px; font: inherit; font-size: 1.1em; color: var(--text); background: #0b1222; border: 1px solid var(--line); border-radius: 10px; }
.dot { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; margin-right: 0.5em; vertical-align: -0.05em; }

/* ---------------------------------------------------------------- login */
.page-login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 420px; }
.login-or { display: flex; align-items: center; gap: 10px; color: #64748b; font-size: 0.85em; margin: 4px 0 12px; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: #24314d; }
#play-anonymous { width: 100%; }

/* ---------------------------------------------------------------- controller (phone) */
.page-controller { overflow: hidden; position: fixed; top: 0; right: 0; bottom: 0; left: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.page-controller input { -webkit-user-select: text; user-select: text; }
/* Turned controller (ADR 0005, src/client/controller/turn.ts): when a game's orientation differs from
   the page's shape, the whole page turns a quarter turn; turn.ts sets its size and transform. The
   layout rules below key on .wide / .tall (the controller's shape), not on the phone's orientation,
   and use --cw / --ch (the controller's width and height) instead of vw / vh. */
.turnable.turned { right: auto; bottom: auto; -webkit-transform-origin: 0 0; transform-origin: 0 0; }
.turn-hint { position: absolute; left: 50%; top: 50%; z-index: 9; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); padding: 14px 22px; border-radius: 16px; background: rgba(5, 8, 18, 0.9); border: 2px solid var(--me); color: #fff; font-weight: 800; font-size: 1.1em; text-align: center; white-space: nowrap; pointer-events: none; opacity: 1; -webkit-transition: opacity 0.4s; transition: opacity 0.4s; }
.turn-hint::before { content: ""; display: block; width: 16px; height: 28px; margin: 2px auto 12px; border: 3px solid var(--me); border-radius: 5px; -webkit-animation: turn-hint-phone 1.2s ease-in-out infinite; animation: turn-hint-phone 1.2s ease-in-out infinite; }
@-webkit-keyframes turn-hint-phone { 0%, 20% { -webkit-transform: rotate(90deg); } 60%, 100% { -webkit-transform: rotate(0deg); } }
@keyframes turn-hint-phone { 0%, 20% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0deg); } }
.turn-hint.turn-hint-out { opacity: 0; }
.page-controller #join { touch-action: auto; }
.screen { position: absolute; top: 44px; left: 0; right: 0; bottom: 0; }
#join.screen { top: 0; }
.center { display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; }
.center .card { width: 100%; max-width: 440px; }
.join-form { text-align: left; }
.bar { position: absolute; top: 0; left: 0; right: 0; height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); background: #0e1527; border-bottom: 3px solid var(--me); z-index: 5; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--me); }
/* Two equal sides keep End game in the middle of the bar; the right side never shrinks below its buttons. */
.bar-side { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; }
.bar-end { min-width: -webkit-min-content; min-width: min-content; justify-content: flex-end; }
.bar b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { width: 12px; height: 12px; border-radius: 50%; background: #475569; }
.link.good { background: var(--good); }
.link.ok { background: var(--ok); }
.link.bad { background: var(--bad); }
.bar-button { flex: none; white-space: nowrap; background: #1e293b; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; min-width: 36px; }
.bar-button:focus-visible { outline: 4px solid #93c5fd; outline-offset: 2px; }
.bar-button.open { outline: 4px solid #93c5fd; outline-offset: 1px; }
/* Take control lives here, not as a sticky catalog button. One row, over the catalog. */
.take-menu { position: absolute; top: 44px; right: max(10px, env(safe-area-inset-right)); z-index: 7; width: 220px; max-width: calc(100% - 20px); padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45); }
.take-menu::before { content: ""; position: absolute; top: -5px; right: 18px; width: 8px; height: 8px; background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line); -webkit-transform: rotate(45deg); transform: rotate(45deg); }
.take-menu button { display: block; width: 100%; min-height: 44px; background: #1e293b; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-weight: 700; }
.take-menu button:disabled { background: transparent; color: var(--muted); cursor: default; }
.take-menu button:focus-visible { outline: 4px solid #93c5fd; outline-offset: 2px; }
.page-controller.fs-note .take-menu { top: calc(44px + var(--fs-note-h, 0px)); }
.fullscreen-note { position: absolute; top: 44px; left: 0; right: 0; z-index: 6; margin: 0; padding: 6px 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); background: rgba(5, 8, 18, 0.92); color: #fde68a; font-size: 14px; line-height: 1.35; text-align: center; pointer-events: none; }
.fullscreen-note.in-overlay { position: static; z-index: auto; max-width: 18em; padding: 0 8px; background: transparent; }
.page-controller.fs-note .screen:not(#join) { top: calc(44px + var(--fs-note-h, 0px)); }
.page-controller.fs-note .phone-diag { top: calc(44px + var(--fs-note-h, 0px)); }
.page-controller.fs-note.fs-diag .screen:not(#join) { top: calc(44px + var(--fs-note-h, 0px) + var(--fs-diag-h, 0px)); }
/* Hold to end: fills with red over --hold-ms (set by hold.ts); letting go empties it quickly. */
#end-game { color: var(--bad); border-color: var(--bad); padding: 4px 14px; background-image: linear-gradient(var(--bad), var(--bad)); background-repeat: no-repeat; background-size: 0% 100%; -webkit-transition: background-size 0.15s ease-out, color 0.15s; transition: background-size 0.15s ease-out, color 0.15s; touch-action: none; }
#end-game.holding { color: #fff; background-size: 100% 100%; -webkit-transition: background-size var(--hold-ms, 3s) linear, color 0.3s; transition: background-size var(--hold-ms, 3s) linear, color 0.3s; }
.phone-diag { position: absolute; top: 44px; left: 0; right: 0; z-index: 4; background: rgba(5, 8, 18, 0.9); padding: 6px 10px; font: 11px/1.4 ui-monospace, Menlo, monospace; pointer-events: none; }
.you { font-size: 1.15em; margin: 0 0 10px; }
.you b { color: var(--me); }
/* catalog: scrolls, unlike the controller screens */
.catalog { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.catalog-inner { max-width: 480px; margin: 0 auto; padding: 14px 14px 0; }
.catalog h1 { font-size: 1.4em; }
.catalog h3 { margin: 12px 0 4px; font-size: 0.95em; }
.notice { background: #7f1d1d; border-radius: 10px; padding: 8px 12px; font-weight: 700; }
.status { background: #1e3a8a; border-radius: 10px; padding: 8px 12px; font-weight: 700; }
#cat-asking-line { margin: -4px 0 10px; }
/* "Take control": the main player's banner keeps the game list usable underneath */
.keep-banner { position: -webkit-sticky; position: sticky; top: 0; z-index: 2; margin: 0 0 10px; padding: 10px 12px; background: #1e3a8a; border-radius: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45); }
.keep-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.keep-head b { color: #facc15; }
.asking { margin: 0; font-weight: 700; }
.count { font: 900 44px/1 ui-monospace, Menlo, monospace; color: #facc15; margin: 6px 0 2px; }
.cat-links { display: flex; flex-wrap: wrap; justify-content: space-between; }
.cat-links .link-button { margin: 2px 0; }
.game-detail.faded { opacity: 0.6; }
.sheet { position: absolute; top: 44px; left: 0; right: 0; bottom: 0; z-index: 6; padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; background: rgba(11, 16, 32, 0.94); }
.sheet-card { max-width: 480px; margin: 0 auto; padding: 16px; }
.roster { list-style: none; margin: 0 0 14px; padding: 0; }
.roster li { display: flex; align-items: center; gap: 8px; min-height: 48px; border-bottom: 1px solid var(--line); }
.roster-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster li.offline .roster-name { color: #64748b; }
.roster .tag { font-size: 0.7em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.roster .remove { background: #1e293b; color: var(--bad); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-weight: 700; }
.roster .remove.armed { background: #7f1d1d; border-color: #7f1d1d; color: #fff; }
.game-list { list-style: none; margin: 0 0 12px; padding: 0; }
.game-row { display: flex; width: 100%; align-items: center; gap: 12px; margin: 0 0 8px; padding: 6px; border: 2px solid transparent; border-radius: 12px; background: var(--panel); color: var(--text); text-align: left; }
.game-row.selected { border-color: #facc15; }
.game-row.unfit { opacity: 0.5; }
.game-row img { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: #1e293b; flex: none; }
.game-row b { display: block; }
.game-row small { color: var(--muted); }
.game-detail { padding: 16px; }
.detail-cover { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: #1e293b; }
.game-detail h2 { font-size: 1.5em; margin-bottom: 2px; }
.controls { list-style: none; padding: 0; margin: 0; color: var(--muted); }
.controls b { color: var(--text); margin-right: 6px; }
.seat { margin: 12px 0 0; color: #facc15; }
.cat-actions { position: -webkit-sticky; position: sticky; bottom: 0; padding: 12px 0 14px; background: var(--bg); text-align: center; }
.badge { display: inline-block; background: #facc15; color: #422006; font-size: 0.65em; font-weight: 800; text-transform: uppercase; border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 0.15em; }
.pad { display: flex; }
.stick-zone { position: relative; flex: 1; border-right: 1px dashed #1e293b; touch-action: none; }
.stick-base { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid #334155; opacity: 0.5; pointer-events: none; }
.stick-base.active { opacity: 1; border-color: var(--me); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; transform: translate(-50%, -50%); border-radius: 50%; background: var(--me); opacity: 0.9; }
.buttons { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6vw; gap: calc(var(--cw, 100vw) * 0.06); padding: 16px; touch-action: none; }
.pad-button { width: min(34vw, 34vh); height: min(34vw, 34vh); max-width: 200px; max-height: 200px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.25); background: var(--me); color: #fff; font-size: 1.4em; font-weight: 800; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); touch-action: none; }
/* Three or four gamepad buttons: a 2×2 grid in listed order, a wider button side. */
.pad.many .buttons { flex: 1.3; display: grid; grid-template-columns: 1fr 1fr; align-content: center; justify-items: center; gap: 3vmin; padding: 12px 10px 26px; }
.pad.many .pad-button { width: min(23vw, 38vh); height: min(23vw, 38vh); width: min(calc(var(--cw, 100vw) * 0.23), calc(var(--ch, 100vh) * 0.38)); height: min(calc(var(--cw, 100vw) * 0.23), calc(var(--ch, 100vh) * 0.38)); max-width: 170px; max-height: 170px; font-size: 1.15em; line-height: 1.1; }
.pad.many .buttons.count-3 .pad-button:last-child { grid-column: 2; }
/* Thumb cluster (gamepad buttons with sizes): src/client/controller/cluster.ts places each button. */
.pad.clustered .buttons { flex: 1.25; }
.tall .pad.clustered .buttons { flex: 1.5; }
.buttons.cluster { position: relative; display: block; padding: 0; }
.buttons.cluster .pad-button { position: absolute; max-width: none; max-height: none; padding: 0 6px; line-height: 1.1; overflow-wrap: break-word; }
.buttons.cluster .pad-button.size-large { border-width: 5px; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08), 0 6px 18px rgba(0, 0, 0, 0.45); }
.buttons.cluster .pad-button:not(.size-large) { filter: brightness(0.82); }
.buttons.cluster .pad-button.down { filter: brightness(1.3); }
.big-buttons { display: flex; align-items: center; justify-content: center; padding: 16px; }
.big-grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4vmin; width: 100%; height: 100%; touch-action: none; }
.big-grid .pad-button { width: 40vmin; height: 40vmin; max-width: 260px; max-height: 260px; }
.big-grid.count-1 .pad-button { width: 70vmin; height: 70vmin; max-width: 420px; max-height: 420px; font-size: 2.2em; }
.pad-button.down { transform: scale(0.92); filter: brightness(1.3); border-color: #fff; }
.pad-hint { position: absolute; left: 0; right: 0; bottom: 6px; margin: 0; text-align: center; color: #475569; font-size: 13px; pointer-events: none; }
/* Display square (gamepad and buttons controllers): what the player has, at a glance. Takes no touches. */
.display { position: absolute; z-index: 1; width: 32vmin; height: 32vmin; max-width: 160px; max-height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px; border-radius: 14px; border: 3px solid var(--me); background: #0e1527; pointer-events: none; text-align: center; }
.display-pic { display: block; flex: 0 1 auto; width: 64%; height: 64%; min-height: 0; object-fit: contain; }
.display-caption { display: block; max-width: 100%; max-height: 2.3em; margin-top: 2px; overflow: hidden; font-weight: 800; font-size: 13px; font-size: max(11px, 3.4vmin); line-height: 1.15; color: #fff; }
.display-mark { position: absolute; top: 4%; right: 7%; font-weight: 900; font-size: 18px; font-size: max(14px, 5vmin); line-height: 1; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000; }
.display.look-busy { border-style: dashed; }
.display.look-empty { border: 3px dashed #334155; background: transparent; }
.display.look-empty .display-caption { color: #64748b; margin-top: 0; }
.display.look-alert { border-color: #facc15; }
.display.look-alert .display-caption { color: #fde047; }
/* Gamepad: in the stick area, against the divider (a thumb on it still steers); upright, above the buttons. */
.pad .display { top: 50%; right: 50%; margin-right: 3vmin; -webkit-transform: translateY(-50%); transform: translateY(-50%); }
/* Against the divider when the button side is wider: thumb cluster (flex 1.25) and 2×2 grid (1.3). */
.wide .pad.clustered .display { right: 55.56%; }
.wide .pad.many .display { right: 56.52%; }
.tall .pad .display { top: 10px; right: auto; left: 75%; margin-right: 0; width: 22vmin; height: 22vmin; -webkit-transform: translateX(-50%); transform: translateX(-50%); }
/* The thumb cluster sits low, leaving the top of the button side free for a bigger square. */
.tall .pad.clustered .display { left: 70%; width: 30vmin; height: 30vmin; }
/* Buttons: beside the buttons when the phone is sideways, above them when upright. */
.big-buttons .display { position: relative; flex: none; margin: 0 3vmin 0 0; }
.big-buttons.with-display .big-grid { width: auto; flex: 1; min-width: 0; }
.tall .big-buttons.with-display { flex-direction: column; }
.tall .big-buttons .display { margin: 0 0 3vmin; width: 24vmin; height: 24vmin; }
.tall .big-buttons.with-display .big-grid { width: 100%; height: auto; min-height: 0; }
/* A game's own phone view (ADR 0004). The game's root cuts off inheritance like the TV's game root:
   the game styles itself (scoped .game-<id>); the kit parts below are the platform's defaults. */
.view-screen { overflow: hidden; }
.view-stage { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.phone-root { all: initial; display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.view-cover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; background: var(--bg); color: var(--text); font-weight: 700; font-size: 1.15em; }
.view-cover.cover-loading .view-cover-text::before { content: ""; display: block; width: 36px; height: 36px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--me); -webkit-animation: view-spin 0.9s linear infinite; animation: view-spin 0.9s linear infinite; }
.view-cover.cover-stopped .view-cover-text { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 24px; max-width: 20em; }
@-webkit-keyframes view-spin { to { -webkit-transform: rotate(360deg); } }
@keyframes view-spin { to { transform: rotate(360deg); } }
.kit-stick-zone { position: relative; touch-action: none; }
.kit-stick-base { position: absolute; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid #334155; opacity: 0.5; pointer-events: none; box-sizing: border-box; }
.kit-stick-base.active { opacity: 1; border-color: var(--me); }
.kit-stick-knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); border-radius: 50%; background: var(--me); opacity: 0.9; }
.kit-button { touch-action: none; }
.overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 8; display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; padding: 24px; text-align: center; background: rgba(11, 16, 32, 0.92); font-size: 1.2em; }
.flash { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 7; pointer-events: none; opacity: 0; }
.flash.on { animation: flash 0.6s ease-out; }
@keyframes flash { from { opacity: 0.55; } to { opacity: 0; } }
