@font-face {
  font-family: "Fredoka";
  src: url("../fonts/fredoka.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --bg: #e9edf1;
  --text: #26343f;
  --muted: #566470;
  --hairline: #bac5cf;
  --filled: #fff;
  --key: #e6edf0;
  --key-text: #35454f;
  --absent: #b9c4d0;
  --present: #f2b51a;
  --correct: #218767;
  --correct-feedback: #0ae59b;
  --feedback-ink: #253443;
  --tile-face: #e5ebef;
  --tile-edge: #a1afb9;
  --toast: #fff;
  --toast-text: #26343f;
  --modal: #f6f8f8ed;
  --shadow: 0 24px 80px #52637240;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #d5dce2;
  --key: #d7e1e7;
  --tile-face: #d7e0e6;
  --modal: #eef2f5f5;
}

:root[data-colorblind="on"] {
  --present: #f6d45e;
  --correct-feedback: #00a765;
}

* { box-sizing: border-box; }
html, body { height: 100%; min-height: 100dvh; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 15% 12%, #fff 0%, transparent 46%), radial-gradient(ellipse at 92% 80%, #e0ddeb99, transparent 45%), linear-gradient(155deg, #f4f4f0, var(--bg) 54%, #dce9e9);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body::before, body::after {
  content: "";
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: radial-gradient(circle at 28% 22%, #fff9, #ffffff08 48%, #a7bcc529 75%, #fff8);
  box-shadow: inset 3px 4px 12px #fff, inset -4px -5px 14px #b0c0c733;
  pointer-events: none;
  z-index: 0;
}
body::before { top: 4%; left: calc(50% - 380px); }
body::after { right: calc(50% - 390px); bottom: 8%; width: 300px; height: 300px; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  z-index: 1;
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: env(safe-area-inset-top) 12px max(12px, env(safe-area-inset-bottom));
}

.header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 104px;
  gap: 4px;
  padding: 12px 0 8px;
}
.header-left, .header-right {
  display: flex;
  gap: 5px;
  align-items: center;
}
.header-left, .header-right, .masthead { transform: none; }
.header-right { justify-content: flex-end; }
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text);
  border: 1px solid #fff;
  border-radius: 50%;
  background: radial-gradient(ellipse at 30% 0%, #fff, #ffffff18 62%), linear-gradient(140deg, #fff9, #becbd84d);
  box-shadow: inset 0 2px 3px #fff, inset 0 -3px 4px #8c9fa755, 0 4px 7px #52677530;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 120ms ease;
}
.icon-btn:active { transform: scale(.93); }
.icon-btn svg { width: 22px; height: 22px; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: center;
}
.wordmark {
  font-family: "Fredoka", ui-rounded, -apple-system, sans-serif;
  font-weight: 650;
  letter-spacing: -.055em;
  font-size: clamp(40px, 12.8vw, 56px);
  line-height: 1;
  color: #fff;
  -webkit-text-fill-color: #cdd9e2;
  -webkit-text-stroke: .5px #fff;
  text-shadow: 0 1px 0 #9aaebd, 0 2px 0 #9aaebd, 0 3px 0 #839ba9, 0 5px 3px #718b9a50;
  transform: rotate(-3deg);
}
.board-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transform: none;
  flex-wrap: wrap;
}

