:root {
  color-scheme: light;
  --viewport-bg: #fbfff8;
  --paper: #fbfff8;
  --paper-bright: #fffffc;
  --ink: #111;
  --ink-mid: #3f3f3f;
  --ink-light: #5f5f5f;
  --ink-faint: #737373;
  --red: #8b0000;
  --red-light: #a52a2a;
  --green: #237a3b;
  --teal: #4e7785;
  --gold: #9a6a00;
  --blue: #005eb8;
  --blue-hover: #004785;
  --rule: #e0e3dc;
  --hover: rgba(0, 0, 0, 0.025);
  --panel-border: rgba(17, 17, 17, 0.24);
  --panel-shadow: 0 8px 24px rgba(17, 17, 17, 0.12);
  --tray-bg: color-mix(in srgb, var(--paper) 94%, white);
  --tray-highlight: rgba(255, 255, 255, 0.65);
  --tile-edge: rgba(17, 17, 17, 0.72);
  --tile-shadow: rgba(17, 17, 17, 0.06);
  --drag-shadow: rgba(17, 17, 17, 0.18);
  --button-border: rgba(0, 94, 184, 0.28);
  --button-bg: rgba(0, 94, 184, 0.055);
  --button-border-hover: rgba(0, 94, 184, 0.42);
  --button-bg-hover: rgba(0, 94, 184, 0.08);
  --button-muted-border: rgba(0, 94, 184, 0.22);
  --button-muted-bg: rgba(0, 94, 184, 0.035);
  --button-muted-border-hover: rgba(0, 94, 184, 0.36);
  --button-muted-bg-hover: rgba(0, 94, 184, 0.06);
  --game-highlight: rgba(0, 94, 184, 0.025);
  --game-update-bg: rgba(0, 94, 184, 0.035);
  --theme-toggle-track: #e3e7dd;
  --theme-toggle-border: rgba(17, 17, 17, 0.22);
  --theme-toggle-active: #fffffc;
  --theme-toggle-icon: #111;
  --theme-toggle-muted: #737373;
  --theme-toggle-shadow: 0 1px 5px rgba(17, 17, 17, 0.14);
  --board-bg: #fbfff8;
  --grid-fill: rgba(255, 255, 255, 0.5);
  --grid-stroke: rgba(17, 17, 17, 0.18);
  --preview-fill: rgba(35, 122, 59, 0.08);
  --preview-stroke: rgba(35, 122, 59, 0.42);
  --hover-fill: rgba(139, 0, 0, 0.08);
  --tile-face: #fffffc;
  --tile-text: #111;
  --tile-subtext: rgba(17, 17, 17, 0.62);
  --tile-canvas-shadow: rgba(17, 17, 17, 0.16);
  --tile-fill-alpha: 0.16;
  --tile-highlight-alpha: 0.26;
  --current-player: #0072b2;
  --other-player: #d55e00;
  --other-player-colors: #d55e00, #c47900, #b64a35, #9f5a1c, #7f6720, #6f7e2c, #4f8738, #a98a45, #a36f51, #bf6f24, #8f4d2e, #b49360;
  --font: "Crimson Pro", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--paper);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --viewport-bg: #10130f;
  --paper: #10130f;
  --paper-bright: #171b15;
  --ink: #f4f0e7;
  --ink-mid: #d8d2c3;
  --ink-light: #aaa38f;
  --ink-faint: #817b68;
  --red: #ff8d78;
  --red-light: #ffb09f;
  --green: #89d48b;
  --teal: #8bbcc7;
  --gold: #e0b65b;
  --blue: #8ec9ff;
  --blue-hover: #b8ddff;
  --rule: #2c3128;
  --hover: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(244, 240, 231, 0.18);
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  --tray-bg: color-mix(in srgb, var(--paper) 88%, black);
  --tray-highlight: rgba(255, 255, 255, 0.06);
  --tile-edge: rgba(244, 240, 231, 0.56);
  --tile-shadow: rgba(0, 0, 0, 0.34);
  --drag-shadow: rgba(0, 0, 0, 0.45);
  --button-border: rgba(142, 201, 255, 0.36);
  --button-bg: rgba(142, 201, 255, 0.12);
  --button-border-hover: rgba(142, 201, 255, 0.54);
  --button-bg-hover: rgba(142, 201, 255, 0.17);
  --button-muted-border: rgba(142, 201, 255, 0.28);
  --button-muted-bg: rgba(142, 201, 255, 0.08);
  --button-muted-border-hover: rgba(142, 201, 255, 0.44);
  --button-muted-bg-hover: rgba(142, 201, 255, 0.13);
  --game-highlight: rgba(142, 201, 255, 0.07);
  --game-update-bg: rgba(142, 201, 255, 0.1);
  --theme-toggle-track: #090b08;
  --theme-toggle-border: rgba(244, 240, 231, 0.24);
  --theme-toggle-active: #252a21;
  --theme-toggle-icon: #f4f0e7;
  --theme-toggle-muted: #817b68;
  --theme-toggle-shadow: 0 1px 7px rgba(0, 0, 0, 0.42);
  --board-bg: #0f120d;
  --grid-fill: rgba(255, 255, 255, 0.035);
  --grid-stroke: rgba(244, 240, 231, 0.18);
  --preview-fill: rgba(137, 212, 139, 0.12);
  --preview-stroke: rgba(137, 212, 139, 0.45);
  --hover-fill: rgba(255, 141, 120, 0.14);
  --tile-face: #1b2018;
  --tile-text: #f4f0e7;
  --tile-subtext: rgba(244, 240, 231, 0.68);
  --tile-canvas-shadow: rgba(0, 0, 0, 0.36);
  --tile-fill-alpha: 0.34;
  --tile-highlight-alpha: 0.46;
  --current-player: #62b8ef;
  --other-player: #ff9f68;
  --other-player-colors: #ff9f68, #eeb84f, #ff8d78, #d99642, #c3a94c, #a8c95a, #78c46c, #d7bd78, #d69c7a, #f0a84c, #d97865, #ddc18b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  background: var(--viewport-bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--viewport-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:disabled {
  cursor: default;
  opacity: 0.38;
}

