:root {
  color-scheme: dark;
  --bg: #10101c;
  --panel: #191a2a;
  --line: #2b2c42;
  --text: #f6f3fe;
  --muted: #aaa8c4;
  --soft: #c7c3dd;
  --accent: #ff795c;
  --violet: #ae9cff;
  --radius: 15px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --gutter: clamp(16px, 3.2vw, 48px);
  --sidebar-width: clamp(270px, 23vw, 322px);
  font-family: Inter, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  min-width: 300px;
  min-height: 100svh;
  margin: 0;
  background:
    radial-gradient(ellipse at 40% -28%, #34245280, transparent 52%),
    radial-gradient(ellipse at 100% 14%, #251b313d, transparent 36%),
    var(--bg);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .44; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.shell {
  width: min(calc(100% - 2 * var(--gutter)), clamp(950px, calc((100svh - 249px) * 1.4333 + var(--sidebar-width) + 18px), 1730px));
  margin-inline: auto;
}
.site-header {
  background: #11111ee8;
  border-bottom: 1px solid #28263a;
}
.header-inner {
  min-height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(14px, 2.5vw, 39px);
}
.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  white-space: nowrap;
  font-size: 1.52rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: -.09em;
  flex-shrink: 0;
}
.brand-ball { margin-left: 3px; color: var(--accent); }
.brand-mark {
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  display: grid;
  grid-template-columns: repeat(2, 7px);
  grid-auto-rows: 5px;
  align-content: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid #ff9d85;
  border-radius: 10px;
  background: linear-gradient(146deg, #ff9c82, #ff6f54);
  box-shadow: 0 2px 13px #ff735b32, inset 0 1px #ffbca3;
}
.brand-mark i {
  display: block;
  width: 7px;
  height: 5px;
  border-radius: 1.2px;
  background: #231726;
  transform: rotate(-12deg);
}
.brand-mark i:last-child { width: 5px; border-radius: 50%; margin-inline: auto; }
#navigation {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
#navigation a {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 680;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
#navigation a:hover { color: var(--text); background: #212034; }
#navigation a[aria-current="page"] {
  color: #fee9ed;
  border-color: #ff92795a;
  background: #ff795c16;
}
#navigation a[aria-current="page"] svg { color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #333449;
  background: #1e1e30;
  color: var(--soft);
  transition: background-color 120ms, color 120ms, border-color 120ms;
}
.icon-button:hover:not(:disabled) { background: #2b2a40; border-color: #514969; color: var(--text); }
.language-control {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding-inline: 9px 6px;
  background: #1e1e30;
  border: 1px solid #333449;
  border-radius: 8px;
  color: var(--soft);
}
.language-control span { display: flex; }
.language-control select {
  padding: 0 1px;
  min-width: 64px;
  border: 0;
  background: transparent;
  color: var(--soft);
  font-size: .85rem;
  font-weight: 650;
  cursor: pointer;
}
.language-control:focus-within { outline: 2px solid var(--violet); outline-offset: 3px; }
.language-control select:focus-visible { outline: none; }

main { padding-block: 23px 25px; }
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.page-heading h1 {
  font-size: clamp(2.05rem, 3vw + .2rem, 3.85rem);
  font-weight: 820;
  line-height: 1.02;
  letter-spacing: -.052em;
}
.page-heading h1:focus { outline: none; }
.page-heading p { margin-top: 7px; color: var(--muted); font-size: .96rem; line-height: 1.45; }
.heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 9px 26px #0606112a;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  min-height: 38px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 720;
  font-size: .88rem;
  line-height: 1.15;
  text-align: center;
  transition: background-color 140ms, color 140ms, box-shadow 140ms, border-color 140ms;
}
.button svg { flex-shrink: 0; }
.button-primary {
  color: #27151e;
  border-color: #ff9c82;
  background: #ff795c;
  box-shadow: inset 0 1px #ffac97, 0 4px 13px #ff6f542b;
}
.button-primary:hover:not(:disabled) { background: #ff937b; box-shadow: inset 0 1px #ffbead, 0 5px 18px #ff6f5452; }
.button-secondary { color: var(--soft); border-color: #373850; background: #222337; }
.button-secondary:hover:not(:disabled) { color: var(--text); border-color: #5e5276; background: #2c2b43; }
.button-danger { color: #ffa49b; border-color: #693745; background: #422733; }
.button-danger:hover:not(:disabled) { color: #ffc3b8; background: #59313f; }
.eyebrow, .panel-heading {
  color: var(--soft);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .115em;
  line-height: 1.2;
  text-transform: uppercase;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  align-items: start;
  gap: 18px;
}
.game-panel {
  overflow: hidden;
  background: #19192a;
  box-shadow: 0 12px 42px #05050c66, 0 0 0 1px #9c90fa0a;
}
.field-toolbar {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px 5px 15px;
  border-bottom: 1px solid #33334a;
  gap: 8px;
}
.field-left, .field-right { display: flex; align-items: center; min-width: 0; }
.field-left { gap: 9px; }
.field-right { gap: 6px; }
.field-divider { display: block; height: 14px; width: 1px; background: #3a3a53; }
#field-mode { color: var(--muted); font-size: .79rem; font-weight: 620; }
.field-button { width: 31px; height: 31px; background: #222237; border-color: #35354d; }
.phase-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  margin-right: 3px;
  border: 1px solid #85e7bd35;
  border-radius: 6px;
  background: #6addb313;
  color: #a1e9c9;
  font-size: .72rem;
  font-weight: 710;
  white-space: nowrap;
}
.phase-tag > span:first-child { width: 6px; height: 6px; flex: 0 0 6px; background: currentColor; border-radius: 50%; box-shadow: 0 0 7px currentColor; }
.phase-tag[data-phase="paused"], .phase-tag[data-phase="levelComplete"] { color: #ffe1a2; border-color: #fad27649; background: #fad27615; }
.phase-tag[data-phase="lost"] { color: #ff9ead; border-color: #ff9ead41; background: #ff9ead14; }
.board {
  display: grid;
  position: relative;
  isolation: isolate;
  aspect-ratio: 43 / 30;
  background: #0b1024;
  overflow: hidden;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  outline: 0;
}
#game-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--violet); }
.board-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-items: center;
  justify-items: center;
  pointer-events: none;
}
.board-overlay button { pointer-events: auto; }
.board-overlay:not([data-phase="idle"]):not([data-phase="ready"]) {
  background: #080a18ac;
  backdrop-filter: blur(2px);
}
.start-content {
  position: absolute;
  top: 64%;
  display: grid;
  justify-items: center;
  gap: 12px;
}
.board-action {
  min-height: 44px;
  padding-inline: 16px;
  font-size: .96rem;
}
.start-content .board-action {
  min-height: 48px;
  padding-inline: 23px;
  border-radius: 9px;
  box-shadow: 0 6px 25px #ff795c43, inset 0 1px #ffae97;
}
.start-content p { color: #bbb8d7; font-size: .8rem; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 22px;
  padding-inline: 5px;
  color: #dedbf3;
  background: #222238;
  border: 1px solid #3b3a54;
  border-bottom-color: #4a4965;
  border-radius: 5px;
  font: 650 .72rem var(--mono);
  line-height: 1;
}
.start-content kbd { margin-inline: 2px; }
.overlay-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 24px 29px;
  background: #191a2af5;
  border: 1px solid #4b4665;
  border-radius: 15px;
  box-shadow: 0 14px 38px #03040dcf;
  text-align: center;
}
.overlay-card h2 { font-size: clamp(1.2rem, 2.35vw, 2.35rem); line-height: 1.05; letter-spacing: -.03em; }
.overlay-card p { color: var(--muted); font-size: .9rem; }
.overlay-medal {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: #ff795c20;
  border: 1px solid #ff795c4d;
  border-radius: 11px;
  color: var(--accent);
}
.result-score { color: #fedea4; font: 700 1rem var(--mono); }
.overlay-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 4px; }
.ready-card { transform: translateY(50%); }
.play-sidebar { display: grid; gap: 13px; min-width: 0; }
.play-sidebar > .panel { padding: 16px; }
.stats-panel {
  background: radial-gradient(ellipse at 100% 0%, #34254880, transparent 80%), var(--panel);
}
.stats-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
}
.stats-numbers > div { display: grid; min-width: 0; gap: 4px; }
.stats-numbers > div + div { padding-left: 15px; border-left: 1px solid #3a344b; }
.stats-numbers span, .life-row > span {
  color: var(--muted);
  font-size: .79rem;
  font-weight: 650;
}
.stats-numbers strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font: 760 clamp(1.55rem, 2.6vw, 2.65rem)/1 var(--mono);
  letter-spacing: -.075em;
  white-space: nowrap;
}
#best-score { color: #ffd5a0; }
.life-row {
  min-height: 35px;
  margin-top: 15px;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  border-top: 1px solid #3a344b;
}
#hearts { display: flex; gap: 6px; align-items: center; }
#hearts span { display: flex; color: #836273; }
#hearts .has-life { color: #ff8d9d; filter: drop-shadow(0 2px 5px #fa719845); }
#hearts .has-life svg { fill: #ff7892; }
#hearts small { color: var(--soft); font: 650 .72rem var(--mono); }
.level-panel { background: #191b2e; }
.level-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#level-number {
  display: inline-grid;
  place-items: center;
  padding: 4px 6px;
  min-width: 44px;
  border: 1px solid #3d3b59;
  border-radius: 5px;
  background: #25243c;
  color: #cec2fb;
  white-space: nowrap;
  font: 650 .72rem var(--mono);
}
.level-details { display: flex; align-items: center; gap: 11px; margin-top: 14px; }
#level-preview {
  display: block;
  flex: 0 0 69px;
  width: 69px;
  height: 45px;
  border: 1px solid #454562;
  border-radius: 6px;
}
.level-details > div { display: grid; gap: 3px; min-width: 0; }
.level-details strong { font-size: .98rem; font-weight: 775; overflow-wrap: anywhere; }
.level-details span { color: var(--muted); font-size: .76rem; line-height: 1.25; }
.level-progress { display: flex; gap: 3px; margin-top: 14px; }
.level-progress span { flex: 1; height: 4px; min-width: 0; border-radius: 2px; background: #33344d; }
.level-progress .current { background: #c7acff; box-shadow: 0 0 8px #bb8dff80; }
.level-progress .complete { background: #815fce; }
.controls-panel { background: #171827; }
#controls-list { margin-top: 10px; }
.control-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .81rem;
}
.control-row + .control-row { border-top: 1px solid #65617d27; }
.keys { display: flex; align-items: center; gap: 4px; }
.pointer-key { display: flex; align-items: center; color: #c3b8ec; padding-inline: 1px; }

.power-toast {
  position: fixed;
  z-index: 3;
  right: max(var(--gutter), calc((100vw - 1730px) / 2));
  bottom: max(17px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 11px 15px;
  max-width: min(390px, calc(100vw - 2 * var(--gutter)));
  border: 1px solid #62618c;
  border-radius: 9px;
  background: #24233ce8;
  box-shadow: 0 9px 25px #0303108c;
  color: var(--text);
  font-size: .87rem;
  font-weight: 660;
}
.power-toast svg { color: #d0b5fa; flex-shrink: 0; }

@media (min-width: 1900px) {
  :root { font-size: 17px; --sidebar-width: 360px; }
  .header-inner { min-height: 78px; }
  main { padding-top: 30px; }
  .play-sidebar > .panel { padding: 20px; }
  .play-sidebar { gap: 16px; }
  .play-layout { gap: 22px; }
}
@media (max-width: 940px) {
  :root { --sidebar-width: 238px; }
  #navigation a { padding-inline: 9px; }
  .play-layout { gap: 12px; }
  .play-sidebar { gap: 10px; }
  .play-sidebar > .panel { padding: 13px; }
}
@media (max-width: 780px) {
  .header-inner { flex-wrap: wrap; gap: 0; padding-top: 9px; }
  .header-tools { margin-left: auto; }
  #navigation { order: 3; width: 100%; min-height: 48px; justify-content: space-between; }
  #navigation a { padding: 8px 7px; font-size: clamp(.68rem, 2vw, .87rem); gap: 5px; }
  #navigation a svg { width: 14px; height: 14px; }
  main { padding-top: 18px; }
  .page-heading { margin-bottom: 13px; align-items: center; }
  .page-heading p { font-size: .87rem; }
  .play-layout { grid-template-columns: minmax(0, 1fr); }
  .play-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls-panel { grid-column: 1 / -1; }
  .field-toolbar { min-height: 38px; }
  .field-button { width: 27px; height: 27px; }
}
@media (max-width: 470px) {
  .header-inner, main { --gutter: 12px; }
  .view:not(#play) .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading:has(#campaign-button:not([hidden])) { align-items: flex-start; flex-direction: column; }
  #navigation { gap: 1px; }
  #navigation a { gap: 4px; padding-inline: 5px; }
  .brand-mark { height: 31px; width: 31px; flex-basis: 31px; }
  .page-heading p { max-width: 30ch; }
  #guide-button { padding-inline: 7px; font-size: .77rem; }
  .field-toolbar { padding-left: 8px; padding-right: 6px; }
  .field-left { gap: 6px; }
  .field-left .eyebrow { font-size: .64rem; }
  #field-mode { font-size: .7rem; }
  .phase-tag { max-width: 110px; font-size: .62rem; padding: 4px; margin-right: 0; }
  .field-right { gap: 4px; }
  .stats-numbers { margin-top: 12px; }
  .stats-numbers strong { font-size: clamp(1.05rem, 5.3vw, 1.55rem); }
  .stats-numbers > div + div { padding-left: 9px; }
  .life-row { margin-top: 10px; padding-top: 6px; }
  #hearts { gap: 3px; }
  #hearts svg { width: 13px; height: 13px; }
  .play-sidebar > .panel { padding: 11px; }
  .level-details { margin-top: 11px; gap: 7px; }
  #level-preview { flex-basis: 44px; width: 44px; height: 30px; }
  .level-details strong { font-size: .83rem; }
  .level-details span { font-size: .69rem; }
  .level-progress { margin-top: 11px; }
  .start-content { top: 57%; gap: 5px; }
  .start-content .board-action { min-height: 36px; padding-inline: 12px; }
  .start-content p { font-size: .68rem; }
  .start-content kbd { min-height: 16px; font-size: .64rem; }
  .overlay-card { padding: 13px; gap: 7px; }
  .overlay-card p { font-size: .76rem; }
  .overlay-medal { width: 33px; height: 33px; }
  .overlay-card .button { min-height: 34px; padding-inline: 8px; font-size: .79rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
}
