/* Bubble Shooter 泡泡消除 — styles. System fonts only; no external resources. */

:root {
  --bg: #150f3d;
  --bg-image: radial-gradient(120% 60% at 50% 0%, rgba(255, 120, 220, 0.2), transparent 60%),
    linear-gradient(180deg, #1d1450, #14205a 55%, #0c2a5c);
  --card-top: #2a2470;
  --panel-solid: #1a1850;
  --soft: rgba(255, 255, 255, 0.1);
  --off: rgba(255, 255, 255, 0.2);
  --overlay-bg: rgba(8, 6, 30, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f4f2ff;
  --muted: #b9b5e6;
  --accent: #ff5fae;
  --accent-hi: #ff9ad0;
  --accent-shadow: #b8306f;
  --accent-ink: #ffffff;
  --cyan: #5ff2ff;
  --gold: #ffd34d;
  --danger: #ff6b7d;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-image);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.ic {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- screens ---------------- */
.screen {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--soft);
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: transform 0.12s, background 0.2s;
}
.icon-btn .ic {
  display: block;
  flex: none;
}
.icon-btn:active {
  transform: scale(0.92);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 26px;
  min-height: 48px;
  font-weight: 700;
  font-size: 17px;
  color: var(--accent-ink);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: 0 4px 0 var(--accent-shadow), 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.2s;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--accent-shadow), 0 6px 14px rgba(0, 0, 0, 0.25);
}
.btn.secondary {
  color: var(--text);
  background: var(--soft);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
}
.btn.big {
  font-size: 22px;
  padding: 14px 48px;
  min-height: 60px;
}
.btn.small {
  font-size: 15px;
  padding: 8px 18px;
  min-height: 40px;
}
.btn:focus-visible,
.icon-btn:focus-visible,
.switch:focus-visible,
.seg button:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------- home ---------------- */
.home .corner {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: 12px;
}
.home-main {
  margin: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  max-width: 440px;
}
.logo {
  position: relative;
  width: 150px;
  height: 104px;
  margin-bottom: 4px;
}
.lb {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.95) 0 10%, var(--c) 46%, rgba(0, 0, 0, 0.35) 100%), var(--c);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 6px 14px rgba(0, 0, 0, 0.3);
  animation: bob 2.4s ease-in-out infinite;
}
.b1 { --c: #ff4d5e; left: 5px; top: 0; }
.b2 { --c: #ffd93b; left: 52px; top: 0; animation-delay: -0.4s; }
.b3 { --c: #3d7bff; left: 99px; top: 0; animation-delay: -0.8s; }
.b4 { --c: #3fd86b; left: 28px; top: 41px; animation-delay: -1.2s; }
.b5 { --c: #a45cff; left: 75px; top: 41px; animation-delay: -1.6s; }
@keyframes bob {
  50% { transform: translateY(-6px); }
}
.title {
  margin: 0;
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.5px;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}
.subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}
.home-best {
  font-weight: 700;
  color: var(--muted);
}
.home-best b {
  color: var(--gold);
  font-size: 18px;
}

/* ---------------- game ---------------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(8px + var(--safe-t)) 12px 4px;
}
.hud-score {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}
.hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-score b {
  font-size: 28px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.hud-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
.pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
}
.pill b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-bottom: var(--safe-b);
  touch-action: none;
}
#field {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}

/* Round clear banner */
.banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  padding: 18px 34px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 95, 174, 0.92), rgba(140, 70, 255, 0.92));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  pointer-events: none;
  animation: banner-in 480ms cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.banner-title {
  font-size: 32px;
  font-weight: 900;
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.banner-sub {
  font-weight: 700;
  color: var(--gold);
}
@keyframes banner-in {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
}

/* Tutorial */
.tutorial {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(8, 6, 30, 0.35);
  cursor: pointer;
}
.tutorial-box {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  width: min(320px, calc(100% - 32px));
  padding: 16px;
  border-radius: 20px;
  background: rgba(26, 24, 80, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: fade 250ms ease-out;
}
.tutorial.low .tutorial-box {
  top: 40%;
}
.tutorial-text {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}
.hand {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 44px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
  /* The fingertip (top-center of the glyph) sits on the point. */
  margin: -4px 0 0 -22px;
}
.hand.drag {
  animation: hand-drag 2.2s ease-in-out infinite;
}
.hand.tap {
  transform: translate(var(--x0), var(--y0));
  animation: hand-tap 1s ease-in-out infinite;
}
@keyframes hand-drag {
  0% { transform: translate(var(--x0), var(--y0)) scale(1); opacity: 0; }
  12% { transform: translate(var(--x0), var(--y0)) scale(0.88); opacity: 1; }
  70% { transform: translate(var(--x1), var(--y1)) scale(0.88); opacity: 1; }
  82% { transform: translate(var(--x1), var(--y1)) scale(1); opacity: 1; }
  100% { transform: translate(var(--x1), var(--y1)) scale(1); opacity: 0; }
}
@keyframes hand-tap {
  0%, 100% { transform: translate(var(--x0), var(--y0)) scale(1); }
  50% { transform: translate(var(--x0), calc(var(--y0) + 8px)) scale(0.88); }
}

/* ---------------- overlays ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade 200ms ease-out;
  overflow: auto;
}
#settings,
#confirm {
  z-index: 60;
}
@keyframes fade {
  from { opacity: 0; }
}
.card {
  position: relative;
  width: min(360px, 100%);
  padding: 22px 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--card-top), var(--panel-solid));
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: pop-in 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
}
.center-card {
  text-align: center;
  align-items: stretch;
}
.center-card .btn-row .btn {
  flex: 1;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-head h2 {
  margin: 0;
  font-size: 22px;
}
.card-title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
}
.card-title.over {
  color: var(--danger);
}
.newbest {
  align-self: center;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: #4a3200;
  font-weight: 900;
  animation: pop-in 500ms cubic-bezier(0.34, 1.8, 0.64, 1) 200ms both;
}
.go-score-label {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: -12px;
}
.go-score {
  font-size: 52px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.stats {
  margin: 0;
  display: grid;
  gap: 6px;
}
.stats div {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}
.stats dt {
  color: var(--muted);
  font-weight: 600;
}
.stats dd {
  margin: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.switch {
  position: relative;
  width: 54px;
  height: 32px;
  border-radius: 16px;
  border: 0;
  padding: 0;
  background: var(--off);
  transition: background 0.2s;
  flex: none;
}
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch[aria-checked="true"] {
  background: var(--accent);
}
.switch[aria-checked="true"] i {
  transform: translateX(22px);
}
.seg {
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.seg button {
  border: 0;
  padding: 8px 14px;
  min-height: 38px;
  background: transparent;
  font-weight: 700;
}
.seg button[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}
.settings-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.credits {
  padding-top: 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  -webkit-user-select: text;
  user-select: text;
}
.credits h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--text);
}
.credits p {
  margin: 0;
  overflow-wrap: anywhere;
}
.credits b {
  color: var(--text);
}
.credits a {
  color: var(--cyan);
}
.credits small {
  font-size: 12px;
  opacity: 0.8;
}
.confirm-text {
  margin: 4px 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
}

@media (prefers-reduced-motion: reduce) {
  .lb,
  .hand.drag,
  .hand.tap {
    animation: none;
  }
  .hand.drag {
    transform: translate(var(--x1), var(--y1));
  }
}

/* =========================================================================
 * LOCAL PLAYER PROFILE (one-tap register, no forms) + volume sliders
 * Reuses the existing look: pink primary button, translucent secondary,
 * rounded night-sky cards, soft borders.
 * ======================================================================= */
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
.overlay {
  padding: max(16px, var(--safe-t)) 16px max(16px, var(--safe-b));
}
/* Register dialogs sit above Settings (you can register from there). */
#reg-prompt,
#reg-success,
#reg-error,
#save-notice {
  z-index: 70;
}

/* home */
.home {
  overflow-y: auto; /* short screens may scroll; nothing gets cut off */
}
.home-main {
  width: 100%;
  max-width: 420px;
  padding: calc(64px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  gap: 12px;
}
.home-cta {
  width: 100%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.home-cta small {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}
.home-cta small:empty {
  display: none;
}
.btn.wide {
  width: 100%;
}
.btn.outline {
  color: var(--text);
  background: var(--soft);
  border: 1.5px solid rgba(244, 242, 255, 0.4);
  box-shadow: none;
}
.btn.outline:active {
  transform: scale(0.98);
  box-shadow: none;
}
.home-register {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.note {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}
.home-aux {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.home-aux:not(:has(:not([hidden]))) {
  display: none;
}
.btn.compact {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 14px;
  font-size: 15px;
}
.profile-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 16px 5px 5px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
}
.avatar .ic {
  width: 18px;
  height: 18px;
}
.profile-name {
  font-weight: 700;
  letter-spacing: 0.3px;
  overflow-wrap: anywhere;
}
/* short "working…" state while registering */
.btn.busy {
  pointer-events: none;
  opacity: 0.85;
}
.btn.busy::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* settings: player profile + volume sliders */
.profile-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.sec-title {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}
.profile-row {
  display: flex;
  flex-wrap: wrap; /* narrow phones: the button moves to its own line */
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.profile-row .profile-name {
  flex: 1 1 auto;
  overflow-wrap: normal;
}
#btn-settings-register {
  flex: 1 0 auto; /* fills its line when wrapped */
}
.profile-box .note {
  text-align: left;
}
.setting > span:first-child {
  flex: 1;
}
.vol {
  width: clamp(80px, 30vw, 130px);
  height: 44px; /* tap target */
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: pan-x;
}
.vol:disabled {
  opacity: 0.35;
  cursor: default;
}
/* Switches stay 54×32 visually, but the tap area is at least 44px tall. */
.switch::before {
  content: "";
  position: absolute;
  inset: -6px -4px;
}

/* register dialogs */
.reg-card {
  width: min(380px, 100%);
  align-items: center;
  text-align: center;
  gap: 12px;
  padding-top: 26px;
}
.dlg-close {
  position: absolute;
  top: 12px;
  right: 12px;
}
.dlg-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  flex: none;
}
.dlg-icon.check {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: var(--accent-ink);
  border: 0;
}
.dlg-icon.check .ic {
  width: 30px;
  height: 30px;
  stroke-width: 2.6;
}
/* small bubble cluster icon for the Round 3 prompt */
.dlg-icon.bubbles {
  width: auto;
  height: auto;
  border-radius: 18px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
}
.mb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.95) 0 12%, var(--c) 50%, rgba(0, 0, 0, 0.35) 100%), var(--c);
}
.mb.m1 { --c: #ff4d5e; }
.mb.m2 { --c: #ffd93b; transform: translateY(-6px); }
.mb.m3 { --c: #3d7bff; }
.dlg-title {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 800;
}
.dlg-text {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}
.dlg-text.strong {
  color: var(--text);
  font-weight: 600;
}
/* Message dialogs with a ✕: keep the text clear of the close button. */
.dlg-msg {
  padding: 30px 8px 0;
}
.name-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 8px 8px;
  border-radius: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
}
.name-card-text {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: clamp(15px, 4.7vw, 22px);
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap; /* never split the username */
}
/* Dialog buttons: one line on narrow phones */
.reg-card .btn.big {
  font-size: 19px;
  min-height: 54px;
  padding: 12px 20px;
}

/* Any dialog card taller than a short / landscape screen scrolls inside itself,
   so no button is ever out of reach. */
.card {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* toast */
.toast {
  position: fixed;
  top: calc(76px + var(--safe-t));
  left: 50%;
  z-index: 80;
  transform: translate(-50%, -10px);
  max-width: calc(100% - 32px);
  width: max-content;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(14, 10, 46, 0.92);
  border: 1px solid var(--line);
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
/* Very narrow phones (≤ 359px): give the username the whole name card. */
@media (max-width: 359px) {
  .reg-card {
    padding-left: 14px;
    padding-right: 14px;
  }
  .name-card .avatar {
    display: none;
  }
}
