:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #66706c;
  --paper: #f4f3ed;
  --surface: #ffffff;
  --line: #d8dcd7;
  --green: #23664d;
  --green-dark: #174735;
  --red: #a14335;
  --amber: #c49035;
  --blue: #356e95;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

button, input, select { font: inherit; }

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) { border-color: var(--green); }
button:disabled { cursor: not-allowed; opacity: .5; }

button.primary {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

button.danger { border-color: #d7aaa3; color: var(--red); }

input, select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd1cc;
  border-radius: 6px;
  background: white;
  padding: 0 12px;
  color: var(--ink);
}

label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; font-weight: 650; }
h1, h2, p { margin: 0; }
h1 { font-size: 42px; line-height: 1.12; }
h2 { font-size: 17px; }
.hidden { display: none !important; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(18px, env(safe-area-inset-left));
  background: var(--ink);
  color: white;
}

.brand { font-family: Georgia, serif; font-size: 21px; font-weight: 700; }
.subtitle { margin-top: 1px; color: #b9c4bf; font-size: 10px; text-transform: uppercase; }
.connection { font-size: 13px; color: #b9c4bf; }
.connection.online { color: #94d4b8; }

main { width: min(1180px, 100%); margin: 0 auto; padding: 24px 18px 48px; }
.eyebrow { color: var(--green); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.entry-panel {
  min-height: calc(100vh - 116px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr);
  align-items: center;
  gap: 9vw;
}

.entry-copy { display: grid; gap: 18px; max-width: 650px; }
.entry-copy > p:last-child { max-width: 520px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.entry-form { display: grid; gap: 22px; padding: 28px; border: 1px solid var(--line); background: var(--surface); }
.entry-actions { display: grid; gap: 12px; }
.join-row { display: grid; grid-template-columns: 1fr 92px; gap: 8px; }

.room-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 22px;
}

.room-heading h1 { margin-top: 7px; font-size: 29px; }
.text-button { min-height: auto; padding: 0; border: 0; color: var(--green); background: transparent; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; }
.board-column { min-width: 0; display: grid; align-content: start; gap: 18px; }

.players { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.player {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  background: var(--surface);
}
.player.current { border-left-color: var(--amber); }
.player.self { background: #f7fbf8; }
.player.eliminated { opacity: .52; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.player-score { flex: 0 0 auto; color: var(--green); font-size: 13px; font-weight: 800; }
.player-meta { display: flex; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 12px; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: #aeb5b1; }
.dot.online { background: #3b986d; }

.hand-section, .action-panel, .log-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
}

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title span { color: var(--muted); font-size: 12px; }
.hand { display: flex; min-height: 94px; align-items: center; gap: 8px; overflow-x: auto; padding-top: 14px; }
.card {
  width: 58px;
  height: 78px;
  flex: 0 0 58px;
  display: grid;
  place-items: center;
  border: 1px solid #c9cec9;
  border-radius: 6px;
  background: #fffef9;
  box-shadow: 0 3px 0 #dfe2dc;
  font-family: Georgia, serif;
  font-size: 29px;
  font-weight: 700;
}
.empty { color: var(--muted); font-size: 14px; }

.action-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.action-tabs button { padding: 0 7px; font-size: 13px; }
.action-tabs button.active { border-color: var(--green); background: #eaf4ef; color: var(--green-dark); }
.action-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; margin-top: 12px; align-items: end; }
.action-form label { min-width: 0; }
.action-form button { padding: 0 18px; }
.response-box { display: grid; gap: 12px; margin-top: 14px; }
.response-copy { color: var(--muted); line-height: 1.55; }
.response-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.response-actions button { padding: 0 16px; }
.guess-list { display: grid; gap: 8px; }
.guess-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  padding: 7px 8px 7px 12px;
}
.guess-option button { flex: 0 0 auto; min-height: 36px; padding: 0 14px; }
.guess-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 270px; }

.log-panel { min-height: 420px; align-self: stretch; }
.logs { display: grid; gap: 0; margin: 12px 0 0; padding: 0; list-style: none; }
.logs li { padding: 11px 0; border-top: 1px solid #eceeeb; color: #4d5853; font-size: 13px; line-height: 1.45; }
.logs time { display: block; margin-top: 3px; color: #939b97; font-size: 10px; }

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  transform: translate(-50%, 20px);
  border-radius: 6px;
  background: var(--ink);
  color: white;
  padding: 11px 16px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 800px) {
  .entry-panel { grid-template-columns: 1fr; align-content: center; gap: 36px; }
  .game-layout { grid-template-columns: 1fr; }
  .log-panel { min-height: 0; }
}

@media (max-width: 560px) {
  main { padding: 18px 12px 36px; }
  .topbar { height: 60px; }
  .entry-panel { min-height: calc(100vh - 96px); }
  .entry-copy h1 { font-size: 30px; }
  .entry-form { padding: 18px; }
  .room-heading { align-items: center; }
  .room-heading h1 { font-size: 23px; }
  .players { grid-template-columns: 1fr; }
  .player { padding: 11px 12px; }
  .player-meta { margin-top: 8px; }
  .hand-section, .action-panel, .log-panel { padding: 14px; }
  .action-form { grid-template-columns: 1fr 1fr; }
  .action-form label:first-child { grid-column: 1 / -1; }
  .action-form button { grid-column: 1 / -1; }
  .action-tabs button { min-height: 48px; }
}
