:root {
  color-scheme: light;
  --ink: #302837;
  --muted: #6c606c;
  --accent: #754c85;
  --paper: #fffdf9;
  --line: #e9e0e4;
  --lavender: #eee3f3;
  --green: #dfeadd;
  font-family: "Instrument Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 9% 2%, #f9dfcc 0, transparent 50%),
    radial-gradient(ellipse at 94% 87%, #e7dbf1 0, transparent 59%),
    #f7eee9;
}
main {
  width: min(100% - 28px, 510px);
  margin: auto;
  padding: clamp(24px, 9vh, 90px) 0 28px;
}
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 3px;
  margin-bottom: 15px;
}
h1 {
  margin: 0;
  font: 500 clamp(34px, 8.1vw, 57px)/1 Georgia, serif;
  letter-spacing: -.075em;
}
h1 span { color: var(--accent); }
button {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--lavender);
  color: #573667;
  font: 650 13px system-ui, sans-serif;
  cursor: pointer;
  transition: background-color .18s, transform .18s;
}
button:hover:enabled { background: #e4d2ee; }
button:active:enabled { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .46; cursor: default; }
#show-levels { background: #fffaf7a0; border-color: #dfd1d8; white-space: nowrap; }
#show-levels:hover { background: var(--paper); }
#show-levels span { margin-left: 4px; }
.board {
  position: relative;
  background: var(--paper);
  border: 1px solid #ded0db;
  border-radius: 23px;
  box-shadow: 0 2px 0 #fefbf7, 0 20px 46px #50315514;
  padding: clamp(13px, 4vw, 28px);
}
.round, .level-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.round-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.04em; }
#difficulty { padding: 3px 7px; border-radius: 5px; background: var(--lavender); color: #573667; font-size: 11px; font-weight: 650; }
#budget { color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.instructions { margin: 10px 0 17px; max-width: 33ch; color: var(--muted); font-size: 13px; line-height: 1.5; }
.chain { container-type: inline-size; display: grid; gap: 7px; }
.row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 6px;
  border: 1px solid #f1e8ed;
  border-radius: 12px;
  background: #fbf7f8;
  transition: border-color .18s, background .18s;
}
.row:has(.seed) { background: #f1e9f4; border-color: #eaddf0; }
.row:has(.solved:not(.seed)) { background: #f2f6ef; border-color: #e8efe5; }
.row.locked { opacity: .6; }
.row.active, .row:focus-within { background: #f6eef9; border-color: #c6a8d4; }
.row form { display: flex; justify-content: space-between; align-items: center; flex: 1; min-width: 0; gap: 3px; }
.word { position: relative; min-width: 0; }
.letters { display: flex; gap: 3px; }
.letter {
  display: grid;
  place-items: center;
  width: clamp(15px, calc((100cqw - 90px) / 8), 37px);
  aspect-ratio: 1 / 1.12;
  border: 1px solid #e5dce1;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 1px 0 #ebe2e8;
  font-size: clamp(12px, 3.5cqw, 19px);
  font-weight: 750;
}
.letter.clue { background: #f0e5f4; border-color: #dcc8e5; color: #573768; }
.letter.typed { background: white; border-color: #ba9acb; }
.active .letter.cursor { border-color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.word:focus-within .letter.selection { background: #e5d4ee; }
.solved .letter { background: var(--green); border-color: #c8dbc7; box-shadow: 0 1px 0 #c8dbc7; color: #334e39; }
.seed .letter { background: #604269; border-color: #604269; box-shadow: 0 1px 0 #432d49; color: #fff; }
.word input { position: absolute; inset: 0; width: 100%; border: 0; padding: 0; opacity: 0; cursor: text; font-size: 16px; }
.row-label { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 650; }
.submit { width: 30px; height: 32px; padding: 0; font-size: 17px; }
.hint { padding-inline: 5px; background: transparent; font-size: 12px; }
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 22px; margin-top: 12px; }
.feedback:has(#status:empty):has(#action[hidden]) { margin-top: 0; min-height: 0; }
#status { margin: 0; color: var(--muted); font-size: 12px; }
#status:empty { visibility: hidden; }
#status[data-tone="success"] { color: #395843; }
#status[data-tone="error"] { color: #963d4e; }
#action { margin-left: auto; background: #604269; color: #fff; }
#action:hover { background: #754c85; }
#continue-panel {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbf7f8;
  font-size: 13px;
}
#continue-panel p { margin: 0 0 8px; }
#coin-balance { color: var(--muted); }
.continue-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#spend-coin:enabled { background: #604269; color: white; }
#spend-coin:hover:enabled { background: var(--accent); }
#continue-panel .test-payment { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
dialog {
  width: min(100% - 32px, 335px);
  padding: 0;
  border: 1px solid #e7d4eb;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 80px #2f173d44;
}
dialog[open] { animation: enter .24s ease-out; }
dialog::backdrop { background: #34243b60; backdrop-filter: blur(3px); }
.level-panel { padding: 20px; }
#completion { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.close { padding: 0; width: 34px; height: 34px; font-size: 20px; }
.progress { height: 5px; background: var(--lavender); border-radius: 5px; margin: 14px 0 16px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
#new-puzzle { width: 100%; margin-top: 12px; }
nav button { aspect-ratio: 1.2; padding: 0; }
nav button.done { background: var(--green); color: #334e39; }
nav button[aria-current] { background: #604269; color: white; }
[hidden] { display: none !important; }
.enter { animation: enter .28s backwards; animation-delay: calc(var(--slot) * 36ms); }
.correct .letter { animation: flip .38s backwards; animation-delay: calc(var(--letter) * 25ms); }
.reveal .letter.new-clue { animation: flip .35s both; }
.wrong .letters { animation: shake .3s ease-out; }
.wrong .letter { border-color: #d99aa7; }
.board.win { animation: win .66s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(7px); } }
@keyframes flip { 0% { transform: rotateX(85deg); } 68% { transform: rotateX(-12deg); } }
@keyframes shake { 25%, 75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@keyframes win { 45% { box-shadow: 0 0 0 6px #c9e3c770, 0 20px 46px #50315514; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
