:root {
  --bg: #121213;
  --tile: #3a3a3c;
  --border: #565758;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;
  --text: #f8f8f8;
  --muted: #818384;
  --surface: #1b1b1d;
  --surface-2: #252528;
  --field: #0e0e10;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font-ui: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-game: "Helvetica Neue", Arial, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  letter-spacing: -0.01em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* the game itself stays classic wordle */
.board .tile, .key { font-family: var(--font-game); letter-spacing: normal; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 56px 16px;
}

h1 {
  font-size: 1.9rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 700;
}
h1 span { color: var(--correct); }

.card {
  background: var(--surface);
  border-radius: 20px; /* 12 inner + 8… card children use 8px radii, padding 28 */
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(380px, 92vw);
  box-shadow:
    0 0 0 1px oklch(1 0 0 / 0.06),
    0 8px 24px oklch(0 0 0 / 0.35),
    0 2px 6px oklch(0 0 0 / 0.3);
}

input, select, button {
  font: inherit;
  border-radius: 8px;
  padding: 12px 14px;
}

input, select {
  background: var(--field);
  border: 1px solid transparent;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.1);
  color: var(--text);
  transition-property: box-shadow;
  transition-duration: 0.15s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--correct);
}
#code-input, #opt-word { text-transform: uppercase; letter-spacing: 4px; }

button {
  background: var(--surface-2);
  border: none;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  min-height: 44px;
  transition-property: scale, filter, background-color;
  transition-duration: 0.15s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
button:hover { filter: brightness(1.15); }
button:active { scale: 0.96; }
button.primary { background: var(--correct); font-weight: 700; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); filter: none; }

.row { display: flex; gap: 10px; }
.row input { flex: 1; min-width: 0; }

.divider {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: oklch(1 0 0 / 0.08);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

#host-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid oklch(1 0 0 / 0.08);
}

#lobby-players {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#lobby-players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--field);
  border-radius: 8px;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.05);
}
#lobby-players .badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--correct);
  background: oklch(from var(--correct) l c h / 0.15);
  border-radius: 4px;
  padding: 3px 7px;
}
#lobby-players .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
#lobby-players .dot.on { background: var(--correct); }
#lobby-players .kick {
  margin-left: auto;
  background: none;
  color: var(--muted);
  min-height: 0;
  padding: 4px 10px;
  position: relative;
}
#lobby-players .kick::after { content: ""; position: absolute; inset: -8px; }
#lobby-players .kick:hover { color: var(--text); filter: none; }

/* ---- game ---- */
#screen-game { padding: 20px 16px; gap: 20px; }

#game-header {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}
#game-code {
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08);
  border-radius: 999px;
  padding: 6px 14px;
}

#arena {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 500px) 1fr;
  gap: 28px;
  width: 100%;
  max-width: 1400px;
  align-items: start;
}

#center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  padding-top: 4px;
}

.board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; }
.board .board-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }

/* board matches keyboard width */
.board.big { width: 100%; max-width: 480px; }
.board.big .tile {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; text-transform: uppercase;
  border: 2px solid var(--tile);
  border-radius: 4px;
  transition-property: border-color;
  transition-duration: 0.1s;
}
.board.big .tile.filled { border-color: var(--border); }
.board.big .tile.pop { animation: pop 0.12s ease-out; }

@keyframes pop {
  0% { scale: 0.92; }
  50% { scale: 1.06; }
  100% { scale: 1; }
}

.mini-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 180px;
  background: var(--surface);
  border-radius: 14px; /* 4 inner + 10 padding */
  padding: 10px;
  box-shadow:
    0 0 0 1px oklch(1 0 0 / 0.06),
    0 4px 12px oklch(0 0 0 / 0.25);
}
.mini-name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 0 2px;
}
.mini-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-name.solved { color: var(--correct); font-weight: 700; }
.mini-name.offline { opacity: 0.45; }
.board.mini { width: 100%; gap: 4px; }
.board.mini .board-row { gap: 4px; }
.board.mini .tile {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  background: var(--field);
  border-radius: 4px;
}

.board .tile.correct { background: var(--correct); border-color: var(--correct) !important; }
.board .tile.present { background: var(--present); border-color: var(--present) !important; }
.board .tile.absent  { background: var(--absent);  border-color: var(--absent)  !important; }

