:root {
  --bg: #0f1020;
  --bg2: #171935;
  --card: #1d2046;
  --card2: #262a5c;
  --ink: #eef0ff;
  --muted: #9aa0d0;
  --accent: #7c5cff;
  --accent2: #00d4b8;
  --good: #36d399;
  --warn: #ffb454;
  --bad: #ff5d73;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Fredoka', system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 600px at 50% -10%, #2a2d66 0%, var(--bg) 60%);
  min-height: 100vh;
}

.topbar { text-align: center; padding: 28px 16px 10px; }
.tagline { color: var(--muted); margin: 6px 0 0; }
.tagline em { color: var(--accent2); font-style: normal; }

/* ---- wordart logo ---- */
.logo { margin: 0; font-size: 2.6rem; line-height: 1; display: inline-flex; align-items: center; gap: 2px; }
.logo.big { font-size: clamp(3rem, 14vw, 5.5rem); }
.logo .logo-bubble { margin-right: 10px; display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.logo .wa {
  display: inline-block;
  font-weight: 700;
  color: hsl(calc(265 + var(--i) * 26), 85%, 66%);
  text-shadow:
    0 1px 0 hsl(calc(265 + var(--i) * 26), 60%, 46%),
    0 2px 0 hsl(calc(265 + var(--i) * 26), 60%, 40%),
    0 3px 0 hsl(calc(265 + var(--i) * 26), 60%, 34%),
    0 4px 6px rgba(0, 0, 0, 0.45);
  animation: waBounce 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.09s);
}
@keyframes waBounce { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }

#app { max-width: 760px; margin: 18px auto; padding: 0 16px 60px; }

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--bg2) 100%);
  border: 1px solid #2c2f63;
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.screen { display: none; }
.screen.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

h2 { margin-top: 0; }
h3 { margin: 0 0 10px; color: var(--accent2); font-weight: 600; }

label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 0.92rem; }

