:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --ink: #24231f;
  --muted: #625f58;
  --wash: #efede7;
  --gutter: clamp(24px, 4vw, 64px);
  --top: clamp(32px, 6svh, 72px);
  font: 15px/1.5 system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  --page-top: max(var(--top), env(safe-area-inset-top));
  --page-bottom: max(36px, env(safe-area-inset-bottom));
  margin: 0;
  min-height: 100svh;
  padding: var(--page-top)
    max(var(--gutter), env(safe-area-inset-right)) var(--page-bottom)
    max(var(--gutter), env(safe-area-inset-left));
}

body.in-room {
  --footer-bottom: max(var(--top), 1.5rem, env(safe-area-inset-bottom));
  --page-bottom: calc(44px + .55rem + var(--footer-bottom));
}
#stage { width: 100%; max-width: 44rem; margin-inline: auto; }
#room-meta {
  display: flex;
  align-items: start;
  gap: .5rem;
  margin-bottom: clamp(1.3rem, 5svh, 2.75rem);
}
.game-select { width: min(100%, 25rem); margin-top: .65rem; }
.game-description { margin-top: .65rem; }
.selected-game { margin-top: .65rem; }
.round-players {
  min-width: 0;
  margin-left: auto;
  padding-top: .15rem;
  text-align: right;
  font-size: .82rem;
}
.round-players h2 { font-size: inherit; font-weight: 650; }
.round-player-names {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#room-footer {
  position: fixed;
  z-index: 1;
  inset: auto max(var(--gutter), env(safe-area-inset-right), calc((100% - 44rem) / 2)) 0
    max(var(--gutter), env(safe-area-inset-left), calc((100% - 44rem) / 2));
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: .25rem var(--footer-bottom);
  background: var(--paper);
  color: #a12f24;
}
.forehead #room-footer {
  left: max(var(--gutter), env(safe-area-inset-left));
  right: max(var(--gutter), env(safe-area-inset-right));
}
#leave-room { margin-left: auto; }
.round-heading {
  font-size: 1.07rem;
  font-weight: 550;
  letter-spacing: normal;
  line-height: 1.5;
}
.round-instructions { margin-top: .4rem; max-width: 53ch; }
.room-invite { display: flex; align-items: center; gap: .25rem; flex: none; }
.room-code { display: grid; font-size: .8rem; line-height: 1.1; }
.room-code-label { color: var(--muted); }
.room-code .code { font-size: clamp(1.55rem, 5.3vw, 2.45rem); }
.lobby-setup { margin: 1.5rem 0 .45rem; }
.lobby-setup h2 { margin-bottom: .25rem; }
.lobby-start { margin-top: clamp(1.35rem, 4svh, 2.25rem); }
#players:not([hidden]) + #screen:not([hidden]) { margin-top: clamp(1.5rem, 6svh, 3.25rem); }
h1, h2, p, ul { margin: 0; }
h1 {
  font-size: clamp(2.1rem, 5vw, 3.55rem);
  font-weight: 440;
  line-height: 1.07;
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}
h2 { font-size: 1rem; font-weight: 550; }
.section-title { font-size: clamp(1.35rem, 4vw, 1.65rem); letter-spacing: -.025em; }
p { overflow-wrap: anywhere; }
.lead { margin-top: 1.05rem; max-width: 39ch; font-size: 1.12rem; color: var(--muted); }
.muted { color: var(--muted); }
.notice { color: #8b3428; margin-bottom: 1rem; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 0;
  background: transparent;
  cursor: pointer;
  min-height: 44px;
  padding: .4rem 0;
  text-align: left;
}
button:disabled { color: var(--muted); opacity: .65; cursor: default; }
[aria-disabled="true"] { cursor: wait; }
dialog {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  padding: 1.25rem 1.5rem 1rem;
  max-width: min(28rem, calc(100% - 2rem));
}
dialog::backdrop { background: #24231f42; }
dialog form { display: flex; justify-content: end; margin-top: .5rem; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}
.link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
}
.link:hover:not(:disabled) { text-decoration-thickness: 2px; }
.subtle { color: var(--muted); }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 .95rem; }
form { display: grid; gap: .85rem; margin-top: 2rem; max-width: 25rem; }
form > button { justify-self: start; }
.field { display: grid; gap: .35rem; min-width: 0; }
input, textarea, select {
  border: 0;
  border-radius: 0;
  background: var(--wash);
  min-height: 46px;
  padding: .55rem .75rem;
  min-width: 0;
  width: 100%;
  font-size: max(16px, 1rem);
}
select {
  appearance: none;
  padding-right: 2.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%2324231f' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right .95rem center;
  background-repeat: no-repeat;
  background-size: 1rem;
  text-overflow: ellipsis;
}
textarea { min-height: 6rem; resize: vertical; }
.answer-form { margin-top: 1rem; }
.saved-answer { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 .85rem; margin-top: .85rem; }
.saved-answer p { font-size: 1.14rem; }
.answer-progress { font-size: .88rem; margin-top: .65rem; }
.code { font-family: ui-monospace, monospace; letter-spacing: .12em; }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--muted);
}
.icon-button:hover { background: var(--wash); color: var(--ink); }
.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.clipboard-fallback { position: fixed; inset: 0 auto auto 0; width: 1px; height: 1px; opacity: 0; }
.game-list { margin-top: 1.6rem; max-width: 25rem; }
.game-list ul { list-style: none; display: grid; gap: .9rem; padding: 0 0 0 1rem; }
.game-list p { margin-top: .15rem; }
.round-actions { margin-top: 1.35rem; }
.player-list { list-style: none; padding: 0; margin-top: .6rem; }
.player-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
}
.player-name { display: flex; align-items: baseline; gap: 0 .65rem; flex-wrap: wrap; overflow-wrap: anywhere; }
.player-list small { color: var(--muted); }
.player-actions { display: flex; }
summary { min-height: 44px; padding-block: .65rem; cursor: pointer; }
.matching { max-width: 32rem; gap: .45rem; margin-top: .75rem; }
.matching .field { grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); align-items: center; gap: .7rem; }
.matching .field > span { overflow-wrap: anywhere; }
.read-card {
  width: 100%;
  display: grid;
  align-items: center;
  min-height: clamp(10rem, 30svh, 17rem);
  font-size: clamp(2rem, 6.4vw, 4rem);
  font-weight: 450;
  line-height: 1.12;
  letter-spacing: -.048em;
  overflow-wrap: anywhere;
}
.read-card:hover { color: var(--muted); }
.reading-count { font-size: .88rem; }
body.forehead {
  height: 100svh;
  padding-top: max(.4rem, env(safe-area-inset-top));
  --gutter: clamp(14px, 3vw, 32px);
}
.forehead #room-meta { margin: 0; }
.forehead .room-code .code { font-size: 1.15rem; }
.forehead #stage { height: 100%; min-height: 0; max-width: none; padding: 0; display: flex; flex-direction: column; }
.forehead #screen { flex: 1; min-height: 0; max-width: none; display: flex; flex-direction: column; }
.forehead #players { display: none; }
.forehead .notice { margin: .25rem 0; }
.clue-window {
  display: grid;
  place-items: center;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
  padding: .25rem;
  text-align: center;
}
.clue {
  width: 100%;
  font-weight: 650;
  font-size: clamp(1.75rem, 10vmin, 7rem);
  line-height: 1;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.clue-prompt { color: var(--muted); font-size: .95rem; font-style: italic; }

@media (max-width: 680px) {
  body { --top: 1.05rem; --gutter: 22px; }
}
@media (orientation: landscape) and (max-height: 480px) {
  body { --top: 1rem; }
}
