:root {
  --ink: #16384a;
  --muted: #6d8b9a;
  --teal: #0f9d8a;
  --teal-dark: #087d6e;
  --teal-soft: #dff8f2;
  --coral: #ff7a6b;
  --amber: #f4b54c;
  --violet: #8b7cf6;
  --paper: rgba(255, 255, 255, 0.72);
  --line: rgba(22, 56, 74, 0.1);
  --shadow: 0 28px 70px rgba(46, 119, 143, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(255, 255, 255, 0.98), transparent 30%),
    radial-gradient(circle at 94% 16%, rgba(199, 245, 234, 0.72), transparent 30%),
    linear-gradient(180deg, #f8fdff 0%, #eaf8ff 48%, #effcf6 100%);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background-image: radial-gradient(rgba(15, 157, 138, 0.1) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 78%);
}

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

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

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(8px);
  opacity: 0.55;
}

.orb-a {
  top: -180px;
  right: -120px;
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, rgba(184, 242, 255, 0.95), rgba(184, 242, 255, 0));
}

.orb-b {
  bottom: -220px;
  left: -180px;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(182, 241, 221, 0.82), rgba(182, 241, 221, 0));
}

.orb-c {
  top: 42%;
  left: 50%;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 250, 222, 0.7), rgba(255, 250, 222, 0));
  transform: translateX(-50%);
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(1120px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 20px 0 22px;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 12px 36px rgba(52, 121, 146, 0.08);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  color: var(--teal);
  background:
    radial-gradient(circle at 30% 20%, #ffffff, transparent 58%),
    linear-gradient(145deg, #dffbf3, #c9f5ec);
  box-shadow:
    inset 0 1px 0 #ffffff,
    0 8px 18px rgba(15, 157, 138, 0.14);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 2px rgba(15, 157, 138, 0.15));
}

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

.brand-copy p {
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.brand-copy h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.hud-stats {
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}

.stat {
  display: flex;
  min-width: 66px;
  flex-direction: column;
  justify-content: center;
  padding: 6px 11px;
  border: 1px solid rgba(22, 56, 74, 0.055);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.stat span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.4;
}

.stat strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.best-stat strong {
  color: var(--teal-dark);
}

.lives {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 21px;
}

.life-pip {
  width: 15px;
  height: 7px;
  border-radius: 999px;
  background: #d7e9ee;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.life-pip.is-on {
  background: linear-gradient(90deg, #ff9a86, var(--coral));
  box-shadow: 0 2px 8px rgba(255, 122, 107, 0.34);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 3px;
}

.chip-btn {
  height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(22, 56, 74, 0.09);
  border-radius: 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.62);
  font: inherit;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.chip-btn:hover:not(:disabled) {
  border-color: rgba(15, 157, 138, 0.24);
  background: #ffffff;
  transform: translateY(-1px);
}

.chip-btn:active:not(:disabled) {
  transform: translateY(0);
}

.chip-btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  height: clamp(390px, calc(100svh - 196px), 690px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  background:
    radial-gradient(ellipse at 16% 18%, rgba(255, 255, 255, 0.98) 0 7%, transparent 7.4%),
    radial-gradient(ellipse at 22% 15%, rgba(255, 255, 255, 0.8) 0 5%, transparent 5.4%),
    radial-gradient(ellipse at 80% 23%, rgba(255, 255, 255, 0.9) 0 9%, transparent 9.4%),
    linear-gradient(180deg, #fbffff 0%, #eaf9ff 58%, #effcf6 100%);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 #ffffff;
  touch-action: none;
}

.stage::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 157, 138, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 157, 138, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 48%, rgba(0, 0, 0, 0.9), transparent 82%);
}

.stage::after {
  position: absolute;
  right: -170px;
  bottom: -190px;
  z-index: 0;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle, rgba(112, 222, 201, 0.3), transparent 69%);
  filter: blur(8px);
}

.cloud {
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  filter: blur(16px);
  pointer-events: none;
  animation: cloud-drift 36s linear infinite;
}

.cloud-a {
  top: 15%;
  left: -28%;
  width: 250px;
  height: 76px;
  opacity: 0.8;
}

.cloud-b {
  top: 42%;
  left: -18%;
  width: 170px;
  height: 58px;
  opacity: 0.52;
  animation-duration: 48s;
  animation-delay: -18s;
}

.cloud-c {
  top: 68%;
  left: -32%;
  width: 310px;
  height: 94px;
  opacity: 0.5;
  animation-duration: 58s;
  animation-delay: -34s;
}

@keyframes cloud-drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(100vw + 680px));
  }
}

canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  cursor: crosshair;
  touch-action: none;
}

canvas:focus {
  outline: none;
}

