:root {
  --bg: #f3f3f4;
  --ink: #111;
  --muted: #6d7075;
  --tile-border: #bcc1c9;
  --tile-filled: #b2b5bc;
  --tile-correct: #6aaa64;
  --tile-present: #c9b458;
  --tile-absent: #787c7e;
  --key-bg: #c2c7d0;
  --key-ink: #101113;
  --layout-gap: clamp(10px, 1.25dvh, 16px);
  --kb-gap: clamp(4px, 0.5vmin, 6px);
  --kb-width: min(96vw, 840px);
  --key-unit: min(calc((var(--kb-width) - 9 * var(--kb-gap)) / 10), 5.8dvh);
  --kb-track-width: calc(10 * var(--key-unit) + 9 * var(--kb-gap));
  --key-height: var(--key-unit);
  --tile-gap: clamp(3px, 0.5vmin, 5px);
  --max-attempts: 8;
  --header-block-height: clamp(68px, 10.5dvh, 98px);
  --keyboard-block-height: calc(6 * var(--key-height) + 5 * var(--kb-gap));
  --board-height-limit: calc(100dvh - var(--header-block-height) - var(--keyboard-block-height) - 2 * var(--layout-gap) - 22px);
  --tile-size: min(
    calc(var(--key-unit) * 1.18),
    58px,
    calc((var(--board-height-limit) - (var(--max-attempts) - 1) * var(--tile-gap)) / var(--max-attempts))
  );
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
}

.shell {
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--layout-gap) 24px 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  animation: fade-in 260ms ease-out;
}

