:root {
  --bg: #070a11;
  --panel: rgba(13, 21, 34, 0.82);
  --line: rgba(93, 120, 158, 0.18);
  --text: #e9f0fb;
  --muted: #8ea1ba;
  --faint: #61758f;
  --cyan: #22d3ee;
  --cyan-bright: #67e8f9;
  --mint: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius: 20px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body[data-screen="game"] {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(34, 211, 238, 0.28);
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 720px at 50% -12%, #0c1a2b 0%, transparent 62%),
    linear-gradient(180deg, #070a11 0%, #080c14 58%, #060910 100%);
}

.ambient-grid {
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(103, 232, 249, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 232, 249, 0.055) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 72% 62% at 50% 38%, #000 22%, transparent 76%);
  mask-image: radial-gradient(ellipse 72% 62% at 50% 38%, #000 22%, transparent 76%);
  opacity: 0.7;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.22;
  pointer-events: none;
}

.orb-a {
  width: 520px;
  height: 520px;
  left: -12%;
  top: 6%;
  background: #0891b2;
}

.orb-b {
  width: 460px;
  height: 460px;
  right: -10%;
  top: 34%;
  background: #7c3aed;
  opacity: 0.14;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 54px) 18px;
}

body[data-screen="game"] .app {
  height: 100dvh;
}

.topbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 22px;
  height: 56px;
}

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

.brand:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 24px rgba(34, 211, 238, 0.08);
}

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

.brand-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.brand-text b {
  color: var(--cyan);
}

.topbar-meta {
  margin-left: 8px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.theme-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 21, 34, 0.55);
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.theme-toggle:hover {
  color: var(--cyan);
  border-color: rgba(103, 232, 249, 0.32);
  background: rgba(18, 30, 48, 0.75);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-icon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun,
html[data-theme="light"] .theme-icon-moon {
  display: block;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 5px 4px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 21, 34, 0.7);
}

.user-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  overflow: hidden;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  background: #132033;
  object-fit: cover;
}

.user-name {
  max-width: 140px;
  overflow: hidden;
  color: #cddcf0;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-logout {
  padding: 4px 6px;
  color: var(--faint);
  font-size: 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.user-logout:hover {
  color: var(--rose);
  background: rgba(251, 113, 133, 0.08);
}

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.screen {
  flex: 1;
  min-height: 0;
}

.menu-screen {
  display: flex;
  flex-direction: column;
  gap: clamp(26px, 4.5vh, 48px);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(26px, 6vh, 64px) 0 30px;
  animation: screenIn 0.5s ease both;
}

.hero {
  max-width: 880px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
  animation: pulse 2.2s infinite;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 6.2vw, 86px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

h1 span {
  color: transparent;
  background: linear-gradient(92deg, #e9f0fb 0%, #67e8f9 46%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-copy {
  max-width: 600px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.25vw, 16px);
  line-height: 1.75;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.hero-tags span {
  padding: 6px 10px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(13, 21, 34, 0.5);
}

.menu-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(16, 27, 45, 0.86), rgba(8, 13, 22, 0.94));
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.panel-heading span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.difficulty-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-card {
  height: 94px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.02) 30%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.02) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.difficulty-card {
  position: relative;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  overflow: hidden;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 17, 29, 0.7);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.difficulty-card::after {
  position: absolute;
  right: -20%;
  bottom: -60%;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--diff-glow);
  filter: blur(40px);
  opacity: 0;
  pointer-events: none;
  content: "";
  transition: opacity 0.25s ease;
}

