:root {
  --bg: #111318;
  --surface: #1b2028;
  --surface-2: #242b35;
  --text: #f4f7fb;
  --muted: #9aa6b5;
  --line: #3a4350;
  --accent: #59c3a6;
  --accent-dark: #32856f;
  --yellow: #d5a943;
  --green: #56a86f;
  --gray: #48515e;
  --danger: #e66b6b;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(89, 195, 166, 0.16), transparent 28rem),
    linear-gradient(145deg, #101218 0%, #191d25 55%, #111318 100%);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: #07110e;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: #71d6bb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

button.secondary:hover,
button.ghost:hover {
  background: #303846;
}

button.ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: #12161d;
  outline: none;
  text-transform: uppercase;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(89, 195, 166, 0.18);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar,
.status-line,
.boards,
.lobby,
.guess-form,
.button-row,
.join-row {
  display: flex;
  gap: 16px;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.3rem);
  line-height: 0.95;
  max-width: 760px;
}

h2 {
  font-size: 1rem;
}

.room-pill {
  min-width: 150px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(27, 32, 40, 0.9);
}

.room-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.room-pill strong {
  font-size: 1.55rem;
  letter-spacing: 0.08em;
}

.lobby {
  align-items: stretch;
}

.panel {
  flex: 1;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 40, 0.92);
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.button-row,
.join-row {
  margin-top: 14px;
}

.button-row button,
.join-row button {
  flex: 1;
}

.game {
  display: grid;
  gap: 20px;
}

.game[hidden],
.lobby[hidden],
.room-pill[hidden] {
  display: none;
}

.status-line {
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 32, 40, 0.86);
}

.status-line span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.boards {
  align-items: flex-start;
}

.board-section {
  flex: 1.05;
  min-width: 0;
}

.board-section.opponent {
  flex: 0.92;
}

.board-section header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
}

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

.tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #171b22;
  color: var(--text);
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.opponent .tile {
  color: transparent;
}

.tile.correct {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.tile.present {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #16120a;
}

.tile.absent {
  border-color: var(--gray);
  background: var(--gray);
  color: #fff;
}

.opponent .tile.correct,
.opponent .tile.present,
.opponent .tile.absent {
  color: transparent;
}

.guess-form {
  align-items: center;
}

.guess-form input {
  max-width: 220px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.keyboard {
  display: grid;
  gap: 8px;
  width: min(100%, 760px);
  margin: -4px auto 0;
  touch-action: manipulation;
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  min-width: 0;
  width: clamp(30px, 8vw, 52px);
  height: clamp(44px, 8vw, 56px);
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-2);
  font-size: clamp(0.82rem, 2.5vw, 1rem);
  font-weight: 900;
  line-height: 1;
}

.key:hover {
  background: #303846;
}

.key.key-action {
  width: clamp(58px, 15vw, 94px);
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
}

.key.correct {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.key.present {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #16120a;
}

.key.absent {
  border-color: var(--gray);
  background: var(--gray);
  color: #fff;
}

.key.correct:hover,
.key.present:hover,
.key.absent:hover {
  filter: brightness(1.08);
}

.message {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 620px);
    padding: 18px 0;
  }

  .topbar,
  .lobby,
  .boards,
  .status-line,
  .guess-form,
  .button-row,
  .join-row {
    flex-direction: column;
  }

  .board {
    gap: 6px;
  }

  .tile {
    border-radius: 5px;
  }

  .guess-form input {
    max-width: none;
  }

  .keyboard {
    gap: 7px;
  }

  .key-row {
    gap: 4px;
  }
}