.freq-sidebar,
.dict-sidebar {
  position: fixed;
  top: 10px;
  bottom: 10px;
  width: clamp(192px, 20vw, 244px);
  z-index: 20;
  background: #fbfbfc;
  border: 1px solid #e2e4e8;
  border-radius: 16px;
  padding: 10px 10px 8px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.freq-sidebar {
  left: 10px;
}

.dict-sidebar {
  right: 10px;
}

.side-head {
  border-bottom: 1px solid #e7e8eb;
  padding: 2px 2px 10px;
}

.side-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-kicker {
  margin: 0;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #8b9098;
}

.side-title {
  margin: 4px 0 0;
  font-size: 0.94rem;
  line-height: 1.2;
  color: #20242b;
}

.side-close-btn {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #7e858f;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.side-close-btn:hover {
  background: #f0f1f3;
  color: #4a5059;
}

.freq-list,
.dict-list {
  margin: 0;
  padding: 0 0 2px;
  list-style: none;
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.5;
  letter-spacing: 0;
  scrollbar-width: none;
}

.freq-list li,
.dict-list li {
  padding: 8px 6px;
  border-radius: 0;
  border-bottom: 1px solid #eceef1;
  opacity: 1;
  margin-bottom: 0;
  background: transparent;
  border-top: 0;
  border-left: 0;
  border-right: 0;
}

.freq-list li.freq-head {
  opacity: 1;
  font-weight: 700;
  color: #3a4250;
  font-size: 0.8rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.freq-list li.freq-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
}

.freq-rank {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #efeff1;
  color: #525863;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
}

.freq-kana {
  font-size: 0.98rem;
  font-weight: 700;
  color: #191c22;
}

.freq-pct {
  font-size: 0.74rem;
  font-weight: 700;
  color: #5f6673;
}

.freq-list li.freq-empty {
  color: #737985;
}

.dict-list li.dict-guide {
  color: #737985;
}

.dict-list li.dict-head {
  font-weight: 700;
  color: #3a4250;
  font-size: 0.8rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.dict-list li.dict-item {
  font-weight: 700;
  color: #1f232b;
  font-size: 0.98rem;
}

.dict-list li.dict-empty {
  color: #737985;
}

.dict-list li:last-child {
  border-bottom: 0;
}

.hero {
  width: min(100%, var(--kb-track-width));
  justify-self: center;
  margin-bottom: var(--layout-gap);
}

.hero-bar {
  border: 0;
  border-radius: 14px;
  background: #f8f9fb;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.hero-actions {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4dvh, 2rem);
  line-height: 1;
  justify-self: center;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #d8dce4;
  border-radius: 999px;
  background: #f7f8fb;
  color: #464b54;
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 700;
  transition: transform 120ms ease, background-color 140ms ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: #eef1f6;
}

.content-grid {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  justify-items: center;
  align-content: stretch;
}

.play {
  min-height: 0;
  height: 100%;
  width: min(100%, var(--kb-track-width));
  max-width: 100%;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: start;
  gap: var(--layout-gap);
  padding-top: 0;
}

.settings-wrap {
  position: relative;
}

.settings-btn {
  border: 1px solid #d8dce4;
  border-radius: 10px;
  background: #f7f8fb;
  color: #3d4149;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  padding: 8px 12px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0;
  transition: transform 120ms ease, background-color 140ms ease;
}

.help-btn {
  background: #ffffff;
}

.settings-btn:hover {
  transform: translateY(-1px);
}

.settings-btn[aria-expanded='true'] {
  background: #eef1f6;
  border-color: #c9cfda;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 35;
  width: min(86vw, 244px);
  padding: 4px 0;
  border: 1px solid #e4e8ef;
  border-radius: 12px;
  background: #fff;
  backdrop-filter: none;
  display: grid;
  gap: 0;
  animation: pop-in 180ms ease-out;
}

.settings-popover,
.result-modal-panel,
.freq-list,
.dict-list {
  scrollbar-width: thin;
  scrollbar-color: #b9c2d0 transparent;
}

.settings-popover::-webkit-scrollbar,
.result-modal-panel::-webkit-scrollbar,
.freq-list::-webkit-scrollbar,
.dict-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.settings-popover::-webkit-scrollbar-track,
.result-modal-panel::-webkit-scrollbar-track,
.freq-list::-webkit-scrollbar-track,
.dict-list::-webkit-scrollbar-track {
  background: transparent;
}

.settings-popover::-webkit-scrollbar-thumb,
.result-modal-panel::-webkit-scrollbar-thumb,
.freq-list::-webkit-scrollbar-thumb,
.dict-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #bec7d4 0%, #a8b3c4 100%);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.settings-popover::-webkit-scrollbar-thumb:hover,
.result-modal-panel::-webkit-scrollbar-thumb:hover,
.freq-list::-webkit-scrollbar-thumb:hover,
.dict-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #b5bfce 0%, #9faabc 100%);
  background-clip: padding-box;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
}

.setting-row + .setting-row {
  border-top: 1px solid #eef1f5;
}

.setting-select-row {
  background: transparent;
  border: 0;
  border-radius: 0;
}

.setting-label {
  font-size: 0.82rem;
  color: #2f343d;
  font-weight: 500;
}

.setting-select-row select {
  border: 1px solid #d3d8e1;
  border-radius: 7px;
  background: #fff;
  color: #111;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 6px;
}

.setting-toggle-row {
  background: transparent;
  border: 0;
  border-radius: 0;
}

.setting-btn {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  min-height: 38px;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 0;
  background: #c8cdd6;
  padding: 0;
  display: inline-flex;
  align-items: center;
  transition: background-color 150ms ease, transform 120ms ease;
}

.toggle-switch:active {
  transform: scale(0.98);
}

.switch-knob {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(30 36 45 / 24%);
  transform: translateX(2px);
  transition: transform 160ms ease;
}

.toggle-switch.is-active {
  background: #9ab2d8;
  border-color: #8ea7cf;
}

.toggle-switch.is-active .switch-knob {
  transform: translateX(20px);
}

.next-word-btn {
  border: 0;
  border-radius: 10px;
  background: #eceff4;
  color: #444953;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  padding: 9px 10px;
  white-space: nowrap;
  transition: transform 120ms ease, background-color 140ms ease;
}

.next-word-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #dfe5ef;
}

