/* Shared UI shell — the "maison" chrome every game reuses
 * ---------------------------------------------------------------------------
 * Tokens live in theme.css; this file is the STRUCTURE layer: the app bar,
 * panels, forms, roster, modals, rules/chat, toasts and standings that used to
 * be copy-pasted into every game's app.css. Load order is:
 *     fonts.css  ->  theme.css  ->  components.css  ->  <game>/app.css
 * so a game's own app.css can still override any rule here for its specifics.
 *
 * Everything reads from tokens (radii, scrim, colors), so a re-theme is a
 * token edit here + in theme.css — never a per-game edit. See DESIGN.md.
 *
 * The renovation language: cool parchment grounds, emerald-ink headings,
 * flat hairline-bordered surfaces, squared buttons, Libre Caslon + Inter. */

.screen { min-height: 100vh; }
.wrap { max-width: var(--wrap, 560px); margin: 0 auto; padding: 12px 14px 44px; }

/* ---- app bar ---- */
.appbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 2px 16px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.wordmark, .wm { font-family: var(--font-serif); font-weight: 400; font-size: 1.3rem; line-height: 1.1; color: var(--ink-strong); word-break: keep-all; }
@media (max-width: 420px) { .wordmark, .wm { font-size: 1.12rem; } }
.bar-right { display: flex; gap: 6px; align-items: center; }
.icon { min-width: 42px; height: 42px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: var(--radius-btn); border: 1px solid var(--line); background: transparent; color: var(--ink); font: 600 .8rem var(--font-sans); letter-spacing: .04em; cursor: pointer; position: relative; touch-action: manipulation; white-space: nowrap; transition: border-color .18s, background .18s, color .18s; }
.icon:hover { border-color: var(--accent); color: var(--ink-strong); }
.icon.plain { border-color: transparent; }
.icon.plain:hover { background: var(--panel-2); }
.icon.danger { color: var(--c0); }
.icon.small { min-width: 34px; height: 34px; padding: 0 8px; }
.icon .dot { position: absolute; top: -6px; right: -6px; background: var(--c0); color: #fff; border-radius: var(--radius-pill); font-size: .64rem; padding: 1px 5px; font-weight: 600; }
/* inline-SVG glyphs for chrome icons (replaces the Material Symbols font) */
.ic { display: inline-flex; width: 18px; height: 18px; }
.ic svg { width: 100%; height: 100%; display: block; }
.gi { display: inline-flex; align-items: center; justify-content: center; color: var(--ink-strong); flex: 0 0 auto; }
.gi svg { width: 100%; height: 100%; display: block; }
.gi img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---- panels + forms ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 18px; }
.panel.hero .lead { font-size: 1.02rem; line-height: 1.55; margin: 2px 0 18px; }
.panel h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.25rem; color: var(--ink-strong); margin: 14px 0 8px; }
.field { margin: 8px 0; }
.field label { display: block; font: 600 var(--fs-eyebrow) var(--font-sans); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input { width: 100%; padding: 12px 13px; border: 1px solid var(--line-2); border-radius: var(--radius-input); background: var(--well); color: var(--ink); font: 1rem var(--font-sans); }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 10px; margin-top: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }
.small { font-size: .82rem; }
.sep { text-align: center; color: var(--muted); font-size: .8rem; margin: 16px 0 8px; }
.hint { margin: -2px 0 10px; }
.btn.small { padding: 8px 12px; font-size: .74rem; min-height: 38px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- roster / codes ---- */
.codebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.code { font-family: var(--font-mono); font-size: 1.2rem; letter-spacing: .16em; color: var(--accent); cursor: pointer; }
.players { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--panel-2); }
.prow.off { opacity: .55; }
.pname { flex: 1; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.tag { font: 600 .58rem var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); border-radius: var(--radius-chip); padding: 2px 6px; }
.tag.you { color: var(--accent); border-color: var(--accent); }
.tag.over { color: var(--c0); border-color: var(--c0); }
.tag.host { color: var(--btn-fg); background: var(--btn-bg); border-color: var(--btn-bg); }