.difficulty-card:hover,
.difficulty-card:focus-visible {
  border-color: var(--diff-line);
  outline: none;
  background: rgba(13, 23, 39, 0.95);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.difficulty-card:hover::after,
.difficulty-card:focus-visible::after {
  opacity: 0.28;
}

.difficulty-card[data-difficulty="easy"] {
  --diff: #34d399;
  --diff-glow: rgba(52, 211, 153, 0.5);
  --diff-line: rgba(52, 211, 153, 0.4);
}

.difficulty-card[data-difficulty="normal"] {
  --diff: #22d3ee;
  --diff-glow: rgba(34, 211, 238, 0.5);
  --diff-line: rgba(34, 211, 238, 0.4);
}

.difficulty-card[data-difficulty="hard"] {
  --diff: #fb7185;
  --diff-glow: rgba(251, 113, 133, 0.48);
  --diff-line: rgba(251, 113, 133, 0.4);
}

.mini-maze {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 1px;
  width: 64px;
  height: 64px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #070d16;
}

.mini-cell {
  border-radius: 1px;
  background: transparent;
}

.mini-cell.wall {
  background: var(--diff, var(--cyan));
  opacity: 0.48;
}

.mini-cell.start {
  background: #67e8f9;
  opacity: 0.9;
}

.mini-cell.end {
  background: var(--amber);
  opacity: 0.92;
}

.diff-copy {
  min-width: 0;
}

.diff-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.diff-name {
  font-size: 17px;
  font-weight: 700;
}

.diff-size {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.diff-desc {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.diff-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--diff);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  opacity: 0.75;
}

.diff-cta svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.difficulty-card:hover .diff-cta svg {
  transform: translateX(3px);
}

.panel-note {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.6;
}

.lb-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(7, 12, 20, 0.7);
}

.segmented button {
  padding: 5px 9px;
  color: var(--faint);
  font-size: 11.5px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.active {
  color: var(--text);
  background: rgba(34, 211, 238, 0.12);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.2);
}

.segmented.metric button.active {
  color: #04121a;
  font-weight: 700;
  background: var(--cyan);
}

.segmented button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
}

.lb-head,
.lb-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 82px 56px;
  gap: 8px;
  align-items: center;
}

.lb-head {
  padding: 0 8px 8px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.lb-head .lb-col-time,
.lb-head .lb-col-steps {
  text-align: right;
}

.lb-list {
  max-height: 350px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  scrollbar-color: rgba(103, 232, 249, 0.18) transparent;
  scrollbar-width: thin;
}

.lb-list::-webkit-scrollbar {
  width: 6px;
}

.lb-list::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: rgba(103, 232, 249, 0.18);
}

.lb-row {
  padding: 8px;
  font-size: 12.5px;
  border-bottom: 1px solid rgba(93, 120, 158, 0.09);
}

.lb-row:last-child {
  border-bottom: 0;
}

.lb-row:hover {
  background: rgba(103, 232, 249, 0.035);
}

.lb-rank {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
}

.lb-row:nth-child(1) .lb-rank {
  color: var(--amber);
}

.lb-row:nth-child(2) .lb-rank {
  color: #cbd5e1;
}

.lb-row:nth-child(3) .lb-rank {
  color: #d97706;
}

