:root {
  --bg: #0b0e17;
  --panel: #131828;
  --panel-2: #1b2236;
  --line: #273049;
  --text: #e8ecf8;
  --muted: #8b97b8;
  --accent: #4dd2ff;
  --good: #7cff4d;
  --warn: #ffd24d;
  --bad: #ff4d6d;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* ---- header ---- */

.bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #151b2c, #0f1420);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 3px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}

.stat { display: flex; flex-direction: column; line-height: 1.2; }
.stat label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat.right { margin-left: auto; }

.progress {
  flex: 1 1 160px;
  max-width: 320px;
  height: 8px;
  border-radius: 99px;
  background: var(--panel-2);
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--good));
  transition: width .25s ease;
}

/* ---- layout ---- */

main {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 190px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 0;
  overflow-y: auto;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

#board {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  background: #070a12;
  border: 1px solid var(--line);
}

/* ---- players ---- */

/* "You are ..." bar: the one place to rename yourself, reachable during a
   round as well as in the lobby. */
.you {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  min-height: 38px;
}

.you .youname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you .youlabel { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.linkbtn {
  margin-left: auto;
  background: none;
  border: 0;
  padding: 2px 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.linkbtn:hover { filter: brightness(1.2); }

.you input[type=text] {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--text);
}

.players li.me { outline: 1px solid var(--accent); cursor: pointer; }

.players ul { list-style: none; margin: 0 0 14px; padding: 0; }

.players li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: var(--panel-2);
  transition: opacity .2s;
}

.players li.gone { opacity: .38; }

.chip { width: 10px; height: 10px; border-radius: 3px; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pscore { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.pready { font-size: 11px; font-weight: 700; color: var(--good); }
.pwait { font-size: 11px; color: var(--muted); }

.hint h3, .goal h3 {
  margin: 14px 0 6px;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.hint dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0;
  font-size: 12px;
}

.hint dt { color: var(--accent); font-weight: 700; }
.hint dd { margin: 0; color: var(--muted); }

.goal p { margin: 0; font-size: 12px; color: var(--muted); }
.goal b { color: var(--text); }

.mini { width: 100%; height: 62px; background: #070a12; border: 1px solid var(--line); border-radius: 8px; }
.mini.tall { height: 176px; }

/* ---- overlay ---- */

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 9, 16, .82);
  backdrop-filter: blur(5px);
  z-index: 20;
}

.overlay.show { display: flex; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 30px;
  min-width: 400px;
  max-width: 560px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}

.card h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: 1px; }
.card .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

.card input[type=text] {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  margin-bottom: 12px;
}

.card input[type=text]:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  font: inherit;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 9px;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: #04121a;
  transition: filter .15s, transform .05s;
}

button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.on { background: var(--good); color: #08210a; }
button:disabled { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.grid-players {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 4px 0 18px;
}

.slot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid transparent;
}

.slot.ready { border-color: var(--good); }
.slot .tick { margin-left: auto; font-weight: 700; }
.slot.ready .tick { color: var(--good); }
.slot .tick.no { color: var(--muted); font-weight: 400; }

.count {
  font-size: 76px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 4px;
  line-height: 1.05;
}

table.results { width: 100%; border-collapse: collapse; margin: 6px 0 18px; }
table.results td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.results tr:last-child td { border-bottom: 0; }
table.results td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.results td.rank { color: var(--muted); width: 26px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1080px) {
  main { grid-template-columns: 176px minmax(0, 1fr) 150px; }
  .brand-sub { display: none; }
}
