:root {
  --cream: #f4efe4;
  --card: #fffaf0;
  --card-strong: #fffdf7;
  --ink: #1d1a17;
  --muted: #786f63;
  --line: #dcd2c1;
  --line-strong: #c9bda8;
  --rose: #d34f69;
  --rose-soft: #f9dce3;
  --green: #2f5d50;
  --green-soft: #dcebe4;
  --gold: #a56a21;
  --shadow: 0 12px 34px rgba(54, 42, 28, 0.09);
  --radius: 22px;
  --sans: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 18% -10%, rgba(211, 79, 105, 0.10), transparent 34%),
    radial-gradient(circle at 85% 8%, rgba(47, 93, 80, 0.10), transparent 30%),
    var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.desktop-wall { display: none; }

html.is-desktop body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

html.is-desktop body::before,
html.is-desktop .shell,
html.is-desktop .site-footer,
html.is-desktop .install-prompt { display: none; }

html.is-desktop .desktop-wall { display: block; width: min(560px, 100%); }

.desktop-wall-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.desktop-wall-card h1 { font-size: clamp(32px, 6vw, 44px); }
.desktop-wall-card .muted { max-width: 34ch; margin: 0 auto; }

.desktop-wall-mark {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 24px auto 0;
  max-width: 340px;
}

.desktop-wall-mark span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--cream);
  font-family: var(--serif);
  font-size: clamp(14px, 3.4vw, 22px);
  font-weight: 700;
}

.desktop-wall-mark span:nth-child(2) { background: var(--green-soft); }
.desktop-wall-mark span:nth-child(5) { background: var(--rose-soft); }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(29, 26, 23, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 26, 23, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  z-index: -1;
}

a { color: inherit; }

button, input, select {
  font: inherit;
}

button { color: inherit; }

.shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.topbar,
.session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 20px;
}

