/* Original paper-and-arcade styling. The existing scripts retain all game behavior. */
.wordspider-root {
  min-height: 100vh;
  background-image: radial-gradient(#dcd9cf 0.8px, transparent 0.8px);
  background-size: 22px 22px;
  padding-bottom: 24px;
}
.site-header { background: var(--paper); border-bottom: 1px solid #d8d5cc; }
.site-header__inner {
  width: min(1120px, calc(100% - 64px));
  margin: auto;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark {
  width: 43px;
  height: 43px;
  padding: 5px;
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 11px;
  box-shadow: 2px 2px 0 var(--ink);
  transform: rotate(-5deg);
}
.brand__name { position: relative; isolation: isolate; font-size: 24px; font-weight: 850; letter-spacing: -1px; }
.brand__name::after { content: ""; position: absolute; inset: 56% -4px 2px; background: var(--mint); transform: rotate(-2deg); z-index: -1; }
.header-actions { display: flex; align-items: center; gap: 16px; }
.sound-toggle { min-height: 44px; padding: 6px 10px; border: 1px solid #d8d5cc; border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.sound-toggle[aria-pressed="true"] { background: var(--mint); }
.sound-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.help-link { display: flex; align-items: center; gap: 8px; text-decoration: none; font-size: 13px; font-weight: 700; }
.help-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.help-link__icon { display: grid; place-items: center; border: 1.5px solid; border-radius: 50%; width: 21px; height: 21px; font-size: 12px; }
.page-shell { width: min(680px, calc(100% - 48px)); margin: auto; padding-top: 32px; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: start; }
.game-card { background: var(--white); border: 1px solid var(--ink); border-radius: 19px; box-shadow: 2px 2px 0 var(--ink); padding: 0 14px 12px; isolation: isolate; }
.game-card__header { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; align-items: start; min-height: 0; padding: 8px 0; border-bottom: 1px solid #e4e1d9; margin-bottom: 8px; }
.score-strip__best, .score-strip__current { display: grid; gap: 3px; }
.score-strip__best { grid-template-columns: 1fr auto; align-items: center; border-right: 1px solid #e4e1d9; padding-right: 12px; }
.score-strip__best > .score-strip__label, .score-strip__best > .score-strip__value { grid-column: 1 / -1; }
.score-strip__label { font: 700 9px/1.5 var(--mono); letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.score-strip__value { font-size: 23px; line-height: 1.3; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-strip__value--error { font-size: 13px; line-height: 1.5; color: #993d3d; font-weight: 650; overflow-wrap: anywhere; }
.score-strip__note { font: 9px/1.4 var(--mono); color: var(--muted); }
.wordspider-share {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  justify-self: start; margin-top: 0; padding: 5px 8px;
  border: 1px solid var(--ink); border-radius: 6px;
  background: var(--mint); color: var(--ink); font: 700 11px/1.4 system-ui, sans-serif;
  cursor: pointer;
}
.wordspider-share svg { width: 16px; height: 16px; }
.wordspider-share:disabled { opacity: 0.45; cursor: default; }
.wordspider-share:focus-visible { outline: 3px solid #8462bb; outline-offset: 3px; }
.wordspider-share--new-best { background: #f9dd8c; box-shadow: 0 0 0 3px #f9dd8c80; animation: share-best 800ms ease-in-out 3; }
@keyframes share-best {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 5px #f9dd8c80; }
}
.wordspider-share-dialog { padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid #e0ddd3; }
.wordspider-distribution__yours + .wordspider-share-dialog { margin-top: 16px; }
.wordspider-share-dialog h2 { font-size: 24px; margin: 0 0 12px; }
.wordspider-share-dialog p { font-size: 13px; margin-bottom: 12px; }
.wordspider-share-dialog textarea {
  width: 100%; min-height: 180px; padding: 12px; resize: vertical;
  border: 1px solid #c9c4ba; border-radius: 6px; font: 14px/1.6 system-ui, sans-serif;
  background: var(--white); color: var(--ink);
}
.wordspider-share-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@media (prefers-reduced-motion: reduce) {
  .wordspider-share--new-best { animation: none; }
}
.score-strip__current {
  grid-template-columns: minmax(0, 1fr) auto;
  /* Reserve feedback space below the total so appearing/disappearing badges
     never move the board or share the spider's column, even on phones. */
  grid-template-rows: auto auto minmax(26px, auto);
  column-gap: 6px;
}
.score-strip__current > .score-strip__label { grid-column: 1 / -1; }
.score-strip__current > .score-strip__value { grid-column: 1; grid-row: 2; overflow-wrap: anywhere; }
.score-strip__spider { grid-column: 2; grid-row: 2 / 4; margin-top: 0; align-self: center; }
.score-spider { display: inline-flex; align-items: center; gap: 7px; vertical-align: middle; }
.score-spider img { display: block; flex: 0 0 auto; width: 52px; height: 52px; }
.score-spider__label { font-size: 11px; line-height: 1.3; font-weight: 750; }
.score-strip__spider .score-spider { flex-direction: column; gap: 2px; text-align: center; }
.score-strip__spider .score-spider img { width: 40px; height: 40px; animation: spider-wake 360ms ease-out; }
.score-spider-share { margin: 0 0 16px; }
.score-spider-share .score-spider { gap: 12px; }
.score-spider-share .score-spider img { width: 72px; height: 72px; }
.score-spider-share .score-spider__label { font-size: 18px; }
@keyframes spider-wake {
  0% { transform: scale(.85) rotate(-8deg); }
  60% { transform: scale(1.08) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  .score-strip__spider .score-spider img { animation: none; }
}
.score-strip__change {
  grid-column: 1; grid-row: 3; place-self: start;
  padding: 3px 6px; border-radius: 6px;
  background: #dcf4df; color: #245e32;
  font-size: 16px; line-height: 20px; font-weight: 800; pointer-events: none;
  animation: score-change 1200ms ease-out both;
}
.score-strip__change--negative { background: #f9e4df; color: #993d3d; }
@keyframes score-change {
  0%, 65% { opacity: 1; }
  100% { opacity: 0; }
}
.wordspider-game-container { position: relative; }
.wordspider-board-container {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: 5px;
  width: min(100%, 434px);
  aspect-ratio: 1;
  margin: auto;
  padding: 6px;
  background: #302b40;
  border: 1px solid #262332;
  border-radius: 13px;
  box-shadow: 0 2px 0 #191620;
}
.wordspider-letters-section { margin-top: 12px; }
.rack-heading { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rack-heading__title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rack-shuffle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 7px; border: 1px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; flex-shrink: 0; }
.rack-shuffle svg { width: 20px; height: 20px; }
.rack-shuffle:hover, .rack-shuffle:active { background: var(--mint); }
.rack-shuffle:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.rack-restore, .rack-undo { width: auto; gap: 5px; padding: 0 8px; border-radius: 8px; font-size: 11px; }
.rack-shuffle:disabled { opacity: .45; cursor: default; background: transparent; }
.rack-restore-status { margin-top: 5px; margin-bottom: -8px; overflow: hidden; font-size: 12px; color: var(--muted); }
.wordspider-section-title { font-size: 13px; font-weight: 750; }
.rack-heading > span { font: 10px var(--mono); color: var(--muted); }
.wordspider-letters-container { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 7px; }

/* Below the floating tile (1100); never intercept board/rack hit testing. */
.wordspider-rack-insertion {
  position: fixed;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: #603997;
  box-shadow: 0 0 0 1px #fffdf1;
  pointer-events: none;
  z-index: 1090;
}

/* Remove the shared demo's large 3D faces; retain its drag and drop elements. */
.wordspider-root .letters-tile {
  width: 100%;
  height: auto;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: #f9f1d9;
  color: var(--ink);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 0 #c2b79c;
  transform-style: flat;
  touch-action: none;
  cursor: grab;
}
.wordspider-root .letters-tile__face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: none; color: inherit; border-radius: inherit; box-shadow: none; transform: none; font-size: inherit; letter-spacing: -0.5px; }
.wordspider-root .letters-tile__face.wordspider-word-lit {
  background: #dcf4df; color: #214d2b; box-shadow: inset 0 0 0 2px #79b889;
}
.wordspider-word-pulse { animation: word-complete 650ms ease-out; }
@keyframes word-complete {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
  35% { filter: brightness(1.12) drop-shadow(0 0 6px #50a967); }
}
@media (prefers-reduced-motion: reduce) {
  .wordspider-word-pulse, .score-strip__change { animation: none; }
}
.wordspider-root .letters-tile__gloss, .wordspider-root .letters-tile__base { display: none; }
.wordspider-root .letters-tile--has-value .letters-tile__value { display: block; position: absolute; bottom: 4px; right: 4px; font: 700 12px/1 var(--mono); color: #514b3e; pointer-events: none; }
/* Board selection owns the outer ring; keyboard focus on a letter stays inside it. */
.wordspider-root .letters-tile:focus-visible { outline: none; }
.wordspider-root .letters-tile:not([data-board-square]):focus-visible { outline: 2px solid var(--ink); outline-offset: -5px; }
.wordspider-root .letters-tile--dragging { cursor: grabbing; box-shadow: 0 6px 0 #c2b79c, 0 12px 20px #17122633; }
.wordspider-root .letters-tile--active { box-shadow: 0 3px 0 #c2b79c; }
.wordspider-root [data-board-square] { background: #e5e1ea; border: 1px solid #b4adbf; border-radius: 5px; box-shadow: inset 0 -2px 0 #0000000d; color: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; }
/* A separate layer clears the board's container context and the placed tiles.
   Keep it below the active drag layer (1100), and let all pointer events through. */
.wordspider-selection-outline { position: absolute; pointer-events: none; z-index: 1050; outline: 3px solid #fffdf1; outline-offset: 1px; box-shadow: 0 0 0 4px #24202f; }
/* The small arrow is attached to the active square, so it also works at an edge. */
.wordspider-selection-outline::after { content: "→"; position: absolute; display: grid; place-items: center; width: 16px; height: 16px; right: -11px; top: 50%; transform: translateY(-50%); border: 1px solid var(--ink); border-radius: 50%; background: var(--mint); color: var(--ink); font: 800 14px/1 system-ui, sans-serif; }
[data-typing-direction="vertical"] .wordspider-selection-outline::after { content: "↓"; right: auto; top: auto; left: 50%; bottom: -11px; transform: translateX(-50%); }
.wordspider-root [data-board-square].letters-tile--drop-target { outline: 3px solid #bdebc7; outline-offset: 1px; }
.wordspider-root .letters-tile--drop-target::after { display: none; }
.wordspider-bonus-overlay { color: #343047; font: 750 clamp(9px, 2.6cqw, 12px)/1.2 var(--mono); text-align: center; white-space: pre-line; pointer-events: none; }
.wordspider-root .wordspider-bonus--2xletter, .bonus-chip--2l { background: #b9dbea; border-color: #7ba4b8; }
.wordspider-root .wordspider-bonus--3xletter, .bonus-chip--3l { background: #d3c2ec; border-color: #a48ac5; }
.wordspider-root .wordspider-bonus--2xword, .bonus-chip--2w { background: #efc1b6; border-color: #c98f82; }
.wordspider-root .wordspider-bonus--3xword, .bonus-chip--3w { background: #efc88f; border-color: #bc9258; }
.wordspider-root .wordspider-bonus---10, .bonus-chip--10 { background: #bde1bd; border-color: #81ae82; }
.wordspider-root .wordspider-bonus---50, .bonus-chip--50 { background: #f5de86; border-color: #bca146; }

/* A short, non-interactive burst of fragments from the bonus square. */
.wordspider-bonus-burst {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 1001;
  pointer-events: none;
  color: var(--bonus-color);
}
.wordspider-bonus-burst__ring {
  position: absolute;
  width: var(--bonus-size);
  height: var(--bonus-size);
  border: 3px solid currentColor;
  border-radius: 10px;
  animation: bonus-ring 380ms ease-out both;
}
.wordspider-bonus-burst__shard {
  position: absolute;
  width: calc(var(--bonus-size) * 0.23);
  height: calc(var(--bonus-size) * 0.28);
  background: var(--bonus-color);
  clip-path: polygon(0 0, 100% 18%, 68% 100%, 12% 72%);
  box-shadow: inset 1px 1px 0 #ffffffa6;
  animation: bonus-shard var(--duration) cubic-bezier(0.15, 0.7, 0.25, 1) both;
}
.wordspider-bonus-burst__shard:nth-child(3n) { clip-path: polygon(50% 0, 100% 100%, 0 78%); }
.wordspider-bonus-burst__shard:nth-child(3n + 1) { width: calc(var(--bonus-size) * 0.15); height: calc(var(--bonus-size) * 0.18); }
@keyframes bonus-ring {
  from { transform: translate(-50%, -50%) scale(0.7); opacity: 0.9; }
  to { transform: translate(-50%, -50%) scale(1.65); opacity: 0; }
}
@keyframes bonus-shard {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  12% { opacity: 1; }
  30% { transform: translate(calc(-50% + var(--flight-x) * 0.75), calc(-50% + var(--flight-y) * 0.75)) rotate(calc(var(--spin) * 0.5)) scale(1.1); opacity: 1; }
  70% { transform: translate(calc(-50% + var(--flight-x)), calc(-50% + var(--flight-y))) rotate(var(--spin)) scale(0.85); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--flight-x)), calc(-50% + var(--flight-y) + 12px)) rotate(var(--spin)) scale(0.3); opacity: 0; }
}
.wordspider-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.wordspider-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}
.wordspider-button:hover { background: #eeeaf5; }
.wordspider-button:active { box-shadow: inset 0 2px 0 #26233222; }
.control-icon { width: 18px; height: 18px; font-size: 20px; font-weight: 400; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.play-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.how-to-card { grid-column: 1 / -1; }
.how-to-card { background: #e2efdf; border: 1.5px solid var(--ink); border-radius: 15px; padding: 23px 23px 20px; box-shadow: 3px 3px 0 #bdceba; scroll-margin-top: 24px; }
.how-to-card h2 { font-size: 27px; line-height: 1.15; letter-spacing: -1px; font-weight: 800; }
.daily-puzzle-note { margin-top: 12px; font-size: 12px; line-height: 1.7; color: #505e50; }
.how-to-steps { list-style: none; padding: 0; margin: 22px 0 20px; display: grid; gap: 19px; }
.how-to-steps li { display: flex; align-items: baseline; gap: 12px; }
.step-number { font: 600 10px var(--mono); color: #43664a; border-bottom: 1px solid #8ba790; padding-bottom: 3px; }
.how-to-steps p { font-size: 12px; line-height: 1.7; color: #505e50; }
.how-to-steps strong { color: var(--ink); display: block; font-weight: 750; }
.bonus-card { background: var(--white); border: 1.5px solid var(--ink); border-radius: 13px; padding: 20px; }
.bonus-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 17px; }
.bonus-heading h2 { font-size: 16px; font-weight: 800; letter-spacing: -0.5px; }
.bonus-key { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
.bonus-key__item { display: flex; align-items: center; gap: 7px; font-size: 10px; white-space: nowrap; }
.bonus-chip { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid; border-radius: 5px; font: 700 10px var(--mono); flex-shrink: 0; }
.keyboard-guide { padding: 0 8px; }
.keyboard-guide h2 { font-size: 12px; margin-bottom: 13px; }
.keyboard-guide p { display: flex; align-items: center; gap: 12px; font-size: 11px; color: var(--muted); margin-top: 8px; }
kbd { border: 1px solid #c9c4ba; border-bottom-width: 2px; border-radius: 4px; background: var(--white); padding: 2px 6px; font: 10px/1.5 var(--mono); min-width: 68px; text-align: center; color: var(--ink); }
.keyboard-guide .keyboard-guide__tip { display: block; font-size: 11px; line-height: 1.6; margin-top: 15px; }

/* Share and leaderboard use one native dialog and one scrolling body. */
.wordspider-leaderboard__panel { width: min(100%, 480px); background: var(--white); border: 2px solid var(--ink); border-radius: 15px; box-shadow: 7px 7px 0 var(--ink); overflow: hidden; }
.wordspider-leaderboard__header { display: flex; align-items: center; justify-content: space-between; padding: 17px 22px; background: var(--mint); border-bottom: 2px solid var(--ink); }
.wordspider-leaderboard__header h2 { font-size: 22px; letter-spacing: -0.7px; }
.wordspider-leaderboard__close { display: grid; place-items: center; flex-shrink: 0; padding: 0; background: var(--white); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 6px; width: 36px; height: 36px; cursor: pointer; }
.wordspider-leaderboard__body { padding: 22px; max-height: 60vh; overflow-y: auto; font-size: 14px; }
.wordspider-results-dialog { padding: 0; margin: auto; width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); color: var(--ink); }
.wordspider-results-dialog::backdrop { background: #211d32a6; }
.wordspider-results-dialog__body { padding: 22px; max-height: calc(100dvh - 115px); overflow-y: auto; overscroll-behavior: contain; }
.wordspider-results-dialog .wordspider-leaderboard__body { padding: 0; max-height: none; overflow: visible; }
.wordspider-results-dialog__heading { font-size: 22px; margin-bottom: 16px; }
.wordspider-results-dialog .wordspider-distribution__yours { flex-wrap: wrap; }
.wordspider-results-dialog .wordspider-distribution__yours > span:first-child { flex: 1 1 160px; }
.wordspider-results-dialog [data-leaderboard-share] { flex-shrink: 0; margin-left: auto; }
.wordspider-leaderboard__loading { text-align: center; color: var(--muted); }
.wordspider-leaderboard__error { color: #9b353c; }
.wordspider-leaderboard__table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wordspider-leaderboard__table th, .wordspider-leaderboard__table td { text-align: left; padding: 11px 6px; border-bottom: 1px solid #e0ddd3; }
.wordspider-leaderboard__table th { font: 600 10px var(--mono); text-transform: uppercase; color: var(--muted); }
.wordspider-leaderboard__table caption { text-align: left; font-weight: 700; padding-bottom: 8px; }
.wordspider-distribution { margin: 0 0 24px; }
.wordspider-distribution figcaption { font-size: 18px; font-weight: 800; }
.wordspider-distribution__summary { margin-top: 5px; font-size: 12px; color: var(--muted); }
.wordspider-distribution__chart { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; margin-top: 42px; }
.wordspider-distribution__player-label { position: absolute; top: -20px; left: 0; font-size: 11px; line-height: 14px; font-weight: 650; }
.wordspider-distribution__ticks { position: relative; font: 10px var(--mono); color: var(--muted); }
.wordspider-distribution__ticks span { position: absolute; right: 0; transform: translateY(50%); }
.wordspider-distribution__plot { position: relative; display: grid; gap: 4px; height: 130px; border-left: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.wordspider-distribution__gridline { position: absolute; left: 0; right: 0; border-top: 1px solid #e9e6df; pointer-events: none; }
.wordspider-distribution__bin { position: relative; display: flex; align-items: flex-end; height: 100%; min-width: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.wordspider-distribution__bar { display: block; width: 100%; background: var(--mint); border-radius: 4px 4px 0 0; box-shadow: inset 0 0 0 1px #83b58d; }
.wordspider-distribution__bin--yours .wordspider-distribution__bar { background: #c7b4e5; box-shadow: inset 0 0 0 1px #8462bb; }
.wordspider-distribution__bin:hover .wordspider-distribution__bar, .wordspider-distribution__bin:focus-visible .wordspider-distribution__bar { filter: brightness(.92); }
.wordspider-distribution__bin:focus-visible { outline-offset: 1px; }
.wordspider-distribution__marker { position: absolute; top: -5px; bottom: 0; border-left: 2px dashed #603997; pointer-events: none; }
.wordspider-distribution__marker::before { content: ''; position: absolute; left: -5px; top: -3px; width: 8px; height: 8px; background: #603997; transform: rotate(45deg); }
.wordspider-distribution__marker-label { position: absolute; top: -40px; line-height: 18px; white-space: nowrap; color: #603997; font-size: 12px; font-weight: 750; pointer-events: none; }
.wordspider-distribution__axis { grid-column: 2; display: flex; justify-content: space-between; margin-top: 6px; font: 10px var(--mono); color: var(--muted); }
.wordspider-distribution__detail { min-height: 32px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.wordspider-distribution__detail--active { color: var(--ink); font-weight: 700; }
.wordspider-distribution__yours .score-spider { position: relative; flex-shrink: 0; }
.wordspider-distribution__yours .score-spider img { width: 36px; height: 36px; }
/* Keep the milestone name available to screen readers beside the single icon. */
.wordspider-distribution__yours .score-spider__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wordspider-distribution__yours { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 10px; border-left: 3px solid #603997; background: #f1ebf9; font-size: 13px; font-weight: 650; }
.wordspider-score-dialog { padding: 0; width: min(calc(100% - 40px), 480px); max-height: calc(100dvh - 40px); color: var(--ink); }
.wordspider-score-dialog::backdrop { background: #211d32a6; }
.wordspider-score-dialog .wordspider-leaderboard__body { max-height: min(60vh, calc(100dvh - 130px)); }
.wordspider-score-dialog__total { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.wordspider-score-dialog__total strong { font-size: 30px; }
.wordspider-score-dialog__total strong span { font-size: 14px; color: var(--muted); }
.wordspider-score-dialog caption { text-align: left; font-weight: 700; padding-bottom: 8px; }
.wordspider-score-dialog th:last-child, .wordspider-score-dialog td:last-child { text-align: right; }
.wordspider-score-dialog__bonus { display: flex; justify-content: space-between; margin-top: 16px; padding: 12px; background: var(--mint); border-radius: 6px; }
.wordspider-score-dialog__warnings { margin-top: 18px; padding: 12px; border: 1px solid #d6a2a6; border-radius: 6px; color: #9b353c; background: #fff0f0; overflow-wrap: anywhere; }
.wordspider-score-dialog__warnings p + p { margin-top: 8px; }

/* Give the desktop board more room while accounting for the viewport height.
   Short laptop windows can scroll naturally; no game controls are clipped. */
@media (min-width: 801px) {
  .wordspider-root .letters-tile--has-value .letters-tile__value { font-size: 10px; }
  .site-header__inner { height: 64px; }
  .page-shell { width: min(780px, calc(100% - 48px)); padding-top: 18px; }
  .wordspider-board-container { width: min(100%, clamp(330px, calc(100svh - 350px), 600px)); }
  .wordspider-letters-section { max-width: clamp(440px, calc(100svh - 350px), 600px); margin: 12px auto 0; }
}
@media (min-width: 801px) and (max-height: 800px) {
  .site-header__inner { height: 56px; }
  .page-shell { padding-top: 10px; }
}

/* A side rack lets wide screens grow the board without hiding the letters below it.
   Keep its top fixed so restore messages cannot shift placed tiles as they collapse. */
@media (min-width: 1100px) {
  .page-shell { width: min(calc(clamp(360px, calc(100svh - 250px), 640px) + 294px), calc(100% - 48px)); }
  .wordspider-game-container { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
  .wordspider-board-container { width: 100%; }
  .wordspider-letters-section { width: 100%; max-width: none; margin: 0; }
  .rack-heading { gap: 10px; margin-bottom: 12px; }
  .rack-heading__title { gap: 8px; }
  .wordspider-section-title { flex-basis: calc(100% - 44px); }
  .wordspider-letters-container { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .site-header__inner { width: calc(100% - 40px); height: 70px; }
  .page-shell { width: min(560px, calc(100% - 36px)); }
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .wordspider-letters-container { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
  .rack-heading > span { display: none; }
  .play-guide { grid-template-columns: 1fr 1fr; gap: 18px; }
  .how-to-card { grid-column: 1 / -1; }
  .bonus-key { grid-template-columns: 1fr; }
  .bonus-heading { align-items: flex-start; flex-direction: column; }
  .keyboard-guide { padding: 14px 4px; }
}
@media (max-width: 480px) {
  .site-header__inner { width: calc(100% - 32px); height: 64px; }
  .brand__mark { width: 34px; height: 34px; border-radius: 8px; padding: 3px; }
  .brand__name { font-size: 21px; }
  .header-actions { flex-direction: column; align-items: flex-end; gap: 0; }
  .sound-toggle { min-height: 32px; font-size: 11px; padding: 3px 8px; }
  .help-link { font-size: 11px; gap: 5px; }
  .help-link__icon { width: 18px; height: 18px; font-size: 10px; }
  .page-shell { width: calc(100% - 16px); padding-top: 14px; }
  .game-card { padding: 0 6px 8px; border-width: 1px; border-radius: 12px; box-shadow: 2px 2px 0 var(--ink); }
  .game-card__header { grid-template-columns: 118px minmax(0, 1fr); gap: 8px; margin-bottom: 8px; padding: 8px 0; }
  .score-strip__label { font-size: 8px; }
  .wordspider-share { font-size: 10px; padding: 4px; }
  .wordspider-share svg { width: 14px; height: 14px; }
  .score-strip__value { font-size: 19px; }
  .score-strip__spider .score-spider__label { font-size: 9px; }
  .score-strip__value--error { font-size: 11px; }
  .wordspider-board-container { width: 100%; padding: 5px; gap: 3px; border-width: 1px; border-radius: 8px; box-shadow: 0 2px 0 #191620; }
  .wordspider-letters-section { margin-top: 10px; }
  .rack-heading { gap: 4px; }
  .rack-heading__title { width: 100%; gap: 5px; }
  .rack-shuffle { width: 32px; height: 32px; padding: 6px; }
  .rack-shuffle svg { width: 18px; height: 18px; }
  .rack-restore, .rack-undo { width: auto; padding: 0 7px; font-size: 10px; }
  .rack-restore { margin-left: auto; }
  .wordspider-letters-container { gap: 4px; }
  .wordspider-root .letters-tile { font-size: 22px; border-radius: 5px; }
  .wordspider-root .letters-tile--has-value .letters-tile__value { font-size: 11px; bottom: 2px; right: 2px; }
  .wordspider-root [data-board-square] { border-radius: 4px; }
  .wordspider-controls { margin-top: 10px; gap: 5px; }
  .wordspider-button { font-size: 10px; padding: 6px 3px; gap: 3px; }
  .wordspider-controls .control-icon { display: none; }
  .control-icon { width: 15px; height: 15px; font-size: 18px; }
  .how-to-card { padding: 22px; }
  .how-to-card h2 { font-size: 25px; }
  .bonus-card { padding: 16px; }
  .bonus-heading h2 { font-size: 15px; }
  .keyboard-guide h2 { font-size: 11px; }
  .keyboard-guide p { flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 360px) {
  .wordspider-letters-container { gap: 4px; }
  .wordspider-root .letters-tile { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .wordspider-button { transition: none; }
  .wordspider-bonus-burst { display: none; }
}

.wordspider-practice-note {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  background: #edf4eb;
}
.wordspider-practice-note p,
.wordspider-results-dialog__footer p { margin: 8px 0 12px; }
.wordspider-practice-note a,
.wordspider-results-dialog__footer a { text-decoration: none; }
.wordspider-results-dialog__footer { margin-top: 20px; text-align: center; }

.wordspider-share[hidden] { display: none; }

.wordspider-top-words { margin-top: 18px; border-top: 1px solid #e4e1d9; padding-top: 14px; font-size: 13px; }
.wordspider-top-words summary { cursor: pointer; font-weight: 700; min-height: 44px; padding: 12px 0; }
.wordspider-top-words summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.wordspider-top-words p { line-height: 1.5; }
.wordspider-top-words table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.wordspider-top-words caption { text-align: left; color: var(--muted); padding: 8px 0 12px; }
.wordspider-top-words th, .wordspider-top-words td { padding: 9px 4px; text-align: left; border-bottom: 1px solid #e4e1d9; overflow-wrap: anywhere; }
.wordspider-top-words th { font-size: 12px; }
.wordspider-top-words td:first-child { font-weight: 700; }
.wordspider-top-words a { text-decoration: none; }
