/* v0.4 authenticated page: login / registration card, account block, toast.
   Reuses the table's tokens from styles.css; no external fonts or images. */

#app[hidden],
#shell[hidden],
.toast[hidden] { display: none !important; }

.auth-screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 90% at 50% 30%, var(--felt-1) 0%, var(--felt-2) 45%, var(--felt-3) 75%, var(--night) 100%);
}

.auth-card {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  border-radius: 20px;
  background: rgba(3, 16, 26, 0.82);
  border: 1px solid rgba(242, 196, 107, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand h1 { margin: 0; font-size: 26px; color: var(--gold); line-height: 1.2; }
.auth-brand p { margin: 2px 0 0; color: var(--ink-dim); font-size: 14px; }
.auth-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 28px;
  color: var(--gold);
  background: radial-gradient(circle at 35% 30%, #1d6f78, #0b3442);
  border: 2px solid rgba(242, 196, 107, 0.6);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}
.auth-tab {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-dim);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.auth-tab.active { background: rgba(242, 196, 107, 0.18); color: var(--gold); }
.auth-tab:focus-visible,
.auth-form input:focus-visible,
.auth-submit:focus-visible,
.auth-practice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 15px; font-weight: 700; margin-top: 6px; }
.auth-form input {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(169, 188, 203, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.auth-form small { color: var(--ink-dim); font-size: 13px; }
.auth-error { min-height: 1.4em; margin: 6px 0 0; color: var(--neg); font-size: 15px; font-weight: 700; }
.auth-submit { min-height: 50px; margin-top: 4px; font-size: 18px; width: 100%; }

.auth-note { margin: 0; color: var(--ink-dim); font-size: 13px; line-height: 1.5; }
.auth-note.grant { color: var(--gold); }
.auth-practice {
  align-self: center;
  padding: 10px 6px;
  color: var(--ink);
  font-size: 14px;
  text-underline-offset: 3px;
}

/* account block inside the in-game menu */
.account-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(242, 196, 107, 0.1);
  border: 1px solid rgba(242, 196, 107, 0.35);
}
.account-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 18px; }
.account-chips { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.account-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.account-actions .btn { min-height: 44px; text-decoration: none; display: inline-flex; align-items: center; }

.toast {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(560px, calc(100vw - 24px));
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(60, 10, 22, 0.94);
  border: 1px solid var(--neg);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

@media (prefers-reduced-motion: no-preference) {
  .auth-card { animation: auth-in 260ms ease-out; }
  @keyframes auth-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* online M1: account panel (daily chips, email) — a dialog outside the stage */
.account-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background: rgba(2, 8, 14, 0.72);
  overflow-y: auto;
}
.account-dialog {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(3, 16, 26, 0.96);
  border: 1px solid rgba(242, 196, 107, 0.4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--ink);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 22px; color: var(--gold); }
.panel-section { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid rgba(169, 188, 203, 0.2); }
.panel-section h3 { margin: 0; font-size: 17px; }
.panel-status { margin: 0; font-size: 15px; line-height: 1.5; }
.panel-error { margin: 0; min-height: 1.2em; color: var(--neg); font-size: 14px; font-weight: 700; }
.panel-section small { color: var(--ink-dim); font-size: 13px; line-height: 1.45; }
.account-dialog .btn { min-height: 44px; }
.account-dialog button:focus-visible,
.account-dialog input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.panel-status.pending { color: var(--gold); }
.panel-form { gap: 6px; }
.auth-notice { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(79, 201, 140, 0.12); border: 1px solid rgba(79, 201, 140, 0.45); font-size: 16px; font-weight: 700; line-height: 1.5; }
.auth-notice.error { background: rgba(224, 82, 99, 0.12); border-color: var(--neg); color: var(--ink); }
.link-btn { background: none; border: 0; cursor: pointer; font: inherit; text-decoration: underline; min-height: 44px; }
.auth-subtitle { margin: 0 0 4px; font-size: 19px; color: var(--gold); }

/* Lobby scene after login at / (lobby-scene-20261123T151904Z). Every rule here is scoped to
   the Lobby wrapper (.scene-screen), its root (.lobby-scene) or home-* classes that only the
   Lobby and its join dialog render. Original art: src/ui/lobby-scene-art.js. */
.auth-screen.scene-screen { display: block; padding: 0; overflow: hidden; background: var(--night); }
.lobby-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 35vw, 440px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: 'hud hud' '. modes' 'foot foot';
  gap: 8px 24px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  color: var(--ink);
}
.lobby-scene > .scene-art { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.lobby-scene > :not(.scene-art) { position: relative; z-index: 1; min-width: 0; }
.lobby-scene button:focus-visible,
.lobby-scene a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.lobby-scene .scene-hud { grid-area: hud; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.lobby-scene .scene-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lobby-scene .scene-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 22px;
  color: var(--gold);
  background: radial-gradient(circle at 35% 30%, #1d6f78, #0b3442);
  border: 2px solid rgba(242, 196, 107, 0.6);
}
.lobby-scene .scene-brand h1 { margin: 0; font-size: 19px; line-height: 1.15; color: var(--gold); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.lobby-scene .scene-brand p { margin: 0; font-size: 12px; color: var(--ink-dim); letter-spacing: 0.06em; }
.lobby-scene .home-offline { flex: 0 1 420px; padding: 6px 12px; font-size: 13px; }
.lobby-scene .scene-chips {
  flex: none;
  min-height: 44px;
  padding: 0 16px 0 10px;
  border-radius: 999px;
  background: rgba(3, 16, 26, 0.78);
  border: 1px solid rgba(242, 196, 107, 0.55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  font-size: 18px;
}
.home-chips { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--gold); }
.home-chip-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe3a1, var(--gold) 55%, #a8771f);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.lobby-scene .scene-modes { grid-area: modes; display: flex; flex-direction: column; justify-content: center; gap: 10px; min-height: 0; }
.lobby-scene .scene-play p { margin: 6px 4px 0; font-size: 12px; line-height: 1.35; color: var(--ink-dim); text-shadow: 0 1px 3px #000; }
.lobby-scene #lobby-match {
  width: 100%;
  min-height: 96px;
  border-radius: 20px;
  font-size: 28px;
  letter-spacing: 0.02em;
  box-shadow: 0 5px 0 #8a3405, 0 0 0 2px rgba(255, 227, 161, 0.55), 0 14px 32px rgba(0, 0, 0, 0.55);
}
.lobby-scene .scene-private {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: rgba(3, 16, 26, 0.76);
  border: 1px solid rgba(127, 214, 214, 0.32);
}
.lobby-scene .scene-private h2 { margin: 0; font-size: 15px; color: var(--gold); }
.lobby-scene .scene-private p { margin: 0; font-size: 12px; line-height: 1.35; color: var(--ink-dim); }
.lobby-scene .scene-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lobby-scene .scene-row .btn { min-height: 48px; font-size: 16px; }
.lobby-scene .scene-modes > .auth-error { margin: 0; font-size: 14px; text-shadow: 0 1px 3px #000; }
.lobby-scene .scene-modes > .auth-error:empty { display: none; }

.lobby-scene .scene-foot { grid-area: foot; display: flex; align-items: center; gap: 14px; min-width: 0; }
.lobby-scene .scene-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 1 240px;
  min-width: 0;
  padding: 5px 16px 5px 5px;
  border-radius: 999px;
  background: rgba(3, 16, 26, 0.78);
  border: 1px solid rgba(242, 196, 107, 0.45);
}
.lobby-scene .scene-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  background: radial-gradient(circle at 35% 30%, #1d8f86, #0b3442);
  border: 2px solid var(--gold);
}
.lobby-scene .scene-profile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.lobby-scene .scene-dock {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  border-radius: 18px;
  background: rgba(3, 16, 26, 0.78);
  border: 1px solid rgba(242, 196, 107, 0.3);
}
.lobby-scene .home-daily { flex: 1 1 auto; min-width: 0; padding: 0; background: none; border: 0; }
.lobby-scene .scene-dock .btn { white-space: nowrap; }
.home-primary:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.join-dialog { width: min(440px, calc(100vw - 24px)); }
.join-dialog h2 { margin: 0; color: var(--gold); font-size: 20px; }
.join-form { display: flex; flex-direction: column; gap: 10px; }
#join-code {
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(169, 188, 203, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
#join-code:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.join-buttons { display: flex; gap: 10px; }
.join-buttons .btn { flex: 1 1 0; min-height: 46px; }
.home-daily {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(242, 196, 107, 0.08);
  border: 1px solid rgba(242, 196, 107, 0.3);
}
.home-daily-text { min-width: 0; }
.home-daily h2 { margin: 0; font-size: 13px; color: var(--gold); }
.home-daily-status { margin: 2px 0 0; font-size: 12px; line-height: 1.3; color: var(--ink); }
.home-daily .auth-error { min-height: 0; margin: 2px 0 0; font-size: 13px; }
.home-claim { min-height: 44px; flex: 0 0 auto; }
.home-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.home-resume[hidden] { display: none; }
.home-resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(6, 40, 34, 0.86);
  border: 1px solid rgba(127, 240, 180, 0.5);
}
.home-resume h2 { margin: 0; font-size: 15px; color: var(--pos); }
.home-resume p { margin: 2px 0 0; font-size: 13px; color: var(--ink); }
.home-resume .btn { min-height: 44px; flex: 0 0 auto; }
.home-offline[hidden] { display: none; }
.home-offline { margin: 0; padding: 8px 12px; border-radius: 12px; background: rgba(60, 10, 22, 0.86); border: 1px solid rgba(255, 138, 152, 0.5); color: var(--ink); font-size: 14px; }
@media (prefers-reduced-motion: no-preference) {
  .lobby-scene .scene-modes { animation: scene-modes-in 320ms ease-out; }
  @keyframes scene-modes-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
}
@media (max-height: 520px) {
  .lobby-scene { gap: 6px 16px; padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .lobby-scene .scene-mark { width: 32px; height: 32px; font-size: 18px; border-radius: 9px; }
  .lobby-scene .scene-brand h1 { font-size: 16px; }
  .lobby-scene .scene-brand p { font-size: 11px; }
  .lobby-scene .scene-chips { font-size: 16px; }
  .lobby-scene .scene-modes { gap: 8px; }
  .lobby-scene #lobby-match { min-height: 64px; font-size: 22px; border-radius: 16px; }
  .lobby-scene .scene-play p,
  .lobby-scene .scene-private p { display: none; }
  .lobby-scene .scene-private { padding: 8px 10px 10px; }
  .lobby-scene .scene-private h2 { font-size: 13px; }
  .lobby-scene .scene-row .btn { min-height: 44px; font-size: 14px; }
  .lobby-scene .scene-avatar { width: 36px; height: 36px; font-size: 17px; }
  .lobby-scene .scene-profile { flex-basis: 180px; }
  .lobby-scene .scene-profile strong { font-size: 14px; }
  .lobby-scene .scene-dock { padding: 4px 6px 4px 10px; gap: 8px; }
  .home-daily-status { font-size: 11px; }
  .home-small { min-height: 34px; padding: 0 10px; font-size: 13px; }
  .home-claim, .home-resume .btn { min-height: 40px; }
  .home-resume { padding: 6px 12px; }
  .home-resume p { font-size: 12px; }
}
/* Lobby scene tap targets: every non-card control at least 44x44 CSS px (stage 2 targets). */
.lobby-scene .home-small,
.lobby-scene .home-claim,
.lobby-scene .home-resume .btn { min-height: 44px; }
/* Lobby portrait gate (stage 2 portrait): the scene is landscape-only. */
.scene-screen .scene-rotate { display: none; }
@media (orientation: portrait) {
  .scene-screen .lobby-scene { display: none; }
  .scene-screen .scene-rotate {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
    text-align: center;
    background: radial-gradient(120% 90% at 50% 30%, var(--felt-1) 0%, var(--felt-2) 45%, var(--felt-3) 75%, var(--night) 100%);
  }
  .scene-screen .scene-rotate strong { font-size: 20px; color: var(--gold); }
  .scene-screen .scene-rotate i { width: 64px; height: 100px; border-radius: 14px; border: 4px solid var(--gold); rotate: -90deg; }
}
/* Follow-up: the portrait gate also covers the Lobby-owned join/account overlays. Scoped by
   :has() to a mounted Lobby scene, so the table's own account panel is unaffected. */
@media (orientation: portrait) {
  body:has(> #shell .scene-screen) > .account-overlay { display: none; }
}
/* Follow-up: the resume card sits in the stage area left of the modes column, so a real
   resume never pushes the mode selector into the bottom dock. */
.lobby-scene .scene-modes > .home-resume {
  position: absolute;
  top: 0;
  right: calc(100% + 16px);
  width: min(340px, 52vw);
  z-index: 2;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
}

/* Profile/avatar milestone: selected avatar as the Lobby centrepiece (where the
   decorative card fan used to be), the bottom-left profile control, and the
   editor grid. Art is a 3:4 raster fitted with object-fit: contain; when the
   file is absent the frame shows the honest pending label. */
.avatar-frame { position: relative; margin: 0; aspect-ratio: 3 / 4; display: grid; place-items: center; overflow: hidden; border-radius: 14px; }
.avatar-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.avatar-frame.pending { background: rgba(3, 16, 26, 0.72); border: 1px dashed rgba(242, 196, 107, 0.55); }
.avatar-pending { padding: 6px; text-align: center; color: var(--gold); font-size: 13px; font-weight: 700; line-height: 1.3; }
.lobby-scene > .scene-hero { position: absolute; left: 33%; top: 47%; transform: translate(-50%, -50%); height: min(52%, 360px); aspect-ratio: 3 / 4; z-index: 0; pointer-events: none; }
.lobby-scene > .scene-hero .avatar-frame { height: 100%; }
.lobby-scene > .scene-hero .avatar-frame.pending { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); }
.lobby-scene > .scene-hero .avatar-pending { font-size: 16px; }
.lobby-scene button.scene-profile { font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.lobby-scene button.scene-profile:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.lobby-scene .scene-avatar { overflow: hidden; padding: 0; }
.lobby-scene .scene-avatar .avatar-frame { width: 100%; height: 100%; aspect-ratio: auto; border-radius: 50%; border: 0; }
.lobby-scene .scene-avatar .avatar-pending { font-size: 0; }
.lobby-scene .scene-avatar .avatar-pending::before { content: '…'; font-size: 16px; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.avatar-choice { display: flex; flex-direction: column; gap: 4px; align-items: stretch; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 2px solid transparent; color: var(--ink); font: inherit; cursor: pointer; }
.avatar-choice[aria-pressed='true'] { border-color: var(--gold); background: rgba(242, 196, 107, 0.12); }
.avatar-choice.locked { opacity: 0.55; cursor: not-allowed; }
.avatar-choice small { font-size: 11px; line-height: 1.25; color: var(--ink-dim); text-align: center; }
.avatar-choice:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.avatar-thumb .avatar-pending { font-size: 11px; }
@media (prefers-reduced-motion: no-preference) { .avatar-choice { transition: border-color 0.15s ease, background-color 0.15s ease; } }

/* Acceptance slice: inline name-row avatar thumbnails (waiting seats, shared-table seats).
   Fixed small size, inline, so seat/card geometry is unchanged. Pending = dashed frame + '…'. */
.avatar-frame.avatar-inline { display: inline-grid; width: 18px; height: 24px; aspect-ratio: auto; border-radius: 4px; margin-right: 6px; vertical-align: middle; flex: none; }
.avatar-frame.avatar-inline.pending { border-width: 1px; }
.avatar-pending.compact { padding: 0; font-size: 0; line-height: 1; }
.avatar-pending.compact::before { content: '…'; font-size: 11px; color: var(--gold); }
.seat-name-row { display: inline-flex; align-items: center; min-width: 0; }
