:root {
  --bg: #05080d;
  --panel: #08131a;
  --panel-deep: #071018;
  --ink: #ecfff7;
  --muted: #86a39e;
  --muted-dim: #5d7774;
  --mint: #8dffb5;
  --aqua: #38f0c8;
  --lime: #c9ff6b;
  --coral: #ff7a5c;
  --line: rgba(142, 255, 211, 0.14);
  --line-strong: rgba(142, 255, 211, 0.24);
  --font-ui: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

html {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse at 18% 12%, rgba(30, 224, 165, 0.1), transparent 44%),
    radial-gradient(ellipse at 84% 88%, rgba(255, 106, 86, 0.08), transparent 42%),
    linear-gradient(160deg, #04070b 0%, #060d12 48%, #04070b 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(182, 255, 222, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(182, 255, 222, 0.025) 1px, transparent 1px);
  background-size: 62px 62px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 5%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 50%, #000 5%, transparent 78%);
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}

.orb-a {
  top: -18vmax;
  left: -12vmax;
  width: 46vmax;
  height: 46vmax;
  background: rgba(26, 205, 148, 0.2);
  animation: drift-a 20s ease-in-out infinite alternate;
}

.orb-b {
  right: -16vmax;
  bottom: -22vmax;
  width: 50vmax;
  height: 50vmax;
  background: rgba(255, 92, 74, 0.14);
  animation: drift-b 24s ease-in-out infinite alternate;
}

.orb-c {
  top: 38%;
  left: 46%;
  width: 24vmax;
  height: 24vmax;
  background: rgba(65, 240, 210, 0.07);
  animation: drift-c 16s ease-in-out infinite alternate;
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(92vw, 1100px);
  aspect-ratio: 1.6;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 1.35vw, 18px);
  border: 1px solid rgba(150, 255, 216, 0.16);
  border-radius: clamp(22px, 2.35vw, 32px);
  background:
    radial-gradient(ellipse at 26% -12%, rgba(152, 255, 178, 0.11), transparent 45%),
    linear-gradient(180deg, rgba(13, 28, 35, 0.97) 0%, rgba(6, 13, 20, 0.985) 72%);
  box-shadow:
    0 42px 110px rgba(0, 0, 0, 0.72),
    0 8px 30px rgba(0, 0, 0, 0.5),
    0 0 90px rgba(34, 231, 181, 0.06),
    inset 0 1px 0 rgba(214, 255, 235, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6);
  isolation: isolate;
  animation: shell-in 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(198, 255, 120, 0.08), transparent 26%),
    radial-gradient(circle at 86% 100%, rgba(50, 240, 200, 0.08), transparent 34%);
}

.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.4vw, 16px);
  padding: 2px 4px clamp(8px, 1vw, 12px);
}

.brand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  flex: 0 0 auto;
  width: clamp(28px, 2.7vw, 36px);
  height: clamp(28px, 2.7vw, 36px);
  display: grid;
  place-items: center;
  color: var(--lime);
  border: 1px solid rgba(201, 255, 107, 0.28);
  border-radius: 11px;
  background:
    radial-gradient(circle at 35% 25%, rgba(201, 255, 107, 0.18), transparent 65%),
    rgba(12, 27, 29, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 24px rgba(157, 255, 144, 0.08);
}