.lb-who {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lb-avatar {
  display: grid;
  width: 22px;
  height: 22px;
  flex: none;
  place-items: center;
  overflow: hidden;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 700;
  border-radius: 50%;
  background: #132033;
  object-fit: cover;
}

.lb-name {
  overflow: hidden;
  color: #c9d7ea;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-time,
.lb-steps {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: right;
}

.lb-list[data-metric="time"] .lb-time,
.lb-list[data-metric="steps"] .lb-steps {
  color: var(--cyan-bright);
  font-weight: 600;
}

.lb-status {
  margin: 12px 0 0;
  color: var(--faint);
  font-size: 11px;
  text-align: center;
}

.lb-status.error {
  color: var(--rose);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn.primary {
  color: #04121a;
  background: linear-gradient(92deg, #22d3ee, #67e8f9);
  border-color: transparent;
  box-shadow: 0 8px 26px rgba(34, 211, 238, 0.22);
}

.btn.primary:not(:disabled):hover {
  box-shadow: 0 12px 32px rgba(34, 211, 238, 0.3);
  transform: translateY(-1px);
}

.btn.primary:disabled {
  color: var(--faint);
  background: rgba(18, 29, 46, 0.9);
  border-color: var(--line);
  box-shadow: none;
}

.btn.solid {
  color: #d9f7ff;
  background: #142338;
  border-color: rgba(103, 232, 249, 0.22);
}

.btn.solid:hover {
  background: #172a44;
  border-color: rgba(103, 232, 249, 0.45);
}

.btn.ghost {
  color: var(--muted);
  background: rgba(13, 21, 34, 0.55);
  border-color: var(--line);
}

.btn.ghost:hover {
  color: var(--text);
  background: rgba(18, 30, 48, 0.75);
  border-color: rgba(103, 232, 249, 0.32);
}

.btn.small {
  padding: 6px 11px;
  font-size: 11px;
  border-radius: 8px;
}

.btn.qq-login {
  padding: 7px 12px;
  background: #ffffff;
  border-color: rgba(64, 90, 122, 0.2);
  box-shadow: 0 2px 10px rgba(2, 6, 23, 0.18);
}

.btn.qq-login:hover {
  background: #f0f9ff;
  border-color: rgba(8, 145, 178, 0.4);
  transform: translateY(-1px);
}

.btn.qq-login img {
  display: block;
  width: auto;
  height: 22px;
}

.btn.qq-login.small {
  padding: 4px 9px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.16);
}

.btn.qq-login.small img {
  height: 18px;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.game-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1180px;
  min-height: 0;
  margin: 0 auto;
  padding: 10px 0 4px;
  animation: screenIn 0.35s ease both;
}

.game-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  flex: none;
  gap: 16px;
  align-items: center;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 17, 29, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.hud-stats {
  display: flex;
  gap: 26px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-item span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.hud-item strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

#hud-time {
  color: var(--cyan-bright);
}

.hud-difficulty {
  justify-self: center;
  padding: 6px 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.hud-actions {
  display: flex;
  justify-self: end;
  gap: 8px;
}

.canvas-wrap {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(93, 120, 158, 0.12);
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(34, 211, 238, 0.05), transparent 60%),
    rgba(6, 10, 17, 0.5);
}

#maze-canvas {
  display: block;
  background: #0a111d;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(103, 232, 249, 0.1);
  touch-action: none;
}

body[data-screen="game"] #maze-canvas {
  cursor: crosshair;
}

.joystick {
  position: fixed;
  z-index: 30;
  width: 136px;
  height: 136px;
  margin: -68px 0 0 -68px;
  pointer-events: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid rgba(103, 232, 249, 0.32);
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(34, 211, 238, 0.14),
    rgba(6, 12, 20, 0.42) 68%,
    rgba(6, 12, 20, 0.2) 100%
  );
  box-shadow:
    0 18px 46px rgba(0, 0, 0, 0.4),
    inset 0 0 28px rgba(34, 211, 238, 0.1);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.joystick::before,
.joystick::after {
  content: "";
  position: absolute;
  background: rgba(103, 232, 249, 0.16);
  border-radius: 999px;
}

.joystick::before {
  top: 14px;
  bottom: 14px;
  left: 50%;
  width: 1px;
  margin-left: -0.5px;
}

.joystick::after {
  top: 50%;
  right: 14px;
  left: 14px;
  height: 1px;
  margin-top: -0.5px;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 36% 30%,
    rgba(207, 250, 254, 0.95),
    rgba(34, 211, 238, 0.92) 46%,
    rgba(8, 145, 178, 0.94) 100%
  );
  box-shadow:
    0 8px 22px rgba(8, 145, 178, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  will-change: transform;
}

html[data-theme="light"] .joystick {
  border-color: rgba(8, 145, 178, 0.3);
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.88),
    rgba(226, 239, 249, 0.74) 68%,
    rgba(226, 239, 249, 0.42) 100%
  );
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.18),
    inset 0 0 24px rgba(8, 145, 178, 0.08);
}

html[data-theme="light"] .joystick::before,
html[data-theme="light"] .joystick::after {
  background: rgba(8, 145, 178, 0.16);
}