[hidden] {
  display: none !important;
}

body.no-scroll {
  overflow: hidden;
}

#app {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--paper);
  pointer-events: none;
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease), visibility 0s linear 0.35s;
}

#app.active {
  pointer-events: auto;
  visibility: visible;
  transform: translateX(0);
  transition: transform 0.35s var(--ease), visibility 0s linear 0s;
}

.board-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#board-canvas:active {
  cursor: grabbing;
}

.hud {
  position: absolute;
  z-index: 3;
  top: 0;
  right: 0;
  left: 0;
  padding: calc(18px + env(safe-area-inset-top, 0)) 18px 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-bright);
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin: 0 auto;
  max-width: 780px;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar h1 {
  font-size: 42px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
  line-height: 0.95;
}

.back-home-btn {
  display: block;
  margin-bottom: 7px;
  border: none;
  background: none;
  color: var(--blue);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  pointer-events: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-transform: uppercase;
}

.back-home-btn:hover {
  color: var(--blue-hover);
}

#room-line,
.stats-row,
.tray-meta,
.preview-strip {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

#room-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  pointer-events: auto;
}

.inline-link {
  border: none;
  background: none;
  color: var(--blue);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-transform: uppercase;
}

.inline-link:hover {
  color: var(--blue-hover);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding-top: 5px;
  pointer-events: auto;
}

.theme-toggle {
  position: relative;
  display: grid;
  width: 74px;
  height: 34px;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 1fr);
  align-items: center;
  padding: 3px;
  border: 1px solid var(--theme-toggle-border);
  border-radius: 999px;
  background: var(--theme-toggle-track);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.theme-toggle::before {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 2);
  border-radius: 999px;
  background: var(--theme-toggle-active);
  box-shadow: var(--theme-toggle-shadow);
  content: "";
  transition: transform 0.2s var(--ease);
}