/* keyboard */
#keyboard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  max-width: 480px;
}
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  flex: 1;
  padding: 0;
  height: 54px;
  min-height: 0;
  background: #818384;
  border-radius: 6px;
  border: none;
  color: var(--text);
  font-weight: 700; font-size: 0.85rem; text-transform: uppercase;
  cursor: pointer;
  transition-property: scale, filter, background-color;
  transition-duration: 0.1s;
}
.key:active { scale: 0.94; }
.kb-row:nth-child(2) { padding: 0 5%; }
.key.wide { flex: 1.6; font-size: 0.68rem; }
.key.correct { background: var(--correct); }
.key.present { background: var(--present); }
.key.absent { background: var(--absent); color: var(--muted); }

/* overlays */
#round-overlay, #lobby-overlay {
  position: fixed; inset: 0;
  background: oklch(0 0 0 / 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
#round-overlay .card { align-items: center; text-align: center; gap: 18px; }
#lobby-overlay .card { gap: 18px; max-height: 90vh; overflow-y: auto; }
.card.lobby { width: min(660px, 94vw); }

.lobby-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.lobby-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#host-controls { border-top: none; padding-top: 0; }

.col-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
}
.seg-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-top: 4px;
}

/* custom radio selector */
.seg { display: flex; flex-direction: column; gap: 6px; }
.seg button {
  text-align: left;
  background: var(--field);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08);
  border-radius: 8px;
  padding: 10px 12px 10px 36px;
  min-height: 40px;
  font-size: 0.9rem;
  position: relative;
  transition-property: box-shadow, background-color, scale;
  transition-duration: 0.15s;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}
.seg button::before {
  content: "";
  position: absolute;
  left: 12px; top: 50%;
  translate: 0 -50%;
  width: 14px; height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--muted);
  transition-property: box-shadow, background-color;
  transition-duration: 0.15s;
}
.seg button:hover { filter: none; box-shadow: 0 0 0 1px oklch(1 0 0 / 0.2); }
.seg button.selected {
  box-shadow: 0 0 0 1.5px var(--correct);
  background: oklch(from var(--correct) l c h / 0.1);
}
.seg button.selected::before {
  background: var(--correct);
  box-shadow: inset 0 0 0 4px var(--field);
}

/* horizontal seg (public/private) */
.seg-h { flex-direction: row; }
.seg-h button { flex: 1; text-align: center; padding-left: 12px; }
.seg-h button::before { display: none; }

/* public games list */
#public-card { gap: 10px; }
#public-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.public-room {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
}
.public-room:disabled { opacity: 0.45; cursor: default; }
.public-room .pr-code {
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--correct);
}
.public-room .pr-host {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.public-room .pr-meta { color: var(--muted); font-size: 0.8rem; flex-shrink: 0; }

/* scoreboards */
#lobby-players .wins {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--present);
}
#lobby-players .wins + .kick { margin-left: 8px; }
.mini-wins {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--present);
  background: oklch(from var(--present) l c h / 0.15);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}
#overlay-standings, #leader-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
#overlay-standings li, #leader-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--field);
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.05);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  text-align: left;
}
.st-rank {
  width: 20px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}
#overlay-standings li:first-child .st-rank,
#leader-list li:first-child .st-rank { color: var(--present); }
.st-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-wins { font-weight: 700; color: var(--present); flex-shrink: 0; }

/* armed start button */
#start-btn.armed {
  background: var(--present);
  animation: arm-pulse 1s ease-in-out infinite;
}
@keyframes arm-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

@media (max-width: 640px) {
  .lobby-cols { grid-template-columns: 1fr; }
}
#lobby-overlay h2 {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}
#lobby-overlay h2 span { color: var(--correct); }
#overlay-title { font-size: 1.3rem; }
#overlay-word {
  font-size: 1.5rem;
  letter-spacing: 8px;
  text-indent: 8px; /* optical: offset trailing letter-spacing */
  text-transform: uppercase;
  color: var(--correct);
  font-weight: 700;
}
#overlay-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

#conn-banner {
  position: fixed; bottom: 16px; left: 50%; translate: -50% 0;
  background: var(--present); color: #000;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 700;
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.4);
  z-index: 30;
}

#toast {
  position: fixed; top: 20px; left: 50%; translate: -50% 0;
  background: var(--text); color: #000;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 700;
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.4);
  z-index: 20;
}

@media (max-width: 900px) {
  #screen-game { padding: 12px; gap: 12px; }
  #arena { grid-template-columns: 1fr; gap: 16px; }
  .side { flex-direction: row; flex-wrap: wrap; justify-content: center; order: 2; }
  #center { order: 1; }
  .mini-wrap { max-width: 130px; }
  .board.big .tile { font-size: 1.5rem; }
  .key { height: 48px; }
}