html[data-theme="light"] .joystick-knob {
  background: radial-gradient(circle at 36% 30%, #ecfeff, #22d3ee 46%, #0e7490 100%);
  box-shadow:
    0 8px 20px rgba(8, 145, 178, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.game-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  background: rgba(5, 9, 15, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(103, 232, 249, 0.16);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.game-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  color: var(--faint);
  font-size: 11px;
}

.key-hint {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pointer-hint {
  display: inline-flex;
  align-items: center;
}

.touch-hint {
  display: none;
  align-items: center;
  gap: 8px;
}

.touch-dot {
  width: 8px;
  height: 8px;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.45);
}

kbd {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  color: #a9bdd6;
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-bottom-color: rgba(93, 120, 158, 0.3);
  border-radius: 5px;
  background: rgba(16, 26, 43, 0.8);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.hint-sep {
  margin: 0 4px;
  color: rgba(93, 120, 158, 0.5);
}

.hint-label {
  margin-left: 6px;
}

.goal-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.goal-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--amber);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.7);
}

.footer {
  display: flex;
  flex: none;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 2px 0;
  color: rgba(97, 117, 143, 0.55);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 12, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: overlayIn 0.25s ease both;
}

.result-card {
  width: min(560px, 100%);
  padding: clamp(24px, 4vw, 36px);
  text-align: center;
  border: 1px solid rgba(103, 232, 249, 0.22);
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(34, 211, 238, 0.1), transparent 55%),
    linear-gradient(170deg, #101c2d, #090f19 60%);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.6);
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.result-card .eyebrow {
  justify-content: center;
  margin-bottom: 10px;
}

.result-card h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.03em;
}

.result-stats {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 10px;
  margin: 24px 0 18px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 13, 22, 0.55);
}

.result-stat span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.result-stat strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-stat.primary {
  border-color: rgba(34, 211, 238, 0.3);
  background: rgba(34, 211, 238, 0.06);
}

.result-stat.primary strong {
  color: var(--cyan-bright);
  font-size: clamp(18px, 3.2vw, 24px);
}

.result-rank {
  margin: 0 0 16px;
  padding: 10px 14px;
  color: #a7f3d0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.07);
}

.submit-zone {
  padding: 16px 0 4px;
  border-top: 1px solid var(--line);
}

.submit-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.submit-row .btn.primary {
  min-width: 180px;
}

.submit-hint {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.result-actions .btn {
  min-width: 130px;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 80;
  max-width: min(90vw, 520px);
  padding: 11px 16px;
  color: var(--text);
  font-size: 12.5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 21, 34, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast[data-type="error"] {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.4);
}

.toast[data-type="success"] {
  color: #bbf7d0;
  border-color: rgba(52, 211, 153, 0.35);
}

noscript {
  display: block;
  padding: 24px;
  color: var(--text);
  text-align: center;
}

/* Light theme */

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7fc;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(64, 90, 122, 0.16);
  --text: #101d2e;
  --muted: #55677e;
  --faint: #7b8ba0;
  --cyan: #0e93b0;
  --cyan-bright: #0e7490;
  --mint: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --shadow: 0 24px 64px rgba(30, 41, 59, 0.12);
}

html[data-theme="light"] ::selection {
  background: rgba(14, 147, 176, 0.22);
}

html[data-theme="light"] .ambient {
  background:
    radial-gradient(1200px 720px at 50% -12%, #dff3fb 0%, transparent 62%),
    linear-gradient(180deg, #f8fbff 0%, #eef5fc 58%, #e8f0f9 100%);
}

html[data-theme="light"] .ambient-grid {
  background-image:
    linear-gradient(rgba(14, 147, 176, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 147, 176, 0.09) 1px, transparent 1px);
  opacity: 0.8;
}

html[data-theme="light"] .orb-a {
  background: #bae6fd;
  opacity: 0.5;
}

html[data-theme="light"] .orb-b {
  background: #ddd6fe;
  opacity: 0.35;
}

html[data-theme="light"] .brand-mark {
  border-color: rgba(8, 145, 178, 0.26);
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.18), rgba(255, 255, 255, 0.6));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 6px 18px rgba(8, 145, 178, 0.12);
}

html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .theme-toggle:hover {
  color: var(--cyan);
  border-color: rgba(8, 145, 178, 0.3);
  background: #eef8fc;
}

html[data-theme="light"] .user-chip {
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .user-avatar {
  background: #dbeafe;
}

html[data-theme="light"] .user-name {
  color: #26384d;
}

html[data-theme="light"] h1 span {
  background: linear-gradient(92deg, #0f172a 0%, #0e7490 52%, #0891b2 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="light"] .hero-tags span {
  background: rgba(255, 255, 255, 0.62);
}

html[data-theme="light"] .panel {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.94), rgba(243, 248, 253, 0.9));
}