.wave-toast {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 4;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: #ffffff;
  background: rgba(22, 56, 74, 0.78);
  box-shadow: 0 10px 24px rgba(22, 56, 74, 0.16);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  backdrop-filter: blur(8px);
}

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

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(238, 250, 255, 0.38);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.24s ease, visibility 0.24s;
  backdrop-filter: blur(5px);
}

.overlay.is-hidden {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.overlay-card {
  width: min(430px, 100%);
  padding: 28px 30px 24px;
  border: 1px solid rgba(255, 255, 255, 0.96);
  border-radius: 27px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 28px 70px rgba(33, 104, 128, 0.19);
  text-align: center;
  animation: card-in 0.34s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  backdrop-filter: blur(18px);
}

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

.overlay-kicker {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.19em;
}

.overlay-card h2 {
  margin: 0;
  font-size: clamp(29px, 4vw, 40px);
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.overlay-text {
  max-width: 300px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 19px 0 4px;
  padding: 12px 8px;
  border: 1px solid rgba(15, 157, 138, 0.09);
  border-radius: 17px;
  background: rgba(230, 249, 245, 0.72);
}

.result-grid[hidden] {
  display: none;
}

.result-grid div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.result-grid span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.result-grid strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.primary-btn,
.ghost-btn {
  min-height: 44px;
  padding: 0 22px;
  border-radius: 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-btn {
  border: 1px solid rgba(8, 125, 110, 0.1);
  color: #ffffff;
  background: linear-gradient(145deg, #19b6a0, var(--teal));
  box-shadow: 0 10px 22px rgba(15, 157, 138, 0.28);
}

.primary-btn:hover {
  box-shadow: 0 13px 26px rgba(15, 157, 138, 0.34);
  transform: translateY(-1px);
}

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

.ghost-btn {
  border: 1px solid rgba(22, 56, 74, 0.1);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

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

.overlay-hint {
  margin: 14px 0 0;
  color: #8aa3ae;
  font-size: 10px;
  line-height: 1.5;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.controls span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  place-items: center;
  border: 1px solid rgba(22, 56, 74, 0.1);
  border-bottom-color: rgba(22, 56, 74, 0.17);
  border-radius: 6px;
  color: #4d6b7a;
  background: rgba(255, 255, 255, 0.66);
  font: inherit;
  font-size: 9px;
  font-weight: 650;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.auto-hint {
  color: var(--teal-dark);
  font-weight: 650;
}

button:focus-visible {
  outline: 2px solid rgba(15, 157, 138, 0.68);
  outline-offset: 3px;
}

@media (max-width: 780px) {
  .app {
    gap: 10px;
    width: min(100% - 20px, 680px);
    padding: 10px 0 14px;
  }

  .hud {
    gap: 10px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }

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

  .brand-copy p {
    display: none;
  }

  .brand-copy h1 {
    font-size: 18px;
  }

  .hud-stats {
    flex: 1;
    justify-content: flex-end;
    gap: 4px;
  }

  .stat {
    min-width: 0;
    padding: 5px 8px;
    border-color: transparent;
    background: transparent;
  }

  .stat span {
    font-size: 8px;
  }

  .stat strong {
    font-size: 16px;
  }

  .best-stat {
    display: none;
  }

  .life-pip {
    width: 12px;
    height: 6px;
  }

  .hud-actions {
    gap: 4px;
  }

  .chip-btn {
    height: 34px;
    padding: 0 9px;
    border-radius: 10px;
    font-size: 10px;
  }

  .stage {
    height: clamp(380px, calc(100svh - 170px), 640px);
    border-radius: 23px;
  }

  .overlay-card {
    padding: 24px 20px 21px;
    border-radius: 23px;
  }

  .controls {
    gap: 11px;
    font-size: 10px;
  }

  .auto-hint {
    display: none;
  }
}

@media (max-width: 520px) {
  .hud {
    flex-wrap: wrap;
  }

  .hud-stats {
    width: 100%;
    flex: 0 0 100%;
    justify-content: space-between;
  }

  .hud-actions {
    margin-left: auto;
  }

  .stage {
    height: clamp(390px, calc(100svh - 214px), 620px);
  }

  .overlay {
    padding: 14px;
  }

  .overlay-card {
    padding: 22px 18px 19px;
  }

  .result-grid {
    margin-top: 16px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app {
    padding: 8px 0;
  }

  .hud {
    padding: 7px 12px;
  }

  .stage {
    height: calc(100svh - 118px);
    min-height: 320px;
  }

  .controls {
    display: none;
  }

  .overlay-card {
    padding: 18px 24px;
  }

  .overlay-text,
  .overlay-hint {
    display: none;
  }

  .result-grid {
    margin: 12px 0 0;
  }

  .overlay-actions {
    margin-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cloud {
    animation: none;
  }

  .overlay-card {
    animation: none;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