.brand-mark svg {
  width: 66%;
  height: 66%;
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-name {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(10px, 1.04vw, 14px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.19em;
  color: #ddfff0;
  white-space: nowrap;
}

.brand-sub {
  font-size: clamp(8px, 0.76vw, 10px);
  line-height: 1.1;
  letter-spacing: 0.28em;
  color: var(--muted-dim);
  white-space: nowrap;
}

.hud-scores {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.score-pill {
  min-width: clamp(58px, 5.6vw, 78px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 5px clamp(8px, 0.9vw, 13px) 6px;
  border: 1px solid rgba(142, 255, 211, 0.12);
  border-radius: 12px;
  background: rgba(5, 15, 19, 0.62);
  box-shadow: inset 0 1px 0 rgba(210, 255, 238, 0.04);
}

.score-label {
  font-size: clamp(7px, 0.64vw, 9px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.2em;
  color: var(--muted-dim);
}

.score-value,
.best-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.08;
}

.score-value {
  font-size: clamp(20px, 2.15vw, 30px);
  font-weight: 700;
  color: var(--lime);
  text-shadow: 0 0 20px rgba(201, 255, 107, 0.28);
}

.best-value {
  font-size: clamp(16px, 1.55vw, 21px);
  font-weight: 600;
  color: #d8f2e8;
}

.score-value.bump {
  animation: score-bump 0.34s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.best-value.flash {
  animation: best-flash 0.6s ease;
}

.hud-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-btn {
  width: clamp(32px, 2.8vw, 38px);
  height: clamp(32px, 2.8vw, 38px);
  display: grid;
  place-items: center;
  padding: 0;
  color: #b9d6ce;
  border: 1px solid rgba(142, 255, 211, 0.13);
  border-radius: 11px;
  background: rgba(8, 20, 24, 0.72);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn .icon-play {
  display: none;
}

.icon-btn:hover:not(:disabled) {
  color: var(--lime);
  border-color: rgba(201, 255, 107, 0.34);
  background: rgba(20, 39, 34, 0.9);
  transform: translateY(-1px);
}

.icon-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.96);
}

.icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.icon-btn.is-paused .icon-pause {
  display: none;
}

.icon-btn.is-paused .icon-play {
  display: block;
}

.board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(142, 255, 211, 0.12);
  border-radius: clamp(14px, 1.3vw, 19px);
  background-color: var(--panel-deep);
  background-image:
    radial-gradient(circle at 48% 46%, rgba(27, 220, 171, 0.095), transparent 62%),
    radial-gradient(circle at 82% 88%, rgba(255, 117, 89, 0.045), transparent 38%),
    linear-gradient(rgba(166, 232, 216, 0.043) 1px, transparent 1px),
    linear-gradient(90deg, rgba(166, 232, 216, 0.043) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 44px 44px, 44px 44px;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 58px rgba(0, 0, 0, 0.56),
    inset 0 0 0 1px rgba(207, 255, 235, 0.045);
}

.board-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4, 10, 14, 0.22), transparent 16%, transparent 84%, rgba(4, 10, 14, 0.28));
}

.board-wrap.is-playing {
  cursor: none;
}

.board-wrap.is-playing:active {
  cursor: none;
}

.board-wrap.is-hit canvas {
  animation: board-hit 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 2.6vw, 34px);
  background:
    radial-gradient(circle at 50% 46%, rgba(8, 22, 25, 0.32), rgba(3, 8, 13, 0.72) 74%),
    rgba(3, 8, 13, 0.34);
  -webkit-backdrop-filter: blur(7px) saturate(0.82);
  backdrop-filter: blur(7px) saturate(0.82);
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
}

.overlay-panel {
  width: min(100%, 530px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1vw, 13px);
  text-align: center;
  transform: translateY(0);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.overlay.is-hidden .overlay-panel {
  transform: translateY(9px);
}

.overlay-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid rgba(142, 255, 211, 0.17);
  border-radius: 999px;
  background: rgba(5, 18, 19, 0.66);
  font-family: var(--font-mono);
  font-size: clamp(8px, 0.72vw, 10px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.18em;
  color: #9dc2b8;
  white-space: nowrap;
}

.badge-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px rgba(201, 255, 107, 0.9);
  animation: dot-pulse 1.8s ease-in-out infinite;
}

.overlay-title {
  margin: 0;
  max-width: 100%;
  font-size: clamp(31px, 4.35vw, 58px);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.045em;
  color: #f0fff8;
  text-wrap: balance;
  text-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}

.overlay-text {
  margin: 0;
  max-width: 430px;
  font-size: clamp(12px, 1.03vw, 14px);
  line-height: 1.65;
  color: #9ab8af;
  text-wrap: balance;
}

.overlay-text strong {
  color: var(--lime);
  font-weight: 700;
}