html[data-theme="light"] .skeleton-card {
  background: linear-gradient(100deg, rgba(15, 23, 42, 0.03) 30%, rgba(15, 23, 42, 0.07) 50%, rgba(15, 23, 42, 0.03) 70%);
  background-size: 200% 100%;
}

html[data-theme="light"] .difficulty-card {
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .difficulty-card:hover,
html[data-theme="light"] .difficulty-card:focus-visible {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 30px rgba(30, 41, 59, 0.1);
}

html[data-theme="light"] .difficulty-card:hover::after,
html[data-theme="light"] .difficulty-card:focus-visible::after {
  opacity: 0.16;
}

html[data-theme="light"] .difficulty-card[data-difficulty="easy"] {
  --diff: #059669;
}

html[data-theme="light"] .difficulty-card[data-difficulty="normal"] {
  --diff: #0891b2;
}

html[data-theme="light"] .difficulty-card[data-difficulty="hard"] {
  --diff: #e11d48;
}

html[data-theme="light"] .mini-maze {
  background: #eef4fb;
}

html[data-theme="light"] .mini-cell.wall {
  opacity: 0.55;
}

html[data-theme="light"] .mini-cell.start {
  background: #0891b2;
}

html[data-theme="light"] .segmented {
  background: rgba(236, 243, 250, 0.85);
}

html[data-theme="light"] .segmented button.active {
  background: rgba(8, 145, 178, 0.12);
  box-shadow: inset 0 0 0 1px rgba(8, 145, 178, 0.22);
}

html[data-theme="light"] .segmented.metric button.active {
  color: #04121a;
  background: var(--cyan);
  box-shadow: none;
}

html[data-theme="light"] .lb-list {
  scrollbar-color: rgba(8, 145, 178, 0.28) transparent;
}

html[data-theme="light"] .lb-list::-webkit-scrollbar-thumb {
  background: rgba(8, 145, 178, 0.28);
}

html[data-theme="light"] .lb-row {
  border-bottom-color: rgba(64, 90, 122, 0.1);
}

html[data-theme="light"] .lb-row:hover {
  background: rgba(8, 145, 178, 0.05);
}

html[data-theme="light"] .lb-row:nth-child(2) .lb-rank {
  color: #64748b;
}

html[data-theme="light"] .lb-row:nth-child(3) .lb-rank {
  color: #b45309;
}

html[data-theme="light"] .lb-avatar {
  background: #dbeafe;
}

html[data-theme="light"] .lb-name {
  color: #26384d;
}

html[data-theme="light"] .btn.primary:disabled {
  background: rgba(226, 232, 240, 0.9);
}

html[data-theme="light"] .btn.solid {
  color: #0e7490;
  background: #e0f2fe;
  border-color: rgba(8, 145, 178, 0.25);
}

html[data-theme="light"] .btn.solid:hover {
  background: #bae6fd;
  border-color: rgba(8, 145, 178, 0.45);
}

html[data-theme="light"] .btn.ghost {
  background: rgba(255, 255, 255, 0.7);
}

html[data-theme="light"] .btn.ghost:hover {
  background: rgba(240, 249, 255, 0.95);
  border-color: rgba(8, 145, 178, 0.3);
}

html[data-theme="light"] .btn.qq-login {
  background: #ffffff;
  border-color: rgba(64, 90, 122, 0.18);
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.08);
}

html[data-theme="light"] .btn.qq-login:hover {
  background: #f5fbff;
  border-color: rgba(8, 145, 178, 0.35);
}

html[data-theme="light"] .game-hud {
  background: rgba(255, 255, 255, 0.78);
}

html[data-theme="light"] .canvas-wrap {
  border-color: rgba(64, 90, 122, 0.14);
  background:
    radial-gradient(ellipse at 50% 40%, rgba(8, 145, 178, 0.06), transparent 60%),
    rgba(240, 246, 252, 0.7);
}

html[data-theme="light"] #maze-canvas {
  background: #f8fbfe;
  box-shadow: 0 22px 55px rgba(30, 41, 59, 0.14), 0 0 0 1px rgba(8, 145, 178, 0.14);
}