.theme-toggle[data-theme="dark"]::before {
  transform: translateX(100%);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.theme-toggle-side {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  color: var(--theme-toggle-muted);
  transition: color 0.2s;
}

.theme-toggle[data-theme="light"] .theme-toggle-light,
.theme-toggle[data-theme="dark"] .theme-toggle-dark {
  color: var(--theme-toggle-icon);
}

.theme-toggle-side::before,
.theme-toggle-light::after {
  display: block;
  content: "";
}

.theme-toggle-light::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.theme-toggle-light::after {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  color: currentColor;
  box-shadow:
    0 -8px 0 0 currentColor,
    0 8px 0 0 currentColor,
    -8px 0 0 0 currentColor,
    8px 0 0 0 currentColor,
    -6px -6px 0 0 currentColor,
    6px -6px 0 0 currentColor,
    -6px 6px 0 0 currentColor,
    6px 6px 0 0 currentColor;
}

.theme-toggle-dark::before {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: inset 5px -3px 0 0 currentColor;
  transform: rotate(-16deg);
}

.header-user,
.action-link {
  border: none;
  background: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.header-user {
  max-width: 180px;
  overflow: hidden;
  color: var(--blue);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: underline;
  text-overflow: ellipsis;
  text-underline-offset: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-user:hover {
  color: var(--blue-hover);
}

.sync-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
}

.sync-dot.synced {
  background: var(--green);
}

.sync-dot.syncing,
.sync-dot.pending {
  background: var(--gold);
}

.sync-dot.offline,
.sync-dot.local,
.sync-dot.idle {
  background: var(--red);
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  max-width: 780px;
  margin: 8px auto 0;
}

.preview-strip {
  position: absolute;
  z-index: 4;
  right: 18px;
  bottom: 14px;
  left: 18px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  max-width: 780px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--paper-bright);
  box-shadow: var(--panel-shadow);
  color: var(--ink-light);
  pointer-events: none;
}

.preview-strip.valid {
  color: var(--green);
}

.preview-strip.notice {
  color: var(--blue);
}

.preview-strip.complete {
  color: var(--green);
}

.preview-strip.invalid {
  color: var(--red);
}

.preview-strip.invalid span:first-child {
  white-space: normal;
}

.preview-strip span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-strip span:last-child {
  flex: 0 0 auto;
  color: var(--ink);
}

.confirmation-strip {
  position: fixed;
  z-index: 340;
  bottom: calc(112px + env(safe-area-inset-bottom, 0));
  align-items: center;
  pointer-events: auto;
}

.confirmation-strip .confirmation-detail {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--ink-mid);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confirmation-strip .confirmation-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 14px;
}

.confirmation-strip .action-link {
  padding: 0;
  font-size: 10px;
}

.tray-panel {
  position: relative;
  z-index: 5;
  padding: 10px 18px calc(8px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--rule);
  background: var(--tray-bg);
}

.tray-panel::before {
  position: absolute;
  right: 18px;
  left: 18px;
  top: 0;
  height: 1px;
  background: var(--tray-highlight);
  content: "";
}

.tray-meta,
.tray-actions,
.tile-tray {
  max-width: 780px;
  margin-right: auto;
  margin-left: auto;
}

.tray-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-height: 16px;
  margin-bottom: 8px;
}

#pending-label {
  color: var(--gold);
}

.tile-tray {
  --rack-gap: 8px;
  --rack-half-gap: 4px;
  display: grid;
  grid-template-columns: repeat(6, minmax(42px, 1fr));
  gap: var(--rack-gap);
  max-width: 372px;
  min-height: 112px;
  margin-bottom: -18px;
}

.rack-tile {
  position: relative;
  display: flex;
  aspect-ratio: 0.8660254;
  min-width: 0;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: grab;
  filter: drop-shadow(0 1px 0 var(--tile-shadow));
  touch-action: none;
}

.rack-tile::before,
.rack-tile::after {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  content: "";
}

.rack-tile::before {
  background: var(--tile-edge);
}

.rack-tile::after {
  inset: 1.5px;
  background: var(--paper-bright);
}