/* ---- phase eyebrow (a section label; games that pair it with a timer set
   justify-content:space-between in their own app.css) ---- */
.phase-eyebrow { display: flex; justify-content: center; align-items: center; gap: 8px; font: 600 var(--fs-eyebrow)/1 var(--font-sans); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--muted); margin: 4px 0 10px; }

/* ---- League chrome (banner into a sub-game + the return flow) ---- */
.ksbanner { display: block; text-align: center; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-card); padding: 8px; margin-bottom: 10px; color: var(--ink); font-size: .84rem; text-decoration: none; }
.ksbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; border: 1px solid var(--accent); border-radius: var(--radius-card); background: var(--accent-soft); margin: 0 0 12px; text-decoration: none; color: inherit; font-size: .85rem; }
.ksbar b { color: var(--accent); white-space: nowrap; }
.ksreturn { margin-top: 14px; }
.ksreturn .btn { width: 100%; }
.ksreturn p { text-align: center; color: var(--muted); font-size: .82rem; margin: 8px 0 0; }

/* ---- standings / final rows ---- */
.standings { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--panel-2); }
.srow.first { border-color: var(--accent); background: var(--accent-soft); }
.srow .rank { font-family: var(--font-serif); font-size: 1.2rem; width: 22px; text-align: center; color: var(--muted); }
.srow.first .rank { color: var(--accent); }
.srow .pname { flex: 1; }
.srow .coins { font-weight: 600; font-variant-numeric: tabular-nums; }
.winline { font-family: var(--font-serif); font-weight: 400; font-size: 1.35rem; color: var(--ink-strong); margin: 10px 0 14px; }

/* ---- roster strip (compact chips) ---- */
.pstrip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pchip { border: 1px solid var(--line); border-radius: var(--radius-chip); padding: 6px 10px; font-size: .82rem; background: var(--panel-2); }
.pchip.off { opacity: .5; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink-strong); color: var(--bg); padding: 12px 18px; border-radius: var(--radius-card); box-shadow: var(--shadow-lg); font-size: .9rem; z-index: 60; max-width: 90vw; text-align: center; }