.session-top {
  padding-bottom: 10px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.wordmark-dot { color: var(--rose); }
.wordmark-small { font-size: 20px; }

.topnav {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wordmark { flex: 0 0 auto; }

.text-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.text-link:hover { color: var(--ink); }

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  text-decoration: none;
  font-size: 20px;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid var(--line);
}

.back-link-labeled {
  gap: 5px;
  min-width: 0;
  height: auto;
  min-height: 40px;
  padding: 8px 14px 8px 11px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.back-link-labeled span {
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--rose);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 12px;
  font-family: var(--serif);
  font-size: clamp(34px, 10vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 8px;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 4px;
  font-size: 15px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--card);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.button:active { transform: scale(0.985); }
.button:disabled { opacity: 0.36; cursor: not-allowed; }
.button-wide { width: 100%; }

.button-small {
  min-height: 38px;
  padding: 0 15px;
  font-size: 13px;
}

.button-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

.button-danger {
  background: var(--rose);
  border-color: var(--rose);
}

.home { padding-bottom: 24px; }

.hero { padding: 18px 2px 20px; }

.hero-mark {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 10px 0 30px;
  max-width: 430px;
}

.hero-mark span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  font-family: var(--serif);
  font-size: clamp(20px, 7vw, 32px);
  font-weight: 700;
  box-shadow: var(--shadow);
}

.hero-mark span:nth-child(2) { background: var(--green-soft); }
.hero-mark span:nth-child(5) { background: var(--rose-soft); }
.hero-mark span:nth-child(7) { transform: rotate(6deg); }

.hero h1 { font-size: clamp(38px, 11.5vw, 54px); }
.lede { color: var(--muted); font-size: 16px; max-width: 38ch; }

.hero-actions,
.home-actions {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.how {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.how-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.55);
}

.how-item p { margin: 0; color: var(--muted); font-size: 14px; }

.how-num {
  display: block;
  margin-bottom: 8px;
  color: var(--rose);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.home-heading { padding: 12px 2px 18px; }
.home-heading h1 { margin-bottom: 6px; }

.session-list { display: grid; gap: 10px; }

.session-card {
  display: block;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 6px 20px rgba(54, 42, 28, 0.04);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.session-card:active { transform: scale(0.99); }

.session-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-active { color: var(--green); border-color: #b7cfc5; background: var(--green-soft); }
.status-waiting { color: var(--gold); border-color: #e0c9a4; background: #f8ebd6; }
.status-completed { color: var(--rose); border-color: #ecc2cc; background: var(--rose-soft); }

.session-card h2 { margin-bottom: 4px; font-size: 25px; }
.session-players { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.session-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot-sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); }

.site-footer {
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.58);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  transition: color 120ms;
}

.site-footer a:hover { color: var(--rose); }

.form-page { padding: 8px 2px 20px; }
.page-heading { padding-bottom: 22px; }
.page-heading h1 { margin-bottom: 8px; }

.stack-form { display: grid; gap: 16px; }

.field { display: grid; gap: 7px; margin: 0; padding: 0; border: 0; }
.field-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }

.input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: var(--card-strong);
  color: var(--ink);
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(29, 26, 23, 0.08);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 23px, calc(100% - 13px) 23px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.code-input {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.choice-grid { display: grid; gap: 9px; }

.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }

.choice-body {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice input:checked + .choice-body {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--card);
}

.choice input:checked + .choice-body .choice-copy { color: rgba(255, 250, 240, 0.7); }
.choice input:focus-visible + .choice-body { box-shadow: 0 0 0 3px rgba(29, 26, 23, 0.12); }
.choice-title { font-weight: 800; font-size: 14px; }
.choice-copy { color: var(--muted); font-size: 12px; }

.banner {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
}

.banner-error { border-color: #e7b4bf; background: #fbe5ea; color: #7c2233; }
.banner-success { border-color: #b7cfc5; background: var(--green-soft); color: #1d463b; }
.banner-warn { border-color: #e0c9a4; background: #f8ebd6; color: #6f4712; }
.banner-neutral { background: rgba(255, 250, 240, 0.7); color: var(--muted); }

.session-title { flex: 1; min-width: 0; }
.session-title h1 { margin: 0; font-size: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-title .eyebrow { margin-bottom: 1px; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.72);
  cursor: pointer;
}

.icon-button.is-on {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

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

.lobby-card,
.waiting-card,
.lobby-tips {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.code-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 12px;
}

#session-code {
  font-family: var(--mono);
  font-size: clamp(30px, 10vw, 42px);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.copy-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--card);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.join-link {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

.avatar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
}

.avatar-1 { background: var(--green-soft); color: #1d463b; }
.avatar-2 { background: var(--rose-soft); color: #7c2233; }
.avatar-empty { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }

.waiting-pulse {
  width: 26px;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 4px, transparent 4px 8px);
}

.lobby-tips p { margin: 0; color: var(--muted); font-size: 13px; }
.lobby-tips strong { color: var(--ink); }

.poll-sentinel { height: 0; }

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
  margin: 4px 0 12px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
}

.player-card.is-turn {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink);
}

.player-copy { display: grid; min-width: 0; }
.player-name { font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-role { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.score { margin-left: auto; font-family: var(--serif); font-size: 26px; font-weight: 700; }
.scoreboard-divider { align-self: center; color: var(--muted); font-size: 10px; font-style: italic; }

.turn-banner,
.result-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.7);
  font-size: 13px;
  font-weight: 650;
}

.turn-mine { border-color: var(--green); background: var(--green-soft); color: #1d463b; }

.turn-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(47, 93, 80, 0.13);
}

.turn-dot.waiting { background: var(--gold); box-shadow: 0 0 0 4px rgba(165, 106, 33, 0.13); }

.result-banner {
  display: block;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--card);
}

.result-banner .eyebrow { color: #e9a9b6; }
.result-banner h2 { font-size: 32px; margin-bottom: 4px; }
.result-line { margin-bottom: 8px; font-family: var(--mono); font-size: 13px; }
.result-banner .muted { color: rgba(255, 250, 240, 0.68); }
.result-banner .button { margin-top: 10px; color: var(--card); border-color: rgba(255, 250, 240, 0.3); }

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 15px 1px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--rose));
  transition: width 0.35s ease;
}

.board-wrap { margin-top: 16px; }

.board { position: relative; }

.ink-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.ink-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.56;
  mix-blend-mode: multiply;
}

.ink-line.seat-1 { stroke: var(--green); }
.ink-line.seat-2 { stroke: var(--rose); }
.ink-line.ink-selection { stroke: var(--ink); stroke-width: 7; opacity: 0.44; }

.board-head,
.word-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.board-hint { color: var(--muted); font-size: 11px; }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--line);
  box-shadow: var(--shadow);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.grid.is-armed,