.board {
  width: min(100%, var(--kb-track-width));
  display: grid;
  gap: var(--tile-gap);
  justify-items: center;
  align-self: center;
  margin: 0;
  animation: rise-in 220ms ease-out;
}

.board.is-shake {
  animation: board-shake 360ms ease;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--tile-size));
  gap: var(--tile-gap);
}

.board-row.is-clickable-attempt {
  cursor: pointer;
  border-radius: 8px;
  transition: transform 120ms ease, filter 120ms ease;
}

.board-row.is-clickable-attempt:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

.board-row.is-reveal-row .cell {
  animation: tile-reveal 420ms ease both;
  animation-delay: var(--reveal-delay, 0ms);
}

.board-row.is-celebrate-row .cell.is-correct {
  animation: celebrate-bounce 420ms ease both;
  animation-delay: var(--reveal-delay, 0ms);
}

.cell {
  width: var(--tile-size);
  height: var(--tile-size);
  border: 2px solid var(--tile-border);
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: clamp(1.05rem, 2.6dvh, 1.8rem);
  font-weight: 700;
  background: transparent;
}

.cell.is-filled {
  border-color: var(--tile-filled);
}

.cell.is-input-pop {
  animation: cell-pop 120ms ease-out;
}

.cell.is-correct {
  border-color: var(--tile-correct);
  background: var(--tile-correct);
  color: #fff;
}

.cell.is-present {
  border-color: var(--tile-present);
  background: var(--tile-present);
  color: #fff;
}

.cell.is-absent {
  border-color: var(--tile-absent);
  background: var(--tile-absent);
  color: #fff;
}

.kana-keyboard {
  width: min(100%, var(--kb-track-width));
  display: grid;
  gap: 4px;
  justify-items: center;
  align-self: end;
  padding-top: 0;
  margin: 0;
  animation: rise-in 260ms ease-out;
}

.kana-keyboard.is-shake {
  animation: board-shake 340ms ease;
}

.kb-basic {
  display: grid;
  gap: 4px;
  width: 100%;
}

.kb-row {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(10, var(--key-unit));
  justify-content: center;
  gap: var(--kb-gap);
  animation: key-row-in 220ms ease both;
}

.kb-row:nth-child(1) { animation-delay: 20ms; }
.kb-row:nth-child(2) { animation-delay: 60ms; }
.kb-row:nth-child(3) { animation-delay: 100ms; }
.kb-row:nth-child(4) { animation-delay: 140ms; }
.kb-row:nth-child(5) { animation-delay: 180ms; }

.kb-row-controls {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, var(--key-unit));
  justify-content: center;
  margin-top: 1px;
  gap: var(--kb-gap);
  animation: key-row-in 220ms ease both;
  animation-delay: 220ms;
}

.kana-key,
.kana-spacer {
  height: var(--key-height);
}

.kana-key {
  width: 100%;
  min-width: 0;
  position: relative;
  border: 0;
  border-radius: 10px;
  background: var(--key-bg);
  color: var(--key-ink);
  font-size: clamp(1rem, 2.1vmin, 1.2rem);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: transform 110ms ease, filter 120ms ease, background-color 140ms ease;
}

.kana-key.is-frequency-toned {
  background: hsl(220 14% calc(92% - var(--freq-tone, 0) * 40%));
}

.kana-key.is-frequency-toned .key-main,
.kana-key.is-frequency-toned .key-sub {
  color: hsl(220 14% calc(12% + var(--freq-tone, 0) * 8%));
}

.kana-key.is-correct .key-main,
.kana-key.is-correct .key-sub,
.kana-key.is-present .key-main,
.kana-key.is-present .key-sub,
.kana-key.is-absent .key-main,
.kana-key.is-absent .key-sub {
  color: #fff;
}

