/* Wuju Alias — Capstar visual language (ice / indigo / glass) */
:root {
  --deep: #0a0f1e;
  --slate: #0f172a;
  --ice: #e8f4ff;
  --frost: #bae6fd;
  --snow: #f8fafc;
  --accent: #7dd3fc;
  --indigo: #818cf8;
  --violet: #a78bfa;
  --ok: #6ee7b7;
  --warn: #fde68a;
  --err: #fca5a5;
  --text: #e2e8f0;
  --muted: rgba(186, 230, 253, 0.72);
  --muted2: rgba(148, 163, 184, 0.9);
  --stroke: rgba(125, 211, 252, 0.22);
  --stroke-strong: rgba(125, 211, 252, 0.38);
  --card: rgba(15, 23, 42, 0.48);
  --card-hi: rgba(30, 41, 59, 0.42);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --r: 1.15rem;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  color: var(--text);
  font-family: var(--font);
  background: var(--deep);
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---- Capstar sky background ---- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(165deg, #1e1b4b 0%, #0f172a 42%, #020617 100%);
}
.bg-tints { position: absolute; inset: 0; }
.bg-tint {
  position: absolute;
  inset: 0;
  animation: bg-tint-pulse 42s ease-in-out infinite alternate;
  will-change: opacity;
}
.bg-tint-a {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(99, 102, 241, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 80% 90%, rgba(30, 58, 138, 0.32), transparent 55%),
    linear-gradient(165deg, #1e293b 0%, #0f172a 50%, transparent 100%);
  animation-delay: 0s;
}
.bg-tint-b {
  background:
    radial-gradient(ellipse 90% 60% at 48% -8%, rgba(129, 140, 248, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 82% 88%, rgba(37, 99, 235, 0.42), transparent 55%),
    linear-gradient(165deg, #1e3a8a 0%, #172554 40%, #0c1929 70%, transparent 100%);
  animation-delay: -21s;
}
.bg-tint-c {
  background:
    radial-gradient(ellipse 90% 60% at 52% -10%, rgba(167, 139, 250, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 78% 90%, rgba(109, 40, 217, 0.32), transparent 55%),
    linear-gradient(165deg, #4c1d95 0%, #2e1065 38%, #0c0a1a 70%, transparent 100%);
  animation-delay: -18s;
}
.bg-wash {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 55% 45% at 20% 30%, rgba(96, 165, 250, 0.12), transparent 62%),
    radial-gradient(ellipse 50% 40% at 78% 65%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(ellipse 45% 35% at 50% 85%, rgba(99, 102, 241, 0.1), transparent 55%);
  animation: bg-wash-drift 36s ease-in-out infinite alternate;
  opacity: 0.9;
}
.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.22;
  mix-blend-mode: screen;
  animation: nebula-breathe 28s ease-in-out infinite alternate;
}
.nebula-a {
  width: min(55vw, 28rem);
  height: min(40vw, 20rem);
  left: -8%;
  top: 18%;
  background: radial-gradient(ellipse at 40% 50%, rgba(129, 140, 248, 0.48), transparent 70%);
}
.nebula-b {
  width: min(50vw, 24rem);
  height: min(38vw, 18rem);
  right: -6%;
  bottom: 12%;
  background: radial-gradient(ellipse at 60% 50%, rgba(167, 139, 250, 0.4), transparent 70%);
  animation-delay: -10s;
}
@keyframes bg-tint-pulse {
  from { opacity: 0.08; }
  to { opacity: 0.9; }
}
@keyframes bg-wash-drift {
  from { transform: translate(0, 0) scale(1); opacity: 0.65; }
  to { transform: translate(2%, -1.5%) scale(1.06); opacity: 1; }
}
@keyframes nebula-breathe {
  from { transform: scale(1); opacity: 0.16; }
  to { transform: scale(1.08); opacity: 0.28; }
}

/* ---- App shell ---- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  /* Top padding clears fixed topbar (Home + brand) */
  padding:
    calc(3.5rem + var(--st))
    calc(1.15rem + var(--sr))
    calc(1.25rem + var(--sb))
    calc(1.15rem + var(--sl));
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hidden { display: none !important; }

/* Flush to the real top-left of the viewport */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  flex-shrink: 0;
  padding:
    calc(0.65rem + var(--st))
    0.75rem
    0.55rem
    calc(0.75rem + var(--sl));
  pointer-events: none; /* only children clickable */
}
.topbar > * {
  pointer-events: auto;
}
.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.8rem;
  border-radius: 0.65rem;
  font-size: 0.85rem;
  font-weight: 750;
  text-decoration: none;
  color: var(--ice);
  border: 1px solid var(--stroke);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.1), rgba(15, 23, 42, 0.42));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: filter 0.15s, border-color 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.home-btn:hover {
  filter: brightness(1.1);
  border-color: var(--stroke-strong);
  transform: translateY(-1px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  margin-left: 0;
}
.brand-mark {
  /* Just the logo — soft circle, no extra chrome */
  width: 2.65rem;
  height: 2.65rem;
  display: block;
  flex-shrink: 0;
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 50%;
  padding: 0;
  overflow: hidden;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background: transparent;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--snow);
}
.brand-sub {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--frost);
  opacity: 0.85;
}
/* ---- Screens ---- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screen.center {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.55rem;
  padding-bottom: 1rem;
}

.kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.title {
  margin: 0;
  font-size: clamp(2rem, 7vw, 2.65rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--snow);
  text-shadow: 0 2px 24px rgba(125, 211, 252, 0.2);
}
.title.sm { font-size: clamp(1.55rem, 5vw, 2rem); }
.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
  max-width: 22rem;
}
.tagline.tight { margin-top: 0; max-width: none; }

.code-hero {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  font-size: clamp(2.4rem, 12vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.26em;
  padding: 0.2rem 0.45rem 0.2rem 0.55rem;
  line-height: 1.1;
  color: var(--frost);
  text-shadow: 0 0 36px rgba(125, 211, 252, 0.35);
  font-variant-numeric: tabular-nums;
  user-select: all;
  cursor: pointer;
  border-radius: 0.75rem;
  transition: background 0.15s, border-color 0.15s, filter 0.15s, transform 0.12s;
}
.code-hero:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(125, 211, 252, 0.3);
  filter: brightness(1.08);
}
.code-hero:active {
  transform: scale(0.98);
}
.code-hero.copied {
  color: var(--ok);
  border-color: rgba(110, 231, 183, 0.35);
  background: rgba(110, 231, 183, 0.1);
  text-shadow: 0 0 28px rgba(110, 231, 183, 0.35);
}

/* ---- Glass panels (hub-style) ---- */
.panel {
  border-radius: var(--r);
  border: 1px solid var(--stroke);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.09) 0%, rgba(15, 23, 42, 0.42) 100%);
  backdrop-filter: blur(18px) saturate(1.3) brightness(1.03);
  -webkit-backdrop-filter: blur(18px) saturate(1.3) brightness(1.03);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}