html[data-theme="light"] .game-loading {
  background: rgba(244, 249, 254, 0.78);
}

html[data-theme="light"] .spinner {
  border-color: rgba(8, 145, 178, 0.18);
  border-top-color: var(--cyan);
}

html[data-theme="light"] kbd {
  color: #43566d;
  border-bottom-color: rgba(64, 90, 122, 0.28);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .hint-sep {
  color: rgba(64, 90, 122, 0.45);
}

html[data-theme="light"] .footer {
  color: rgba(71, 85, 105, 0.65);
}

html[data-theme="light"] .overlay {
  background: rgba(226, 236, 247, 0.7);
}

html[data-theme="light"] .result-card {
  border-color: rgba(8, 145, 178, 0.22);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(8, 145, 178, 0.07), transparent 55%),
    linear-gradient(170deg, #ffffff, #f1f7fc 60%);
  box-shadow: 0 40px 100px rgba(30, 41, 59, 0.18);
}

html[data-theme="light"] .result-stat {
  background: rgba(241, 246, 252, 0.8);
}

html[data-theme="light"] .result-stat.primary {
  border-color: rgba(8, 145, 178, 0.3);
  background: rgba(8, 145, 178, 0.06);
}

html[data-theme="light"] .result-rank {
  color: #047857;
  border-color: rgba(5, 150, 105, 0.28);
  background: rgba(5, 150, 105, 0.08);
}

html[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 45px rgba(30, 41, 59, 0.16);
}

html[data-theme="light"] .toast[data-type="error"] {
  color: #be123c;
  border-color: rgba(225, 29, 72, 0.35);
}

html[data-theme="light"] .toast[data-type="success"] {
  color: #047857;
  border-color: rgba(5, 150, 105, 0.35);
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes overlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 10px var(--cyan);
  }
  50% {
    opacity: 0.45;
    box-shadow: 0 0 4px var(--cyan);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (max-width: 980px) {
  .menu-grid {
    grid-template-columns: 1fr;
  }

  .menu-screen {
    padding-top: 32px;
  }

  .topbar-meta {
    display: none;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 14px 14px 12px;
  }

  body[data-screen="game"] .app {
    padding-bottom: 10px;
  }

  .topbar {
    height: 48px;
  }

  .brand-text {
    font-size: 13px;
  }

  .menu-screen {
    gap: 24px;
    padding-top: 22px;
  }

  .hero-copy {
    margin-top: 16px;
    font-size: 13.5px;
  }

  .hero-tags {
    margin-top: 18px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .difficulty-card {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 12px;
  }

  .mini-maze {
    width: 50px;
    height: 50px;
  }

  .diff-name {
    font-size: 15px;
  }

  .diff-desc {
    font-size: 11.5px;
  }

  .diff-cta span {
    display: none;
  }

  .lb-list {
    max-height: 290px;
  }

  .game-hud {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px 12px;
  }

  .hud-stats {
    gap: 18px;
  }

  .hud-item strong {
    font-size: 17px;
  }

  .hud-difficulty {
    grid-row: 2;
    grid-column: 1 / -1;
    justify-self: start;
    padding: 4px 9px;
    font-size: 9px;
  }

  .hud-actions {
    grid-row: 1;
    grid-column: 2;
  }

  .game-footer {
    font-size: 10px;
  }

  .goal-hint {
    display: none;
  }

  .pointer-hint {
    display: none;
  }

  .result-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .result-stat.primary {
    grid-column: 1 / -1;
  }

  .footer {
    display: none;
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 38px;
  }

  .eyebrow {
    font-size: 9px;
  }

  .segmented button {
    padding: 5px 7px;
  }

  .lb-head,
  .lb-row {
    grid-template-columns: 24px minmax(0, 1fr) 70px 44px;
    gap: 6px;
  }

  .submit-row .btn.primary {
    flex: 1;
    min-width: 0;
  }
}

@media (hover: none) and (pointer: coarse) {
  .key-hint {
    display: none;
  }

  .touch-hint {
    display: inline-flex;
  }
}

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