:root {
  color-scheme: light;
  --paper: #f5f2ea;
  --surface: #fffdf8;
  --ink: #20211f;
  --muted: #73736c;
  --line: #d5d1c7;
  --line-strong: #4a4a45;
  --coral: #e45d4f;
  --teal: #248c83;
  --amber: #d89a27;
  --blue: #4c72c3;
  --shadow: 0 18px 45px rgba(38, 35, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(51, 49, 44, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 49, 44, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}
[hidden] {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.topbar {
  width: min(1120px, calc(100% - 32px));
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 20px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 18px);
  gap: 2px;
}

.brand-mark i {
  width: 18px;
  height: 23px;
  display: grid;
  place-items: center;
  background: var(--ink);
  border-radius: 3px;
  color: white;
  font-size: 12px;
  font-style: normal;
}

.brand-mark i:nth-child(2) {
  background: var(--coral);
}

.brand-mark i:nth-child(3) {
  background: var(--teal);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.help-button {
  font-size: 17px;
  font-weight: 900;
}

.auth-button {
  min-width: 78px;
  height: 38px;
  padding: 0 10px;
  display: grid;
  align-content: center;
  justify-items: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.05;
}

.auth-button span {
  max-width: 118px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-button small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}
.game-layout {
  width: min(1060px, calc(100% - 32px));
  margin: 36px auto 48px;
  display: grid;
  grid-template-columns: minmax(0, 690px) minmax(240px, 290px);
  gap: 54px;
  align-items: start;
}

.turn-strip {
  min-height: 63px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 18px;
}

.bag-count {
  min-width: 61px;
  height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.72);
}

.bag-icon {
  color: var(--muted);
  font-size: 22px;
  transform: rotate(45deg);
}

.board-frame {
  width: 100%;
  max-width: 690px;
  aspect-ratio: 1;
  padding: 7px;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--line-strong);
  box-shadow: var(--shadow);
}

.sudoku-board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 1px;
  background: #777b72;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--block-accent, var(--line)) 18%, transparent), rgba(255, 255, 255, 0.18) 46%, transparent 100%),
    var(--block-color, var(--surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--block-accent, var(--line)) 44%, transparent),
    inset 0 0 0 999px rgba(255, 255, 255, 0.04);
  color: var(--ink);
  cursor: pointer;
  font-size: 27px;
  font-weight: 650;
  transition: background 120ms ease, transform 120ms ease;
}

.cell.box-right {
  border-right: 3px solid var(--line-strong);
}

.cell.box-bottom {
  border-bottom: 3px solid var(--line-strong);
}

.cell.given {
  background:
    linear-gradient(rgba(32, 33, 31, 0.13), rgba(32, 33, 31, 0.13)),
    linear-gradient(135deg, color-mix(in srgb, var(--block-accent, var(--line)) 18%, transparent), rgba(255, 255, 255, 0.1)),
    var(--block-color, #e7e3da);
  font-weight: 850;
  cursor: default;
}

.cell.placed {
  color: var(--owner-color);
}

.cell.placed::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--owner-color);
}

.cell.block-center::before {
  content: "\2605";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--block-accent, var(--line-strong));
  font-size: 28px;
  line-height: 1;
  opacity: 0.42;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.62);
}

.cell.block-center.board-center::before {
  font-size: 47px;
  opacity: 0.52;
}
.cell:not(.given):not(.placed):hover {
  background:
    linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)),
    var(--block-color, #f0eee8);
}

.cell.is-related {
  box-shadow:
    inset 0 0 0 999px rgba(255, 255, 255, 0.28),
    inset 0 0 0 2px var(--block-accent, var(--line));
}

.cell.is-selected {
  outline: 3px solid var(--ink);
  outline-offset: -4px;
}

.cell.is-correct {
  z-index: 1;
  color: #167746;
  background: #ccebd8;
  box-shadow: inset 0 0 0 4px #36a867;
  animation: correct-pulse 650ms ease;
}

.cell.block-complete {
  z-index: 2;
  animation: block-complete-pulse 1.05s ease;
}

.cell.line-complete {
  z-index: 3;
  animation: line-complete-glow 0.95s ease var(--line-step, 0ms) both;
}