.panel-head.tight { margin-bottom: 0.5rem; align-items: center; }
.panel-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ice);
}
.panel-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--muted2);
  font-weight: 500;
}

/* ---- Home: Alle rom (left) stretches full height of Alias + Namn; equal column widths ---- */
.screen.home {
  gap: 0;
  width: 100%;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.home-layout {
  flex: 0 1 auto;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "main"
    "rooms";
  gap: 0.85rem;
  align-content: center;
  min-height: 0;
}

.home-main {
  grid-area: main;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-hero {
  text-align: center;
  width: 100%;
  flex-shrink: 0;
}

.rooms-panel {
  grid-area: rooms;
  width: 100%;
  min-width: 0;
  min-height: 11rem;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.05rem;
}

.join-panel {
  width: 100%;
  min-width: 0;
  padding: 1.1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  justify-content: flex-start;
  flex-shrink: 0;
}

/* Empty list fills the tall panel */
.rooms-panel .room-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rooms-panel .room-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 8rem;
  margin: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 1.5rem 1rem;
}

/*
 * Desktop:
 *  [ Alle rom  ] [ Alias title… ]
 *  [ (tall)    ] [ Namn card    ]
 * Equal column widths; Alle rom stretches top (Alias) → bottom (Namn).
 */
@media (min-width: 700px) {
  .home-layout {
    grid-template-columns: 1fr 1fr; /* same width as Namn column */
    grid-template-areas: "rooms main";
    gap: 1rem;
    align-items: stretch;
    justify-content: center;
    max-width: 36rem; /* two equal columns */
    width: 100%;
  }

  .home-main {
    grid-area: main;
    height: 100%;
    align-self: stretch;
    justify-content: flex-start;
  }

  .home-hero {
    text-align: left;
  }

  .rooms-panel {
    grid-area: rooms;
    height: 100%;
    min-height: 100%;
    align-self: stretch;
    max-height: none;
  }

  .join-panel {
    /* natural height; left column grows to full main (hero + join) */
  }
}

@media (min-width: 1100px) {
  .home-layout {
    max-width: 38rem;
    gap: 1.1rem;
  }
}

.room-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 211, 252, 0.35) transparent;
}

