/* 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 { font-size: 24px; font-weight: 850; letter-spacing: -1px; }
.site-header__note { color: var(--muted); font-size: 13px; }
.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(960px, calc(100% - 48px)); margin: auto; }
.game-intro { display: flex; align-items: center; justify-content: space-between; padding: 36px 0 30px; gap: 24px; }
.eyebrow { font: 700 10px/1.5 var(--mono); letter-spacing: 1.7px; }
.game-intro .eyebrow { color: var(--muted); margin-bottom: 8px; }
.wordspider-title { font-size: clamp(40px, 5.2vw, 62px); line-height: 1.12; letter-spacing: -3px; font-weight: 850; }
.wordspider-title span { position: relative; isolation: isolate; }
.wordspider-title span::after { content: ""; position: absolute; inset: 56% -6px -1px; background: var(--mint); transform: rotate(-2deg); z-index: -1; }
.wordspider-tagline { color: var(--muted); font-size: 14px; margin-top: 12px; }
.intro-stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 112px;
  height: 112px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #f9dd8c;
  box-shadow: 3px 3px 0 var(--ink);
  font: 800 11px/1.4 var(--mono);
  letter-spacing: 1px;
  transform: rotate(9deg);
  margin-right: 30px;
}
.intro-stamp__spark { font: 38px/1 system-ui, sans-serif; margin-bottom: 5px; }
.play-layout { display: grid; grid-template-columns: minmax(0, 600px) minmax(0, 300px); gap: 32px; align-items: start; }
.game-card { background: var(--white); border: 2px solid var(--ink); border-radius: 19px; box-shadow: 6px 7px 0 var(--ink); padding: 0 26px 18px; isolation: isolate; }
.game-card__header { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 22px; align-items: start; min-height: 102px; padding: 17px 0; border-bottom: 1px solid #e4e1d9; margin-bottom: 18px; }
.score-strip__best, .score-strip__current { display: grid; gap: 3px; }
.score-strip__best { border-right: 1px solid #e4e1d9; padding-right: 12px; }
.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-game-container { position: relative; }
.wordspider-board-container {
  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: 12px;
  background: #302b40;
  border: 2px solid #262332;
  border-radius: 13px;
  box-shadow: 0 4px 0 #191620;
}
.wordspider-letters-section { margin-top: 24px; }
.rack-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.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; }

/* 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__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: 600 9px/1 var(--mono); color: #686150; pointer-events: none; }
.wordspider-root .letters-tile:not([data-board-square]):hover { background: #fff6d6; border-color: #766044; }
.wordspider-root .letters-tile:focus-visible { outline: 3px solid #8462bb; outline-offset: 3px; }
.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; }
.wordspider-root [data-board-square]:hover { border-color: #fff; }
.wordspider-root [data-board-square].wordspider-board-square--selected { outline: 3px solid #fffdf1; outline-offset: 1px; box-shadow: 0 0 0 4px #24202f; z-index: 1; }
.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 9px/1.25 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(2, minmax(0, 1fr)); gap: 9px; margin-top: 22px; }
.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; }
.game-card__footnote { text-align: center; font-size: 11px; color: var(--muted); margin-top: 15px; }
.play-guide { display: grid; gap: 22px; }
.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; }
.guide-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.guide-heading .eyebrow { font-size: 9px; letter-spacing: 1.25px; }
.guide-spark { font-size: 27px; line-height: 1; }
.how-to-card h2 { font-size: 27px; line-height: 1.15; letter-spacing: -1px; font-weight: 800; }
.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; }
.guide-note { border-top: 1px solid #b8cbb6; padding-top: 16px; display: flex; align-items: center; gap: 12px; }
.guide-note > span { font-size: 27px; }
.guide-note p { font-size: 11px; line-height: 1.6; color: #4c624f; }
.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-heading .eyebrow { font-size: 8px; letter-spacing: 1px; color: var(--muted); }
.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; }
.site-footer { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); margin-top: 35px; padding: 18px 0 0; border-top: 1px solid #d9d6cd; font-size: 11px; }
.site-footer > span:first-child { font: 9px/1.7 var(--mono); letter-spacing: 1px; }

/* The existing leaderboard uses the same paper, ink, and mint treatment. */
.wordspider-leaderboard { position: fixed; inset: 0; background: #211d32a6; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 2000; }
.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; background: var(--white); border: 1.5px solid var(--ink); border-radius: 6px; width: 36px; height: 36px; font-size: 24px; cursor: pointer; }
.wordspider-leaderboard__body { padding: 22px; max-height: 60vh; overflow-y: auto; font-size: 14px; }
.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); }

