:root {
  --ink: #11110f;
  --bone: #eee9df;
  --crimson: #c8102e;
  --rule: rgba(17, 17, 15, .16);
  --soft: rgba(17, 17, 15, .06);
  --muted: rgba(17, 17, 15, .72);
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bone);
  font-synthesis: none;
  line-height: 1.45;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; }
a { color: inherit; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: .14em; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
::selection { background: var(--ink); color: var(--bone); }
:focus-visible { outline: 2px solid var(--crimson); outline-offset: 3px; }

.site-header, main, .site-footer { width: min(100% - 2rem, 76rem); margin-inline: auto; }
.site-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { display: inline-flex; align-items: center; gap: .65rem; font-size: 1rem; font-weight: 700; text-decoration: none; }
.mark { width: 18px; height: 18px; display: inline-block; border: 5px solid var(--ink); transform: rotate(-8deg); }
.header-link { font-size: .875rem; font-weight: 600; }
main { flex: 1; padding-block: 2rem 5rem; }
.site-footer { padding-block: 2rem; font-size: .8rem; color: var(--muted); }

h1, h2 { line-height: 1.1; text-wrap: balance; letter-spacing: -.025em; }
h1 { font-size: clamp(1.5rem, 5vw, 2rem); margin: 0; }
h2 { font-size: 1rem; margin: 0; }
p { max-width: 65ch; text-wrap: pretty; }
.entry { max-width: 42rem; padding-top: clamp(2rem, 8vw, 5rem); }
.entry h1 { font-size: clamp(2rem, 8vw, 3.6rem); max-width: 16ch; }
.intro { font-size: 1.1rem; margin: 1.5rem 0 2rem; max-width: 42ch; }
.supporting { color: var(--muted); margin-block: 1.5rem; }

.button {
  min-height: 44px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-size: .875rem; font-weight: 700; text-decoration: none; text-align: center;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}
.button:active { transform: translateY(1px); }
.primary { background: var(--crimson); color: var(--bone); }
.primary:hover { background: var(--ink); }
.secondary { background: var(--ink); color: var(--bone); }
.secondary:hover { background: transparent; color: var(--ink); border-color: var(--ink); }
.text-button { min-height: 44px; padding-inline: 0; background: transparent; border: 0; text-decoration: underline; }
.danger-outline { background: transparent; color: var(--crimson); border-color: var(--crimson); }
.danger-outline:hover { background: var(--crimson); color: var(--bone); }

.notice { margin-block: 1.5rem; padding: 1rem; border: 1px solid var(--ink); border-radius: 6px; }
.notice p { margin: 0; }
.dev-banner { padding: .55rem 1rem; background: var(--ink); color: var(--bone); font-size: .8rem; font-weight: 700; text-align: center; }
.dev-form { margin-top: 4rem; max-width: 28rem; }
.dev-form form, .compact-form, .upload-form, .control-stack { display: grid; gap: 1rem; }

label { display: block; margin-bottom: .4rem; font-size: .82rem; font-weight: 700; }
input, select {
  width: 100%; min-height: 44px; padding: .6rem .7rem; background: transparent;
  border: 1px solid var(--ink); border-radius: 6px;
}
input[type="file"] { padding: .55rem; }
input[type="checkbox"] { width: auto; min-height: auto; padding: 0; }
.check-label { display: flex; align-items: center; gap: .45rem; margin: 0; }
.field-label { display: block; margin-bottom: .4rem; font-size: .82rem; font-weight: 700; }
.joined-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.joined-control input { border-radius: 6px 0 0 6px; }
.joined-control .button { border-radius: 0 6px 6px 0; }
.form-note { margin: 0; font-size: .8rem; color: var(--muted); }

.title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.title-row p { margin: .55rem 0 0; color: var(--muted); }
.hub-grid, .room-grid { display: grid; gap: 1rem; align-items: start; }
.game-list, .join-panel, .create-panel, .assignment {
  border: 1px solid var(--rule); border-radius: 8px; padding: 1rem;
}
.room-grid { gap: 0; border: 1px solid var(--rule); border-radius: 8px; }
.players-panel, .host-panel { padding: 1rem; }
.host-panel { border-top: 1px solid var(--rule); }
.section-heading, .assignment-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.list-rows { display: grid; }
.game-row {
  min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding-block: .75rem; border-top: 1px solid var(--rule); text-decoration: none;
}
.game-row:first-child { border-top: 0; }
.game-row > span:first-child { display: grid; gap: .2rem; min-width: 0; }
.game-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row small { font-size: .78rem; color: var(--muted); }
.row-end { display: flex; align-items: center; gap: .75rem; flex: none; }
.status { display: inline-flex; width: fit-content; padding: .2rem .45rem; border-radius: 4px; background: var(--soft); font-size: .72rem; text-transform: capitalize; }
.status-running { background: var(--ink); color: var(--bone); }
.status-paused { border: 1px solid var(--ink); background: transparent; }
.status-finished { opacity: .65; }
.empty-state { min-height: 90px; display: grid; place-items: center; padding: 1rem; background: var(--soft); border-radius: 6px; }
.empty-state p { margin: 0; text-align: center; color: var(--muted); }
.join-panel h2 { margin-bottom: 1rem; }

.create-panel { margin-block: 1rem 2rem; display: grid; gap: 1.5rem; }
.section-copy p { color: var(--muted); }
.create-form { display: grid; gap: 1rem; }
.create-form .button { width: fit-content; }

.game-header { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.game-header h1 { margin-top: .5rem; }
.game-header p { display: flex; align-items: center; gap: .6rem; margin: .65rem 0 0; color: var(--muted); font-size: .875rem; }
.back-link { font-size: .8rem; }
.invite-key { min-width: 12rem; padding: .85rem 1rem; background: var(--ink); color: var(--bone); border-radius: 8px; display: grid; }
.invite-key span, .invite-key small { font-size: .72rem; opacity: .75; }
.invite-key strong { font-size: 1.5rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.invite-panel, .settings-panel { margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--rule); border-radius: 8px; }
.invite-controls, .settings-form, .settings-summary { display: grid; gap: 1rem; }
.code-control { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.code-control strong { font-size: 1.25rem; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.settings-form .button { align-self: end; }
.settings-summary { margin: 0; }
.settings-summary div { display: grid; gap: .2rem; }
.settings-summary dt { font-size: .78rem; font-weight: 700; color: var(--muted); }
.settings-summary dd { margin: 0; }
.assignment { margin-bottom: 1rem; padding: clamp(1rem, 4vw, 1.5rem); }
.assignment-head { align-items: flex-start; }
.assignment-head p { margin: .4rem 0 0; color: var(--muted); font-size: .85rem; }
.waiting { font-size: .8rem; white-space: nowrap; }
.start-panel { padding: 1.25rem; background: var(--soft); border-radius: 6px; }
.start-panel p { margin-top: 0; }
.seed-prompt, .complete-note { padding: 1rem; background: var(--soft); border-radius: 6px; }
.handed-image { margin: 1rem 0; max-width: 36rem; }
.handed-image img, .reveal-step img { width: 100%; height: auto; display: block; border-radius: 4px; }
.upload-form { max-width: 36rem; margin-top: 1.25rem; }
.upload-form .button { width: fit-content; }
.rules-note { margin: 1.25rem 0 0; font-size: .8rem; color: var(--muted); }
.finished-callout { display: flex; flex-direction: column; align-items: flex-start; gap: 1rem; }
.finished-callout p { margin-bottom: 0; color: var(--muted); }

.player-list { list-style: none; padding: 0; margin: 0; counter-reset: roster; }
.player-list li { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--rule); counter-increment: roster; }
.player-list li:first-child { border-top: 0; }
.player-list li > .player-identity { min-width: 0; display: grid; grid-template-columns: auto 32px minmax(0, 1fr); align-items: center; gap: .65rem; }
.player-list li > .player-identity::before { content: counter(roster) "."; color: var(--muted); font-variant-numeric: tabular-nums; }
.avatar { width: 32px; height: 32px; display: block; border-radius: 50%; object-fit: cover; background: var(--soft); }
.player-details { min-width: 0; display: flex; flex-direction: column; }
.player-list small { color: var(--muted); font-size: .72rem; }
.removed-tag { width: fit-content; color: var(--crimson) !important; font-weight: 700; }
.player-action { display: flex; align-items: center; gap: .75rem; }
.host-panel > p { color: var(--muted); font-size: .85rem; }
.host-panel h2 { margin-bottom: 1rem; }
.control-stack .button { width: 100%; }
.extend-form label { margin-bottom: .4rem; }

.invite-page { max-width: 48rem; }
.reveal-header { margin-bottom: 3rem; }
.reveal-header h1 { font-size: clamp(2rem, 7vw, 3.5rem); }
.reveal-header p { color: var(--muted); }
.lineage { margin-block: 3rem; }
.lineage > h2 { font-size: 1.35rem; margin-bottom: 1rem; }
.reveal-steps { display: grid; gap: 1rem; }
.reveal-step { padding: 1rem; border: 1px solid var(--rule); border-radius: 8px; }
.reveal-step > header { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--rule); }
.reveal-step > header span { color: var(--muted); }
.reveal-step figure { margin: 1rem 0 0; }
.reveal-step figcaption { margin-top: .45rem; font-size: .78rem; color: var(--muted); }
.skipped { margin: 1rem 0 0; padding: 1rem; background: var(--soft); }

.skip-link { position: absolute; left: 1rem; top: -10rem; z-index: 2; background: var(--ink); color: var(--bone); padding: .75rem; }
.skip-link:focus { top: 1rem; }

@media (min-width: 44rem) {
  .site-header, main, .site-footer { width: min(100% - 3rem, 76rem); }
  main { padding-top: 2.5rem; }
  .hub-grid { grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); }
  .create-panel { grid-template-columns: minmax(13rem, .75fr) minmax(0, 2fr); padding: 1.5rem; }
  .create-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .create-form .wide, .create-form .form-note { grid-column: 1 / -1; }
  .game-header { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .invite-controls { grid-template-columns: minmax(0, 2fr) minmax(12rem, .75fr); align-items: end; }
  .settings-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; }
  .settings-form .wide { grid-column: 1 / -1; }
  .settings-summary { grid-template-columns: 2fr repeat(3, 1fr); }
  .finished-callout { flex-direction: row; justify-content: space-between; align-items: center; }
  .room-grid { grid-template-columns: minmax(0, 1.6fr) minmax(17rem, 1fr); }
  .room-grid > :only-child { grid-column: 1 / -1; }
  .host-panel { border-top: 0; border-left: 1px solid var(--rule); }
  .reveal-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .button { transition: none; }
}