.room-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.65rem;
  align-items: center;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(125, 211, 252, 0.14);
  background: linear-gradient(165deg, rgba(255,255,255,0.06), rgba(15,23,42,0.45));
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, filter 0.15s, transform 0.12s, background 0.15s;
}
.room-card:hover:not(:disabled) {
  border-color: var(--stroke-strong);
  filter: brightness(1.06);
  transform: translateY(-1px);
  background: linear-gradient(165deg, rgba(125, 211, 252, 0.1), rgba(30, 41, 59, 0.5));
}
.room-card:disabled {
  opacity: 0.62;
  cursor: default;
}
.room-card .rc-code {
  font-weight: 850;
  letter-spacing: 0.14em;
  font-size: 1.05rem;
  color: var(--frost);
}
.room-card .rc-meta {
  font-size: 0.78rem;
  color: var(--muted2);
  font-weight: 550;
}
.room-card .rc-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.22rem;
}
.room-card .rc-join {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.room-card .rc-status {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.rc-status.open {
  color: var(--ok);
  background: rgba(110, 231, 183, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.28);
}
.rc-status.live {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.rc-status.ended {
  color: var(--muted2);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.room-card .rc-bar {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.room-card .rc-bar > i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
}
.room-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted2);
  font-size: 0.88rem;
  line-height: 1.45;
  border-radius: 0.9rem;
  border: 1px dashed rgba(125, 211, 252, 0.28);
  background: rgba(2, 6, 23, 0.28);
}
.room-empty strong {
  display: block;
  color: var(--ice);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.room-empty-sub {
  display: block;
  max-width: 14rem;
  margin: 0 auto;
  color: var(--muted2);
  font-size: 0.8rem;
  font-weight: 550;
  line-height: 1.4;
  opacity: 0.92;
}

/* ---- Forms ---- */
.field-label {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.inp {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(125, 211, 252, 0.2);
  background: rgba(2, 6, 23, 0.45);
  color: var(--snow);
  font: inherit;
  font-weight: 600;
  padding: 0.72rem 0.9rem;
  border-radius: 0.75rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.inp::placeholder { color: rgba(148, 163, 184, 0.75); }
.inp:focus {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.inp.code {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 800;
  font-size: 1.05rem;
  flex: 1;
  min-width: 0;
}
.inp.guess {
  flex: 1;
  min-width: 0;
  font-size: 1.02rem;
  border-radius: 0.85rem;
}

.btn {
  appearance: none;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(165deg, rgba(255,255,255,0.1), rgba(30, 41, 59, 0.5));
  color: var(--ice);
  font: inherit;
  font-weight: 750;
  font-size: 0.92rem;
  padding: 0.72rem 1.05rem;
  border-radius: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: filter 0.12s, transform 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
  border-color: var(--stroke-strong);
}
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}
.btn.block { width: 100%; }
.btn.primary {
  border-color: rgba(125, 211, 252, 0.4);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.45), rgba(99, 102, 241, 0.42));
  color: #f0f9ff;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2);
}
.btn.danger {
  border-color: rgba(252, 165, 165, 0.35);
  background: linear-gradient(165deg, rgba(248, 113, 113, 0.12), rgba(127, 29, 29, 0.38));
  color: #fecaca;
}

.join-row { display: flex; gap: 0.5rem; }
.or-line {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--muted2);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0.15rem 0;
}
.or-line::before, .or-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(125, 211, 252, 0.15);
}

.msg {
  min-height: 1.05rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--err);
  text-align: center;
}
.msg.ok { color: var(--ok); }
.msg.info { color: var(--warn); }
.center-msg { margin-top: 0.15rem; }

.icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.7rem;
  border: 1px solid var(--stroke);
  background: linear-gradient(165deg, rgba(255,255,255,0.08), rgba(15,23,42,0.4));
  color: var(--ice);
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: filter 0.12s;
}
.icon-btn:hover { filter: brightness(1.12); }
.icon-btn.danger {
  border-color: rgba(252, 165, 165, 0.35);
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
  margin-left: auto;
}

/* ---- Lobby ---- */
.lobby-card {
  width: min(100%, 22rem);
  padding: 1.05rem;
  text-align: left;
}
/* Own bubble under players — everyone sees it */
.settings-card {
  width: min(100%, 22rem);
  padding: 0.95rem 1.05rem 1rem;
  text-align: left;
  margin-top: 0.15rem;
}
.settings-card .panel-head {
  margin-bottom: 0.65rem;
}
.settings-lock {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted2);
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.45);
  white-space: nowrap;
}
.settings-card.is-readonly {
  opacity: 0.92;
}
.settings-card.is-readonly .check-row {
  cursor: default;
}
.settings-card.is-readonly input[type="checkbox"] {
  cursor: not-allowed;
  opacity: 0.75;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}
.check-row input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #38bdf8;
  flex-shrink: 0;
  cursor: pointer;
}
.check-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.check-copy strong {
  font-size: 0.88rem;
  font-weight: 750;
  color: var(--snow);
  letter-spacing: -0.01em;
}
.check-copy em {
  font-style: normal;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--muted2);
  line-height: 1.35;
}
.count-pill {
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.28);
  font-variant-numeric: tabular-nums;
}
.avatars {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 12rem;
  overflow-y: auto;
}
.avatars li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.75rem;
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(125, 211, 252, 0.12);
}
.avatars .dot {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.82rem;
  color: #0f172a;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.25);
}
.avatars .nm {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--snow);
}
.avatars .tag {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--warn);
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  background: rgba(253, 230, 138, 0.1);
  border: 1px solid rgba(253, 230, 138, 0.22);
}
.avatars .tag.muted {
  color: var(--muted2);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}

/* ---- Game ---- */
.screen.game { gap: 0.6rem; }

.round-progress {
  width: 100%;
  padding: 0.75rem 0.9rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.rp-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.rp-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.rp-count {
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  color: var(--ice);
}
.rp-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.45);
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.12);
}
.rp-track > i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #818cf8 55%, #6ee7b7);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
  transition: transform 0.35s ease;
}
.rp-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.rp-ticks span {
  flex: 1;
  border-right: 1px solid rgba(0,0,0,0.2);
}
.rp-ticks span:last-child { border-right: none; }

.phase-steps {
  display: flex;
  gap: 0.35rem;
}
.phase-steps span {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 750;
  padding: 0.35rem 0.3rem;
  border-radius: 0.55rem;
  color: var(--muted2);
  background: rgba(2, 6, 23, 0.3);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.phase-steps span.on {
  color: #0f172a;
  background: linear-gradient(135deg, #7dd3fc, #818cf8);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.28);
}
.phase-steps span.done {
  color: var(--ok);
  border-color: rgba(110, 231, 183, 0.22);
  background: rgba(110, 231, 183, 0.08);
}

.turn-strip {
  width: 100%;
  padding: 0.5rem 0.55rem;
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: thin;
}
.turn-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.55rem 0.32rem 0.32rem;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(125, 211, 252, 0.12);
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.72;
  transition: all 0.2s ease;
  color: var(--text);
}
.turn-chip .td {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 900;
  color: #0f172a;
}
.turn-chip.on {
  opacity: 1;
  border-color: rgba(125, 211, 252, 0.45);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.12);
}
.turn-chip.you:not(.on) {
  border-color: rgba(129, 140, 248, 0.35);
}
.turn-chip .mic { font-size: 0.68rem; }

.game-chrome {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.meta-chip {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(125, 211, 252, 0.14);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pts-live {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.28rem 0.6rem;
  border-radius: 0.7rem;
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid rgba(110, 231, 183, 0.25);
  min-width: 3.4rem;
}
.pts-lab {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted2);
}
.pts-val {
  font-size: 1.05rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  line-height: 1.1;
}

.timer-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.45);
  overflow: hidden;
  border: 1px solid rgba(125, 211, 252, 0.1);
}
.timer-track > i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #6ee7b7);
  will-change: transform;
}

