:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-soft: #0b1120;
  --panel: rgba(13, 20, 36, 0.78);
  --panel-strong: rgba(17, 26, 45, 0.94);
  --line: rgba(148, 163, 184, 0.14);
  --line-strong: rgba(148, 163, 184, 0.24);
  --text: #eef2ff;
  --muted: #91a0bd;
  --muted-strong: #b8c4da;
  --cyan: #67e8f9;
  --teal: #2dd4bf;
  --violet: #a78bfa;
  --pink: #f472b6;
  --amber: #fbbf24;
  --green: #86efac;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -15%, rgba(103, 232, 249, 0.11), transparent 34rem),
    radial-gradient(circle at 100% 45%, rgba(167, 139, 250, 0.08), transparent 30rem),
    linear-gradient(180deg, #080d19 0%, #070b16 55%, #060a13 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

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

[hidden] {
  display: none !important;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.13;
  pointer-events: none;
}

.page-glow-one {
  top: 8%;
  left: -16rem;
  background: var(--cyan);
}

.page-glow-two {
  right: -18rem;
  bottom: 4%;
  background: var(--violet);
}

.app-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(103, 232, 249, 0.12), rgba(167, 139, 250, 0.08));
  box-shadow: inset 0 0 20px rgba(103, 232, 249, 0.05), 0 0 24px rgba(103, 232, 249, 0.06);
}

.brand-mark svg {
  width: 29px;
  height: 29px;
  overflow: visible;
  fill: none;
  stroke: var(--cyan);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.8;
}

.brand-mark circle {
  fill: var(--amber);
  stroke: none;
}

.brand-name {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.brand-name span {
  margin-left: 5px;
  color: var(--cyan);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button,
.quiet-button,
.secondary-button,
.primary-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.58);
}

.icon-button svg,
.quiet-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-button:hover,
.quiet-button:hover,
.secondary-button:hover:not(:disabled) {
  border-color: rgba(103, 232, 249, 0.34);
  color: var(--text);
  background: rgba(30, 41, 59, 0.72);
}

.icon-button:active,
.quiet-button:active,
.secondary-button:active:not(:disabled),
.primary-button:active {
  transform: translateY(1px);
}

.sound-off-icon {
  display: none;
}

.icon-button[aria-pressed="false"] .sound-on-icon {
  display: none;
}

.icon-button[aria-pressed="false"] .sound-off-icon {
  display: block;
}

.quiet-button {
  min-height: 42px;
  padding: 0 15px;
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.58);
  font-size: 13px;
  font-weight: 650;
}

.hero {
  display: flex;
  gap: 32px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 48px 0 34px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 13px;
  color: var(--muted-strong);
}

.eyebrow span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.hero h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 49px);
  font-weight: 730;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.hero h1 em {
  color: var(--cyan);
  font-style: normal;
  text-shadow: 0 0 32px rgba(103, 232, 249, 0.22);
}

.hero-progress {
  width: 220px;
  flex: 0 0 auto;
  padding-bottom: 4px;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.progress-copy strong {
  color: var(--muted-strong);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.progress-track {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.12);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  box-shadow: 0 0 14px rgba(103, 232, 249, 0.55);
  transition: width 400ms ease;
}

.game-layout {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr) 248px;
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(17, 26, 45, 0.78), rgba(9, 14, 26, 0.76));
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
}

