:root {
  --bg: #150e33;
  --panel: #1f1440;
  --panel-2: #2a1c52;
  --line: #3b2a6b;
  --text: #f2eefb;
  --muted: #c6badf;
  --accent: #E04307;
  --accent-2: #EF8903;
  --bad: #ff6b81;
  --good: #4ec9a7;
  --tile: #3a2470;
  --tile-faded: #241a45;
  --warn: #EF8903;
  --danger: #E04307;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #1a1038;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  letter-spacing: 4px;
  font-size: 18px;
  color: var(--accent);
}

.topbar-center { display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.mini-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
}

@media (max-width: 560px) { .hide-sm { display: none; } }

.badge {
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.badge.muted { color: var(--muted); }

main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 16px 60px;
  overflow: auto;
}

body.play-active { overflow: hidden; }
body.play-active main { padding: 8px 12px 10px; overflow: hidden; }

.screen { display: none; }
.screen.active { display: block; }

h1 { font-size: 26px; margin: 8px 0 6px; }
h2 { font-size: 22px; }
.lead { color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 14px 0;
}

details.card > summary {
  cursor: pointer;
  font-weight: 600;
}

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field select::placeholder, .field input::placeholder { color: var(--muted); opacity: 1; }
.field select, .field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a1038;
  color: var(--text);
  font-size: 16px;
}

button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; font-weight: 700; width: 100%; }
button.primary:hover { filter: brightness(1.08); }
/* The accent-orange buttons always keep white text, also while hovered, focused or pressed. */
button.primary:hover, button.primary:focus, button.primary:active { color: #fff; }
button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.ghost:hover { background: var(--panel-2); }
button.small-btn { padding: 8px 12px; font-size: 13px; margin-top: 4px; }
button:disabled { opacity: 0.5; cursor: default; }

.rules { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; color: var(--muted); }

/* Play screen */
.playhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.player-label { font-size: 18px; font-weight: 700; }
.clock { text-align: right; }
.clock-value { font-size: 34px; font-weight: 800; line-height: 1; }
.clock-label { font-size: 11px; color: var(--muted); }

/* Clock levels: amber on the last ten seconds, brand orange on the last five, so the
   player sees the turn running out. The level classes are set from app.js. */
.clock.warn .clock-value, .clock.warn .clock-label { color: var(--warn); }
.clock.danger .clock-value, .clock.danger .clock-label { color: var(--danger); }
.clock.danger .clock-value { animation: clock-pulse 0.7s ease-in-out infinite; }
@keyframes clock-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.timebar { height: 8px; background: var(--panel-2); border-radius: 999px; margin: 10px 0 16px; overflow: hidden; }
.timebar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s linear; }

/* Three-beat start (Ready, Set, Go) before the clock begins. It covers the screen
   while the players get ready and drops away the moment the minute starts. */
.count-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  text-align: center;
  padding: 24px;
}
.count-overlay[hidden] { display: none; }
.count-word {
  font-size: clamp(44px, 14vw, 92px);
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--brand-purple, #522D6E);
}
.count-word.go { color: var(--accent); }

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.tile {
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 800;
  text-transform: lowercase;
  transition: transform 0.15s ease, opacity 0.3s ease, background 0.3s ease;
}
.tile.clickable { cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; }
.tile.clickable:hover { transform: translateY(-2px); }
.tile.faded {
  background: var(--tile-faded);
  color: #6b5a9c;
  opacity: 0.45;
  transform: scale(0.9);
  cursor: default;
}
.tile.spent {
  background: #2d1b4e;
  border-color: var(--bad);
  color: #e9c9d6;
}

.entry-row { display: flex; gap: 8px; }
.entry-row input::placeholder { color: var(--muted); opacity: 1; }
.entry-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a1038;
  color: var(--text);
  font-size: 20px;
  letter-spacing: 1px;
  text-transform: lowercase;
  caret-color: transparent;
}
.entry-row button { width: auto; flex: 0 0 auto; }
.entry-row .key-back { padding: 12px 12px; }
.entry-row .key-add { padding: 12px 14px; }

.accent-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.accent-bar button {
  min-width: 42px;
  padding: 8px 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 18px;
}
.accent-bar button:hover { background: #3b2a6b; }

.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.suggestions .chip {
  background: #2a1c52;
  border: 1px dashed var(--accent);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 15px;
  cursor: pointer;
}
.suggestions .chip:hover { background: #3a2470; }

.entry-msg { min-height: 20px; margin-top: 10px; font-size: 14px; overflow-wrap: anywhere; }
.entry-msg.ok { color: var(--good); }
.entry-msg.bad { color: var(--bad); }

.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.word-list li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 15px;
}

/* Play screen: a fixed, scroll-free layout. On desktop the two word lists sit in a
   left column; on small screens they become a compact strip on top. */
#screen-play.active {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  min-height: 0;
}
#screen-play .timebar { margin: 4px 0 8px; }