.stage {
  width: 100%;
  flex: 1;
  min-height: 11rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1.2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stage::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.12), transparent 52%);
  pointer-events: none;
}
/* Wrong guesses float for the explainer — along bottom of stage bubble */
.float-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.float-wrong {
  position: absolute;
  left: 50%;
  /* Sit near the bottom of the stage panel */
  top: 86%;
  font-size: clamp(0.82rem, 2.5vw, 1.05rem);
  font-weight: 750;
  color: rgba(252, 165, 165, 0.78);
  text-shadow: 0 1px 8px rgba(127, 29, 29, 0.25);
  white-space: nowrap;
  max-width: min(28%, 9rem);
  overflow: hidden;
  text-overflow: ellipsis;
  will-change: transform, opacity;
  animation: float-wrong-drift 2.5s ease-out forwards;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}
@keyframes float-wrong-drift {
  0% {
    opacity: 0;
    transform: translate(-50%, 20%) rotate(var(--rot, 0deg)) scale(0.92);
  }
  14% {
    opacity: 0.9;
    transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
  }
  100% {
    opacity: 0;
    /* Gentle rise only — little lateral drift, almost no spin */
    transform: translate(-50%, calc(-50% + var(--dy1, -28px)))
      rotate(var(--rot, 0deg)) scale(0.98);
  }
}
.role-pill {
  position: relative;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.32);
  background: rgba(56, 189, 248, 0.1);
}
.word {
  position: relative;
  font-size: clamp(2.1rem, 10vw, 3.2rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  word-break: break-word;
  max-width: 100%;
  color: var(--snow);
}
.word.secret {
  color: var(--indigo);
  letter-spacing: 0.18em;
  opacity: 0.9;
}
.word.reveal, .word.word {
  color: var(--frost);
  text-shadow: 0 0 36px rgba(125, 211, 252, 0.4);
  animation: word-in 0.35s ease;
}
.word.timeout-reveal {
  color: var(--warn);
  text-shadow: 0 0 40px rgba(253, 230, 138, 0.45);
  animation: word-timeout-reveal 1.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes word-in {
  from { transform: scale(0.88); opacity: 0.25; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes word-timeout-reveal {
  0% {
    filter: blur(14px);
    opacity: 0;
    letter-spacing: 0.45em;
    transform: scale(0.82) translateY(8px);
  }
  45% {
    filter: blur(5px);
    opacity: 0.75;
    letter-spacing: 0.12em;
    transform: scale(1.04) translateY(0);
  }
  100% {
    filter: blur(0);
    opacity: 1;
    letter-spacing: -0.03em;
    transform: scale(1) translateY(0);
  }
}
.stage.timeout-flash {
  animation: timeout-pulse 1s ease;
}
@keyframes timeout-pulse {
  0% { box-shadow: 0 0 0 0 rgba(253, 230, 138, 0.45), var(--shadow); }
  40% { box-shadow: 0 0 0 10px rgba(253, 230, 138, 0.12), var(--shadow); }
  100% { box-shadow: 0 0 0 16px rgba(253, 230, 138, 0), var(--shadow); }
}
.hint {
  position: relative;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  max-width: 18rem;
  line-height: 1.35;
}
.word-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  max-width: 16rem;
  margin-top: 0.25rem;
  opacity: 0.75;
}
.word-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
}
.word-dots i.on {
  background: var(--ok);
  box-shadow: 0 0 6px rgba(110, 231, 183, 0.5);
}
.word-dots i.cur {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.65);
  transform: scale(1.35);
}

.guess-dock {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}
.guess-dock .btn { flex-shrink: 0; padding-inline: 1.1rem; }

.skip-wrap {
  position: relative;
  margin-top: 0.35rem;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}
.skip-btn {
  font-size: 0.82rem;
  padding: 0.45rem 0.9rem;
  border-color: rgba(125, 211, 252, 0.35);
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
}
.skip-btn:hover:not(:disabled) {
  border-color: rgba(125, 211, 252, 0.55);
  background: rgba(56, 189, 248, 0.16);
}
.giveup-btn {
  font-size: 0.82rem;
  padding: 0.45rem 0.9rem;
  border-color: rgba(253, 230, 138, 0.3);
  background: rgba(253, 230, 138, 0.08);
  color: var(--warn);
}
.giveup-btn:hover:not(:disabled) {
  border-color: rgba(253, 230, 138, 0.5);
  background: rgba(253, 230, 138, 0.14);
}

.score-rail {
  width: 100%;
  padding: 0.75rem 0.85rem 0.85rem;
  max-height: 11rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}
.rail-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.45rem;
}
.board {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow-y: auto;
  min-height: 0;
}
.board .row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.4rem 0.5rem;
  border-radius: 0.6rem;
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid transparent;
  font-size: 0.88rem;
}
.board .row.you {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.28);
}
.board .rank {
  font-weight: 900;
  color: var(--muted2);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}