.kana-key.has-sub-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 1;
}

.kana-key .key-main {
  font-size: clamp(0.86rem, 1.8vmin, 1.02rem);
  font-weight: 700;
}

.kana-key .key-sub {
  font-size: clamp(0.66rem, 1.2vmin, 0.76rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.72;
  text-transform: lowercase;
}

.kana-key:hover:not(:disabled) {
  filter: brightness(0.98);
}

.kana-key:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.kana-key.is-wide {
  width: 100%;
  min-width: 0;
}

.kana-key.is-mod {
  background: #ccd2dc;
}

.kb-row-controls .kana-key.is-wide {
  grid-column: span 2;
}

.kana-key.is-enter {
  background: #9eb3d3;
}

.kana-key.is-secondary {
  background: #afb5c0;
}

.kana-key.is-correct {
  background: var(--tile-correct);
  color: #fff;
}

.kana-key.is-present {
  background: var(--tile-present);
  color: #fff;
}

.kana-key.is-absent {
  background: var(--tile-absent);
  color: #fff;
}

.kana-spacer {
  display: inline-block;
  width: 100%;
}

.message {
  min-height: 1.2em;
  margin: 4px 0 0;
  color: #31333a;
  font-size: clamp(0.78rem, 1.6vmin, 0.95rem);
  font-weight: 700;
  text-align: center;
}

.message:empty {
  min-height: 0;
  height: 0;
  margin: 0;
}

.message.is-pop {
  animation: message-pop 200ms ease;
}

.card {
  min-height: 0;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d8dadd;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.card-head h2 {
  margin: 0;
  font-size: 1rem;
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.78rem;
}

#learning-card {
  min-height: 0;
  overflow: auto;
}

.learning-kana {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.learning-orthography,
.learning-meaning,
.learning-syn {
  margin: 6px 0;
  font-size: 0.9rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: #2f3136;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #5f646d;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgb(17 17 17 / 45%);
}

.result-modal.hidden {
  display: none;
}

.result-modal-panel {
  width: min(92vw, 460px);
  max-height: 86dvh;
  overflow: auto;
  background: #fff;
  color: var(--ink);
  border: 1px solid #d8dadd;
  border-radius: 12px;
  padding: 14px;
  animation: pop-in 190ms ease-out;
}

.help-modal-panel {
  width: min(94vw, 680px);
  max-height: none;
  overflow: hidden;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.help-hero {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eceef1;
}

.help-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #828895;
}

.help-section {
  display: grid;
  gap: 8px;
}

.help-section h3 {
  margin: 0;
  font-size: 0.94rem;
}

.help-steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  color: #2f343d;
}

.help-example-card {
  border: 1px solid #e6e8eb;
  border-radius: 14px;
  padding: 12px;
  background: #fafafb;
  display: grid;
  gap: 10px;
}

.help-example-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 46px));
  gap: 6px;
  justify-content: start;
}

.help-example-tile {
  width: 46px;
  height: 46px;
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 700;
  background: #fff;
}

.help-example-tile.sample-correct,
.help-example-tile.is-correct {
  border-color: var(--tile-correct);
  background: var(--tile-correct);
  color: #fff;
}

.help-example-tile.sample-present,
.help-example-tile.is-present {
  border-color: var(--tile-present);
  background: var(--tile-present);
  color: #fff;
}

.help-example-tile.sample-absent,
.help-example-tile.is-absent {
  border-color: var(--tile-absent);
  background: var(--tile-absent);
  color: #fff;
}

.help-example-tile.sample-empty,
.help-example-tile.is-empty {
  border-color: var(--tile-border);
  background: #fff;
  color: #111;
}

.help-legend {
  display: grid;
  gap: 8px;
}

.help-legend-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  align-items: start;
}

.help-legend-item p {
  margin: 0;
  color: #434852;
}

.help-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  margin-top: 4px;
}

.help-dot.is-correct {
  background: var(--tile-correct);
}