.grid.is-armed .cell {
  touch-action: none;
}



.cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--card-strong);
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(11px, calc(52vw / var(--n) / 1.6), 18px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, color 0.1s ease, transform 0.1s ease;
}

.cell:disabled { opacity: 1; cursor: default; }
.cell.owner-1 { background: var(--green-soft); color: #173b31; }
.cell.owner-2 { background: var(--rose-soft); color: #6c2030; }
.cell.owner-3 { background: linear-gradient(135deg, var(--green-soft) 50%, var(--rose-soft) 50%); color: var(--ink); }
.cell.start, .cell.end { outline: 3px solid var(--ink); outline-offset: -2px; z-index: 2; }
.cell.path { background: #eadfcd; color: var(--ink); box-shadow: inset 0 0 0 2px rgba(29, 26, 23, 0.1); }
.cell.path.owner-3 { background: #eadfcd; }
.grid.is-armed .cell:not(.path):not(.owner-1):not(.owner-2):not(.owner-3) { opacity: 0.8; }

.word-panel { margin-top: 18px; }

.word-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.word-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  text-align: left;
}

.word-chip.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.word-chip.is-found { opacity: 0.55; background: var(--green-soft); text-decoration: line-through; }
.word-chip:disabled { cursor: default; }
.word-text { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.03em; overflow-wrap: anywhere; }
.word-meta { flex: 0 0 auto; color: var(--muted); font-size: 9px; }

.clue-list { display: grid; gap: 7px; }

.clue-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.clue-card.is-selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.clue-card.is-found { opacity: 0.6; background: var(--green-soft); }

.clue-main {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 13px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.clue-main:disabled { cursor: default; }
.clue-text { font-size: 13px; font-weight: 600; }
.clue-meta { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.clue-answer { display: flex; gap: 7px; padding: 0 9px 9px; }
.clue-answer .input { min-height: 44px; font-size: 14px; }
.clue-draw {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--card-strong);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.selection-strip {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(calc(100% - 32px), 488px);
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 10px 30px rgba(54, 42, 28, 0.16);
  backdrop-filter: blur(10px);
  font-size: 12px;
  pointer-events: none;
}

.selection-strip button { pointer-events: auto; }

.selection-label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.selection-word { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-weight: 700; }
.selection-dir { margin-left: auto; flex: 0 0 auto; color: var(--muted); font-size: 10px; }

.selection-board,
.selection-cancel {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.selection-cancel {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: rgba(29, 26, 23, 0.07);
  font-size: 16px;
  line-height: 1;
  text-transform: none;
}

.game { padding-bottom: 64px; }

.hidden-form { display: none; }

.offline-cache { display: grid; gap: 8px; margin: 12px 0 20px; }
.offline-card { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--card); text-decoration: none; }
.offline-card strong { display: block; font-size: 15px; }
.offline-card span { color: var(--muted); font-size: 12px; }

[x-cloak] { display: none !important; }

@media (max-width: 370px) {
  .word-list { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: 1fr; }
  .scoreboard-divider { display: none; }
  .score { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

.toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(150px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 460px);
  padding: 12px 16px;
  transform: translate(-50%, 12px);
  border-radius: 14px;
  background: var(--ink);
  color: var(--card);
  box-shadow: 0 16px 40px rgba(29, 26, 23, 0.28);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 9px 16px;
  background: #f8ebd6;
  border-bottom: 1px solid #e0c9a4;
  color: #6f4712;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.is-offline .selection-strip,
.is-offline .poll-sentinel,
.is-offline .invite-form,
.is-offline .result-banner form { display: none !important; }
.is-offline .cell,
.is-offline .word-chip,
.is-offline .clue-main,
.is-offline .icon-button { pointer-events: none; }
.is-offline .game { padding-bottom: 24px; }

.history {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 250, 240, 0.62);
  overflow: hidden;
}

.history summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.history summary::-webkit-details-marker { display: none; }
.history summary span { color: var(--ink); }
.history ol { margin: 0; padding: 0 14px 10px; list-style: none; }
.history li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid rgba(220, 210, 193, 0.65);
  font-size: 12px;
}

.history-player {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 10px;
  font-weight: 700;
}
.history-player.seat-1 { background: var(--green-soft); color: #1d463b; }
.history-player.seat-2 { background: var(--rose-soft); color: #7c2233; }
.history-name { color: var(--muted); }
.history-word { margin-left: auto; font-family: var(--mono); font-weight: 700; letter-spacing: 0.03em; }
.history-points { width: 34px; text-align: right; color: var(--green); font-weight: 800; }

.nav-user {
  max-width: 110px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topnav form { margin: 0; }
.topnav button.text-link { padding: 0; border: 0; background: transparent; cursor: pointer; }

.home-caption {
  margin: 4px 0 22px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  line-height: 1.35;
}

.home-caption strong {
  color: var(--ink);
  font-style: normal;
  font-weight: 700;
}

.home-caption-landing { margin-top: -4px; }

.invite-list { display: grid; gap: 10px; margin-bottom: 24px; }

.invite-card {
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--rose-soft);
}

.invite-card h2 { font-size: 23px; margin-bottom: 2px; }
.invite-card .eyebrow { color: #8d2d44; }
.invite-actions { display: flex; gap: 8px; margin-top: 13px; }
.invite-actions form { margin: 0; }

.invite-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 10px 0 12px;
}

.invite-form .input { min-height: 46px; }
.invite-form .button { min-height: 46px; padding: 0 15px; }

.session-logout { margin-left: auto; }
.session-logout + .icon-button { margin-left: 0; }

.field-help { color: var(--muted); font-size: 11px; }
.form-switch { margin: 22px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.form-switch a { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.install-prompt {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(calc(100% - 28px), 492px);
  padding: 10px 12px;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.98);
  box-shadow: 0 16px 40px rgba(54, 42, 28, 0.2);
  backdrop-filter: blur(12px);
}

.install-prompt[hidden] { display: none; }
.install-copy { display: flex; align-items: center; gap: 10px; min-width: 0; }
.install-copy strong { display: block; font-size: 12px; }
.install-copy p { margin: 1px 0 0; color: var(--muted); font-size: 10px; }
.install-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: var(--ink);
  color: var(--card);
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
}
.install-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.install-actions .button { min-height: 36px; padding: 0 12px; font-size: 11px; }
.install-dismiss {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}


@media (min-width: 700px) and (pointer: fine) {
  html:not(.is-desktop) body {
    display: grid;
    min-height: 100dvh;
    place-items: center;
    padding: 24px;
  }
  html:not(.is-desktop) body::before,
  html:not(.is-desktop) .shell,
  html:not(.is-desktop) .site-footer,
  html:not(.is-desktop) .install-prompt { display: none; }
  html:not(.is-desktop) .desktop-wall { display: block; width: min(560px, 100%); }
}
