/* Phone controller (Pantouflard). Safari 14.1+ and Android Chrome: no aspect-ratio (padding boxes
   instead), no :has(), no dvh. */
:root {
  --bg: #25132f;
  --panel: #3a1f4a;
  --line: #553069;
  --text: #fbf3ff;
  --muted: #c4aed4;
  --accent: #4fd1c5;
  --warm: #f6ad55;
  --cream: #f3eee3;
  --good: #68d391;
  --bad: #fc8181;
  /* Text on light colours (cream, accents, avatars). */
  --ink: #0f1530;
  /* The running (or selected) game's accent; set by phone.ts from GameInfo.accent. */
  --game: #4fd1c5;
  --display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --hand: 'Caveat', 'Bradley Hand', 'Chalkboard SE', cursive;
  --mono: 'DM Mono', Menlo, 'Roboto Mono', monospace;
  /* Side margins: clear of the notch and the rounded corners in landscape (viewport-fit=cover). */
  --edge-l: max(16px, env(safe-area-inset-left));
  --edge-r: max(16px, env(safe-area-inset-right));
  /* Tablets and computers: the lobby's width (shelf, header, start bar), and the narrower column
     the settings, the guest's lobby and a game's screens keep to instead of stretching edge to edge. */
  --lobby-max: 1080px;
  --column-max: 720px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--display);
  font-size: 17px;
  touch-action: manipulation;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 15px; min-width: 0; font-size: 18px;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
