:root {
  color-scheme: light;
  --bg: #dbe9df;
  --ink: #172033;
  --muted: #5f6f79;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --line: rgba(60, 78, 86, 0.16);
  --mint: #9ed7c2;
  --teal: #147c72;
  --blue: #8ec5ff;
  --coral: #ef7b6d;
  --gold: #e8b94f;
  --shadow: 0 22px 60px rgba(23, 32, 51, 0.18);
  --bubble-shadow: 0 18px 30px rgba(69, 110, 118, 0.26);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(142, 197, 255, 0.42), transparent 28%),
    radial-gradient(circle at 85% 16%, rgba(239, 123, 109, 0.22), transparent 26%),
    linear-gradient(135deg, #cce3d8 0%, #edf0e8 46%, #d8e8ef 100%);
  overflow-x: hidden;
}

button {
  border: 0;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid #2453d6;
  outline-offset: 3px;
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  padding: 16px;
}

.top-bar,
.play-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 540px) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}

.eyebrow,
.stat span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.4rem);
  line-height: 1;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 1.4rem;
  line-height: 1;
}

.tool-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbf7;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.1);
}

.icon-button.accent {
  background: var(--teal);
  color: white;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.play-field {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  padding: 16px;
}

.sheet-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #293845;
  font-size: 0.98rem;
  font-weight: 750;
}

.sheet-meta p:last-child {
  flex: 0 0 auto;
  color: var(--muted);
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
}

.progress-track span {
  display: block;
  inline-size: 0;
  block-size: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transition: inline-size 180ms ease;
}

.bubble-sheet {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(52px, 1fr));
  align-content: center;
  gap: clamp(10px, 2vw, 22px);
  min-height: 0;
  padding: clamp(12px, 3vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 12px),
    rgba(155, 209, 194, 0.56);
}

.bubble {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transform: translate(var(--dx), var(--dy)) rotate(var(--rotate));
  transition: transform 140ms ease;
}

.bubble:hover:not(:disabled) {
  transform: translate(var(--dx), calc(var(--dy) - 2px)) rotate(var(--rotate)) scale(1.03);
}

.bubble-skin {
  position: absolute;
  inset: 5%;
  border-radius: 999px;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.9) 0 7%, transparent 8%),
    radial-gradient(circle at 64% var(--shine), rgba(255, 255, 255, 0.64), transparent 26%),
    radial-gradient(circle at 50% 56%, rgba(155, 241, 233, 0.58), rgba(255, 255, 255, 0.24) 52%, rgba(49, 127, 135, 0.2) 72%, rgba(255, 255, 255, 0.32));
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow:
    inset -9px -13px 22px rgba(62, 104, 117, 0.16),
    inset 8px 12px 20px rgba(255, 255, 255, 0.72),
    var(--bubble-shadow);
}

.bubble.large .bubble-skin {
  inset: 0;
}

.bubble.small .bubble-skin {
  inset: 10%;
}

.bubble.is-popped {
  cursor: default;
  transform: translate(var(--dx), var(--dy)) rotate(var(--rotate)) scale(0.92);
}

.bubble.is-popped .bubble-skin {
  background:
    radial-gradient(circle at 42% 42%, rgba(255, 255, 255, 0.2), transparent 30%),
    linear-gradient(135deg, rgba(96, 128, 132, 0.22), rgba(255, 255, 255, 0.12));
  border-color: rgba(83, 111, 119, 0.2);
  box-shadow:
    inset 8px 8px 16px rgba(60, 78, 86, 0.19),
    inset -8px -8px 14px rgba(255, 255, 255, 0.36);
}

.bubble.is-popped .bubble-skin::before,
.bubble.is-popped .bubble-skin::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 40% 60% 52% 48%;
  border: 2px solid rgba(63, 85, 91, 0.28);
  border-left-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(28deg);
}

.bubble.is-popped .bubble-skin::after {
  inset: 33% 25% 25% 36%;
  transform: rotate(145deg);
}

.pop-burst,
.pop-flash,
.pop-ring,
.pop-particle {
  position: absolute;
  pointer-events: none;
}

.pop-burst {
  inset: -12%;
  z-index: 1;
  display: grid;
  place-items: center;
  overflow: visible;
}

.pop-flash {
  width: 38%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 0 18px rgba(255, 255, 255, 0.72),
    0 0 26px rgba(142, 197, 255, 0.42);
  animation: popFlash 260ms ease-out forwards;
}

.pop-ring {
  width: 70%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.36);
  animation: popRing 420ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pop-particle {
  width: 8px;
  aspect-ratio: 1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 18%, rgba(255, 255, 255, 0.72) 19% 46%, rgba(142, 197, 255, 0.35) 47% 100%);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
  opacity: 0;
  transform: rotate(var(--angle)) translateX(0) scale(0.78);
  animation: popParticle 520ms ease-out var(--delay) forwards;
}

@keyframes popFlash {
  0% {
    opacity: 0.95;
    transform: scale(0.35);
  }
  70% {
    opacity: 0.45;
    transform: scale(1.18);
  }
  100% {
    opacity: 0;
    transform: scale(1.36);
  }
}

@keyframes popRing {
  0% {
    opacity: 0.82;
    transform: scale(0.48);
  }
  100% {
    opacity: 0;
    transform: scale(1.58);
  }
}

@keyframes popParticle {
  0% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(0) scale(0.5);
  }
  12% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(0.18);
  }
}

@media (max-width: 920px) {
  .top-bar {
    grid-template-columns: 1fr;
  }

  .tool-strip {
    justify-content: flex-start;
  }
}

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

  .top-bar,
  .play-field {
    padding: 12px;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sheet-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .bubble-sheet {
    grid-template-columns: repeat(var(--columns), minmax(48px, 1fr));
  }
}

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