input[type=text], input:not([type]), select, .code {
  width: 100%;
  padding: 12px 14px;
  background: #0d0e22;
  border: 1px solid #34387a;
  color: var(--ink);
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

button {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--card2);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(135deg, var(--accent), #9d7bff); }
button.ghost { background: transparent; border-color: #3a3e80; color: var(--muted); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* splash that pops at the point of every click/tap */
.tap-ripple {
  position: fixed; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%; pointer-events: none; z-index: 240;
  background: radial-gradient(circle, var(--accent2), rgba(0, 212, 184, 0) 70%);
  animation: tapRipple 0.5s ease-out forwards;
}
@keyframes tapRipple {
  from { transform: scale(0.4); opacity: 0.75; }
  to { transform: scale(5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .tap-ripple { display: none; } }

.row { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.row.end { justify-content: flex-end; margin-top: 22px; }
.divider { text-align: center; color: var(--muted); margin: 16px 0; }
.join-row .code { text-transform: uppercase; letter-spacing: 6px; text-align: center; max-width: 150px; }

.error { color: var(--bad); min-height: 1.2em; }
.hint { color: var(--muted); min-height: 1.2em; }
.warn { color: var(--warn); }

/* lobby */
.lobby-head { display: flex; justify-content: space-between; align-items: baseline; }
.roomcode { color: var(--muted); }
.roomcode span { color: var(--accent2); font-weight: 700; letter-spacing: 4px; font-size: 1.3rem; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.25fr; gap: 24px; margin-top: 10px; align-items: stretch; }
@media (max-width: 640px) { .lobby-grid { grid-template-columns: 1fr; } }
.lobby-left { display: flex; flex-direction: column; min-height: 0; }
.roomcode .small { margin-left: 10px; vertical-align: 2px; }

/* ---- chat ---- */
/* pinned to the bottom of the left column */
.chat { display: flex; flex-direction: column; margin-top: auto; padding-top: 16px; }
.chat h3 { margin-bottom: 6px; }
.chat-list {
  list-style: none; margin: 0 0 8px; padding: 8px 10px; flex: 1; overflow-y: auto;
  background: #11132b; border: 1px solid #2a2d63; border-radius: 10px; min-height: 160px;
}
/* cap the lobby chat so new messages scroll inside the box instead of growing
   the column (which stretched the settings panel beside it) */
.lobby-chat .chat-list { min-height: 200px; max-height: 320px; }
.chat-list li { margin-bottom: 5px; font-size: 0.9rem; line-height: 1.35; word-break: break-word; }
.chat-list .c-name { font-weight: 600; color: var(--accent2); }
.chat-list .c-sys { color: var(--muted); font-style: italic; font-size: 0.82rem; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.chat-form button { padding: 10px 16px; }

/* floating in-game chat widget */
.chat-widget { position: fixed; right: 16px; bottom: 16px; z-index: 45; display: none; flex-direction: column; align-items: flex-end; gap: 8px; }
.chat-widget.on { display: flex; }
.chat-toggle {
  width: 52px; height: 52px; border-radius: 50%; font-size: 1.3rem; padding: 0;
  background: linear-gradient(135deg, var(--accent), #9d7bff); box-shadow: 0 8px 24px rgba(0,0,0,.45); position: relative;
}
.chat-unread {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--bad); color: #fff; border-radius: 999px; font-size: 0.72rem; line-height: 20px; font-weight: 700;
}
.chat-panel {
  width: min(330px, 88vw); height: 380px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid #2c2f63;
  border-radius: 14px; padding: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.chat-panel[hidden] { display: none; }
.chat-panel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 8px; }
.chat-panel-head button { background: transparent; border: none; color: var(--muted); font-size: 1rem; padding: 2px 8px; }

.players { list-style: none; padding: 0; margin: 0; }
.players li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: #14162f; border-radius: 10px; margin-bottom: 8px;
}
.players .crown { color: var(--warn); }
.players .pl-main { display: flex; align-items: center; gap: 7px; min-width: 0; }
.players .pl-right { display: flex; align-items: center; gap: 8px; flex: none; }
.players .bot-tag { font-size: 0.7rem; color: var(--accent2); background: #11233a; border: 1px solid #1f4a5e; padding: 2px 7px; border-radius: 999px; }
.players .kick-btn, .players .botx-btn {
  background: transparent; border: 1px solid #4a2f50; color: #ff8aa5;
  padding: 3px 9px; border-radius: 999px; font-size: 0.74rem;
}
.players .kick-btn:hover, .players .botx-btn:hover { background: #3a1f2c; }
.players .kick-votes { font-size: 0.72rem; color: var(--warn); }

/* lobby "you" editor */
.me-edit { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.me-edit-label { font-size: 0.78rem; color: var(--muted); flex: none; }
.me-edit input { flex: 1; padding: 8px 12px; }
.me-edit .small { padding: 8px 10px; }
.avatar-picker.mini { margin-bottom: 12px; max-height: 132px; overflow-y: auto; }

/* allow-bots: add-bot buttons */
.bot-panel { margin-top: 10px; }
.bot-panel > label { display: block; margin-bottom: 6px; }
.bot-add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.bot-add-row button {
  display: inline-flex; align-items: center; gap: 6px; background: #14162f;
  border: 1px solid #2a2d63; padding: 7px 12px; border-radius: 999px; font-size: 0.85rem;
}
.bot-add-row button:hover { border-color: var(--accent2); }

/* in-game playback-speed slider */
.speed-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; font-size: 0.9rem; }
.speed-row input[type=range] { flex: 1; }
.speed-row output { color: var(--accent2); font-weight: 600; min-width: 5ch; }
#btn-slow { min-width: 132px; }

/* early-bonus chip in the reveal */
.pts .bonus { color: var(--warn); font-size: 0.78rem; margin-left: 3px; }

/* game-mode picker + Boss Baby UI */
.mode-pick-wrap { margin: 4px 0 8px; }
.mode-pick-wrap > label { display: block; margin-bottom: 4px; }
.mode-pick-wrap.locked { opacity: 0.6; pointer-events: none; }
.mode-pick { display: flex; gap: 10px; margin: 4px 0 12px; }
.mode-card {
  flex: 1; display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 10px 12px; border-radius: 12px; background: #14162f; border: 2px solid #2c2f63; cursor: pointer;
}
.mode-card b { color: var(--ink); }
.mode-card small { color: var(--muted); font-size: 0.72rem; font-weight: 400; line-height: 1.25; }
.mode-card.active { border-color: var(--accent2); background: #15233a; }
.boss-banner {
  background: linear-gradient(135deg, #3a2b53, #243a5e); border: 1px solid #4a3f80;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 0.95rem; line-height: 1.4;
}
.boss-banner b { color: var(--warn); }
.reveal-boss { margin: 10px 0 14px; padding: 10px 12px; background: #161a33; border: 1px solid #2c2f63; border-radius: 12px; }
.rb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rb-meta { color: var(--muted); font-size: 0.85rem; }
.rb-meta b { color: var(--ink); }
#relay-wave { width: 100%; height: 60px; display: block; }
.results .boss-badge { font-size: 0.7rem; color: var(--warn); background: #3a2b1a; border: 1px solid #5e4a1f; padding: 2px 7px; border-radius: 999px; margin-left: 4px; }

/* Bluff mode: decoy input, voting panel, decoy reveal */
.decoy-row { margin: 8px 0 0; }
.decoy-row label { display: block; margin-bottom: 4px; color: var(--warn); font-size: 0.85rem; }
.vote-panel { margin-top: 14px; }
.vote-panel h3 { margin: 0 0 4px; }
.vote-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.vote-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: #14162f; border: 1px solid #2c2f63; border-radius: 12px;
}
.vote-list li.picked { border-color: var(--accent2); background: #15233a; }
.vote-list .vtxt { flex: 1; font-size: 0.95rem; word-break: break-word; }
.vote-list .vwave { width: 110px; height: 34px; flex: none; }
.vote-list .vpick { flex: none; }
.reveal-bluff { margin: 6px 0 14px; }
.reveal-bluff h4 { margin: 0 0 8px; }
.bluff-decoys { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bluff-decoys li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: #161a33; border: 1px solid #2c2f63; border-radius: 12px; flex-wrap: wrap;
}
.bluff-decoys .bd-who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.bluff-decoys .bd-text { flex: 1; color: var(--muted); font-size: 0.9rem; word-break: break-word; min-width: 80px; }
.bluff-decoys .bd-votes { flex: none; font-size: 0.82rem; color: var(--muted); }
.bluff-decoys .bd-pts { flex: none; color: var(--warn); font-weight: 600; }
.results .decoy-pts { color: var(--warn); font-size: 0.78rem; margin-left: 3px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  background: #14162f; padding: 8px 12px; border-radius: 999px; cursor: pointer; color: var(--ink);
}
.checks input { width: auto; }
.sliders label { display: flex; align-items: center; gap: 10px; }
.sliders output { color: var(--accent2); font-weight: 600; min-width: 2ch; }
.sliders input[type=range] { flex: 1; }
.host-only-tag { font-size: 0.7rem; color: var(--muted); font-weight: 400; }
.settings.locked { opacity: 0.6; pointer-events: none; }

/* simple/advanced mode toggle */
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.settings-head h3 { margin: 0; }
.mode-toggle { display: inline-flex; background: #0d0e22; border: 1px solid #34387a; border-radius: 999px; padding: 2px; }
.mode-toggle .seg { background: transparent; border: none; color: var(--muted); padding: 5px 14px; border-radius: 999px; font-size: 0.82rem; }
.mode-toggle .seg.active { background: linear-gradient(135deg, var(--accent), #9d7bff); color: #fff; }
/* hide advanced rows when in simple mode */
.settings.simple .adv { display: none; }
#voice-select { width: 100%; }

/* play */
.play-head { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.pill { background: #14162f; padding: 8px 14px; border-radius: 999px; color: var(--muted); }
.pill.timer { margin-left: auto; color: var(--accent2); font-weight: 700; min-width: 64px; text-align: center; }
.pill.timer.danger { color: var(--bad); }

.listen { text-align: center; padding: 18px; background: #11132b; border-radius: 14px; }
.replay {
  font-size: 1.3rem; padding: 18px 30px;
  background: linear-gradient(135deg, var(--accent2), #2fe6c6); color: #03241f;
}
.replay.small { font-size: 1rem; padding: 10px 18px; }
.listen-hint { color: var(--muted); margin: 12px 0 6px; }
.listen-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.guess { margin-top: 20px; }
.count { color: var(--accent2); }

/* waveforms */
.wave {
  width: 100%; height: 46px; display: block;
  background: #0d0e22; border: 1px solid #2a2d63; border-radius: 8px; margin-top: 8px;
  cursor: pointer; touch-action: none;
}
/* karaoke letter shading while the pronunciation plays */
.kchar { transition: color 0.08s ease, text-shadow 0.08s ease; }
.kchar.lit { color: var(--accent2); text-shadow: 0 0 8px rgba(0, 212, 184, 0.65); }
.wave.target { height: 60px; }
#self-wave { height: 38px; opacity: 0.9; }
.legend { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.ghost-key { color: var(--accent); }
.guess-key { color: var(--accent2); }
.reveal-target-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.play-btn {
  background: #14162f; border: 1px solid #34387a; border-radius: 999px;
  width: 38px; height: 38px; padding: 0; font-size: 0.95rem; color: var(--accent2);
}
.play-btn:disabled { color: var(--muted); }

/* results */
.results { list-style: none; padding: 0; margin: 16px 0; }
.results li {
  display: grid; grid-template-columns: 26px 38px 1fr auto auto; gap: 10px 12px; align-items: center;
  padding: 12px 14px; background: #14162f; border-radius: 10px; margin-bottom: 8px;
}
.results .rank { color: var(--muted); }
.results .who { font-weight: 600; min-width: 0; }
.results .guessed { color: var(--muted); font-style: italic; }
.results .pts { font-weight: 700; color: var(--accent2); }
.results .total { color: var(--muted); font-size: 0.9rem; }
.results .wave { grid-column: 1 / -1; margin-top: 4px; }
.results.final li { grid-template-columns: 40px 1fr auto; }
.results.final li { grid-template-columns: 40px 1fr auto; }
.results.final .pts { font-size: 1.2rem; }

.reveal-target { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 8px; }
.target-meta { color: var(--muted); }
.target-meta code { color: var(--accent2); background: #11132b; padding: 2px 8px; border-radius: 6px; }

.foot { text-align: center; padding: 10px 16px 40px; min-height: 1.4em; }

/* ---- circular language flags ---- */
.flag {
  display: inline-flex; width: 20px; height: 20px; border-radius: 50%; overflow: hidden;
  vertical-align: middle; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px #34387a; background: #0d0e22; font-size: 13px; flex: none;
}
.flag img { width: 100%; height: 100%; object-fit: cover; }

/* ---- avatars (a real Egyptian hieroglyph in a chosen colour, slowly spinning) ---- */
.avatar { display: inline-block; vertical-align: middle; margin-right: 2px; }
.avatar.glyph, .avatar-cur, .ab-glyph {
  font-family: 'Noto Sans Egyptian Hieroglyphs', 'Fredoka', system-ui, sans-serif;
}
@keyframes avatarSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
/* a centred square box so the glyph spins about its own middle (no wobble), sized
   a little larger than the glyph + a margin so the rotation never clips neighbours.
   the actual animation (duration/direction) is set inline per avatar in JS. */
.avatar.glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4em; height: 1.4em; line-height: 1; margin: 0 0.12em;
  vertical-align: middle; transform-origin: 50% 50%;
}
.avatar-cur { display: inline-flex; align-items: center; justify-content: center; }

/* character + colour builder */
.avatar-build { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.avatar-picker.mini { max-height: 240px; overflow-y: auto; }
.ab-row-label { font-size: 0.72rem; color: var(--muted); margin: 2px 0 -2px; }
.ab-colors { display: flex; flex-wrap: wrap; gap: 7px; }
.ab-color { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid #2a2d63; cursor: pointer; }
.ab-color.sel { border-color: #fff; transform: scale(1.14); box-shadow: 0 0 0 2px rgba(255,255,255,.22); }
.ab-glyphs { display: flex; flex-wrap: wrap; gap: 6px; max-height: 168px; overflow-y: auto; padding: 2px; }
.ab-glyph {
  width: 40px; height: 40px; padding: 0; font-size: 1.55rem; line-height: 38px; text-align: center;
  background: #14162f; border: 2px solid transparent; border-radius: 10px;
}
.ab-glyph.sel { border-color: var(--accent2); background: #1d2046; transform: translateY(-2px); }
.avatar-preview { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--muted); }
.avatar-preview .avatar-cur { font-size: 2rem; }

/* ---- "thinking baby" while audio is generating ---- */
.thinking { color: var(--warn); min-height: 1.2em; margin: 8px 0 0; }
.thinking .baby { display: inline-block; font-size: 1.2em; transform-origin: 70% 80%; animation: scratch 0.5s ease-in-out infinite; }
@keyframes scratch { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) translateY(-1px); } }

/* ---- local profile ---- */
.profile { color: var(--muted); margin: 0 0 12px; font-size: 0.9rem; min-height: 1.1em; }
.profile b { color: var(--accent2); }

/* ---- global stats ---- */
.global-stats {
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
  margin-top: 20px; color: var(--muted); font-size: 0.9rem;
}
.global-stats span { background: #14162f; border: 1px solid #2c2f63; border-radius: 999px; padding: 6px 14px; }
.global-stats b { color: var(--accent2); font-variant-numeric: tabular-nums; }
.global-stats b.bump { animation: statBump 0.4s ease; }
@keyframes statBump { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: var(--warn); } 100% { transform: scale(1); } }

/* ---- public lobby browser ---- */
.public-lobbies { margin-top: 22px; border-top: 1px solid #2c2f63; padding-top: 14px; }
.pl-head { display: flex; justify-content: space-between; align-items: center; }
button.small { padding: 6px 12px; font-size: 0.85rem; }
.rooms { list-style: none; padding: 0; margin: 10px 0 0; }
.rooms li { background: #14162f; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.rooms .rooms-empty { color: var(--muted); text-align: center; font-style: italic; }
.room-row { display: flex; align-items: center; gap: 12px; }
.room-row .rc { font-weight: 700; letter-spacing: 3px; color: var(--accent2); }
.room-row .meta { color: var(--muted); font-size: 0.85rem; flex: 1; }
.room-row .badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: #23264f; color: var(--muted); }
.room-row .badge.live { color: var(--good); }

/* ---- toggles ---- */
.toggles { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.switch { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); cursor: pointer; }
.switch input { width: auto; }

/* ---- preview / tries area ---- */
.preview-area { margin-top: 18px; border-top: 1px solid #2c2f63; padding-top: 14px; display: none; }
.preview-area.on { display: block; }
.wave-label { color: var(--muted); font-size: 0.85rem; display: block; margin-bottom: 4px; }
.preview-area h4 { margin: 14px 0 8px; color: var(--accent2); }
.hint-inline { color: var(--muted); font-weight: 400; }
.tries { list-style: none; padding: 0; margin: 0; }
.tries .tries-empty { color: var(--muted); font-style: italic; }
.tries li.try {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 8px 10px; align-items: center;
  background: #14162f; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.tries .try .txt { font-weight: 600; }
.tries .try .wave { grid-column: 1 / -1; height: 38px; }
.tries .try .use { background: linear-gradient(135deg, var(--accent), #9d7bff); }

/* ---- HUD ---- */
.hud { position: fixed; top: 14px; right: 14px; display: none; gap: 8px; z-index: 40; }
.hud.on { display: flex; }
.hud-btn {
  width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 1.1rem;
  background: #1d2046; border: 1px solid #3a3e80; color: var(--ink); box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.hud-btn.danger { color: var(--bad); }
.hud-btn:disabled { opacity: 0.4; }

/* ---- overlays (pause + help) ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(8,9,20,.78); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.overlay.on { display: flex; }
.overlay-box { text-align: center; max-width: 460px; }
.overlay-box.help { text-align: left; }
.overlay-box .big { font-size: 2.2rem; font-weight: 700; margin-bottom: 8px; }
.help ol { padding-left: 20px; line-height: 1.55; }
.help li { margin-bottom: 8px; }

/* ---- public profiles + analytics ---- */
.muted { color: var(--muted); }
.profiles-cta { display: flex; gap: 10px; justify-content: center; margin: 8px 0 2px; }
.profiles-box { max-width: 720px; width: 100%; text-align: left; max-height: 86vh; overflow-y: auto; }
.profiles-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.profiles-head h2 { margin: 0; flex: 1; font-size: 1.25rem; }
.profiles-search { display: flex; gap: 8px; margin-bottom: 10px; }
.profiles-search input { flex: 1; }
.center-msg { text-align: center; padding: 16px; }

.profiles-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.profiles-list li.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  background: #14162f; border: 1px solid #262a59; border-radius: 12px;
  transition: transform .08s ease, border-color .15s ease;
}
.profiles-list li.row:hover { border-color: var(--accent); transform: translateX(2px); }
.profiles-list .prank { width: 22px; color: var(--muted); font-weight: 700; text-align: center; }
.profiles-list .pavatar { font-size: 1.5rem; }
.profiles-list .pname { font-weight: 600; flex: 1; word-break: break-word; }
.profiles-list .pmeta { color: var(--muted); font-size: .82rem; text-align: right; line-height: 1.35; flex: none; }

.profile-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pd-avatar { font-size: 2.6rem; line-height: 1; }
.profile-hero-txt { flex: 1; min-width: 0; }
.profile-hero-txt h3 { margin: 0; }
.pd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; margin-bottom: 18px; }
.pd-stats .stat { background: #14162f; border: 1px solid #262a59; border-radius: 12px; padding: 10px 8px; text-align: center; }
.pd-stats .stat b { display: block; font-size: 1.35rem; color: var(--accent2); }
.pd-stats .stat span { font-size: .74rem; color: var(--muted); }

.pd-block { margin-bottom: 18px; }
.pd-block h4 { margin: 0 0 8px; }
canvas.chart { width: 100%; height: 150px; display: block; background: #11132b; border: 1px solid #2a2d63; border-radius: 10px; }

.pd-langs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pd-langs li { display: flex; align-items: center; gap: 10px; }
.pd-langs .lf { width: 132px; display: flex; align-items: center; gap: 7px; font-size: .9rem; flex: none; }
.pd-langs .lbar { flex: 1; height: 12px; background: #1c1f44; border-radius: 999px; overflow: hidden; }
.pd-langs .lbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); border-radius: 999px; }
.pd-langs .lv { width: 86px; text-align: right; font-size: .85rem; }
.pd-langs .lv small { color: var(--muted); }
.dist-note { margin-top: 8px; font-size: .85rem; line-height: 1.45; }

/* ---- toasts ---- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #23264f; border: 1px solid #3a3e80; color: var(--ink);
  padding: 10px 16px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  animation: toastIn .2s ease, toastOut .3s ease 2.4s forwards;
}
.toast .lock { color: var(--accent2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---- reveal foot ---- */
.reveal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }

/* ---- confetti ---- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 55; display: none; }
.confetti.on { display: block; }

/* ---- intro splash ---- */
.intro {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 24px;
  /* light veil so the animated background letters stay visible behind content */
  background: radial-gradient(680px 420px at 50% 30%, rgba(15, 16, 32, 0.28) 0%, rgba(15, 16, 32, 0.5) 78%);
}
.intro.on { display: flex; }
/* while the intro is up, hide the page content so only the animated letters
   show through its translucent background (not the join card) */
#intro.on ~ .topbar, #intro.on ~ #app { visibility: hidden; }

/* "edit your character" button (join screen + top of the lobby player list) */
.profile-edit {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 14px; margin: 0 0 12px; border-radius: 12px;
  background: #14162f; border: 1px solid #2c2f63; cursor: pointer;
}
.profile-edit:hover { border-color: var(--accent2); }
.profile-edit .avatar-cur { font-size: 1.7rem; flex: none; }
.pe-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.pe-text b { color: var(--ink); }
.pe-text small { color: var(--muted); font-size: 0.74rem; font-weight: 400; }
.pe-edit { font-size: 1.1rem; flex: none; opacity: 0.8; }

/* profile modal */
.profile-box { max-width: 460px; width: 100%; text-align: left; max-height: 88vh; overflow-y: auto; }
.pf-spin { display: flex; align-items: center; gap: 24px; margin: 14px 0 6px; flex-wrap: wrap; }
.pf-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pf-preview {
  width: 76px; height: 76px; border-radius: 16px; padding: 0; font-size: 2.5rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: #11132b; border: 1px solid #2a2d63;
}
.pf-preview:hover { border-color: var(--accent2); }
.pf-hint { font-size: 0.7rem; color: var(--muted); }
.knob-wrap { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.knob {
  width: 64px; height: 64px; border-radius: 50%; position: relative; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 50% 32%, #2a2e63, #14162f 72%); border: 2px solid #3a3e80;
}
.knob:active { cursor: grabbing; }
.knob:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.knob-ind { position: absolute; left: 50%; top: 7px; width: 4px; height: 16px; margin-left: -2px; background: var(--accent2); border-radius: 2px; transform-origin: 50% 25px; }
.knob-label { font-size: 0.78rem; color: var(--muted); }
.knob-label b { color: var(--accent2); }
.intro.fade-out { animation: introOut 0.5s ease forwards; }
@keyframes introOut { to { opacity: 0; transform: scale(1.04); visibility: hidden; } }
.intro-card { text-align: center; max-width: 640px; }
.intro-tag { color: var(--muted); font-size: 1.2rem; margin: 18px 0 26px; line-height: 1.5; }
.intro-tag em { color: var(--accent2); font-style: normal; }
.intro-card .logo { animation: dropIn 0.6s cubic-bezier(.2,1.4,.4,1) both; }

.flow { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 30px; }
.flow-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #14162f; border: 1px solid #2c2f63; border-radius: 14px; padding: 12px 16px; min-width: 78px;
  opacity: 0; animation: popIn 0.5s ease forwards; animation-delay: calc(var(--s) * 0.18s + 0.4s);
}
.flow-step .fi { font-size: 1.8rem; animation: bob 3s ease-in-out infinite; animation-delay: calc(var(--s) * 0.2s); }
.flow-step .fl { color: var(--muted); font-size: 0.85rem; }
.flow-arrow { color: var(--accent); font-size: 1.4rem; opacity: 0; animation: popIn 0.5s ease forwards; animation-delay: calc(var(--s) * 0.18s + 0.4s); }
.big-btn { font-size: 1.2rem; padding: 16px 34px; opacity: 0; animation: popIn 0.5s ease forwards 1.5s; }

@keyframes dropIn { from { opacity: 0; transform: translateY(-30px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(12px) scale(0.9); } to { opacity: 1; transform: none; } }

/* ---- loading screen ---- */
.loading-overlay { z-index: 70; }
.equalizer { display: flex; gap: 7px; height: 64px; align-items: flex-end; justify-content: center; margin-bottom: 16px; }
.equalizer span {
  width: 11px; border-radius: 6px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  animation: eq 0.9s ease-in-out infinite;
}
.equalizer span:nth-child(1) { animation-delay: 0s; }
.equalizer span:nth-child(2) { animation-delay: 0.15s; }
.equalizer span:nth-child(3) { animation-delay: 0.3s; }
.equalizer span:nth-child(4) { animation-delay: 0.45s; }
.equalizer span:nth-child(5) { animation-delay: 0.6s; }
@keyframes eq { 0%, 100% { height: 16px; } 50% { height: 64px; } }
#loading-msg { color: var(--ink); font-size: 1.1rem; }

/* ---- animated multilingual letters ---- */
#bg-letters { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ---- music toggle ---- */
.music-toggle {
  position: fixed; top: 14px; left: 14px; z-index: 85; width: 42px; height: 42px;
  border-radius: 50%; padding: 0; font-size: 1.15rem; background: #1d2046;
  border: 1px solid #3a3e80; box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.music-toggle.off { opacity: 0.55; filter: grayscale(1); }

/* ---- drifting background bubbles ---- */
#bg-bubbles { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
#bg-bubbles span {
  position: absolute; bottom: -120px; left: var(--x);
  width: var(--sz); height: var(--sz); border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(124,92,255,.30), rgba(0,212,184,.10));
  border: 1px solid rgba(124,92,255,.18);
  animation: rise var(--t) linear infinite; animation-delay: var(--d);
}
@keyframes rise {
  0% { transform: translateY(0) translateX(0) scale(0.9); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.5; }
  100% { transform: translateY(-115vh) translateX(30px) scale(1.1); opacity: 0; }
}
#app, .topbar { position: relative; z-index: 1; }

/* timer pulse when time is short */
.pill.timer.danger { animation: pulse 0.6s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