.rack-tile:active {
  cursor: grabbing;
  opacity: 0.7;
}

.rack-tile:nth-child(n+7) {
  transform: translate(calc(50% + var(--rack-half-gap)), calc(-25% - var(--rack-half-gap)));
}

.rack-placeholder {
  cursor: default;
  filter: none;
  pointer-events: none;
}

.rack-placeholder::before,
.rack-placeholder::after {
  opacity: 0;
}

.rack-tile span {
  position: relative;
  z-index: 1;
  font-size: 27px;
  font-weight: 600;
  line-height: 1;
}

.rack-tile small {
  position: absolute;
  z-index: 1;
  bottom: 17%;
  left: 50%;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  transform: translateX(-50%);
}

.tray-actions {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.action-link {
  display: inline-block;
  padding: 8px 0;
  color: var(--blue);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.15s, opacity 0.15s;
}

.action-link:hover {
  color: var(--blue-hover);
}

.action-link.primary {
  font-weight: 700;
}

.action-link.muted {
  color: var(--blue);
}

.action-link.muted:hover {
  color: var(--blue-hover);
}

.action-link.danger {
  color: var(--red);
}

.action-link.danger:hover {
  color: var(--red-light);
}

.tray-actions .action-link {
  min-width: 78px;
  padding: 7px 13px;
  border: 1px solid var(--button-border);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--blue);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
}

.tray-actions .action-link:hover {
  border-color: var(--button-border-hover);
  background: var(--button-bg-hover);
}

.tray-actions .action-link.muted {
  border-color: var(--button-muted-border);
  background: var(--button-muted-bg);
  color: var(--blue);
}

.tray-actions .action-link.muted:hover {
  border-color: var(--button-muted-border-hover);
  background: var(--button-muted-bg-hover);
  color: var(--blue-hover);
}

.overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  overflow-y: auto;
  visibility: hidden;
  background: var(--paper);
  overscroll-behavior-y: contain;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease), visibility 0s linear 0.35s;
  -webkit-overflow-scrolling: touch;
}

.home-overlay {
  z-index: 100;
}

.setup-overlay {
  z-index: 120;
}

.invite-overlay {
  z-index: 125;
}

.leaderboard-overlay {
  z-index: 130;
}

.overlay.active {
  visibility: visible;
  transform: translateX(0);
  transition: transform 0.35s var(--ease), visibility 0s linear 0s;
}

#app,
#app.active,
.overlay,
.overlay.active {
  transition: none;
}

:root.motion-ready #app,
:root.motion-ready .overlay {
  transition: transform 0.35s var(--ease), visibility 0s linear 0.35s;
}

:root.motion-ready #app.active,
:root.motion-ready .overlay.active {
  transition: transform 0.35s var(--ease), visibility 0s linear 0s;
}

.invite-overlay,
.leaderboard-overlay {
  background: transparent;
}

.overlay-content {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top, 0)) 24px calc(60px + env(safe-area-inset-bottom, 0));
}

.invite-content,
.leaderboard-content {
  width: min(640px, calc(100% - 36px));
  margin-top: calc(24px + env(safe-area-inset-top, 0));
  margin-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--paper-bright);
  box-shadow: var(--panel-shadow);
}

.leaderboard-content {
  width: min(860px, calc(100% - 36px));
}

.invite-link-actions {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding-bottom: 8px;
}

.setup-content h1 {
  margin-bottom: 10px;
  font-size: 52px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
  line-height: 1;
}

.setup-content p {
  margin-bottom: 28px;
  color: var(--ink-light);
  font-size: 18px;
}

.home-content {
  max-width: 780px;
}

.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 30px;
}

.home-header > div {
  min-width: 0;
}

.home-header h1 {
  margin-bottom: 8px;
  font-size: 52px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
  line-height: 1;
}

.home-name {
  font-family: var(--sans);
  font-size: 11px;
}

.home-new-game {
  margin-bottom: 4px;
  white-space: nowrap;
}

.home-list-actions {
  display: flex;
  align-items: baseline;
  gap: 22px;
  margin-bottom: -20px;
}