@media (min-width: 1000px) {
  .wordspider-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .site-header__inner { width: calc(100% - 40px); height: 70px; }
  .site-header__note { display: none; }
  .page-shell { width: min(560px, calc(100% - 36px)); }
  .game-intro { padding: 28px 0; }
  .intro-stamp { width: 84px; height: 84px; margin-right: 3px; font-size: 8px; }
  .intro-stamp__spark { font-size: 26px; }
  .wordspider-title { font-size: 44px; letter-spacing: -2px; }
  .wordspider-tagline { max-width: 330px; font-size: 13px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: 30px; }
  .play-guide { grid-template-columns: 1fr 1fr; gap: 18px; }
  .how-to-card { grid-column: 1 / -1; }
  .how-to-card h2 br { display: none; }
  .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; }
  .help-link { font-size: 11px; gap: 5px; }
  .help-link__icon { width: 18px; height: 18px; font-size: 10px; }
  .page-shell { width: calc(100% - 28px); }
  .game-intro { padding: 22px 2px 24px; }
  .game-intro .eyebrow { font-size: 8px; letter-spacing: 1.5px; }
  .wordspider-title { font-size: 39px; }
  .wordspider-tagline { font-size: 12px; max-width: 240px; line-height: 1.6; margin-top: 10px; }
  .intro-stamp { width: 69px; height: 69px; font-size: 7px; letter-spacing: 0.6px; margin-left: -14px; margin-right: 2px; }
  .intro-stamp__spark { font-size: 23px; margin-bottom: 3px; }
  .game-card { padding: 0 12px 15px; border-radius: 14px; box-shadow: 4px 5px 0 var(--ink); }
  .game-card__header { grid-template-columns: 88px minmax(0, 1fr); gap: 14px; min-height: 92px; margin-bottom: 14px; padding: 14px 0; }
  .score-strip__label { font-size: 8px; }
  .score-strip__value { font-size: 21px; }
  .score-strip__value--error { font-size: 11px; }
  .wordspider-board-container { padding: 8px; gap: 4px; border-radius: 10px; }
  .wordspider-letters-section { margin-top: 21px; }
  .wordspider-letters-container { gap: 5px; }
  .wordspider-root .letters-tile { font-size: 17px; border-radius: 4px; }
  .wordspider-root .letters-tile--has-value .letters-tile__value { font-size: 7px; bottom: 2px; right: 2px; }
  .wordspider-root [data-board-square] { border-radius: 4px; }
  .wordspider-bonus-overlay { font-size: 7px; }
  .wordspider-controls { margin-top: 19px; gap: 8px; }
  .wordspider-button { font-size: 11px; padding: 9px 5px; gap: 5px; }
  .control-icon { width: 15px; height: 15px; font-size: 18px; }
  .game-card__footnote { font-size: 10px; margin-top: 13px; }
  .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; }
  .site-footer { flex-direction: column; align-items: center; gap: 5px; margin-top: 26px; }
}
@media (max-width: 360px) {
  .wordspider-title { font-size: 34px; }
  .intro-stamp { display: none; }
  .wordspider-tagline { max-width: none; }
  .wordspider-letters-container { gap: 4px; }
  .wordspider-root .letters-tile { font-size: 15px; }
  .wordspider-root .letters-tile--has-value .letters-tile__value { font-size: 6px; }
  .wordspider-bonus-overlay { font-size: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .wordspider-button { transition: none; }
  .wordspider-bonus-burst { display: none; }
}
