:root {
  color-scheme: dark;
  --page: #1a211a;
  --ink: #f7f6e8;
  --muted: #c1c6b5;
  --tile: #ebeddd;
  --signal: #ffa78f;
  --mono: "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-family: system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 50% 2%, #424735, transparent 56rem), var(--page);
  color: var(--ink);
}
button, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
a { color: inherit; }
.masthead {
  width: min(1460px, 94%); min-height: 72px; margin: auto; padding: 6px 6px 8px;
  display: flex; align-items: center; gap: 15px;
}
.masthead h1 { margin: 0; font-size: clamp(1.35rem, 4vw, 2.95rem); line-height: 1; letter-spacing: -.06em; font-weight: 850; }
.brand, .guide { min-height: 44px; display: inline-flex; align-items: center; }
.brand { color: var(--signal); min-width: 44px; justify-content: center; }
.guide { margin-left: auto; font-size: .9rem; text-decoration-color: #9da391; text-underline-offset: .24em; }
.machine {
  position: relative; width: min(1460px, 94%); min-height: min(87dvh, calc(100dvh - 82px)); margin: 0 auto;
  padding: clamp(10px, 1.2vw, 20px) clamp(10px, 1.7vw, 27px); border-radius: 16px;
  background: radial-gradient(ellipse at 24% -18%, #71775a, transparent 64%), linear-gradient(148deg, #4c5642, #2b382d 90%);
  border: 1px solid #778269;
  box-shadow: 0 7px 0 #191d17, 0 21px 40px #10120e70, inset 0 1px 0 #a0a3886e;
  display: grid; grid-template: 1fr / 1fr; isolation: isolate;
}
.console, .overlay { grid-area: 1 / 1; }
.console { display: grid; grid-template-rows: 48px minmax(244px, 1fr) minmax(50px, auto) 49px; gap: 9px; }
.readout { display: flex; align-items: center; gap: clamp(8px, 1.7vw, 24px); }
.date-block { margin-right: auto; }
.date-block strong, .date-block time { display: block; }
.date-block strong { letter-spacing: -.015em; }
.date-block time, .score-block span, .lives-label { color: #dae0cc; font-size: .82rem; }
.lives { display: grid; justify-items: center; gap: 4px; white-space: nowrap; }
.lamps { display: flex; gap: 5px; }
.lamps i {
  width: 14px; height: 8px; border-radius: 2px; background: #ffb59c;
  box-shadow: 0 0 8px #f4a28472, inset 0 1px 0 #ffe2cc;
  transition: background .16s, box-shadow .16s;
}
.lamps i.off { background: #292f25; box-shadow: inset 0 1px 2px #172017; }
.score-block { text-align: center; }
.score-block output { display: block; font: 700 1.15rem/1.05 var(--mono); letter-spacing: .05em; }
.pause-button { width: 44px; height: 44px; border: 1px solid #818773; border-radius: 6px; background: #262e24; color: var(--ink); display: grid; place-items: center; }
.language-switch {
  position: relative; z-index: 2; flex: none; color: var(--ink);
  font: 700 .77rem/1 var(--mono);
}
.language-switch summary {
  display: flex; align-items: center; justify-content: center; gap: .45em;
  cursor: pointer; min-width: 49px; min-height: 44px; list-style: none;
  border: 1px solid #849079; border-radius: 7px; background: #263228;
}
.language-switch summary::-webkit-details-marker { display: none; }
.language-switch summary::after {
  content: ''; width: .44em; height: .44em; border: solid currentColor;
  border-width: 0 1px 1px 0; transform: translateY(-.1em) rotate(45deg);
}
.language-switch nav {
  position: absolute; inset: calc(100% + 5px) 0 auto auto; min-width: 122px;
  padding: 3px; border: 1px solid #849079; border-radius: 7px; background: #263228;
}
.language-switch a {
  display: flex; align-items: center; min-height: 44px; padding: 0 10px;
  border-radius: 4px; text-decoration: none; font-family: system-ui, sans-serif;
}
.language-switch a:hover, .language-switch a[aria-current="page"] { background: #ecedce; color: #262d21; }
.word-deck {
  display: grid; grid-template: repeat(4, minmax(52px, 1fr)) / repeat(4, minmax(0, 1fr));
  gap: clamp(5px, .7vw, 10px); padding: clamp(6px, .8vw, 10px); border-radius: 10px;
  background: repeating-linear-gradient(0deg, #ffffff08 0 1px, transparent 1px 4px), #17251c;
  border: 1px solid #18261c; box-shadow: inset 0 3px 13px #0e1710, 0 1px 0 #819172;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.tile, .group {
  min-width: 0; min-height: 44px; color: #252b20; border-radius: 6px; border: 1px solid transparent;
  padding: 4px; text-align: center;
}
.tile {
  background: linear-gradient(157deg, #fbf9e9, var(--tile) 43%, #d3dec3);
  border-color: #faf8ea; border-bottom-color: #a6af99;
  box-shadow: inset 0 -3px 0 #a5af978c, 0 2px 3px #151b14;
  font: 750 clamp(.8rem, 2.25vw, 1.84rem)/1.08 var(--mono);
  letter-spacing: -.035em; overflow-wrap: anywhere;
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.tile.long-word { font-size: clamp(.73rem, 1.95vw, 1.56rem); }
.tile span { display: block; pointer-events: none; }
.tile[aria-pressed="true"] {
  background: linear-gradient(#ffbd9f, var(--signal) 62%, #f79578);
  border-color: #ffbf9f; border-bottom-color: #cd7257;
  box-shadow: inset 0 2px 4px #b65b4e56, 0 0 0 1px #242b21;
  transform: translateY(2px);
}
.tile.anchor { box-shadow: inset 0 0 0 3px #643c19, inset 0 0 0 6px #f4d683, 0 2px 3px #151b14; }
.tile:focus-visible { outline: 3px solid #fff; outline-offset: -3px; border-color: #3e3426; }
.tile.anchor:focus-visible { outline-offset: 0; }
.group {
  grid-column: 1 / -1; display: grid; place-content: center; gap: 3px; position: relative;
  background: #d8e6ab; border-color: #f0f3cb; box-shadow: inset 0 -2px 0 #393a182e;
}
.group[data-rank="1"] { background: #bce1c3; border-color: #d0f0d7; }
.group[data-rank="2"] { background: #c4d6eb; border-color: #dfedfb; }
.group[data-rank="3"] { background: #ffbca8; border-color: #ffd1c2; }
.group strong { font-size: clamp(.85rem, 2.2vw, 1.25rem); letter-spacing: -.025em; }
.group small { font: 700 clamp(.66rem, 2.65vw, 1rem)/1.15 var(--mono); }
.group.revealed { border-style: dashed; box-shadow: inset 0 0 0 2px #262b23; }
.group[aria-pressed="true"]::after {
  content: ''; position: absolute; inset: 3px; border: 1px solid #232a21; border-radius: 3px; pointer-events: none;
}
.feedback {
  align-self: stretch; display: flex; align-items: center; justify-content: center; gap: 6px 14px;
  min-width: 0; padding: 5px 10px; text-align: center; line-height: 1.2;
  background: #222d23; border: 1px solid #77866e; border-radius: 6px;
}
.status { min-width: 0; color: #f1f3e3; }
.status[data-kind="success"] { color: #eaffbb; }
.status[data-kind="error"] { color: #ffcebd; }
.status[data-kind="note"] { color: #f3edc6; }
.clue-readout { padding-left: 12px; border-left: 2px solid #e8c278; color: #fcdda0; }
.clue-readout strong {
  display: inline-block; padding: .15em .38em; border: 1px solid #d5aa62; border-radius: 4px; color: #ffecbb;
  font: 700 .82em/1.1 var(--mono);
}
.controls, .sheet-buttons, .result-actions { display: flex; align-items: stretch; justify-content: center; gap: clamp(5px, 1vw, 10px); }
.controls { width: min(100%, 630px); justify-self: center; }
.button {
  min-width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: 6px;
  padding: 0 clamp(7px, 1.6vw, 20px); font-weight: 700;
  transition: background .13s, transform .13s, filter .13s;
}
.button:active, .pause-button:active { transform: translateY(2px); }
.secondary, .setting { color: var(--ink); background: #30392e; border-color: #839077; box-shadow: inset 0 -2px 0 #232a23; }
.primary { color: #29241d; background: var(--signal); border-color: #ffc4ad; box-shadow: inset 0 -3px 0 #ca775f85; }
.primary[aria-disabled="true"] { background: #c9cdb8; border-color: #d8dcc7; box-shadow: inset 0 -3px 0 #7f896b65; }
.secondary[aria-disabled="true"] { color: #cbd1bc; }
.idle-controls .primary { min-width: min(50%, 210px); }
.active-controls .button { flex: 1; }
.active-controls .primary { flex: 1.45; }
.button small { font: 700 .77em var(--mono); white-space: nowrap; }
@media (hover: hover) {
  .tile:hover, .group:hover, .button:hover, .pause-button:hover, .language-switch:hover { filter: brightness(1.07); }
}
.overlay { display: grid; place-items: center; z-index: 3; background: #1c211be8; border: 1px solid #737a5e; border-radius: 10px; padding: 6px; }
.sheet { width: min(100%, 430px); padding: clamp(10px, 2.2vw, 24px); }
.sheet h2, .result h2 { margin: 0 0 8px; }
.sheet label, .sheet select { display: block; width: 100%; }
.sheet select { min-height: 44px; margin: 6px 0 12px; padding: 0 9px; background: #30392e; color: var(--ink); border: 1px solid #839077; border-radius: 6px; }
.sheet-buttons { margin-top: 8px; flex-wrap: wrap; }
.sheet-buttons .button { flex: 1 1 40%; }
.setting span { display: inline-block; margin-left: .4ch; color: #e5e8d2; font: .85rem var(--mono); }
.setting[aria-pressed="true"] span { color: #ffbc9b; }
.result {
  grid-row: 4; width: min(100%, 780px); justify-self: center; padding: 3px 0; min-height: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.result h2 { margin: 0 0 1px; font-size: 1.3rem; line-height: 1.05; letter-spacing: -.035em; }
.result p { margin: 0; color: #dde3cf; font-size: .86rem; }
.effects { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.effects i {
  position: absolute; top: 50%; left: calc(50% - 5px); width: 9px; height: 5px; border-radius: 1px;
  background: var(--tone); opacity: 0; animation: scatter .68s var(--wait) ease-out both;
}
.celebrate .word-deck { animation: board-win .36s ease-out; }
@keyframes scatter {
  12% { opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(220deg); opacity: 0; }
}
@keyframes board-win {
  40% { transform: translateY(-4px); box-shadow: 0 0 30px #dce8a486; }
}
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after {
  animation: none !important; transition-duration: 0s !important;
}
.reading, .site-footer {
  width: min(94%, 840px); margin-inline: auto;
}
.reading { margin-top: clamp(44px, 8vw, 106px); margin-bottom: 60px; line-height: 1.65; color: #e5e7d8; }
.reading h1, .reading h2, .reading dt { color: var(--ink); letter-spacing: -.033em; }
.reading h1 { font-size: clamp(2.4rem, 7vw, 4.1rem); line-height: 1.03; margin: 0 0 .45em; }
.reading h2 { font-size: clamp(1.38rem, 4.5vw, 2rem); margin: 0 0 .5em; line-height: 1.15; }
.reading p { margin: .55em 0 1em; }
.reading-header { padding: clamp(14px, 3vw, 30px) 0; border-top: 2px solid #ffa78f; border-bottom: 1px solid #646d58; }
.reading-header p { font-size: clamp(1.05rem, 3vw, 1.24rem); max-width: 62ch; }
.reading section { margin-top: 36px; }
.reading a { color: #ffd2be; text-underline-offset: .23em; }
.reading kbd { font: .9em var(--mono); background: #373f32; border: 1px solid #737b6a; border-radius: 4px; padding: 1px 5px; margin-right: 2px; }
.advice { list-style: square; padding-left: 1.25em; }
.advice li { margin: .8em 0; padding-left: .3em; }
.advice li::marker { color: var(--signal); }
.questions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 30px; }
.questions div { padding: 12px 0 2px; border-top: 1px solid #64705e; }
.questions dt { font-weight: 750; }
.questions dd { margin: 4px 0; }
.site-footer {
  border-top: 1px solid #646d58; padding: 15px 0 max(23px, env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 25px; color: #d3d9c7;
}
.site-footer p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; column-gap: 16px; }
.site-footer a { min-height: 44px; display: inline-flex; align-items: center; text-underline-offset: .23em; }
.inner-header { width: min(94%, 840px); }
.inner-header .guide { margin-left: 0; }
.inner-page { margin-top: clamp(20px, 5vw, 65px); }
.inner-page .return { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 540px) {
  .masthead { min-height: 62px; gap: 5px; width: 96%; }
  .guide { font-size: .78rem; white-space: nowrap; }
  .brand { min-width: 38px; }
  .brand svg { width: 30px; }
  .machine { width: 96%; min-height: min(88dvh, calc(100dvh - 72px)); padding: 9px; }
  .console { gap: 7px; }
  .machine:is([data-mode="won"], [data-mode="over"]) .console { grid-template-rows: 48px minmax(224px, 1fr) minmax(50px, auto) 85px; }
  .word-deck { gap: 5px; }
  .tile { font-size: clamp(.92rem, 4.12vw, 1.17rem); }
  .tile.long-word { font-size: clamp(.75rem, 3.28vw, .97rem); }
  .tile.long-token {
    font-size: clamp(.76rem, 3.3vw, .94rem); line-height: 1.15;
    padding-inline: 2px;
  }
  .feedback { flex-wrap: wrap; gap: 3px; font-size: .88rem; padding: 5px 7px; }
  .clue-readout { flex-basis: 100%; padding: 3px 0 0; border-left: 0; border-top: 1px solid #ad8b54; }
  .result { flex-wrap: wrap; }
  .result-actions { width: 100%; }
  .result-actions .button { flex: 1; }
  .questions { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 400px) {
  .active-controls .button { font-size: .85rem; }
  .active-controls .button small { display: block; }
  .date-block { font-size: .89rem; }
  .readout { gap: 7px; }
}
@media (max-width: 540px) and (max-height: 540px) {
  .masthead { min-height: 48px; padding-block: 0; }
  .machine { min-height: calc(100dvh - 57px); padding: 6px; }
  .console { grid-template-rows: 44px minmax(197px, 1fr) minmax(45px, auto) 44px; gap: 5px; }
  .machine:is([data-mode="won"], [data-mode="over"]) .console {
    grid-template-rows: 44px minmax(197px, 1fr) minmax(45px, auto) 78px;
  }
  .word-deck { grid-template-rows: repeat(4, minmax(44px, 1fr)); gap: 4px; padding: 4px; }
  .feedback { font-size: .79rem; }
  .result h2 { font-size: 1.12rem; }
}
button, select, a { -webkit-tap-highlight-color: transparent; }
@media (max-height: 580px) and (min-width: 541px) {
  .masthead { min-height: 54px; padding-block: 0; }
  .masthead h1 { font-size: clamp(1.6rem, 4vw, 2.5rem); }
  .machine { min-height: calc(100dvh - 64px); padding: 7px 14px; }
  .console { grid-template-rows: 44px minmax(198px, 1fr) minmax(36px, auto) 44px; gap: 6px; }
  .word-deck { grid-template-rows: repeat(4, minmax(44px, 1fr)); gap: 5px; padding: 4px; }
  .tile { font-size: clamp(1rem, 2.15vw, 1.45rem); }
  .tile.long-word { font-size: clamp(.88rem, 1.9vw, 1.25rem); }
  .feedback { font-size: .88rem; }
}
@media (max-height: 430px) and (min-width: 541px) {
  .masthead { min-height: 48px; padding-block: 0; }
  .masthead h1 { font-size: 1.85rem; }
  .machine { min-height: min(335px, calc(100dvh - 54px)); padding: 5px 14px; }
  .console { grid-template-rows: 44px minmax(193px, 1fr) minmax(27px, auto) 44px; gap: 3px; }
  .word-deck { grid-template-rows: repeat(4, minmax(44px, 1fr)); gap: 3px; padding: 3px; }
  .tile { font-size: 1rem; }
  .tile.long-word { font-size: .88rem; }
  .group { gap: 2px; padding-block: 2px; }
  .group strong { font-size: 1rem; line-height: 1.05; }
  .group small { font-size: .82rem; }
  .feedback { padding-block: 2px; }
  .result h2 { font-size: 1.05rem; }
  .result { padding: 0; }
}

/* Localized labels can be longer than the English controls. */
@media (max-width: 540px) {
  html:not([lang="en"]) .active-controls .button,
  html:not([lang="en"]) .result-actions .button {
    padding-inline: 3px;
  }
  html:not([lang="en"]) .active-controls .button {
    flex-basis: auto;
    overflow-wrap: normal;
  }
  .group { overflow-wrap: anywhere; }
  .tile span { hyphens: auto; }
}
@media (max-width: 400px) {
  html:not([lang="en"]) .lives-label { font-size: .73rem; }
  html:not([lang="en"]) .result-actions .button { font-size: .85rem; }
}