.rule-strip {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: clamp(2px, 0.5vw, 6px);
}

.rule {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  text-align: left;
  border: 1px solid rgba(142, 255, 211, 0.1);
  border-radius: 11px;
  background: rgba(7, 19, 22, 0.54);
}

.rule-icon {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(142, 255, 211, 0.13);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--aqua);
  background: rgba(17, 50, 44, 0.42);
}

.rule-icon-score {
  color: var(--coral);
  border-color: rgba(255, 122, 92, 0.18);
  background: rgba(59, 28, 25, 0.38);
}

.rule b {
  display: block;
  font-size: clamp(9px, 0.78vw, 11px);
  font-weight: 600;
  line-height: 1.3;
  color: #d6eee6;
  white-space: nowrap;
}

.rule small {
  display: block;
  margin-top: 1px;
  font-size: clamp(8px, 0.68vw, 9px);
  line-height: 1.3;
  color: var(--muted-dim);
  white-space: nowrap;
}

.final-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 7px 18px;
  border: 1px solid rgba(201, 255, 107, 0.18);
  border-radius: 14px;
  background: rgba(8, 24, 20, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.final-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.final-value {
  font-family: var(--font-mono);
  font-size: clamp(28px, 3vw, 39px);
  font-weight: 700;
  line-height: 1;
  color: var(--lime);
  text-shadow: 0 0 26px rgba(201, 255, 107, 0.26);
}

.final-best {
  font-size: 10px;
  color: var(--muted-dim);
}

.new-record {
  padding: 4px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #2a130c;
  background: linear-gradient(135deg, #ffd08b, var(--coral));
  box-shadow: 0 0 18px rgba(255, 122, 92, 0.2);
}

.primary-btn {
  position: relative;
  min-width: 176px;
  height: clamp(44px, 4.2vw, 54px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 1px;
  padding: 0 clamp(20px, 2vw, 28px);
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  color: #06150e;
  background: linear-gradient(135deg, #ddff8d 0%, #b9ff70 36%, #51f2c3 100%);
  box-shadow:
    0 15px 35px rgba(67, 242, 174, 0.18),
    0 0 0 1px rgba(235, 255, 176, 0.34) inset,
    0 1px 0 rgba(255, 255, 255, 0.5) inset;
  font-size: clamp(12px, 1.03vw, 14px);
  font-weight: 800;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.primary-btn svg {
  width: 19px;
  height: 19px;
  transition: transform 0.18s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 19px 44px rgba(67, 242, 174, 0.26),
    0 0 0 1px rgba(235, 255, 176, 0.4) inset,
    0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

.primary-btn:hover svg {
  transform: translateX(3px);
}

.primary-btn:active {
  transform: translateY(0) scale(0.985);
}

.primary-btn::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -35%;
  width: 26%;
  height: 220%;
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(22deg);
  transition: left 0.45s ease;
}

.primary-btn:hover::after {
  left: 112%;
}

.overlay-foot {
  margin: 0;
  font-size: clamp(9px, 0.72vw, 10px);
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: var(--muted-dim);
}

.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(7px, 0.8vw, 10px) 5px 1px;
  font-family: var(--font-mono);
  font-size: clamp(8px, 0.7vw, 9.5px);
  line-height: 1;
  letter-spacing: 0.09em;
  color: var(--muted-dim);
}

.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.status-right {
  gap: 12px;
}

.status-dot {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #4b6862;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.game-shell[data-phase="running"] .status-dot {
  background: var(--lime);
  box-shadow: 0 0 10px rgba(201, 255, 107, 0.9);
  animation: dot-pulse 1.3s ease-in-out infinite;
}

.game-shell[data-phase="paused"] .status-dot {
  background: #ffd07f;
  box-shadow: 0 0 9px rgba(255, 208, 127, 0.6);
}

.game-shell[data-phase="over"] .status-dot {
  background: var(--coral);
  box-shadow: 0 0 9px rgba(255, 122, 92, 0.72);
}

.speed-label {
  color: #79968e;
  white-space: nowrap;
}

.key-hint {
  color: #4b6661;
  white-space: nowrap;
}

.noscript {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  margin: 0;
  padding: 10px 16px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 122, 92, 0.35);
  border-radius: 10px;
  background: #120b0b;
  color: #ffd7cf;
  font-size: 13px;
}

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

@keyframes drift-a {
  to {
    transform: translate3d(6vmax, 4vmax, 0) scale(1.08);
  }
}

@keyframes drift-b {
  to {
    transform: translate3d(-7vmax, -4vmax, 0) scale(1.04);
  }
}

@keyframes drift-c {
  to {
    transform: translate3d(-4vmax, 5vmax, 0) scale(1.12);
  }
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes score-bump {
  0% {
    transform: scale(1);
  }
  38% {
    transform: scale(1.32);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes best-flash {
  0%,
  100% {
    color: #d8f2e8;
  }
  35% {
    color: var(--lime);
    text-shadow: 0 0 18px rgba(201, 255, 107, 0.45);
  }
}

@keyframes board-hit {
  0%,
  100% {
    transform: translate(0, 0);
  }
  15% {
    transform: translate(-3px, 2px);
  }
  30% {
    transform: translate(3px, -2px);
  }
  45% {
    transform: translate(-2px, -1px);
  }
  60% {
    transform: translate(2px, 1px);
  }
  80% {
    transform: translate(-1px, 1px);
  }
}

@media (max-width: 680px) {
  .game-shell {
    padding: 10px;
    border-radius: 20px;
  }

  .hud {
    gap: 7px;
    padding: 1px 2px 8px;
  }

  .brand {
    gap: 7px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 9px;
  }

  .brand-name {
    font-size: 9.5px;
    letter-spacing: 0.14em;
  }

  .brand-sub {
    font-size: 7.5px;
    letter-spacing: 0.18em;
  }

  .hud-scores {
    gap: 5px;
  }

  .score-pill {
    min-width: 47px;
    padding: 5px 8px;
    border-radius: 9px;
  }

  .score-label {
    font-size: 7px;
    letter-spacing: 0.12em;
  }

  .score-value {
    font-size: 19px;
  }

  .best-value {
    font-size: 15px;
  }

  .hud-actions {
    gap: 5px;
  }

  .icon-btn {
    width: 31px;
    height: 31px;
    border-radius: 9px;
  }

  .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .board-wrap {
    border-radius: 13px;
    background-size: 100% 100%, 100% 100%, 34px 34px, 34px 34px;
  }

  .overlay {
    padding: 14px;
  }

  .overlay-panel {
    gap: 9px;
  }

  .overlay-badge {
    padding: 5px 9px;
    font-size: 7.5px;
  }

  .overlay-title {
    font-size: clamp(28px, 8.4vw, 36px);
  }

  .overlay-text {
    max-width: 310px;
    font-size: 12px;
    line-height: 1.55;
  }

  .rule-strip {
    display: none;
  }

  .final-score {
    padding: 6px 13px;
    gap: 7px;
  }

  .final-value {
    font-size: 27px;
  }

  .primary-btn {
    min-width: 158px;
    height: 43px;
    padding: 0 20px;
    font-size: 12px;
  }

  .overlay-foot {
    font-size: 8px;
  }

  .statusbar {
    padding-top: 7px;
    font-size: 8px;
  }

  .key-hint {
    display: none;
  }
}

@media (max-width: 430px) {
  .brand-sub {
    display: none;
  }

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

  .score-pill {
    min-width: 42px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .status-right {
    gap: 0;
  }
}

@media (max-height: 560px) {
  .game-shell {
    padding: 9px;
  }

  .hud {
    padding-bottom: 7px;
  }

  .rule-strip,
  .overlay-foot {
    display: none;
  }

  .overlay-panel {
    gap: 7px;
  }

  .overlay-title {
    font-size: clamp(26px, 4vw, 38px);
  }

  .overlay-text {
    font-size: 11px;
    line-height: 1.45;
  }

  .statusbar {
    padding-top: 6px;
  }
}

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