.help-dot.is-present {
  background: var(--tile-present);
}

.help-dot.is-absent {
  background: var(--tile-absent);
}

.help-dot.is-empty {
  background: #fff;
  border: 1px solid var(--tile-border);
}

.help-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.help-mini-panel {
  border: 1px solid #e6e8eb;
  border-radius: 14px;
  padding: 12px;
  background: #fafafb;
  display: grid;
  gap: 4px;
}

.help-mini-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #828895;
}

.help-mini-panel strong {
  font-size: 0.96rem;
}

.help-mini-panel p {
  margin: 0;
  color: #4a4f59;
}

.help-modal-panel .result-actions {
  margin-top: 4px;
}

.result-modal-panel.is-guess-panel {
  width: min(92vw, 420px);
}

.result-modal-panel h2 {
  margin: 0;
  font-size: 1.12rem;
}

.result-summary {
  margin: 6px 0 10px;
  color: #31333a;
  font-size: 0.92rem;
  font-weight: 700;
}

.result-learning {
  display: grid;
  gap: 4px;
}

.result-actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.special-word-burst {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 70;
}

.special-word-particle {
  position: absolute;
  bottom: -12vh;
  transform: translateX(-50%);
  animation: special-word-float 2.4s ease-out forwards;
  filter: drop-shadow(0 4px 10px rgb(255 255 255 / 35%));
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cell-pop {
  0% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@keyframes tile-reveal {
  0% { transform: rotateX(0deg); filter: brightness(1); }
  45% { transform: rotateX(90deg); filter: brightness(0.9); }
  100% { transform: rotateX(0deg); filter: brightness(1); }
}

@keyframes celebrate-bounce {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-8px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes key-row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes message-pop {
  0% { transform: scale(0.98); opacity: 0.75; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes special-word-float {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0) rotate(0deg) scale(0.8);
  }
  12% {
    opacity: 1;
  }
  55% {
    opacity: 1;
    transform:
      translateX(calc(-50% + calc(var(--burst-x, 0px) * 0.55)))
      translateY(-58vh)
      rotate(calc(var(--burst-rotate, 0deg) * 0.6))
      scale(2.05);
  }
  100% {
    opacity: 0;
    transform:
      translateX(calc(-50% + var(--burst-x, 0px)))
      translateY(-115vh)
      rotate(var(--burst-rotate, 0deg))
      scale(3.15);
  }
}

@media (max-width: 980px) {
  :root {
    --kb-width: 96vw;
    --key-unit: min(calc((var(--kb-width) - 9 * var(--kb-gap)) / 10), 5.4dvh);
  }

  .shell {
    padding: 8px 10px 10px;
  }

  .dict-sidebar {
    display: none;
  }

  .hero-bar {
    padding: 8px 10px;
    gap: 8px;
  }

  .hero-actions {
    gap: 6px;
  }

  .help-modal-panel {
    width: min(96vw, 620px);
    padding: 14px;
    gap: 10px;
  }

  .help-panel-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: clamp(1.2rem, 2.1dvh, 1.6rem);
  }
}

@media (max-width: 1180px) {
  .freq-sidebar,
  .dict-sidebar {
    width: clamp(176px, 18vw, 212px);
  }
}

@media (max-width: 640px) {
  .hero-bar {
    grid-template-columns: auto 1fr auto;
  }

  .settings-btn {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .help-example-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .help-example-tile {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell,
  .board,
  .kana-keyboard,
  .settings-popover,
  .result-modal-panel,
  .cell.is-input-pop,
  .board-row.is-reveal-row .cell,
  .board-row.is-celebrate-row .cell,
  .kb-row,
  .kb-row-controls,
  .message.is-pop {
    animation: none !important;
  }

  .kana-key,
  .switch-knob,
  .settings-btn,
  .next-word-btn,
  .toggle-switch {
    transition: none !important;
  }
}