button { border: 0; border-radius: 14px; padding: 13px 16px; cursor: pointer; }
button:disabled { opacity: .4; }
.primary { background: var(--accent); color: var(--ink); font-weight: 700; }
.secondary { background: var(--panel); border: 1px solid var(--line); }
.danger { background: transparent; border: 1px solid var(--bad); color: var(--bad); }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.tight { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.wide { width: 100%; max-width: 420px; }
.label { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; }
.note { color: var(--muted); margin: 16px 0; }
/* Titles often hold a player's name: a long one (16 wide letters) wraps instead of widening the screen. */
.title { font-size: 22px; font-weight: 600; text-align: center; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
/* The host's handwritten asides. */
.aside { font-family: var(--hand); font-weight: 700; letter-spacing: 0; text-transform: none; }
.mono { font-family: var(--mono); }
.big-button { width: 100%; padding: 16px; font-size: 20px; font-weight: 800; }

.screen { padding: max(16px, env(safe-area-inset-top)) var(--edge-r) max(16px, env(safe-area-inset-bottom)) var(--edge-l); }
.wordmark { font-size: 52px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.wordmark-dot { color: var(--accent); }
.tagline { font-size: 24px; color: var(--warm); }
/* « Bêta gratuite jusqu'au 30 novembre » on the join screen, while the beta runs (src/shared/beta.ts). */
.beta-badge { display: inline-block; margin-top: 8px; padding: 3px 12px; border: 2px solid var(--accent); border-radius: 999px; color: var(--accent); font-weight: 700; font-size: 15px; }
.beta-badge[hidden] { display: none; }

/* Avatars (src/client/common/avatar.ts): a mascot on a circle of the player's colour, or their initial. */
.avatar { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; color: var(--ink); font-weight: 800; line-height: 1; vertical-align: middle; }
.avatar-img { position: absolute; left: 4%; top: 4%; width: 92%; height: 92%; object-fit: contain; }
.avatar.more { background: var(--panel); color: var(--text); font-weight: 600; }
.avatar-stack { display: inline-flex; align-items: center; }
/* Game covers (src/client/common/art.ts), on a gradient of the game's accent when the art is missing. */
.cover { position: relative; border-radius: 10px; }
.cover-img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
/* 16:9 like the art itself (960×540), as a padding box (Safari 14 has no aspect-ratio). */
.cover.ratio { height: 0; padding-top: 56.25%; }

/* ---------- Join ---------- */
.screen.join {
  min-height: 100vh; display: flex; flex-direction: column; gap: 18px; padding-top: max(60px, env(safe-area-inset-top));
  /* The couch art at 70%: a light veil of the background colour over it. */
  background: linear-gradient(rgba(37, 19, 47, .3), rgba(37, 19, 47, .3)), url(/art/phone.jpg?v=a93b017b13) center top / cover no-repeat var(--bg);
}
@supports (-webkit-touch-callout: none) { .screen.join { min-height: -webkit-fill-available; } }
.join-top { text-align: center; }
.join-card { margin-top: auto; width: 100%; max-width: 440px; align-self: center; background: var(--panel); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.join-card .label { margin: 0; }
.join-card input { font-size: 20px; }

/* The mascot picker: ten circles, taken ones dimmed. */
.mascots { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.mascot { position: relative; width: 100%; height: 0; padding: 100% 0 0; background: none; border-radius: 50%; }
.mascot .avatar { position: absolute; left: 0; top: 0; width: 100% !important; height: 100% !important; font-size: 20px !important; }
.mascot.on .avatar { box-shadow: 0 0 0 3px var(--panel), 0 0 0 6px var(--text); }
.mascot:disabled { opacity: .3; }
.mascots.small { max-width: 320px; margin-top: 8px; }

/* ---------- Lobby ---------- */
.screen.lobby { min-height: 100vh; display: flex; flex-direction: column; }
/* On a tablet or a computer the lobby is a centred column: the shelf as wide as --lobby-max, the
   settings and the guest's view as --column-max (nothing changes on phones). */
.lobby-head, #host-panel > .tabs, #host-panel > .shelf { width: 100%; max-width: var(--lobby-max); margin-left: auto; margin-right: auto; }
.me-card, #guest-panel, .host-settings, .screen.lobby:not(.hosting) .lobby-head, .screen.lobby:not(.hosting) .rating { width: 100%; max-width: var(--column-max); margin-left: auto; margin-right: auto; }
.lobby-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.lobby-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.icon-button { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.icon-button.on { background: var(--accent); color: var(--ink); }
.me-button { flex: none; width: 48px; height: 48px; padding: 0; border-radius: 50%; background: none; }
.me-card { margin-top: 0; margin-bottom: 12px; }
.me-card .row { margin: 8px 0 4px; }
.me-card .leave { display: block; margin: 10px auto 2px; }
.me-card .danger.leave { width: 100%; font-weight: 700; }
/* The host's "pass the host role" list: a player's chip, and the button to make them host. */
.pass-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pass-row .chip { min-width: 0; }
.pass-row button { flex: none; min-height: 40px; padding: 8px 14px; font-size: 15px; }
.lobby-title { min-width: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
#lobby-stack { align-self: flex-start; }
#guest-panel { display: flex; flex-direction: column; }
#host-panel { flex: 1; display: flex; flex-direction: column; }
.waiting { font-size: 26px; text-align: center; margin: 18px 0 4px; overflow-wrap: anywhere; word-break: break-word; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* Never wider than the screen: a long name (16 wide letters) ends in an ellipsis, a long word wraps. */
.chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; background: var(--panel); border-radius: 20px; padding: 6px 14px 6px 6px; overflow-wrap: anywhere; word-break: break-word; }
.chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .tag { flex: none; white-space: nowrap; }
.chip.away { opacity: .45; }
.chip.me { box-shadow: 0 0 0 2px var(--accent); }
.chip .x { background: none; padding: 0 0 0 6px; color: var(--muted); font-size: 18px; }
#word-list .chip { padding-left: 12px; }
.dot { width: 16px; height: 16px; border-radius: 50%; flex: none; display: inline-block; }
.tag { font-size: 11px; font-weight: 600; color: var(--warm); text-transform: uppercase; letter-spacing: .08em; }

/* "Next up" (guests). */
.next-card { display: flex; gap: 12px; align-items: center; background: var(--panel); border-radius: 16px; padding: 10px; border-left: 6px solid var(--game); }
.next-card .cover { width: 112px; height: 63px; flex: none; border-radius: 8px; }
.next-text { min-width: 0; }
.next-label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--game); }
.next-name { font-size: 22px; font-weight: 800; line-height: 1.1; }
.next-desc { font-size: 14px; color: var(--muted); margin-top: 2px; }

/* Filter tabs and the game shelf (host). */
.tabs { display: flex; gap: 6px; background: var(--panel); border-radius: 12px; padding: 4px; font-size: 15px; }
.tabs button { flex: 1; padding: 8px 4px; border-radius: 9px; background: transparent; color: var(--muted); }
.tabs button.on { background: var(--accent); color: var(--ink); font-weight: 600; }
/* Two cards a row on phones, more as the screen widens, so a card stays about phone size (170–230 px)
   on a tablet or a computer instead of growing to half the screen. Every filter keeps the same card size. */
.shelf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 0; align-content: start; }
.shelf-card { display: block; width: 100%; padding: 0; text-align: left; background: var(--panel); border-radius: 14px; }
.shelf-card .cover { border-radius: 14px 14px 0 0; }
.shelf-card.on { box-shadow: 0 0 0 3px var(--card-accent, var(--accent)); }
.shelf-text { padding: 8px 10px 10px; }
.shelf-name { font-size: 16px; font-weight: 800; line-height: 1.15; }
.shelf-min { font-size: 12px; color: var(--muted); margin-top: 2px; }
@media (min-width: 600px) {
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .shelf-name { font-size: 17px; }
}
@media (min-width: 780px) { .shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .shelf { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.host-settings { padding-bottom: 14px; }
.host-settings .card:first-child { margin-top: 0; }
.card { background: var(--panel); border-radius: 16px; padding: 12px 14px; margin-top: 12px; }
.card summary { font-weight: 600; cursor: pointer; padding: 10px 0; margin: -6px 0; }
.card[open] summary { margin-bottom: 6px; }
.card-title { font-weight: 800; font-size: 18px; margin: 2px 0 4px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { min-height: 40px; padding: 8px 12px; border-radius: 8px; background: transparent; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--ink); font-weight: 600; }
#word-list { margin-top: 12px; }
#tv-list { margin-top: 10px; }

/* Edge to edge (over the screen's side padding), its content lined up with the lobby's column. */
.start-bar {
  position: sticky; bottom: 0; z-index: 5;
  margin: auto calc(-1 * var(--edge-r)) 0 calc(-1 * var(--edge-l));
  padding: 12px max(var(--edge-r), calc(var(--edge-r) + 50% - var(--lobby-max) / 2)) max(14px, env(safe-area-inset-bottom)) max(var(--edge-l), calc(var(--edge-l) + 50% - var(--lobby-max) / 2));
  background: var(--bg); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px;
}
/* Wider screens (tablets, a phone on its side): the summary and the button on one line, so the
   bar takes less of the height. */
@media (min-width: 640px) {
  .start-bar { flex-direction: row; align-items: center; gap: 16px; }
  .start-summary { flex: 1; min-width: 0; }
  .start-bar #start { flex: none; width: auto; min-width: 300px; max-width: 50%; }
}
.screen.lobby.hosting { padding-bottom: 0; }
.start-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
#start-summary { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#start-summary.warn { color: var(--warm); }
.link-button { flex: none; background: none; padding: 4px 0; color: var(--accent); font-size: 14px; font-weight: 600; border-radius: 0; }
#start { background: var(--game); color: var(--ink); }

/* ---------- Get ready (the TV plays the game's intro) ---------- */
.screen.intro { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; border-top: 4px solid var(--game); }
.intro-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px; border-bottom: 6px solid var(--game); }
.intro-card .cover { border-radius: 20px 20px 0 0; }
.intro-text { padding: 14px 18px 18px; }
.intro-kicker { font-size: 28px; line-height: 1; color: var(--warm); }
.intro-name { font-size: 32px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; margin-top: 4px; }
.intro-desc { font-size: 16px; color: var(--muted); margin-top: 6px; line-height: 1.3; }
.intro-watch { font-size: 24px; color: var(--muted); }
.intro-host { width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }
.intro-host #skip-intro { background: var(--game); }
/* A tablet or a computer: a bigger card (it still fits the screen's height). */
@media (min-width: 700px) and (min-height: 700px) {
  .intro-card, .intro-host { max-width: 520px; }
  .intro-name { font-size: 38px; }
  .intro-desc { font-size: 18px; }
}

/* ---------- Drawing pad (src/client/common/pad.ts) ---------- */
.pad { display: flex; flex-direction: column; gap: 12px; }
/* min-width 0: in landscape the box may shrink below the canvas it holds (a window made narrower),
   so the canvas refits instead of pushing the tools off the screen. */
.pad-box { width: 100%; min-width: 0; display: flex; justify-content: center; }
.pad-canvas { background: #fff; border-radius: 10px; touch-action: none; display: block; }
.tools { display: flex; flex-direction: column; gap: 12px; }
/* Round swatches as wide as their column (at least 44 px on phones). */
.palette { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; max-width: 440px; }
.swatch { width: 100%; height: 0; padding: calc(100% - 4px) 0 0; border-radius: 50%; border: 2px solid rgba(251, 243, 255, .18); }
.swatch.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.sizes { display: flex; gap: 8px; }
.size { width: 48px; height: 48px; border-radius: 12px; background: var(--panel); display: flex; align-items: center; justify-content: center; padding: 0; }
.size.on, .tool.on { box-shadow: inset 0 0 0 2px var(--accent); }
.size span { background: var(--text); border-radius: 50%; display: block; }
.tool { background: var(--panel); flex: 1; padding: 13px 8px; font-size: 15px; }
.rotate { display: none; color: var(--muted); font-size: 14px; text-align: center; margin-top: 10px; }
@media (orientation: portrait) { .rotate { display: block; } }
@media (orientation: landscape) {
  .pad { flex-direction: row; align-items: flex-start; }
  .pad-box { flex: 1; }
  .tools { width: 250px; flex: none; }
  .palette { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* 250 px can't hold the sizes, Eraser and Undo side by side: sizes on their own line. */
  .tools .row { flex-wrap: wrap; }
  .tools .sizes { flex-basis: 100%; }
  .tools .tool { min-width: 0; }
}

/* ---------- A running game ---------- */
.screen.game { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 4px solid var(--game); }
/* Tablets and computers: a game's phone screens keep to a column instead of stretching edge to
   edge. Games that draw (phone.ts adds .pads once a game makes a pad) keep the whole width. */
#game-root, .game-menu { max-width: var(--column-max); margin-left: auto; margin-right: auto; }
.screen.game.pads #game-root, .screen.game.pads .game-menu { max-width: none; }
.game-head { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 4px 6px; }
.game-title { flex: 1; font-size: 18px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-title b { color: var(--accent); font-size: 22px; letter-spacing: .03em; }
.game-center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 8px; }
.host-bar { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.host-bar .primary, .host-bar .secondary { flex: 1; max-width: 220px; }
/* The game's "⋯": under the game (in the flow, so it never covers a control), and its small sheet. */
.game-menu { display: flex; justify-content: flex-end; margin-top: 8px; }
.menu-button { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--panel); color: var(--muted); display: flex; align-items: center; justify-content: center; }
.menu-button[aria-expanded="true"] { color: var(--text); }
.menu-sheet { position: fixed; left: 0; right: 0; top: 0; bottom: 0; z-index: 9; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.menu-veil { position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: rgba(15, 8, 20, .6); }
.menu-card { position: relative; width: 100%; max-width: 440px; background: var(--bg); border-top: 3px solid var(--game); border-radius: 18px 18px 0 0; padding: 16px 16px max(12px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.menu-card button { width: 100%; font-weight: 700; }
.menu-card .link { font-weight: 400; }
.link { background: none; color: var(--muted); text-decoration: underline; padding: 12px 8px; font-size: 15px; }

/* The secret card: a word only this phone sees. */
.secret-card { flex: 1; min-width: 0; background: var(--cream); color: var(--ink); border-radius: 14px; padding: 8px 14px 10px; text-align: left; }
.secret-card .aside { display: block; font-size: 19px; color: #6b6f80; line-height: 1; }
.secret-card .secret { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; overflow-wrap: anywhere; }

/* Countdowns: a ring in the game's colour. */
/* A circle for two digits; it stretches into a pill for three. */
.timer { flex: none; min-width: 46px; height: 46px; padding: 0 6px; border-radius: 32px; border: 4px solid var(--game); display: inline-flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.timer.big { min-width: 64px; height: 64px; border-width: 5px; font-size: 26px; }
.timer:empty { display: none; }
.timer.low { border-color: var(--warm); color: var(--warm); }

/* Choosing, guessing, results */
.mask { font-size: 30px; letter-spacing: .3em; font-family: var(--mono); word-break: break-all; }
.choice-button { font-size: 24px; padding: 18px; font-weight: 800; }
.feedback { min-height: 28px; font-size: 20px; font-weight: 600; }
.feedback.correct { color: var(--good); }
.feedback.close { color: var(--warm); }
.feedback.wrong { color: var(--muted); font-weight: 400; }
.word { max-width: 100%; font-size: 44px; color: var(--accent); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; overflow-wrap: anywhere; word-break: break-word; }
.gain { font-size: 28px; color: var(--good); font-weight: 600; }
.ranking { list-style: none; padding: 0; margin: 0; width: 100%; max-width: 420px; }
.ranking li { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; font-size: 19px; }
.ranking .n { color: var(--muted); width: 24px; }
.ranking .name { flex: 1; text-align: left; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--warm); color: var(--ink); text-align: center; padding: 6px; font-size: 14px; font-weight: 600; z-index: 10; }
.toast { position: fixed; left: var(--edge-l); right: var(--edge-r); bottom: max(16px, env(safe-area-inset-bottom)); background: var(--cream); color: var(--ink); border-radius: 14px; padding: 12px 16px; text-align: center; font-weight: 600; z-index: 10; }

/* ---------- 👍 / 👎 (src/client/phone/rating.ts; hosted site only) ---------- */
/* "Did you like <game>?": above the host bar on the results, or under the lobby's header. */
.rating { display: flex; align-items: center; gap: 6px; width: 100%; max-width: 420px; min-height: 58px; margin: 14px auto 0; padding: 6px 6px 6px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; font-size: 16px; }
.screen.lobby .rating { max-width: var(--lobby-max); margin: 0 auto 14px; }
.rating-q { flex: 1; min-width: 0; line-height: 1.25; }
.rating-q b { font-weight: 800; }
.rating button { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 12px; background: var(--bg); font-size: 22px; line-height: 1; }
.rating .rating-x { width: 36px; background: none; color: var(--muted); font-size: 17px; }
.rating.thanks { justify-content: center; padding: 6px 14px; color: var(--good); font-weight: 700; }
/* Answered or dismissed: it fades but keeps its space, so the buttons under it don't move (rating.ts). */
.rating.gone { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s, visibility 0s .35s; }
/* A game's own content (ctx.rateContent): two small, quiet thumbs; the chosen one stays lit. */
.rate-item { display: inline-flex; gap: 2px; vertical-align: middle; margin-left: 6px; }
.rate-item button { width: 32px; height: 32px; padding: 0; border-radius: 50%; background: none; font-size: 15px; line-height: 1; opacity: .45; }
.rate-item button:disabled { opacity: .2; }
.rate-item button.on, .rate-item button.on:disabled { opacity: 1; background: rgba(251, 243, 255, .12); }