/* ---- modal (bottom sheet on phones, centered on wider screens) ---- */
.modal-layer { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { position: relative; background: var(--panel); border: 1px solid var(--line); border-top-left-radius: var(--radius-modal); border-top-right-radius: var(--radius-modal); box-shadow: var(--shadow-lg); width: 100%; max-width: var(--wrap, 560px); max-height: 82vh; overflow: auto; padding: 20px 18px 26px; }
.modal .close { position: absolute; top: 12px; right: 12px; }
.rules h2, .chat h2 { font-family: var(--font-serif); font-weight: 400; color: var(--ink-strong); margin: 0 40px 12px 0; }
.rule { margin-bottom: 14px; }
.rule h3 { font-family: var(--font-serif); font-weight: 400; font-size: 1.05rem; color: var(--ink-strong); margin: 0 0 4px; }
.rule p { color: var(--muted); line-height: 1.55; margin: 0 0 4px; }
.chatlist { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; margin-bottom: 12px; }
.chatlist.empty { align-items: center; justify-content: center; min-height: 100px; }
.chatmsg { display: flex; flex-direction: column; gap: 1px; }
.chatmsg b { font-size: .74rem; color: var(--accent); }
.chatinput { display: flex; gap: 8px; }
@media (min-width: 620px) { .modal-layer { align-items: center; } .modal { border-radius: var(--radius-modal); } }

/* =========================================================================
 * Shared game LOBBY (the approved design/previews/game-lobby.html layout).
 * Scoped under .lobbyv so it never clashes with the in-game roster (.prow etc.).
 * Every game reuses this; only the .boardframe contents differ per game.
 * ========================================================================= */
.lobbyv { --wrap: 1100px; }
.lobbyv .appbar { position: sticky; top: 0; z-index: 40; height: 60px; padding: 0 clamp(16px,4vw,48px); margin: 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.lobbyv .brand { flex-direction: row; align-items: center; gap: 12px; min-width: 0; }
/* keep the lobby app-bar icons plain even if a game's app.css styles .icon */
.lobbyv .appbar .icon { background: transparent; border: 1px solid var(--line); }
.lobbyv .appbar .icon.plain { border-color: transparent; }
.lobbyv .appbar .icon.plain:hover { background: var(--panel-2); }
.lobbyv .appbar .icon:hover { border-color: var(--accent); color: var(--ink-strong); }
.lobbyv .lobby-main { max-width: var(--wrap); width: 100%; margin: 0 auto; padding: clamp(24px,4vw,44px) clamp(16px,4vw,48px) 80px; }
/* app bar back button (game name stays the wordmark) */
.brand .back { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--muted); font: 600 .72rem var(--font-sans); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; padding: 6px 2px; }
.brand .back:hover { color: var(--ink-strong); }
.brand .back .ic { width: 16px; height: 16px; }

/* hero header */
.lobbyv .lhero { text-align: center; margin-bottom: 40px; }
.lobbyv .lhero .eyebrow { letter-spacing: .24em; }
.lobbyv .lhero h2 { font-family: var(--font-serif); font-size: clamp(2.2rem, 6vw, 3rem); font-weight: 400; letter-spacing: -.02em; color: var(--ink-strong); margin: 8px 0 16px; word-break: keep-all; }
.lobbyv .tags { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.lobbyv .tagchip { padding: 6px 12px; font: 600 .58rem var(--font-sans); letter-spacing: .18em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--muted); }
.lobbyv .tagchip.code { border-color: var(--accent); color: var(--accent); font-family: var(--font-mono); letter-spacing: .14em; cursor: pointer; }

.lobbyv .cols { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 24px; align-items: start; }
.lobbyv .col-h { font: 600 .72rem var(--font-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-strong); border-bottom: 1px solid var(--line); padding-bottom: 10px; margin: 0 0 14px; }
/* A second heading in a column (e.g. Chat below Players) gets breathing room. */
.lobbyv .col-h:not(:first-child) { margin-top: 34px; }

/* players */
.lobbyv .plist { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.lobbyv .plrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; background: var(--bg); }
.lobbyv .plrow.host { background: var(--panel); }
.lobbyv .plrow .who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.lobbyv .pdot { width: 8px; height: 8px; border-radius: var(--radius-pill); flex: 0 0 auto; }
.lobbyv .pdot.on { background: var(--live); } .lobbyv .pdot.off { background: var(--muted); opacity: .4; }
.lobbyv .plrow .nm { font-size: .92rem; color: var(--ink); }
.lobbyv .plrow input.nm { flex: 1; min-width: 0; border: 1px solid transparent; background: transparent; font: 500 .92rem var(--font-sans); color: var(--ink); padding: 4px 6px; border-radius: var(--radius-input); }
.lobbyv .plrow input.nm:hover { border-color: var(--line-2); }
.lobbyv .plrow input.nm:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; background: var(--well); }
.lobbyv .pbadge { font: 600 .58rem var(--font-sans); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
.lobbyv .pbadge.host { background: var(--ink-strong); color: var(--btn-fg); padding: 3px 8px; }
.lobbyv .pbadge.you { color: var(--accent); }
.lobbyv .pbadge.waiting { color: var(--muted); opacity: .55; font-style: italic; }
.lobbyv .invite { display: flex; align-items: center; justify-content: center; padding: 13px; background: var(--bg); border-top: 1px dashed var(--line-2); color: var(--muted); font: 600 .6rem var(--font-sans); letter-spacing: .14em; text-transform: uppercase; cursor: pointer; transition: .2s; }
.lobbyv .invite:hover { color: var(--ink-strong); }

/* center: board preview + CTA */
.lobbyv .lcenter { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.lobbyv .boardframe { position: relative; width: 100%; max-width: 400px; aspect-ratio: 1; border: 1px solid var(--line); background: var(--well); box-shadow: var(--shadow-float); display: grid; place-items: center; overflow: hidden; }
.lobbyv .boardframe::before { content: ""; position: absolute; inset: 14px; border: 1px solid var(--line); pointer-events: none; z-index: 1; }
.lobbyv .boardframe > * { width: 80%; height: 80%; }
.lobbyv .lobby-art { display: grid; place-items: center; }
.lobbyv .lobby-art svg { width: 100%; height: 100%; display: block; }
/* A real board thumbnail is a titled poster of its own aspect ratio — show it
   WHOLE (no crop) framed by the outer border + float shadow; drop the square
   ratio and the inset hairline for photos. The SVG scenes keep their 80% inset. */
.lobbyv .boardframe:has(.board-photo) { aspect-ratio: auto; background: none; }
.lobbyv .boardframe:has(.board-photo)::before { display: none; }
.lobbyv .boardframe > .lobby-art.has-photo { width: 100%; height: auto; }
.lobbyv .board-photo { width: 100%; height: auto; display: block; }
.lobbyv .cta { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lobbyv .startbtn { width: 100%; padding: 20px; border: 1px solid var(--btn-bg); background: var(--btn-bg); color: var(--btn-fg); font: 600 .74rem var(--font-sans); letter-spacing: .28em; text-transform: uppercase; cursor: pointer; transition: transform .1s, background .2s, border-color .2s; border-radius: var(--radius-btn); }
.lobbyv .startbtn:hover:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
.lobbyv .startbtn:active { transform: scale(.99); }
.lobbyv .startbtn:disabled { background: transparent; color: var(--muted); border-color: var(--line-2); cursor: default; letter-spacing: .16em; }
.lobbyv .readystat { font: 600 .62rem var(--font-sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); opacity: .8; }

/* right: settings + chat */
.lobbyv .settings { display: flex; flex-direction: column; gap: 2px; margin-bottom: 28px; }
.lobbyv .setrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lobbyv .setrow:last-child { border-bottom: 0; }
.lobbyv .setrow select { min-width: 96px; }
.lobbyv .setrow .k { font: 600 .66rem var(--font-sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lobbyv .setrow .v { font: 700 .72rem var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-strong); }
.lobbyv .setrow select { font: 700 .72rem var(--font-sans); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-strong); background: transparent; border: 1px solid var(--line-2); padding: 6px 8px; cursor: pointer; border-radius: 0; }
.lobbyv .chatbox { display: flex; flex-direction: column; height: 300px; border: 1px solid var(--line); background: var(--well); }
.lobbyv .chat-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.lobbyv .chat-h span { font: 600 .62rem var(--font-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-strong); }
.lobbyv .chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: .86rem; line-height: 1.5; }
.lobbyv .chat-list .m b { color: var(--ink-strong); font-weight: 600; margin-right: 6px; }
.lobbyv .chat-list .m.sys { color: var(--muted); font-style: italic; opacity: .7; }
.lobbyv .chat-list.empty { align-items: center; justify-content: center; color: var(--muted); font-style: italic; opacity: .7; }
.lobbyv .chat-in { display: flex; align-items: center; border-top: 1px solid var(--line); background: var(--bg); }
.lobbyv .chat-in input { flex: 1; border: 0; background: transparent; padding: 12px 14px; font: 400 .88rem var(--font-sans); color: var(--ink); outline: none; }
.lobbyv .chat-in button { border: 0; background: transparent; padding: 0 14px; color: var(--ink-strong); cursor: pointer; display: inline-flex; align-items: center; }
.lobbyv .chat-in .ic { width: 18px; height: 18px; }

/* Phone: single column, ordered hero → board+Start → settings → players → chat
   (chat lives inside the players column, so it always follows the roster). */
@media (max-width: 900px) {
  .lobbyv .cols { grid-template-columns: 1fr; }
  .lobbyv .lcenter { order: -1; }
  .lobbyv .lset { order: 1; }
  .lobbyv .lplayers { order: 2; }
}