.cell.block-complete.line-complete {
  animation:
    block-complete-pulse 1.05s ease,
    line-complete-glow 0.95s ease var(--line-step, 0ms) both;
}

@keyframes line-complete-glow {
  0%, 100% {
    filter: brightness(1);
    outline: 0 solid transparent;
  }
  38%, 68% {
    filter: brightness(1.3) saturate(1.45);
    outline: 4px solid rgba(255, 255, 255, 0.95);
    outline-offset: -6px;
  }
}
.cell.star-active::before {
  z-index: 3;
  opacity: 1;
  text-shadow:
    0 0 8px white,
    0 0 18px var(--block-accent),
    0 0 30px var(--block-accent);
  animation: star-flare 1.05s ease;
}

@keyframes block-complete-pulse {
  0%, 100% {
    color: var(--ink);
  }
  38%, 66% {
    color: white;
    background: var(--block-accent);
    box-shadow:
      inset 0 0 0 3px white,
      0 0 16px var(--block-accent);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    transform: scale(1.035);
  }
}

@keyframes star-flare {
  0%, 100% {
    opacity: 0.28;
    transform: scale(1);
  }
  35%, 70% {
    color: white;
    opacity: 1;
    transform: scale(1.65) rotate(18deg);
  }
}

.cell.board-center.star-active::before {
  animation-name: center-star-flare;
}

@keyframes center-star-flare {
  0%, 100% {
    opacity: 0.38;
    transform: scale(1);
  }
  35%, 70% {
    color: white;
    opacity: 1;
    transform: scale(1.85) rotate(22deg);
  }
}
.cell.is-wrong {
  z-index: 1;
  animation: shake 260ms ease;
  color: #b72e26;
  background: #f7d3cf;
  box-shadow: inset 0 0 0 4px #d95449;
  font-weight: 850;
}

@keyframes correct-pulse {
  50% {
    color: #0c5e34;
    background: #aee0c1;
    transform: scale(1.06);
  }
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.game-sidebar {
  padding-top: 81px;
}

.score-section,
.rack-section,
.chat-section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.chat-section.is-hidden {
  display: none;
}

.chat-list {
  max-height: 190px;
  margin-bottom: 9px;
  display: grid;
  gap: 7px;
  overflow: auto;
}

.chat-message {
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.35;
}

.chat-message strong {
  color: var(--teal);
  font-size: 11px;
  text-transform: uppercase;
}

.chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.quick-message-grid {
  display: grid;
  gap: 7px;
}

.quick-message-button {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--teal), white 58%);
  border-radius: 6px;
  background: color-mix(in srgb, var(--teal), white 90%);
  color: var(--ink);
  font-weight: 850;
  text-align: left;
  cursor: pointer;
}

.quick-message-button:hover:not(:disabled),
.quick-message-button:focus-visible {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal), white 82%);
  outline: none;
}