.board .row:nth-child(1) .rank { color: var(--warn); }
.board .row:nth-child(2) .rank { color: #e2e8f0; }
.board .row:nth-child(3) .rank { color: #fdba74; }
.board .name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: var(--snow);
}
.board .pts {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
}
/* 2-player: clean correct-guess number */
.board.duo-board .pts {
  font-size: 1.25rem;
  min-width: 1.6rem;
  text-align: center;
  color: var(--frost);
  text-shadow: 0 0 16px rgba(125, 211, 252, 0.25);
}
.board.duo-board.podium .pts,
.board.duo-board .result-row .pts {
  font-size: 1.55rem;
  min-width: 2rem;
}
.board.podium .row,
.board .row.result-row {
  grid-template-columns: 2rem 1fr auto;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  align-items: start;
}
.board.podium .row:nth-child(1),
.board .row.result-row:nth-child(1) {
  background: linear-gradient(90deg, rgba(253, 230, 138, 0.12), transparent);
  border-color: rgba(253, 230, 138, 0.28);
}
.board .result-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  text-align: left;
}
.board .result-stats {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted2);
  line-height: 1.3;
  word-break: break-word;
}

.end-card {
  width: min(100%, 24rem);
  padding: 1.1rem;
  text-align: left;
}
.end-prog {
  margin-bottom: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.end-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}
.end-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  padding: 0.5rem 0.3rem;
  border-radius: 0.7rem;
  border: 1px solid rgba(125, 211, 252, 0.14);
  background: rgba(2, 6, 23, 0.35);
  text-align: center;
}
.end-stat-val {
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--frost);
  line-height: 1.1;
}
.end-stat-lab {
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted2);
  line-height: 1.2;
}
@media (max-width: 400px) {
  .end-totals { grid-template-columns: repeat(2, 1fr); }
}

.flash-ok {
  animation: flash 0.55s ease;
}
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.5), var(--shadow); }
  100% { box-shadow: 0 0 0 14px rgba(110, 231, 183, 0), var(--shadow); }
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--sb));
  transform: translateX(-50%);
  z-index: 50;
  width: min(92vw, 22rem);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  pointer-events: none;
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--stroke-strong);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.94));
  backdrop-filter: blur(14px);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  color: var(--ice);
  box-shadow: var(--shadow);
  animation: toast-in 0.28s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (min-width: 820px) {
  .screen.game {
    display: grid;
    grid-template-columns: 1fr 15rem;
    grid-template-rows: auto auto auto auto 1fr auto auto;
    gap: 0.65rem 0.9rem;
    align-content: start;
  }
  .round-progress { grid-column: 1 / -1; }
  .turn-strip { grid-column: 1 / -1; }
  .game-chrome { grid-column: 1 / -1; }
  .timer-track { grid-column: 1 / -1; }
  /* Stage + score rail share the same row so bottoms align */
  .stage {
    grid-column: 1;
    grid-row: 5;
    min-height: 14rem;
    align-self: stretch;
    height: 100%;
  }
  .score-rail {
    grid-column: 2;
    grid-row: 5; /* same band as main stage bubble — not past the guess dock */
    max-height: none;
    align-self: stretch;
    height: 100%;
    min-height: 0;
  }
  .guess-dock { grid-column: 1; grid-row: 6; }
  .center-msg { grid-column: 1; grid-row: 7; }
}