.puzzle-meta {
  text-align: center;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  border: 1px solid #fff;
  border-radius: 30px;
  padding: 9px 18px;
  background: linear-gradient(#ffffffeb, #e2e8ec80);
  box-shadow: inset 0 2px 3px #fff, inset 0 -2px 3px #98aebb55, 0 4px 10px #8a9baa33;
}
.puzzle-meta::before { content: "▦"; margin-right: 8px; color: #637986; }
.next-day-note {
  padding: 0;
  color: var(--muted);
  font-size: 13px;
}
.practice-length-link, .puzzle-switch {
  padding: 0 12px;
  min-height: 44px;
  border: 1px solid #ffffffaa;
  border-radius: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-underline-offset: 3px;
}
.outcome {
  margin: 4px 0 8px;
  padding: 15px;
  border-radius: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--correct) 5%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--correct) 24%, var(--bg));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 2px 5px rgba(15,45,30,.035);
}
.outcome[hidden] { display: none; }
.outcome[data-result="lost"] {
  background: color-mix(in srgb, var(--present) 5%, var(--bg));
  border-color: color-mix(in srgb, var(--present) 28%, var(--bg));
}
.outcome-copy { display: grid; gap: 2px; min-width: 0; }
.outcome-title {
  font-family: inherit;
  font-size: clamp(18px, 5.5vw, 27px);
  line-height: 1.05;
}
.outcome-detail { font-size: 12px; color: var(--muted); }
.next-name-btn {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(155deg, color-mix(in srgb, var(--correct) 88%, #fff), var(--correct) 58%, color-mix(in srgb, var(--correct) 85%, #000));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 3px 0 color-mix(in srgb, var(--correct) 72%, #061d13), 0 6px 10px rgba(16,50,32,.16);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.next-name-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 0 color-mix(in srgb, var(--correct) 72%, #061d13);
}
.next-name-compact { display: none; }

.board-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 0 16px;
  min-height: max-content;
}
.icon-btn:focus-visible,
.key:focus-visible,
.practice-length-link:focus-visible,
.puzzle-switch:focus-visible,
.length-options button:focus-visible,
.next-name-btn:focus-visible,
.switch:focus-visible,
.primary:focus-visible,
.text-link:focus-visible,
.close:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.board {
  --tile: min(66px, calc((100vw - 64px - (var(--len, 5) - 1) * 5px) / var(--len, 5)), max(28px, calc((100dvh - 400px) / 6)));
  display: grid;
  gap: 5px;
  perspective: 900px;
  padding: 17px;
  border: 1px solid #fff;
  border-radius: 30px;
  background: linear-gradient(128deg, #fff9, #a8bac520 27%, #96abb83d 61%, #ffffff80);
  box-shadow: inset 1px 1px 1px #fff, inset -2px -2px 1px #fff, inset 5px 5px 3px #9daeb850, inset -5px -5px 3px #a8b9c64d, 0 2px 0 #acbbc355, 0 8px 14px #60798a20;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.row {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(var(--len, 5), var(--tile));
  transform-style: preserve-3d;
}
.row.shake { animation: shake 0.6s cubic-bezier(.36,.07,.19,.97); }

.tile {
  width: var(--tile);
  height: var(--tile);
  border: 1px solid #9faeb999;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: calc(var(--tile) * 0.57);
  font-weight: 900;
  text-transform: uppercase;
  background: linear-gradient(145deg, #ffffffa6, #ffffff05 38%, #8da4b02e 84%, #fff9);
  color: var(--text);
  user-select: none;
  position: relative;
  transform-style: preserve-3d;
  transform: none;
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 #7c8c9640, 0 2px 2px #84949e40;
  transition: box-shadow 160ms ease-out, border-color 160ms ease-out;
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(145deg, rgba(255,255,255,.08), transparent 38%, rgba(0,0,0,.025));
  pointer-events: none;
  transform: translateZ(1px);
}
.tile[data-state="tbd"] {
  border-color: var(--filled);
  background: linear-gradient(140deg, #fff, #edf3f8a6);
  box-shadow: inset 0 1px 5px #fff, 0 0 0 2px #8da6b5, 0 4px 10px #667b8c40;
  animation: pop 0.08s ease-out;
}
.row.active .tile { transform: rotateX(-4deg) translateZ(3px); }
.row.active .tile[data-state="empty"] { border-color: #859ba9; }
.tile[data-state="correct"], .tile[data-state="present"], .tile[data-state="absent"] {
  transform: rotateX(-4deg) translateZ(3px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 3px 0 var(--tile-edge), 0 7px 10px rgba(20,48,31,.16);
}
.tile[data-state="correct"], .key[data-state="correct"] { background: linear-gradient(140deg, #c3ffcf, var(--correct-feedback) 52%, #00bd86); border-color: #d6ffde; color: #fff; text-shadow: 0 2px 2px #006647aa; --tile-edge: #008c66; box-shadow: inset 0 2px 5px #fff, inset 0 -3px 4px #00f1a5aa, 0 3px 0 #07956e, 0 5px 7px #137e5738; }
.tile[data-state="present"], .key[data-state="present"] { background: linear-gradient(140deg, #fffac0, var(--present) 52%, #eda510); border-color: #fff8cd; color: #fff; text-shadow: 0 2px 2px #795200c0; --tile-edge: #ad790d; box-shadow: inset 0 2px 5px #fff, 0 3px 0 #c6972e, 0 5px 7px #937b2738; }
.tile[data-state="absent"], .key[data-state="absent"] { background: linear-gradient(140deg, #fff, var(--absent) 65%, #a4b2c2); border-color: #fff; color: var(--feedback-ink); --tile-edge: #8b9dad; box-shadow: inset 0 2px 4px #fff, inset 0 -2px 4px #7c8eab44, 0 3px 0 #8b9dad, 0 5px 7px #627a8b26; }
.tile.flip { animation: flip 0.5s ease forwards; }
.tile.lift { animation: win-lift 0.55s cubic-bezier(.23, 1, .32, 1); }

.finish-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}
.finish-fx::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
}
.finish-fx.won::before {
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--correct) 28%, transparent), transparent 65%);
  animation: finish-glow 1.15s ease-out both;
}
.finish-fx.lost::before {
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--present) 22%, transparent), transparent 70%);
  animation: finish-glow 1.15s ease-out both;
}
.finish-fx i {
  position: absolute;
  top: -24px;
  left: var(--x);
  width: 9px;
  height: 17px;
  border-radius: 2px;
  background: var(--correct);
  opacity: 0;
  animation: finish-fall 1.35s var(--delay) cubic-bezier(.23, 1, .32, 1) both;
}
.finish-fx.won i:nth-child(3n) { background: var(--absent); }
.finish-fx.won i:nth-child(3n + 1) { background: var(--text); }
.finish-fx.lost i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--present);
}

.keyboard {
  width: 100%;
  padding: 12px 10px 14px;
  display: grid;
  gap: 8px;
  user-select: none;
  border: 1px solid #fff;
  border-radius: 26px;
  background: linear-gradient(130deg, #ffffffb0, #ffffff12 45%, #cad5dd50);
  box-shadow: inset 1px 1px 1px #fff, inset -2px -2px 1px #fff, inset 5px 5px 3px #879ead35, 0 6px 12px #60798a20;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
}
.key {
  flex: 1;
  height: 49px;
  min-width: 0;
  border-radius: 7px;
  border: 1px solid #fff;
  background: linear-gradient(145deg, #fff, #ffffff45 45%, #c4d0da65);
  color: var(--key-text);
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  text-transform: uppercase;
  box-shadow: inset 0 1px 1px #fff, inset 0 -1px 1px #8fa1b044, 0 2px 0 #a8b7c455, 0 3px 4px #71879922;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}
.key.wide { flex: 1.65; font-size: 11px; padding: 0 3px; }
.key[data-key="DEL"] { font-size: 20px; }
.app-footer { display: flex; justify-content: center; align-items: center; gap: 13px; min-height: 42px; color: #657984; font-size: 10px; font-weight: 600; letter-spacing: .24em; }
.app-footer span { width: 34px; height: 1px; background: linear-gradient(90deg, transparent, #899eaa); }
.app-footer span:last-child { transform: rotate(180deg); }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--key) 70%, #83908a); }

.toast-wrap {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
.toast {
  background: var(--toast);
  color: var(--toast-text);
  padding: 10px 14px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition: 0.15s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}
.toast.show { opacity: 1; transform: none; }

.overlay {
  position: fixed;
  inset: 0;
  background: #8b9aa566;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  z-index: 30;
}
.overlay.open { display: flex; }
.modal {
  width: min(520px, 100%);
  background: var(--modal);
  color: var(--text);
  border-radius: 26px;
  border: 1px solid #fff;
  box-shadow: var(--shadow);
  padding: 20px 24px 24px;
  position: relative;
  max-height: calc(100vh - 84px);
  overflow: auto;
}
.modal h2 {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 12px;
  font-size: 18px;
  text-transform: none;
  padding-right: 32px;
}
.modal p { line-height: 1.45; }
.modal .close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  font-size: 22px;
  color: var(--text);
  border-radius: 50%;
  background: #739bd522;
}
.example {
  display: flex;
  gap: 5px;
  margin: 10px 0;
}
.example .tile { width: 40px; height: 40px; font-size: 20px; }
.example-caption { font-size: 14px; margin: 0; }

.result-panel {
  display: grid;
  gap: 7px;
  padding: 18px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--correct) 13%, var(--modal));
  border: 1px solid color-mix(in srgb, var(--correct) 45%, var(--modal));
}
.result-panel[hidden] { display: none; }
.result-panel[data-result="lost"] {
  background: color-mix(in srgb, var(--present) 13%, var(--modal));
  border-color: color-mix(in srgb, var(--present) 45%, var(--modal));
}
.result-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.result-title {
  font-family: inherit;
  font-size: 30px;
  line-height: 1.05;
}
.result-copy { font-size: 14px; line-height: 1.4; }

.name-note {
  margin-top: 12px;
  padding: 13px 15px;
  border-left: 3px solid var(--present);
  background: color-mix(in srgb, var(--present) 8%, var(--modal));
}
.name-note[hidden] { display: none; }
.name-note h3 {
  margin: 0 0 5px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.name-note p { margin: 0 0 6px; font-size: 14px; }
.name-note a { color: var(--muted); font-size: 11px; text-underline-offset: 2px; }

.friends-intro, .friends-footnote { color: var(--muted); font-size: 13px; }
.friends-footnote { border-top: 1px solid var(--hairline); padding-top: 12px; margin-bottom: 0; }
.friends-form { display: grid; gap: 8px; margin: 16px 0; }
.friends-form[hidden] { display: none; }
.friends-form label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.friends-form input {
  width: 100%; min-width: 0; height: 44px; padding: 0 12px;
  border: 1px solid var(--hairline); border-radius: 12px;
  background: var(--tile-face); color: var(--text); font: inherit;
}
.friends-form input:focus-visible { outline: 2px solid var(--correct); outline-offset: 2px; }
.friends-code-row { display: flex; gap: 8px; }
.friends-code-row button, .friends-active-head button {
  padding: 0 12px; border: 1px solid var(--hairline); border-radius: 4px;
  background: var(--key); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.friends-form .primary { margin-top: 6px; }
.friends-active[hidden] { display: none; }
.friends-active-head { display: flex; justify-content: space-between; gap: 12px; align-items: stretch; margin-top: 18px; }
.friends-active-head strong { display: block; font-size: 24px; letter-spacing: .1em; }
.friends-active p { font-size: 13px; color: var(--muted); }
.leaderboard-list { list-style: none; padding: 0; margin: 12px 0; }
.leaderboard-list li { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 10px 6px; border-bottom: 1px solid var(--hairline); font-size: 14px; }
.leaderboard-list li b { color: var(--correct); }
.leaderboard-list li strong { font-variant-numeric: tabular-nums; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
  margin: 16px 0;
}
.stats-scope { margin: 16px 0 -8px; color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 32px; font-weight: 700; }
.stat span { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.dist-title {
  margin: 8px 0 4px;
  font-size: 16px;
  font-weight: 700;
}
.dist { margin-top: 8px; }
.dist-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.bar {
  height: 18px;
  background: var(--absent);
  color: var(--feedback-ink);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  min-width: 18px;
}
.bar.win { background: var(--correct); }
.reveal {
  text-align: center;
  margin: 16px 0 0;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  align-items: center;
}
.next {
  flex: 1;
  text-align: center;
}
.next span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.next b {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}
.primary {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  font-weight: 700;
  background: var(--correct);
  color: #fff;
}
.primary:disabled { opacity: 0.45; cursor: default; }
.text-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}
.settings-row h3 { margin: 0; font-size: 16px; }
.settings-row p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.switch {
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  border-radius: 18px;
  background: var(--hairline);
  position: relative;
}
.switch.on { background: var(--correct); }
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #fff;
  transition: 0.15s;
}
.switch.on i { left: 23px; }
.practice-settings {
  border: 0;
  margin: 0;
  padding: 16px 0 0;
}
.practice-settings legend { padding: 0; font-size: 16px; font-weight: 700; }
.practice-settings p { margin: 4px 0 12px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.length-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.length-options button {
  min-height: 44px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}
.length-options button[aria-pressed="true"] { background: var(--correct); border-color: var(--correct); color: #fff; }
.practice-start { width: 100%; margin-top: 12px; }

@keyframes pop {
  from { transform: rotateX(-5deg) translateZ(9px) scale(1.045); }
  to { transform: rotateX(-5deg) translateZ(3px) scale(1); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
@keyframes flip {
  0% { transform: rotateX(-5deg) translateZ(3px); }
  50% { transform: rotateX(-90deg) translateZ(8px); }
  100% { transform: rotateX(-5deg) translateZ(3px); }
}
@keyframes win-lift {
  0%, 100% { transform: translateY(0); }
  42% { transform: translateY(-8px); }
}
@keyframes finish-glow {
  0% { opacity: 0; }
  24% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes finish-fall {
  0% { opacity: 0; transform: translate3d(0, -16px, 0) rotate(0deg); }
  12% { opacity: 0.9; }
  100% { opacity: 0; transform: translate3d(var(--drift), 105dvh, 0) rotate(var(--turn)); }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .row, .key, .icon-btn, .modal, .next-name-btn, .toast, .finish-fx::before, .finish-fx i { animation: none !important; transition: none !important; }
}

@media (max-width: 350px) {
  .outcome { margin: 7px 15px 0; padding: 10px; gap: 8px; }
  .outcome-title { font-size: 20px; }
  .next-name-btn { min-height: 44px; padding: 0 10px; }
  .next-name-full { display: none; }
  .next-name-compact { display: inline; }
}

@media (max-height: 650px) {
  .header { min-height: 58px; padding: 6px 0; }
  .wordmark { font-size: 34px; }
  .outcome { margin: 6px 16px 0; padding: 7px; font-size: 11px; }
  .board-wrap { padding: 2px 0 10px; gap: 7px; }
  .board { --tile: min(44px, calc((100vw - 54px - (var(--len, 5) - 1) * 4px) / var(--len, 5)), max(28px, calc((100dvh - 380px) / 6))); gap: 4px; padding: 11px; border-radius: 18px; }
  .row { gap: 4px; }
  .puzzle-meta { font-size: 12px; padding: 7px 13px; }
  .practice-length-link, .puzzle-switch { font-size: 11px; }
  .keyboard { gap: 5px; padding: 9px 7px 11px; }
  .kb-row { gap: 4px; }
  .key { height: 46px; font-size: 12px; }
  .key.wide { font-size: 10px; }
  .app-footer { min-height: 28px; font-size: 8px; }
}

@media (max-width: 360px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .board-heading { gap: 5px; }
  .puzzle-meta { padding-left: 9px; padding-right: 9px; }
  .practice-length-link, .puzzle-switch { padding-left: 8px; padding-right: 8px; }
  .header { gap: 4px; }
  .header-right { gap: 2px; }
  .wordmark { font-size: 32px; }
}
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: max(16px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)); }
  .modal { max-height: calc(100dvh - 40px - env(safe-area-inset-top)); padding: 26px 22px; border-radius: 28px; }
  .modal::before { content: ""; position: absolute; top: 8px; left: calc(50% - 18px); width: 36px; height: 4px; border-radius: 4px; background: #aec7e955; }
  .overlay.open .modal { animation: sheet-in 220ms cubic-bezier(.2,.8,.2,1); }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.app:has(.outcome:not([hidden])) .board { --tile: min(60px, calc((100vw - 54px - (var(--len, 5) - 1) * 4px) / var(--len, 5)), max(24px, calc((100dvh - 610px) / 6))); }
.history-entry { border-bottom: 1px solid #aec7e933; padding: 8px 0; }
#moreHistoryBtn[hidden] { display: none; }
.history-entry summary { cursor: pointer; min-height: 44px; align-content: center; font-weight: 700; }
.history-entry p { line-height: 1.6; }