.play-grid {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}
.play-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#screen-play .board { width: 100%; max-width: 500px; margin: 0 auto; gap: 8px; }
#screen-play .tile { font-size: 26px; border-radius: 10px; }
#screen-play .card { margin: 0; padding: 10px 12px; }
#screen-play .entry .entry-msg { min-height: 18px; margin-top: 6px; }

/* Per-player word lists. In individual mode the live list is visible; in 1 against 1
   the panel hides the cards and shows a short note instead, so neither player can
   read words before the end. */
.players-panel { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.pcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 0;
}
.pcard.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.pcard-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pname { font-weight: 700; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard.current .pname { color: var(--accent); }
.pword-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
}
.pword-list li {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.players-panel .words-hidden-note {
  margin: 0;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 12px;
  line-height: 1.4;
}
.players-panel.lists-hidden .pcard { display: none; }
.players-panel.solo .pcard[data-player="1"] { display: none; }

@media (max-width: 900px) {
  .play-grid { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
  .players-panel { flex-direction: row; }
  .pcard { padding: 8px 8px 6px; }
  .pword-list { max-height: 46px; }
}

/* How to Play: visual steps with an icon each. */
.howto-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.howto-head h2 { margin: 0; }
.howto-steps { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.howto-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.howto-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  line-height: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.howto-body h3 { margin: 0 0 4px; font-size: 16px; }
.howto-body p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
@media (min-width: 760px) { .howto-steps { grid-template-columns: 1fr 1fr; } }

/* Handoff */
.handoff { text-align: center; padding: 50px 10px; }

/* Review */
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }
.review-actions button { width: auto; flex: 0 1 auto; min-width: 0; }

.winner-banner {
  background: linear-gradient(90deg, #3a2470, #522D6E);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  margin: 6px 0 14px;
  overflow-wrap: anywhere;
}
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .review-grid { grid-template-columns: 1fr; } }

.review-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.review-card h3 { margin: 0 0 4px; font-size: 17px; overflow-wrap: anywhere; }
.review-score { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.review-words { list-style: none; margin: 0; padding: 0; }
.review-words li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-width: 0;
}
.review-words li:hover { background: var(--panel-2); }
.review-words li:last-child { border-bottom: none; }
.mark { width: 20px; text-align: center; font-weight: 800; }
.mark.ok { color: var(--good); }
.mark.bad { color: var(--bad); }
.review-words .w { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.review-words .why { font-size: 12px; color: var(--bad); min-width: 0; overflow-wrap: anywhere; }
.empty-note { color: var(--muted); font-size: 13px; padding: 6px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 26, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  max-width: 460px;
  width: 100%;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
}
.modal-word { font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.modal-status { font-weight: 700; margin-bottom: 12px; }
.modal-status.ok { color: var(--good); }
.modal-status.bad { color: var(--bad); }
.placeholder {
  background: #1a1038;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

/* Meaning and grammatical form slot (final review modal, /api/def) */
.def-slot {
  margin-top: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.def-title { display: block; margin-bottom: 8px; color: var(--brand-purple, #522D6E); }
.def-pos {
  display: inline-block;
  background: rgba(224, 67, 7, 0.10);
  border: 1px solid rgba(224, 67, 7, 0.35);
  color: #8a2c0a;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
}
.def-senses { margin: 0 0 8px 18px; padding: 0; }
.def-senses li { margin-bottom: 4px; }
.def-source { margin: 0; }
.def-msg { margin: 0; }
.def-msg.loading { color: var(--muted); }
@media (max-width: 560px) {
  .modal-box { padding: 16px; border-radius: 14px; }
  .modal-word { font-size: 22px; }
  .def-senses { margin-left: 16px; }
}



/* Paleta A (claro) - aplicada 2026-10-08 */
:root {
  --bg: #f6f2fc; --panel: #ffffff; --panel-2: #f0e9f9; --line: #e2d7f1;
  --text: #2b2140; --muted: #6f6489; --accent: #E04307; --accent-2: #EF8903;
  --bad: #c0392b; --good: #1f9d63; --tile: #ede4f8; --tile-faded: #f6f2fc;
}
.topbar { background: #ffffff; }
.field select, .field input { background: #ffffff; }
.entry-row input { background: #ffffff; }
.placeholder { background: #faf8fd; }
.tile.faded { color: #b9aecd; }
.tile.spent { background: #fdece7; border-color: #E04307; color: #8a2c0a; }
.accent-bar button:hover { background: #ede4f8; }
.suggestions .chip { background: #fdf0ea; border-color: #E04307; }
.suggestions .chip:hover { background: #fbe3d8; }
.winner-banner { background: linear-gradient(90deg, #f6eefc, #eee1f8); }
.modal { background: rgba(43, 33, 64, 0.45); }

/* ===== Landing (portada) con dos accesos diferenciados =====
   Misma marca que el juego: morado #522D6E y naranja #E04307 / #FF6B00.
   Dos tarjetas grandes (Individual / 1 contra 1), cada una con su imagen,
   su titulo, una frase de que es y su boton. */
:root {
  --brand-purple: #522D6E;
  --brand-purple-soft: #6d3f92;
  --brand-orange: #FF6B00;
  --brand-orange-deep: #E04307;
}

.topbar { box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(82, 45, 110, 0.06); }
.brand { color: var(--brand-purple); text-decoration: none; cursor: pointer; }
.brand:hover, .brand:focus { color: var(--brand-orange-deep); }
/* The TranslaStars logo is a real link: it goes to the TranslaStars site in a new tab. */
.ts-link { display: inline-flex; align-items: center; text-decoration: none; line-height: 0; }

.hero { text-align: center; padding: 10px 0 4px; }
.hero-kicker {
  margin: 0 auto 8px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--brand-purple);
  background: rgba(82, 45, 110, 0.08);
  padding: 5px 12px;
  border-radius: 999px;
}
.hero h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.4px;
  color: var(--brand-purple);
  margin: 0 0 10px;
}
.hero .lead { max-width: 620px; margin: 0 auto; font-size: 15px; }

.section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--brand-purple-soft);
  margin: 26px 0 12px;
}

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.mode {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.mode:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(82, 45, 110, 0.14);
  border-color: var(--brand-purple-soft);
}
.mode-shot {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 440 / 377;
  object-fit: cover;
  background: var(--panel-2);
  border-bottom: 1.5px solid var(--line);
}
.mode-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1 1 auto; }
.mode-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-purple);
}
.mode-desc { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; flex: 1 1 auto; }
.mode-cta {
  width: 100%;
  margin-top: 8px;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--brand-orange), var(--brand-orange-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(224, 67, 7, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.mode-cta:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(224, 67, 7, 0.38); }
.mode-cta.solo-cta {
  background: linear-gradient(180deg, var(--brand-purple-soft), var(--brand-purple));
  box-shadow: 0 4px 14px rgba(82, 45, 110, 0.3);
}
.mode-cta.solo-cta:hover { box-shadow: 0 6px 18px rgba(82, 45, 110, 0.4); }

.hidden-select { display: none; }

.options { margin-top: 20px; }
.options-title { margin: 0 0 12px; font-size: 15px; color: var(--brand-purple); }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.options-grid .field { margin-bottom: 8px; }

@media (max-width: 700px) {
  .modes { grid-template-columns: 1fr; gap: 14px; }
  .options-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 27px; }
}


/* ---- Server phase (2026-10-08): online 1v1, lobby, flags, global board ---- */
.flagimg { width: 22px; height: 15px; object-fit: cover; border-radius: 2px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,.12) inset; }

/* Global board */
.leaderboard { margin-top: 20px; }
.lb-modes { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.lb-mode {
  background: transparent; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.lb-mode.on { background: var(--brand-purple); border-color: var(--brand-purple); color: #fff; }
.lb-list { display: flex; flex-direction: column; gap: 4px; }
.lb-row {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  padding: 6px 8px; border-radius: 8px; background: var(--panel-2);
  font-size: 14px;
}
.lb-row.me { outline: 1px solid var(--brand-orange); }
.lb-row .pos { min-width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row .flag { display: inline-flex; }
.lb-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-meta { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; min-width: 0; }
.lb-row .lb-badge, .lb-row .lb-gm {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: rgba(82,45,110,.12); color: var(--brand-purple); white-space: nowrap;
}
.lb-row .lg { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.lb-row .sc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-row .sc small { color: var(--muted); }
.lb-empty, .lb-load { color: var(--muted); padding: 8px 0; }

/* Narrow phones: the row folds into three lines under the medal and the flag,
   so the name, the mode/date and the score never push the board sideways. */
@media (max-width: 560px) {
  .lb-row {
    display: grid;
    grid-template-columns: 44px 22px minmax(0, 1fr);
    grid-template-areas: "pos flag nm" "pos flag meta" "pos flag sc";
    column-gap: 8px; row-gap: 2px; align-items: center;
    padding: 8px;
  }
  .lb-row .pos { grid-area: pos; min-width: 0; }
  .lb-row .flag { grid-area: flag; }
  .lb-row .nm { grid-area: nm; flex: none; }
  .lb-row .lb-meta { grid-area: meta; flex-wrap: wrap; }
  .lb-row .lb-brk { display: none; }
  .lb-row .sc { grid-area: sc; justify-self: start; white-space: normal; font-size: 13px; }
}

/* Lobby */
.lobby { max-width: 640px; margin: 0 auto; }
.lobby .lead { text-align: left; }
.lobby-setup .field { margin-bottom: 12px; }
.lobby-actions { margin: 10px 0 4px; }
.lobby-join { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.lobby-join-row { display: flex; gap: 8px; }
.lobby-join-row input { flex: 1; text-transform: uppercase; }
.lobby-room { margin-top: 16px; text-align: center; }
.room-code { font-size: 34px; font-weight: 800; letter-spacing: 4px; color: var(--brand-purple); margin: 6px 0; }
.room-status { font-size: 15px; margin: 10px 0; }
.lobby-msg { margin-top: 12px; color: var(--muted); min-height: 20px; }
.lobby-count { font-size: 30px; font-weight: 800; color: var(--brand-orange); text-align: center; margin: 10px 0; }

/* Match result cards */
#matchGrid .review-card { background: var(--panel-2); border-radius: 10px; padding: 12px; }
#matchGrid .review-card .flagimg { width: 26px; height: 18px; }

/* Brand lockup: LETRIX with the TranslaStars logo under it, and the footer with the
   same mark. The logo is a real image (public/media), never redrawn text. */
.brand-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-by { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ts-logo { display: block; height: 18px; width: auto; }
.footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: 12px; padding: 10px 16px 14px;
}
body.play-active .footer { padding: 3px 12px 5px; font-size: 11px; }
body.play-active .footer .ts-logo { height: 14px; }

/* Flag picker (CineLingo style): a searchable grid of flag chips, the common
   countries first and then the whole world. The flag is a repository image. */
.flag-field { margin-bottom: 12px; }
.flag-search {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #ffffff; color: var(--text); font-size: 15px; margin-bottom: 8px;
}
.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  align-content: start;
  gap: 6px; max-height: 210px; overflow: auto; padding: 6px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.flag-main {
  border: 2px solid var(--accent-2); border-radius: 10px;
  background: var(--panel-2); padding: 5px; margin-bottom: 8px;
}
.flag-main[hidden], .flag-all-title[hidden] { display: none; }
.flag-main-title, .flag-all-title {
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; margin: 2px 2px 6px;
}
.flag-main-title { color: var(--accent-2); }
.flag-all-title { color: var(--brand-purple-soft); margin: 6px 2px 4px; }
.flag-grid-main {
  border: 0; border-radius: 0; background: transparent; padding: 0;
  max-height: none; overflow: visible;
}
.flag-group {
  grid-column: 1 / -1; font-size: 10px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--brand-purple-soft); margin: 4px 0 2px;
}
.flag-none { grid-column: 1 / -1; font-size: 12px; color: var(--muted); padding: 10px; text-align: center; }
.flagchip {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 2px; width: 100%; height: 54px; padding: 4px 2px 3px;
  border: 2px solid transparent; border-radius: 8px;
  background: #ffffff; color: var(--muted); cursor: pointer; font: inherit; min-width: 0; overflow: hidden;
}
.flagchip.main { border-color: rgba(239, 137, 3, 0.5); }
.flagchip .fl { width: 32px; height: 22px; flex: none; object-fit: cover; display: block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }
.flagchip .cn {
  display: block; width: 100%; max-width: 100%; margin: 0; color: var(--muted);
  font-size: 10px; line-height: 1.05; letter-spacing: .2px;
  text-transform: uppercase; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flagchip:hover { border-color: var(--brand-purple-soft); }
.flagchip:focus-visible { outline: 2px solid var(--brand-purple-soft); outline-offset: 1px; }
.flagchip.on { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.flagchip.on .cn { color: #fff; }
.flagchip.on:hover { border-color: var(--accent); background: var(--accent); color: #fff; }
@media (max-width: 700px) {
  .flag-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); max-height: 170px; gap: 4px; padding: 4px; }
  .flag-grid-main { max-height: none; overflow: visible; padding: 0; }
  .flag-main { padding: 3px; }
  .flagchip { height: 52px; padding: 3px 1px 2px; }
  .flagchip .fl { width: 28px; height: 19px; }
}

/* Keep the top bar inside a narrow phone: the controls drop to a second row
   instead of pushing the page sideways. */
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 8px 10px; }
  .topbar-center { order: 3; width: 100%; justify-content: center; }
}

/* Last-resort guard so a stray wide child can never add a sideways scroll bar. */
html, body { max-width: 100%; overflow-x: hidden; }
