:root {
  font-family: system-ui, sans-serif;
  font-synthesis: none;
  color: #202c37;
  background: #f3eee4;
  --ink: #202c37;
  --tile-face: #fffcf4;
  --border: #cfc1ad;
  --rule: #dcd0bf;
  --muted: #575c60;
  --brown: #76542e;
  --brass: #e0b97a;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:disabled, button[aria-disabled="true"] { cursor: default; }
button:disabled { opacity: .55; }
button:focus-visible, select:focus-visible, [tabindex="-1"]:focus-visible { outline: 3px solid #ab632f; outline-offset: 2px; }
@media (hover: hover) {
  button:hover:not(:disabled, [aria-disabled="true"]) { filter: brightness(.95); }
}
.game {
  width: min(100%, 720px);
  margin-inline: auto;
  padding: 12px 15px 12px;
}
.game-content, header, .mode-nav { max-width: 538px; margin-inline: auto; }
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.studio {
  margin: 0 0 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--brown);
}
h1 {
  margin: 0;
  font: 800 clamp(2rem, 8vw, 2.75rem)/1.05 system-ui, sans-serif;
  letter-spacing: -.065em;
}
.help-button, .text-button, .return-button {
  font-size: .8125rem;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-color: #958369;
}
.help-button { flex-shrink: 0; }
.mode-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.mode-nav button { flex: 1; border-bottom: 3px solid transparent; padding-top: 3px; }
.mode-nav [aria-pressed="true"] { border-color: var(--ink); font-weight: 700; }
.attempt-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 1px;
}
.attempt-bar p { font-size: .8125rem; margin: 0; }
#easy-hints {
  flex-shrink: 0;
  min-height: 32px;
  margin-left: auto;
  padding: 3px 8px;
  font-size: .75rem;
}
#easy-hints[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fffaf0; }
#challenge-date { display: block; color: var(--muted); font-size: .6875rem; }
.challenge-rounds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 0;
  margin: 4px 0 8px;
  list-style: none;
}
.challenge-rounds li {
  padding: 4px 2px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  color: var(--muted);
  text-align: center;
  font-size: .6875rem;
}
.challenge-rounds strong { display: block; color: var(--ink); }
.challenge-rounds [aria-current="step"] { border-color: var(--brown); background: #eae0cf; }
.challenge-rounds li > span { font-variant-numeric: tabular-nums; }
#next-round { padding-inline: 14px; }
.timer { display: flex; gap: 8px; align-items: center; font: 600 1rem var(--mono); font-variant-numeric: tabular-nums; }
.clock-dot { width: 6px; height: 6px; background: #a59176; border-radius: 50%; }
.playing .clock-dot { background: #317569; }
.scale {
  margin: 0 0 6px;
  padding: 9px 10px 7px;
  border: 1px solid #17212a;
  border-radius: 12px;
  background: linear-gradient(160deg, #2c3c4d, #1f2934 65%);
  color: #fffaed;
}
.scale-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.scale-heading h2 { margin: 0; font-size: .9375rem; font-weight: 720; }
.scale-heading p { margin: 0; font-size: .75rem; color: #f1ddbc; }
.scale-heading strong { margin-left: 3px; font: 700 1rem var(--mono); color: #fff7e4; }
.reference-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 6px 0 7px;
  font-size: .75rem;
  font-weight: 650;
}
.reference-picker select {
  appearance: none;
  color-scheme: dark;
  min-height: 36px;
  padding: 4px 24px 4px 8px;
  border: 1px solid #687688;
  border-radius: 5px;
  background:
    linear-gradient(45deg, transparent 50%, var(--brass) 50%) right 12px center / 4px 4px no-repeat,
    linear-gradient(135deg, var(--brass) 50%, transparent 50%) right 8px center / 4px 4px no-repeat,
    #253344;
  color: #fffaf0;
  font: inherit;
}
#reference-weight { margin-left: auto; color: #f1ddbc; }
.scale-instrument {
  --pan-rest: 34px;
  --weight-step: 1.08px;
  --sling-height: 11px;
  --movement: 240ms cubic-bezier(.22, .68, .25, 1);
  position: relative;
  isolation: isolate;
  margin: 0 auto;
  max-width: 440px;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 12%, #738ca319, transparent 75%), #17212b70;
  box-shadow: inset 0 0 0 1px #8192a126;
}
.scale-stand {
  position: absolute;
  left: 50%;
  top: 9px;
  bottom: 30px;
  width: 7px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: linear-gradient(90deg, #655036, #c4a270 48%, #836039);
  opacity: .72;
}
.scale-stand::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 37px;
  height: 6px;
  transform: translateX(-50%);
  border-top: 1px solid #e3bb7c;
  border-radius: 65% 65% 2px 2px;
  background: linear-gradient(#b28350, #5b402a);
}
.scale-beam {
  position: absolute;
  inset: 8px 2% auto;
  height: 6px;
  border: 1px solid #a77c4c;
  border-top-color: #f1ce97;
  border-radius: 4px;
  background: linear-gradient(#e4b87c, #997044);
  box-shadow: 0 2px 3px #100b0950;
}
.scale-beam::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border: 1px solid #f2d09a;
  border-radius: 50%;
  background: radial-gradient(circle at 39% 30%, #e9bc81, #8b603a 73%);
}
.scale-level {
  position: absolute;
  inset: calc(var(--pan-rest) + var(--reference-weight) * var(--weight-step)) 2% auto;
  border-top: 1px dashed #dbc08a;
  opacity: 0;
  transition: top var(--movement), opacity var(--movement);
}
.has-reference .scale-level { opacity: .66; }
.scale-pans {
  position: relative;
  display: flex;
  padding-inline: 2%;
}
.scale-word {
  --pan-position: calc(var(--pan-rest) + var(--weight) * var(--weight-step));
  --brass-cord: #c7a474;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 117px;
  border-radius: 4px;
}
.scale-word.empty { --brass-cord: #8494a480; }
.scale-word:focus-visible { outline-color: #ffdfa8; z-index: 1; }
.scale-cord, .scale-sling, .scale-pan { position: absolute; left: 50%; }
.scale-cord {
  top: 14px;
  width: 1px;
  height: calc(var(--pan-position) - var(--sling-height) - 21px);
  background: var(--brass-cord);
  transition: height var(--movement), background-color var(--movement);
}
.scale-sling, .scale-pan {
  width: min(83%, 56px);
  transform: translateX(-50%);
  transition: top var(--movement), background-color var(--movement);
}
.scale-sling {
  top: calc(var(--pan-position) - var(--sling-height) - 8px);
  height: var(--sling-height);
  background: var(--brass-cord);
  clip-path: polygon(50% 0, 100% 100%, calc(100% - 2px) 100%, 50% 12%, 2px 100%, 0 100%);
}
.scale-pan {
  top: calc(var(--pan-position) - 9px);
  display: grid;
  place-items: center;
  height: 20px;
  border: 1px solid #976b3d;
  border-top: 2px solid #fbdda7;
  border-radius: 2px 2px 48% 48% / 2px 2px 88% 88%;
  background: linear-gradient(170deg, #f2d19b, #d6a463 48%, #a77340);
  box-shadow: inset 0 -2px 3px #6d451c42, 0 2px 3px #0b101980;
  color: #241a14;
  font: 800 .75rem var(--mono);
}
.scale-word.empty .scale-pan {
  border-color: #697a89;
  border-top-color: #a3b0bd;
  color: #f6f2e9;
  background: linear-gradient(#536373, #394854);
  box-shadow: 0 2px 3px #0b101980;
}
.scale-word[aria-pressed="true"] .scale-pan { outline: 1px solid #fff0d2; outline-offset: 2px; }
.scale-word[data-weight-hint="on-weight"] .scale-pan {
  border-color: #72ab8a;
  border-top-color: #bdebcf;
  background: linear-gradient(#a6dfbd, #79ba94);
  color: #153b26;
}
.scale-word[data-weight-hint="off-weight"] .scale-pan {
  border-color: #c28179;
  border-top-color: #f4bdb5;
  background: linear-gradient(#efb0a6, #d48275);
  color: #4d1c18;
}
.scale-pan-label, .scale-pan-delta {
  position: absolute;
  inset-inline: 0;
  font: 700 .6875rem var(--mono);
}
.scale-pan-label { top: 92px; color: #fffaf0; }
.scale-pan-delta { top: 105px; color: #ffdfa8; }
.scale-key {
  margin: 1px 0 0;
  color: #cfdae4;
  font-size: .6875rem;
  text-align: center;
}
.easy-key { display: flex; justify-content: center; gap: 14px; margin-top: 3px; }
.easy-key span:first-child { color: #bdebcf; }
.easy-key span:last-child { color: #ffbcb4; }
.scale-comparison {
  margin: 4px 0 0;
  text-align: center;
  color: #ffdfa8;
  font-size: .8125rem;
  font-weight: 630;
}
.scale-comparison:empty { margin: 0; }
@media (prefers-reduced-motion: reduce) {
  .scale-cord, .scale-sling, .scale-pan, .scale-level { transition: none; }
}
.row-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px;
}
.row-controls span {
  margin-right: auto;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
}
.row-controls .text-button, .row-controls .secondary {
  min-height: 36px;
  padding-inline: 8px;
  font-size: .75rem;
}
.board { display: grid; gap: 2px; --slot-gap: 4px; }
.word-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 34px;
  align-items: center;
  column-gap: 4px;
  padding: 3px 4px 3px 2px;
  border: 1px solid transparent;
  border-bottom-color: var(--rule);
  border-radius: 4px;
}
.row-length {
  color: var(--muted);
  font: 600 .875rem var(--mono);
  text-align: center;
}
.on-scale { background: #eae0cf; border-color: #d6c5a9; }
.on-scale .row-length { color: #6a451e; }
.challenge-solved .word-row { background: #cfe7d5; border-color: #78a786; }
.challenge-solved .slot.filled { background: #e8f4ea; border-color: #78a786; box-shadow: 0 2px 0 #78a786; }
.slots {
  --slot-width: min(44px, calc((100% - var(--slot-gap) * (var(--max-slots) - 1)) / var(--max-slots)));
  display: grid;
  grid-template-columns: repeat(var(--length), var(--slot-width));
  gap: var(--slot-gap);
}
.slot, .tile {
  display: grid;
  place-items: center;
  position: relative;
  height: 40px;
  min-height: 0;
  min-width: 0;
  padding-right: 3px;
  padding-bottom: 2px;
  border-radius: 4px;
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}
.slot { border: 1px solid #c7bba7; background: #e5d9c7; box-shadow: inset 0 1px 2px #594c3320; }
.slot.filled, .tile {
  border: 1px solid #cbbba4;
  background: var(--tile-face);
  color: var(--ink);
  box-shadow: 0 2px 0 #bdac93;
}
.slot.filled:not([aria-disabled="true"]), .tile { touch-action: none; }
.slot[aria-pressed="true"], .tile[aria-pressed="true"] {
  background: #f3d9a8;
  border: 2px solid #96642e;
  box-shadow: 0 2px 0 #96642e;
}
.slot:focus-visible, .tile:focus-visible { z-index: 1; }
.slot small, .tile small {
  position: absolute;
  right: 3px;
  bottom: 3px;
  font-size: .6875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #70563b;
}
.row-weight {
  display: grid;
  grid-template-columns: 19px 1fr;
  align-items: center;
  gap: 2px;
  text-align: right;
  color: var(--muted);
  font: 700 .875rem var(--mono);
  font-variant-numeric: tabular-nums;
}
.row-weight.balanced { color: var(--ink); font-weight: 700; }
.word-row[data-weight-hint="on-weight"] { background: #cfe7d5; border-color: #78a786; }
.word-row[data-weight-hint="off-weight"] { background: #f3d7d3; border-color: #bd827a; }
.word-row.on-scale[data-weight-hint] { box-shadow: inset 3px 0 var(--brown); }
[data-weight-hint="on-weight"] .row-weight, [data-weight-hint="on-weight"] .row-length { color: #18563b; }
[data-weight-hint="off-weight"] .row-weight, [data-weight-hint="off-weight"] .row-length { color: #912e27; }
.balance-mark { text-align: center; }
.row-issue {
  grid-column: 2;
  margin-top: 3px;
  font-size: .8125rem;
  color: #80502e;
}
.pool-section { margin-top: 4px; }
.pool-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
#tray-label {
  text-transform: uppercase;
  font-size: .6875rem;
  letter-spacing: .10em;
  font-weight: 700;
}
#remaining { margin-left: 3px; color: var(--muted); font-size: .75rem; }
.return-button { white-space: nowrap; }
.pool {
  display: flex;
  justify-content: center;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 7px 5px;
  padding: 2px 1px 8px;
  min-height: 50px;
  border-radius: 5px;
}
.tile { width: 41px; height: 40px; cursor: grab; }
.dragging, .dragging button { cursor: grabbing; }
.drag-ghost {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  transform: translate(-50%, -65%) rotate(-5deg);
  box-shadow: 0 6px 18px #202c3730;
}
.empty-pool { align-self: center; color: var(--muted); font-size: .8125rem; }
.feedback {
  min-height: 20px;
  margin: 1px 0 5px;
  text-align: center;
  color: var(--brown);
  font-size: .875rem;
}
.feedback:empty { min-height: 0; margin: 0; }
.feedback.solved { color: var(--ink); font-weight: 700; }
.solve-celebration {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}
.solve-burst {
  --radius: min(18vw, 112px);
  position: absolute;
  top: var(--y);
  left: var(--x);
  color: var(--spark-color);
}
.solve-burst::before {
  content: '';
  position: absolute;
  inset: -11px auto auto -11px;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 50%;
  animation: solve-ring 760ms var(--delay) ease-out both;
}
.solve-burst i {
  position: absolute;
  width: 12px;
  height: 3px;
  margin: -1.5px 0 0 -6px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 0 4px #fff2d7;
  animation: solve-spark 1100ms var(--delay) cubic-bezier(.09,.61,.42,1) both;
}
.solve-burst i:nth-child(2n) { width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; }
@keyframes solve-ring {
  0% { opacity: 0; transform: scale(.15); }
  18% { opacity: .86; }
  100% { opacity: 0; transform: scale(4.2); }
}
@keyframes solve-spark {
  0% { opacity: 0; transform: rotate(var(--angle)) scale(.35); }
  12% { opacity: 1; }
  70% { opacity: .85; }
  100% {
    opacity: 0;
    transform: translate(calc(var(--dx) * var(--radius)), calc(var(--dy) * var(--radius) + 16px)) rotate(var(--angle)) scale(.4);
  }
}
@media (prefers-reduced-motion: reduce) {
  .solve-burst::before {
    border: 0;
    background: currentColor;
    clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
    animation: none;
  }
  .solve-burst i { display: none; }
}
.actions, .dialog-actions { display: flex; justify-content: center; align-items: center; gap: 12px; }
.secondary, .primary, .text-button { padding-inline: 14px; }
.secondary { border: 1px solid #b8aa95; border-radius: 6px; font-size: .875rem; }
.primary { background: var(--ink); color: #fffdf3; border-radius: 7px; min-width: 94px; font-size: .875rem; }
.reveal-button { display: block; margin: 0 auto; }
.storage-warning { color: var(--brown); text-align: center; }
.dialog {
  width: min(calc(100% - 30px), 510px);
  max-height: 90dvh;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffdf5;
  color: var(--ink);
}
.dialog h2 { margin: 0 0 12px; font: 400 1.625rem Georgia, serif; }
.dialog p { line-height: 1.5; }
.dialog::backdrop { background: #202c3780; }
@media (min-width: 700px) {
  .game {
    margin-block: 20px;
    padding: 20px 36px 14px;
    border: 1px solid #e5e3d6;
    border-radius: 14px;
    background: #faf5eb;
    box-shadow: 0 10px 50px #32251c12;
  }
  .slot { height: 41px; }
  .tile { width: 44px; }
}
@media (360px <= width <= 420px) {
  .pool { column-gap: 4px; }
  .tile { width: clamp(32px, calc((100% - 32px) / 9), 39px); }
  .drag-ghost { width: 39px; }
}
@media (max-width: 359px) {
  .game { padding-inline: 11px; }
  .word-row { grid-template-columns: 14px minmax(0, 1fr) 29px; }
  .row-weight { grid-template-columns: 16px 1fr; }
  .board { --slot-gap: 3px; }
  .tile { width: 38px; }
  .slot { font-size: 1.0625rem; }
  .slot small { right: 2px; bottom: 2px; }
  .actions { gap: 8px; }
}

.game-footer {
  max-width: 538px;
  margin: 1.25rem auto 0;
  color: var(--muted);
  font-size: .875rem;
}
.studio a, .game-footer a { color: inherit; text-underline-offset: .2em; }
