:root {
  --bg: #0b1020;
  --card: #111a33;
  --text: #f5f7ff;
  --muted: #b8c2ff;
  --accent: #5ef2d6;
  --accent2: #ff4fd8;
  --danger: #ff6666;
  --tile: #1a2550;
  --tileBorder: #2b3a7a;
  --tileGreen: #2fe57d;
  --tileYellow: #ffe14a;
  --tileGray: #4a5aa6;
  --tileText: #071023;
  --tile-size: 54px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 900px at 10% 10%, #18235a 0%, var(--bg) 45%, #070a14 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

button, input, select { font: inherit; }

.hidden { display: none !important; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.top,
.sectionHeading,
.sessionHeader,
.sessionActions,
.playerIdentity,
.gameMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.top { margin-bottom: 18px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 36px; }
h2 { margin-bottom: 12px; }

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  margin: 2px 0 0;
  font-weight: 700;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.card {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(94, 242, 214, .25);
  border-radius: 18px;
  background: rgba(17, 26, 51, .78);
}

.hero { padding: 24px; }

.lobbyGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

#presentSetupForm {
  grid-template-columns: 120px minmax(180px, 1fr) 150px auto;
}

#presentGameView .board {
  --tile-size: 62px;
  margin-top: 26px;
}

#presentGameView .tile {
  font-size: 28px;
}

.form {
  display: grid;
  gap: 12px;
}

.formInline {
  grid-template-columns: minmax(180px, 1fr) 150px auto;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

input,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(184, 194, 255, .35);
  border-radius: 14px;
  outline: none;
  background: rgba(7, 10, 20, .45);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: rgba(94, 242, 214, .75);
}

.codeInput {
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 900;
}

.btn,
.linkButton {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 900;
}

.btn {
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  color: #061024;
}

.btn.secondary {
  border: 1px solid rgba(94, 242, 214, .25);
  background: #26366f;
  color: var(--text);
}

.btn.danger {
  background: var(--danger);
  color: #1b0710;
}

.linkButton {
  padding: 8px 0;
  background: transparent;
  color: var(--accent);
}

.message {
  min-height: 20px;
  padding: 10px 12px;
  border: 1px solid rgba(94, 242, 214, .25);
  border-radius: 12px;
  background: rgba(7, 10, 20, .22);
  font-weight: 650;
}

.message:empty {
  min-height: 0;
  padding: 0;
  border: 0;
}

.message.error { border-color: rgba(255, 102, 102, .55); }
.message.ok { border-color: rgba(47, 229, 125, .55); }
.message.warn { border-color: rgba(255, 225, 74, .55); }

.sessionCode {
  font-size: 34px;
  font-weight: 950;
  letter-spacing: .14em;
}

.statusPill,
.scoreMini {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: rgba(94, 242, 214, .12);
  color: var(--accent);
  font-weight: 800;
}

.statusPill { padding: 8px 12px; }
.scoreMini { margin-left: 8px; padding: 3px 8px; font-size: 12px; }

.playerList {
  display: grid;
  gap: 8px;
}

.playerRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(7, 10, 20, .28);
}

.successText {
  color: var(--tileGreen);
  font-weight: 800;
}

.tableWrap { overflow-x: auto; }

.scoreTable {
  width: 100%;
  border-collapse: collapse;
}

.scoreTable th,
.scoreTable td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(184, 194, 255, .15);
  text-align: left;
}

.scoreTable th { color: var(--muted); }

.waitingPanel {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.waitingDot {
  width: 18px;
  height: 18px;
  margin-bottom: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 8px rgba(94, 242, 214, .12);
}

.gameMeta { margin-bottom: 12px; }

.board {
  display: grid;
  gap: 8px;
  justify-content: center;
  margin: 18px 0 16px;
  overflow-x: auto;
}

.rowTiles {
  display: grid;
  gap: 8px;
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--tileBorder);
  border-radius: 12px;
  background: var(--tile);
  font-size: 24px;
  font-weight: 900;
  text-transform: uppercase;
  user-select: none;
}

.tile.filled { border-color: var(--accent2); }
.tile.correct { background: var(--tileGreen); color: var(--tileText); border-color: var(--tileGreen); }
.tile.present { background: var(--tileYellow); color: var(--tileText); border-color: var(--tileYellow); }
.tile.absent { background: var(--tileGray); color: #0a1030; border-color: var(--tileGray); }

.keyboard {
  display: grid;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.krow {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.key {
  min-width: 40px;
  height: 48px;
  padding: 0 10px;
  border: 0;
  border-radius: 11px;
  background: #22306a;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}

.key.big { min-width: 76px; }
.key.correct { background: var(--tileGreen); color: var(--tileText); }
.key.present { background: var(--tileYellow); color: var(--tileText); }
.key.absent { background: var(--tileGray); color: #0a1030; }

.roundResult {
  display: grid;
  gap: 6px;
  margin-bottom: 20px;
  font-size: 18px;
}

@media (max-width: 700px) {
  :root { --tile-size: 44px; }

  .lobbyGrid { grid-template-columns: 1fr; }
  .formInline,
  #presentSetupForm { grid-template-columns: 1fr; }

  #presentGameView .board {
    --tile-size: 48px;
  }
  .sessionHeader,
  .sectionHeading {
    align-items: flex-start;
    flex-direction: column;
  }
  .sessionActions { width: 100%; }
  .playerRow { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (max-width: 480px) {
  :root { --tile-size: 38px; }
  .wrap { padding: 12px; }
  .key { min-width: 32px; height: 43px; padding: 0 7px; font-size: 13px; }
  .key.big { min-width: 62px; }
}