.level-panel,
.guide-panel {
  padding: 21px;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.panel-heading h2,
.board-header h2 {
  margin: 6px 0 0;
  font-size: 20px;
  font-weight: 690;
  letter-spacing: -0.025em;
}

.count-badge {
  display: grid;
  min-width: 31px;
  height: 25px;
  padding: 0 7px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.level-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.level-button {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.level-button:hover {
  color: var(--muted-strong);
  background: rgba(148, 163, 184, 0.055);
}

.level-button.active {
  border-color: rgba(103, 232, 249, 0.22);
  color: var(--text);
  background: linear-gradient(100deg, rgba(103, 232, 249, 0.11), rgba(103, 232, 249, 0.025));
}

.level-number {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.32);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.level-button.active .level-number {
  border-color: rgba(103, 232, 249, 0.4);
  color: var(--cyan);
  box-shadow: inset 0 0 14px rgba(103, 232, 249, 0.07);
}

.level-name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 640;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-state {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
}

.level-button.completed .level-state {
  color: var(--green);
}

.level-tip {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 19px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.level-tip p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.tip-orbit {
  position: relative;
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid rgba(103, 232, 249, 0.32);
  border-radius: 50%;
}

.tip-orbit::after {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  content: "";
}

.board-area {
  min-width: 0;
}

.board-header {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 53px;
  margin-bottom: 14px;
  padding: 0 3px;
}

.board-header h2 {
  font-size: 25px;
}

.metrics {
  display: flex;
  gap: 7px;
}

.metric {
  min-width: 61px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(12, 19, 34, 0.62);
  text-align: center;
}

.metric span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.metric-lit strong {
  color: var(--cyan);
}

.board-frame {
  position: relative;
  padding: clamp(12px, 2vw, 20px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(103, 232, 249, 0.055), transparent 55%),
    linear-gradient(145deg, rgba(17, 26, 45, 0.92), rgba(7, 12, 23, 0.94));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.board-frame::before {
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(148, 163, 184, 0.05);
  border-radius: 22px;
  content: "";
  pointer-events: none;
}

.board-corner {
  position: absolute;
  z-index: 2;
  width: 17px;
  height: 17px;
  border-color: rgba(103, 232, 249, 0.34);
  pointer-events: none;
}

.corner-tl {
  top: 11px;
  left: 11px;
  border-top: 1px solid;
  border-left: 1px solid;
  border-top-left-radius: 5px;
}

.corner-tr {
  top: 11px;
  right: 11px;
  border-top: 1px solid;
  border-right: 1px solid;
  border-top-right-radius: 5px;
}

.corner-bl {
  bottom: 11px;
  left: 11px;
  border-bottom: 1px solid;
  border-left: 1px solid;
  border-bottom-left-radius: 5px;
}

.corner-br {
  right: 11px;
  bottom: 11px;
  border-right: 1px solid;
  border-bottom: 1px solid;
  border-bottom-right-radius: 5px;
}

.board {
  --cols: 4;
  --rows: 4;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: clamp(5px, 0.8vw, 9px);
  width: min(100%, 570px);
  margin: 0 auto;
  aspect-ratio: 1;
  touch-action: manipulation;
}

.tile {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: clamp(9px, 1.3vw, 15px);
  color: #34425c;
  background:
    radial-gradient(circle at 50% 45%, rgba(148, 163, 184, 0.055), transparent 65%),
    linear-gradient(145deg, rgba(24, 35, 56, 0.86), rgba(12, 19, 33, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 5px 13px rgba(0, 0, 0, 0.13);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 150ms ease;
}

.tile::after {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(148, 163, 184, 0.04);
  border-radius: calc(clamp(9px, 1.3vw, 15px) - 4px);
  content: "";
  pointer-events: none;
}

.tile:hover:not(.source) {
  z-index: 1;
  border-color: rgba(103, 232, 249, 0.27);
  transform: translateY(-2px);
}

.tile:active:not(.source) {
  transform: translateY(0) scale(0.975);
}

.tile-pipes {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(var(--rotation, 0deg));
  transition: transform 190ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.tile-pipes .pipe {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 9;
  transition: stroke 220ms ease, filter 220ms ease;
}

.tile-pipes .node {
  fill: #111a2b;
  stroke: currentColor;
  stroke-width: 5;
  transition: fill 220ms ease, stroke 220ms ease;
}

.tile-pipes .goal-ring {
  fill: none;
  stroke: var(--pink);
  stroke-width: 2.5;
  opacity: 0.62;
  transition: opacity 220ms ease, stroke 220ms ease;
}

.tile.powered {
  border-color: rgba(103, 232, 249, 0.25);
  color: var(--cyan);
  background:
    radial-gradient(circle at 50% 50%, rgba(103, 232, 249, 0.14), transparent 68%),
    linear-gradient(145deg, rgba(20, 48, 62, 0.88), rgba(10, 27, 39, 0.92));
  box-shadow: inset 0 0 22px rgba(103, 232, 249, 0.05), 0 0 18px rgba(103, 232, 249, 0.045);
}

.tile.powered .pipe {
  filter: drop-shadow(0 0 4px rgba(103, 232, 249, 0.72));
}

.tile.powered .node {
  fill: #d9fbff;
  stroke: var(--cyan);
}

.tile.powered .goal-ring {
  stroke: var(--green);
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(134, 239, 172, 0.75));
}

.tile.source {
  border-color: rgba(251, 191, 36, 0.38);
  color: var(--amber);
  background:
    radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0.19), transparent 66%),
    linear-gradient(145deg, rgba(58, 43, 20, 0.92), rgba(28, 23, 17, 0.94));
  box-shadow: inset 0 0 24px rgba(251, 191, 36, 0.07), 0 0 22px rgba(251, 191, 36, 0.08);
  cursor: default;
}

.tile.source .pipe {
  filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.78));
}

.tile.source .node {
  fill: #fff4c2;
  stroke: var(--amber);
  stroke-width: 6;
}

.source-badge {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid rgba(251, 191, 36, 0.26);
  border-radius: 6px;
  color: var(--amber);
  background: rgba(7, 11, 22, 0.62);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
  font-weight: 800;
}

.tile.hint {
  animation: hint-pulse 850ms ease-in-out 3;
}

@keyframes hint-pulse {
  0%,
  100% {
    border-color: rgba(167, 139, 250, 0.25);
    box-shadow: 0 0 0 rgba(167, 139, 250, 0);
  }
  50% {
    border-color: rgba(167, 139, 250, 0.95);
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.12), 0 0 24px rgba(167, 139, 250, 0.2);
  }
}

.win-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: grid;
  padding: 22px;
  place-items: center;
  border-radius: 28px;
  background: rgba(4, 8, 17, 0.7);
  backdrop-filter: blur(10px);
  animation: overlay-in 260ms ease both;
}

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

.win-card {
  width: min(360px, 100%);
  padding: 30px 26px 25px;
  border: 1px solid rgba(103, 232, 249, 0.23);
  border-radius: 23px;
  background:
    radial-gradient(circle at 50% 0%, rgba(103, 232, 249, 0.12), transparent 55%),
    linear-gradient(160deg, rgba(20, 32, 53, 0.98), rgba(9, 15, 28, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
  animation: card-in 380ms cubic-bezier(0.2, 0.9, 0.2, 1.15) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.win-symbol {
  display: grid;
  width: 57px;
  height: 57px;
  margin: 0 auto 17px;
  place-items: center;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 18px;
  background: rgba(251, 191, 36, 0.08);
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.1);
}

.win-symbol svg {
  width: 30px;
  height: 30px;
  fill: var(--amber);
  filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

.win-card h3 {
  margin: 8px 0 12px;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.stars {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 15px 0 11px;
}

.star {
  width: 27px;
  height: 27px;
  fill: rgba(148, 163, 184, 0.15);
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 1.2;
}

.star.earned {
  fill: var(--amber);
  stroke: #fde68a;
  filter: drop-shadow(0 0 7px rgba(251, 191, 36, 0.4));
  animation: star-in 420ms cubic-bezier(0.2, 0.9, 0.2, 1.3) both;
}

.star:nth-child(2) { animation-delay: 90ms; }
.star:nth-child(3) { animation-delay: 180ms; }

@keyframes star-in {
  from { opacity: 0; transform: scale(0.4) rotate(-20deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

.win-summary {
  margin: 0 0 21px;
  color: var(--muted-strong);
  font-size: 12px;
  line-height: 1.6;
}

.win-actions {
  display: flex;
  gap: 9px;
  justify-content: center;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  padding: 0 15px;
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  border-color: rgba(103, 232, 249, 0.42);
  color: #041018;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.14);
}

.primary-button:hover {
  background: linear-gradient(135deg, #a5f3fc, #5eead4);
  box-shadow: 0 10px 30px rgba(45, 212, 191, 0.22);
}

.secondary-button {
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.64);
}

.board-controls {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 3px;
}

.control-buttons {
  display: flex;
  gap: 7px;
}

.keyboard-hint {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.keyboard-hint span {
  margin: 0 4px;
  color: #475569;
}

kbd {
  display: inline-grid;
  min-width: 20px;
  min-height: 19px;
  padding: 1px 5px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-bottom-color: rgba(148, 163, 184, 0.34);
  border-radius: 5px;
  color: var(--muted-strong);
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 600;
}

.guide-icon {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  color: var(--amber);
  background: rgba(251, 191, 36, 0.055);
}

.guide-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.steps {
  display: grid;
  gap: 19px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
}

.step-number {
  padding-top: 2px;
  color: var(--cyan);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
}

.steps strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
}

.steps p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 11px 14px;
  margin-top: 23px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.legend > div {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 9px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.source-swatch {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}

.goal-swatch {
  border: 1px solid var(--pink);
  background: transparent;
}

.live-swatch {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(103, 232, 249, 0.6);
}

.keyboard-card {
  margin-top: 17px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.24);
}

.keyboard-card p {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 650;
}

.keyboard-card > div {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 7px;
}

.keyboard-card span {
  margin: 0 7px 0 3px;
  color: var(--muted);
  font-size: 9px;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 38px;
  padding: 22px 0 28px;
  border-top: 1px solid var(--line);
  color: #64748b;
  font-size: 10px;
}

.footer-status {
  display: flex;
  gap: 7px;
  align-items: center;
}

.footer-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(134, 239, 172, 0.5);
}

.toast {
  position: fixed;
  z-index: 30;
  bottom: 25px;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 12px;
  color: var(--text);
  background: rgba(20, 27, 47, 0.96);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.help-dialog {
  width: min(470px, calc(100% - 32px));
  padding: 32px;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 24px;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(103, 232, 249, 0.09), transparent 50%),
    #0d1526;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.help-dialog::backdrop {
  background: rgba(2, 6, 16, 0.74);
  backdrop-filter: blur(7px);
}

.help-dialog h2 {
  margin: 9px 0 12px;
  font-size: 28px;
  letter-spacing: -0.035em;
}

.help-dialog > p:not(.panel-kicker) {
  margin: 0;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.7;
}

.help-dialog ul {
  display: grid;
  gap: 11px;
  margin: 21px 0 25px;
  padding: 0;
  list-style: none;
}

.help-dialog li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.help-dialog li::before {
  position: absolute;
  top: 8px;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(103, 232, 249, 0.5);
  content: "";
}

.help-dialog li strong {
  color: var(--muted-strong);
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 31px;
  height: 31px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.6);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 205px minmax(0, 1fr);
  }

  .guide-panel {
    display: none;
  }

  .hero {
    padding-top: 40px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 28px, 620px);
  }

  .topbar {
    min-height: 76px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
    border-radius: 11px;
  }

  .brand-mark svg {
    width: 25px;
    height: 25px;
  }

  .brand-name {
    font-size: 14px;
  }

  .quiet-button {
    width: 42px;
    padding: 0;
    font-size: 0;
  }

  .quiet-button svg {
    width: 19px;
    height: 19px;
  }

  .hero {
    display: block;
    padding: 32px 0 25px;
  }

  .hero h1 {
    font-size: clamp(29px, 8vw, 42px);
  }

  .hero-progress {
    width: 100%;
    margin-top: 23px;
  }

  .game-layout {
    display: flex;
    flex-direction: column;
    gap: 17px;
  }

  .level-panel {
    width: 100%;
    padding: 14px;
    border-radius: 18px;
    order: 2;
  }

  .level-panel .panel-heading,
  .level-tip {
    display: none;
  }

  .level-list {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .level-list li {
    flex: 0 0 auto;
  }

  .level-button {
    display: flex;
    width: auto;
    min-width: 44px;
    padding: 7px;
  }

  .level-name,
  .level-state {
    display: none;
  }

  .level-number {
    width: 28px;
    height: 28px;
  }

  .board-area {
    width: 100%;
    order: 1;
  }

  .board-header {
    gap: 10px;
    align-items: center;
    margin-bottom: 11px;
  }

  .board-header h2 {
    font-size: 21px;
  }

  .metric {
    min-width: 50px;
    padding: 7px 8px;
  }

  .metric strong {
    font-size: 12px;
  }

  .board-frame {
    border-radius: 22px;
  }

  .board-frame::before {
    border-radius: 17px;
  }

  .win-overlay {
    border-radius: 22px;
  }

  .board-controls {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .control-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .control-buttons .secondary-button {
    padding: 0 10px;
  }

  .keyboard-hint {
    text-align: center;
  }

  footer {
    margin-top: 27px;
  }

  .footer-status {
    display: none;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: calc(100% - 20px);
  }

  .top-actions {
    gap: 7px;
  }

  .hero {
    padding-top: 27px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .metrics {
    gap: 4px;
  }

  .metric {
    min-width: 45px;
    padding: 6px;
  }

  .metric span {
    font-size: 7px;
  }

  .board-frame {
    padding: 10px;
  }

  .board {
    gap: 5px;
  }

  .tile {
    border-radius: 9px;
  }

  .tile::after {
    inset: 3px;
    border-radius: 6px;
  }

  .tile-pipes .pipe {
    stroke-width: 10;
  }

  .source-badge {
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    font-size: 7px;
  }

  .win-card {
    padding: 23px 18px 20px;
  }

  .win-card h3 {
    font-size: 22px;
  }

  .win-symbol {
    width: 48px;
    height: 48px;
    margin-bottom: 13px;
  }

  .help-dialog {
    padding: 27px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