.quick-message-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.section-heading {
  min-height: 32px;
  margin-bottom: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading > span {
  color: var(--muted);
  font-size: 13px;
}

.scoreboard {
  display: grid;
  gap: 7px;
}

.player-score {
  height: 58px;
  padding: 0 10px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
}

.player-score.is-active {
  border-color: var(--line);
  background: var(--surface);
}

.player-score .player-dot {
  width: 10px;
  height: 10px;
}

.player-name-stack {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.player-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-rating {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-clock {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
}

.player-clock.is-active {
  color: var(--teal);
}

.player-clock.is-low {
  color: #b54708;
}

.player-clock.is-danger,
.player-clock.is-out {
  color: #9b2f25;
}

.player-rating.is-positive,
.final-rating.is-positive {
  color: #137333;
}

.player-rating.is-negative,
.final-rating.is-negative {
  color: #9b2f25;
}

.player-points {
  min-width: 27px;
  font-size: 20px;
  font-weight: 850;
  text-align: right;
}

.tile-rack {
  min-height: 57px;
  display: grid;
  grid-template-columns: repeat(5, minmax(38px, 1fr));
  gap: 7px;
}

.number-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 0.82;
  padding: 7px 0 0;
  display: grid;
  place-items: center;
  border: 2px solid var(--tile-accent, #cfc8ba);
  border-bottom-width: 7px;
  border-radius: 6px;
  background:
    linear-gradient(to bottom, var(--tile-accent, #cfc8ba) 0 8px, transparent 8px),
    linear-gradient(145deg, rgba(255, 255, 255, 0.34), transparent 58%),
    var(--tile-surface, #fffaf0);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--tile-accent, #cfc8ba) 34%, transparent),
    0 3px 8px rgba(43, 39, 31, 0.12);
  color: color-mix(in srgb, var(--tile-accent, var(--ink)) 78%, var(--ink));
  cursor: pointer;
  font-size: 25px;
  font-weight: 900;
  transition: transform 120ms ease, border-color 120ms ease;
  touch-action: none;
  user-select: none;
}

.facedown-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 0.82;
  border: 1px solid #373833;
  border-bottom-width: 4px;
  border-radius: 6px;
  background: var(--ink);
}

.facedown-tile::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.number-tile:hover {
  transform: translateY(-2px);
}

.number-tile.is-dragging {
  opacity: 0.34;
  transform: scale(0.94);
}

.drag-ghost {
  position: fixed;
  z-index: 100;
  margin: 0;
  pointer-events: none;
  transform: translate(-50%, -58%) scale(1.08);
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--tile-accent) 28%, transparent),
    0 14px 28px rgba(28, 27, 24, 0.3);
}

.cell.is-drop-target {
  z-index: 4;
  outline: 4px solid var(--block-accent, var(--ink));
  outline-offset: -5px;
  filter: brightness(1.16) saturate(1.2);
  transform: scale(0.94);
}

body.is-tile-dragging {
  cursor: grabbing;
}

body.is-tile-dragging .cell:not(.given):not(.placed) {
  cursor: grabbing;
}
.number-tile.is-selected {
  border-color: var(--tile-accent, var(--coral));
  outline: 3px solid var(--tile-accent, var(--coral));
  outline-offset: 2px;
  transform: translateY(-5px);
}

.rack-status {
  min-height: 38px;
  margin: 13px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.solo-high-scores {
  margin: 0 0 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.solo-high-scores.is-hidden {
  display: none;
}

.solo-high-scores h3 {
  margin: 0 0 9px;
  font-size: 13px;
  text-transform: uppercase;
}

.high-score-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, 26px);
  grid-auto-flow: column;
  gap: 2px 12px;
}

.high-score-row {
  min-height: 26px;
  padding: 0 7px;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid #ebe6dc;
  font-size: 13px;
}

.high-score-row:nth-child(-n + 3) .high-score-rank {
  color: var(--coral);
  font-weight: 900;
}

.high-score-rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.high-score-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.high-score-row.is-empty {
  color: #aaa69d;
}

.solo-rank {
  margin: -12px 0 18px;
  color: var(--teal);
  font-weight: 850;
}
.button {
  height: 42px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.button:hover {
  filter: brightness(0.97);
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.2);
  opacity: 0.48;
}

.button:focus-visible,
.auth-button:focus-visible,
.icon-button:focus-visible,
.cell:focus-visible,
.number-tile:focus-visible,
.segmented-control button:focus-visible,
.setup-help-button:focus-visible,
.setup-account-button:focus-visible,
.auth-input:focus {
  outline: 3px solid rgba(36, 140, 131, 0.38);
  outline-offset: 2px;
}

.button-primary {
  width: 100%;
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.button-quiet {
  height: 38px;
  border-color: var(--line);
  background: rgba(255, 253, 248, 0.7);
}

.setup-account-button {
  width: 100%;
  min-height: 50px;
  margin: -6px 0 18px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0ede5;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.setup-account-button span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-account-button strong {
  flex: 0 0 auto;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.setup-help-button {
  margin: 0 auto 16px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.turn-actions {
  display: grid;
  gap: 8px;
}

.button-pass {
  width: 100%;
  border-color: var(--line);
  background: var(--surface);
}

.button-give-up {
  width: 100%;
  border-color: #9b2f25;
  background: #fff5f3;
  color: #9b2f25;
}

.button-give-up:disabled {
  opacity: 0.56;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  padding: 20px;
  display: none;
  place-items: center;
  background: rgba(28, 28, 25, 0.76);
  backdrop-filter: blur(7px);
}

.modal-backdrop.is-visible {
  display: grid;
}

.modal {
  width: min(420px, 100%);
  max-height: calc(100vh - 40px);
  padding: 30px;
  overflow: auto;
  border: 1px solid #d7d0c3;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.26);
  text-align: center;
}

.modal h2 {
  margin-bottom: 22px;
  font-size: 28px;
}

.setup-mark {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 3px solid var(--ink);
  background: var(--ink);
  gap: 2px;
}

.setup-mark span {
  display: grid;
  place-items: center;
  background: var(--surface);
  font-size: 13px;
  font-weight: 850;
}

.setup-mark span:nth-child(2),
.setup-mark span:nth-child(6),
.setup-mark span:nth-child(7) {
  color: var(--coral);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.player-count legend,
.speed-choice legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

.setup-page {
  display: grid;
  gap: 16px;
}

.setup-page[hidden] {
  display: none;
}

.local-setup-page {
  text-align: left;
}

.local-setup-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.local-setup-heading h2 {
  margin: 0;
  font-size: 24px;
}

.local-back-button {
  width: auto;
  padding: 0 12px;
}

.local-setup-page .name-fields {
  margin: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eeeae1;
}

.segmented-control button {
  min-height: 36px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.05;
}

.segmented-control button small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.speed-control {
  grid-template-columns: repeat(3, 1fr);
}

.speed-control button {
  min-height: 46px;
}

.segmented-control button.is-selected {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(28, 27, 24, 0.12);
}

.name-fields {
  margin: 18px 0 22px;
  display: grid;
  gap: 10px;
}

.name-fields label {
  display: grid;
  grid-template-columns: 12px 70px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}

.name-fields label.is-hidden {
  display: none;
}

.name-fields input {
  width: 100%;
  height: 39px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  font-weight: 700;
  outline: none;
}

.name-fields input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 140, 131, 0.14);
}

.player-dot,
.handoff-dot {
  display: inline-block;
  border-radius: 50%;
  background: var(--player-color);
}

.player-1 { --player-color: var(--coral); }
.player-2 { --player-color: var(--teal); }
.player-3 { --player-color: var(--amber); }
.player-4 { --player-color: var(--blue); }

.handoff-modal p:not(.eyebrow) {
  margin: -12px 0 24px;
  color: var(--muted);
}

.handoff-dot {
  width: 28px;
  height: 28px;
  margin-bottom: 17px;
}

.trophy {
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--amber);
  color: white;
  font-size: 27px;
}

.final-scores {
  margin: -5px 0 24px;
  display: grid;
  gap: 7px;
}

.final-score {
  padding: 9px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 750;
  text-align: left;
}

.final-score strong {
  white-space: nowrap;
}

.final-name-stack {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.final-name-stack > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-rating {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 24px;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.fireworks-layer {
  position: fixed;
  z-index: 35;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.fireworks-layer i {
  position: absolute;
  left: var(--start-x);
  top: var(--start-y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--firework-color);
  box-shadow: 0 0 10px var(--firework-color);
  opacity: 0;
  animation: firework-burst 1.25s cubic-bezier(0.14, 0.72, 0.3, 1) var(--delay) both;
}

@keyframes firework-burst {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.2);
  }
  12% {
    opacity: 1;
  }
  80% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(var(--travel-x), var(--travel-y)) scale(0.55);
  }
}

.auth-modal {
  width: min(480px, 100%);
  text-align: left;
}

.auth-summary {
  margin: 10px 0 20px;
  padding: 13px 14px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0ede5;
}

.auth-summary strong {
  overflow-wrap: anywhere;
}

.auth-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-field {
  display: block;
  margin: 13px 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-profile {
  margin: -6px 0 18px;
}

.auth-profile[hidden] {
  display: none;
}

.auth-profile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.auth-profile-row .button {
  height: 42px;
  padding: 0 10px;
}

.auth-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  font-weight: 750;
  outline: none;
}

.auth-input:focus {
  border-color: var(--teal);
}

.auth-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}


.auth-credentials[hidden] {
  display: none;
}

.auth-mode-link {
  width: max-content;
  margin: 0 auto;
  padding: 3px 4px;
  border: 0;
  background: transparent;
  color: var(--teal);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-mode-link:disabled {
  cursor: default;
  opacity: 0.55;
}

.auth-status {
  min-height: 34px;
  margin: 12px 0 2px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
}

.auth-status.is-error {
  color: #8d3029;
}


.auth-signout {
  width: 100%;
  margin-top: 7px;
}

.auth-modal .setup-help-button {
  display: block;
  margin: 12px auto 0;
}

.setup-actions {
  display: grid;
  gap: 9px;
}

.button-lan {
  width: 100%;
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.whatsapp-share-link {
  width: fit-content;
  margin: -2px auto 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #127c43;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
}

.whatsapp-share-link::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #25d366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.14);
}

.whatsapp-share-link:hover,
.whatsapp-share-link:focus-visible {
  color: #075e31;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.leaderboard-modal {
  width: min(520px, 100%);
  text-align: left;
}

.leaderboard-note {
  margin: 2px 0 17px;
  color: var(--muted);
  line-height: 1.45;
}

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

.leaderboard-row {
  min-height: 56px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #ebe6dc;
}

.leaderboard-rank {
  color: var(--teal);
  font-size: 16px;
  font-weight: 900;
}

.leaderboard-name {
  min-width: 0;
  display: grid;
  gap: 2px;
  font-weight: 850;
}

.leaderboard-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-name small,
.leaderboard-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.leaderboard-rating {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.leaderboard-empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0ede5;
}

.lan-modal {
  width: min(520px, 100%);
  text-align: left;
}

.lan-intro {
  margin: 10px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.online-hub {
  margin: 0 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0ede5;
}

.online-hub-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

.online-hub h3,
.online-hub h4 {
  margin: 0;
  font-size: 14px;
}

.online-hub h4 {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.online-hub p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.online-hub p.is-error {
  color: #9b2f25;
}

.friend-request-row {
  margin: 12px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
}

.random-match-button {
  width: 100%;
  margin: 0 0 12px;
}

.online-lists {
  display: grid;
  gap: 12px;
}

.online-list {
  display: grid;
  gap: 6px;
}

.online-game-detail {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.online-game-detail small {
  white-space: normal;
}

.online-standings {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.online-standing {
  padding: 3px 6px;
  border: 1px solid #d8d0c1;
  border-radius: 5px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.online-standing.is-current {
  border-color: var(--teal);
  background: #dff4f1;
}

.online-standing.is-low {
  border-color: #d89a27;
  background: #fff1c2;
}

.online-standing.is-danger,
.online-standing.is-out {
  border-color: #d95d4d;
  background: #ffd8d2;
  color: #8f2c22;
}
.online-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.online-row-actions .button {
  min-width: 72px;
}

.button-decline {
  color: #9b2f25;
}
.online-row {
  min-height: 44px;
  padding: 8px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #ded7ca;
}

.online-row span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.online-row strong,
.online-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.online-row .online-game-detail small {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
.online-row small,
.online-empty {
  color: var(--muted);
  font-size: 12px;
}

.online-empty {
  margin: 4px 0 0;
}

.lan-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lan-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  font-weight: 750;
  outline: none;
}

.lan-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 140, 131, 0.14);
}

.lan-option {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.lan-option h3 {
  margin: 0 0 13px;
  font-size: 15px;
}

.lan-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}

.lan-create-row > .button {
  width: 100%;
}

.lan-player-count {
  grid-template-columns: repeat(4, 1fr);
}

.lan-divider {
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lan-join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

.room-code-input {
  text-align: center;
  text-transform: uppercase;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 18px;
}

.lan-error {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--coral);
  background: #fff1ef;
  color: #8d3029;
  font-size: 13px;
  line-height: 1.45;
}

.lan-lobby-modal {
  width: min(460px, 100%);
}

.room-code {
  margin: -6px 0 6px;
  color: var(--teal);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 38px;
  font-weight: 900;
}

.room-code-help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.lan-share-url {
  margin: 8px 0 11px;
  padding: 9px 10px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f0ede5;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  font-weight: 750;
}

.lan-whatsapp-share-link {
  margin-bottom: 18px;
}

.lan-player-list {
  margin: 0 0 15px;
  border-top: 1px solid var(--line);
}

.lan-player-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.lan-player-row .player-dot {
  width: 12px;
  height: 12px;
}

.lan-lobby-status {
  min-height: 42px;
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.lan-leave-button {
  width: 100%;
  margin-top: 9px;
}
.rules-modal {
  width: min(600px, 100%);
  text-align: left;
}

.rules-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.rules-heading .eyebrow {
  margin-bottom: 4px;
}

.rules-heading h2 {
  margin-bottom: 0;
}

.rules-intro {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.rules-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.rules-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.rules-section p {
  margin: 0;
  line-height: 1.55;
}

.turn-rules {
  margin: 0;
  padding-left: 22px;
}

.turn-rules li {
  margin-bottom: 9px;
  padding-left: 4px;
  line-height: 1.5;
}

.rules-note {
  margin-top: 12px !important;
  padding-left: 12px;
  border-left: 3px solid var(--coral);
  color: var(--muted);
}

.rules-score-list {
  display: grid;
}

.rules-score-list > div {
  min-height: 42px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #ebe6dc;
  font-size: 14px;
}

.rules-score-list strong {
  font-variant-numeric: tabular-nums;
}

.rule-symbol {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: white;
  font-size: 11px;
  font-weight: 900;
}

.number-symbol {
  color: var(--ink);
  font-size: 14px;
}

.color-symbol {
  border-color: #0057b8;
  background: #b8dcff;
  box-shadow: inset 0 0 0 5px white;
}

.star-symbol {
  color: var(--amber);
  font-size: 18px;
}

.big-star-symbol {
  border-color: var(--coral);
  color: var(--coral);
  font-size: 23px;
}

.complete-symbol {
  background: var(--ink);
  color: white;
}

.score-example {
  margin-top: 14px !important;
  padding: 12px 14px;
  border-radius: 5px;
  background: #f0ede5;
}

.rules-modal > .button-primary {
  margin-top: 6px;
}
@media (max-width: 860px) {
  .game-layout {

    width: min(650px, calc(100% - 28px));
    margin-top: 24px;
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .game-sidebar {
    padding-top: 0;
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: 24px;
  }

  .score-section,
  .rack-section {
    padding-top: 18px;
  }
}

@media (max-width: 570px) {
  .topbar {
    width: calc(100% - 24px);
    height: 64px;
  }

  .brand {
    font-size: 17px;
  }

  .brand-mark {
    grid-template-columns: repeat(3, 15px);
  }

  .brand-mark i {
    width: 15px;
    height: 20px;
    font-size: 10px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .auth-button {
    min-width: 64px;
    padding: 0 7px;
  }

  .auth-button span {
    max-width: 58px;
  }

  .auth-button small {
    display: none;
  }
  .button-quiet {
    padding: 0 12px;
  }

  .game-layout {

    width: calc(100% - 20px);
    margin-top: 17px;
  }

  .turn-strip {
    min-height: 55px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .board-frame {
    padding: 4px;
    border-width: 1px;
  }

  .cell {
    font-size: 20px;
  }

  .cell.block-center::before {
    font-size: 20px;
  }

  .cell.block-center.board-center::before {
    font-size: 34px;
  }
  .cell.placed::after {
    right: 4px;
    bottom: 4px;
    width: 4px;
    height: 4px;
  }

  .game-sidebar {
    display: block;
  }

  .scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .player-score {
    height: 52px;
  }

  .player-rating {
    font-size: 10px;
  }

  .leaderboard-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 9px;
  }

  .modal {
    padding: 25px 20px;
  }

  .modal h2 {
    font-size: 24px;
  }
  .lan-create-row,
  .lan-join-row,
  .friend-request-row,
  .online-hub-heading {
    grid-template-columns: 1fr;
  }

  .room-code {
    font-size: 32px;
  }
  .rules-score-list > div {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 8px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fireworks-layer i {
    animation-duration: 0.8s !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