.join-game-form {
  max-width: 420px;
  margin-top: 26px;
  margin-bottom: -14px;
}

.join-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
}

.join-field .field-input {
  margin-bottom: 0;
  text-transform: uppercase;
}

.join-error {
  margin-top: 8px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

.game-section {
  margin-top: 34px;
}

.game-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--rule);
}

.game-section-header h2 {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.game-section-header span,
.game-list-empty {
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

.game-list-empty {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.game-card {
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
}

.game-card.recently-shared {
  background: var(--game-highlight);
}

.game-card.has-updates {
  background: var(--game-update-bg);
}

.game-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: baseline;
  margin: 0 -12px;
  padding: 15px 12px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.game-row:hover {
  background: var(--hover);
}

.game-card-actions {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 15px;
}

.game-row-main,
.game-row-meta {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.game-title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.game-update-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blue);
}

.game-title-line strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row-main span,
.game-row-meta span {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

.game-row-meta {
  justify-items: end;
  text-align: right;
}

.length-options {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.length-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: baseline;
  width: 100%;
  padding: 13px 0;
  border: none;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.length-option strong {
  font-size: 24px;
  font-weight: 500;
}

.length-option span {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

.length-option.selected {
  border-bottom-color: var(--red);
  color: var(--red);
}

.length-option.selected span {
  color: var(--red);
}

.friend-picker {
  margin: 26px 0 22px;
}

.friend-picker h2 {
  margin-bottom: 6px;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.friend-list {
  border-top: 1px solid var(--rule);
}

.friend-option {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: baseline;
  padding: 11px 0;
  border: none;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.friend-option strong {
  min-width: 0;
  overflow: hidden;
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-option span {
  color: var(--blue);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.friend-option.selected strong {
  color: var(--blue);
}

.overlay-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.overlay-header h2 {
  font-size: 46px;
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
  line-height: 1;
}

.overlay-section + .overlay-section {
  margin-top: 32px;
}

.overlay-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.overlay-section-header h3 {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-table {
  border-top: 1px solid var(--rule);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 52px 52px 52px 64px;
  gap: 10px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
}

.leaderboard-row span {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
}

.leaderboard-row strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-player-name {
  display: flex;
  gap: 7px;
  align-items: center;
}

.player-color-hex {
  width: 13px;
  height: 15px;
  flex: 0 0 auto;
  background: var(--player-color);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  filter: drop-shadow(0 1px 0 var(--tile-shadow));
}

.leaderboard-player-name .player-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-player-name small {
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
}

.leaderboard-remove {
  padding: 0;
  font-size: 10px;
}

.leaderboard-heading {
  padding: 8px 0;
}

.leaderboard-heading span {
  color: var(--ink-faint);
}

.leaderboard-empty {
  padding: 16px 0;
  border-top: 1px solid var(--rule);
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
}

.history-table {
  border-top: 1px solid var(--rule);
}

.history-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1.35fr) minmax(80px, 0.75fr) minmax(0, 1fr) 64px;
  gap: 12px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
}

.history-row span {
  min-width: 0;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.history-row strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-jump {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.history-jump:hover,
.history-jump:focus-visible {
  background: color-mix(in srgb, var(--paper) 88%, var(--green) 12%);
}

.history-jump:focus-visible {
  outline: 1px solid var(--green);
  outline-offset: -1px;
}

.word-separator {
  color: var(--ink-light);
}

.word-reverse {
  margin-left: 0.45em;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

.preview-strip .word-reverse {
  color: var(--green);
}

.history-score {
  text-align: right;
}

.history-heading {
  padding: 8px 0;
}

.history-heading span {
  color: var(--ink-faint);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field-input {
  width: 100%;
  margin-bottom: 20px;
  padding: 8px 0;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-bottom-color: var(--ink);
}

.field-input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}

.copy-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.copy-field .field-input {
  margin-bottom: 0;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 10.5px;
}

.copy-field .action-link {
  padding-bottom: 8px;
}

.link-device-form {
  margin-top: 22px;
}

.account-delete-row {
  margin-top: 28px;
}

.setup-input {
  text-transform: none;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 20px;
}

.drag-ghost {
  position: fixed;
  z-index: 200;
  top: 0;
  left: 0;
  display: flex;
  width: 54px;
  height: 62.35px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  filter: drop-shadow(0 8px 18px var(--drag-shadow));
  pointer-events: none;
}

.drag-ghost::before,
.drag-ghost::after {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  content: "";
}

.drag-ghost::before {
  background: var(--red);
}

.drag-ghost::after {
  inset: 1.5px;
  background: var(--paper-bright);
}

.drag-ghost.invalid {
  opacity: 0.6;
}

.drag-ghost.invalid::before {
  background: var(--ink-faint);
}

.drag-ghost span {
  position: relative;
  z-index: 1;
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}

.drag-ghost small {
  position: absolute;
  z-index: 1;
  bottom: 17%;
  left: 50%;
  color: var(--ink-light);
  font-family: var(--mono);
  font-size: 9px;
  transform: translateX(-50%);
}

@media (max-width: 520px) {
  .hud {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topbar {
    gap: 12px;
  }

  .topbar h1 {
    font-size: 37px;
  }

  .header-right {
    gap: 8px;
  }

  .theme-toggle {
    width: 62px;
    height: 30px;
  }

  .theme-toggle-light::before {
    width: 8px;
    height: 8px;
  }

  .theme-toggle-light::after {
    box-shadow:
      0 -7px 0 0 currentColor,
      0 7px 0 0 currentColor,
      -7px 0 0 0 currentColor,
      7px 0 0 0 currentColor,
      -5px -5px 0 0 currentColor,
      5px -5px 0 0 currentColor,
      -5px 5px 0 0 currentColor,
      5px 5px 0 0 currentColor;
  }

  .theme-toggle-dark::before {
    width: 14px;
    height: 14px;
  }

  .home-header {
    gap: 12px;
  }

  .home-header h1 {
    font-size: 48px;
  }

  .home-new-game {
    margin-top: 0;
  }

  .game-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .game-row-meta {
    justify-items: start;
    text-align: left;
  }

  .header-user {
    max-width: 82px;
  }

  .preview-strip {
    right: 14px;
    bottom: 10px;
    left: 14px;
  }

  .confirmation-strip {
    bottom: calc(112px + env(safe-area-inset-bottom, 0));
  }

  .confirmation-strip .confirmation-detail {
    display: none;
  }

  .tray-panel {
    padding-right: 14px;
    padding-left: 14px;
  }

  .tile-tray {
    --rack-gap: 6px;
    --rack-half-gap: 3px;
    min-height: 112px;
  }

  .rack-tile span {
    font-size: 24px;
  }

  .leaderboard-row {
    grid-template-columns: 22px minmax(0, 1fr) 36px 42px 34px 48px;
    gap: 8px;
  }

  .leaderboard-player-name {
    gap: 6px;
  }

  .player-color-hex {
    width: 11px;
    height: 13px;
  }

  .leaderboard-player-name .player-name {
    font-size: 18px;
  }

  .leaderboard-remove {
    font-size: 9px;
  }

  .history-row {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) auto;
    grid-template-areas:
      "player bonuses score"
      "words words words";
    gap: 5px 8px;
    align-items: start;
  }

  .history-heading {
    display: none;
  }

  .history-index {
    display: none;
  }

  .history-player {
    grid-area: player;
  }

  .history-bonuses {
    grid-area: bonuses;
  }

  .history-score {
    grid-area: score;
  }

  .history-words {
    grid-area: words;
  }

  .history-row strong {
    font-size: 18px;
    white-space: normal;
    text-overflow: clip;
  }
}

@media (min-width: 560px) {
  .tile-tray {
    grid-template-columns: repeat(11, minmax(42px, 1fr));
    max-width: 780px;
    min-height: 0;
    margin-bottom: 0;
  }

  .rack-tile:nth-child(n+7) {
    transform: none;
  }
}
