:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8b6bff;
  --text: #fff;
  --muted: #aaadbe;
  --secondary: #2a2b3d;
  --tw: 52px;
  --th: 172px;
  --gap: 12px;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  padding: 10px;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid #ffd23f;
  outline-offset: 3px;
}
.ws-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ws-app {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* HUD */
.ws-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ws-brand {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #7fd8ff, #4d8bff 60%, #8f5bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.ws-chips {
  display: flex;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}
.ws-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 0 rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.ws-chip span {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.ws-chip strong {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.ws-chip-star strong::before {
  content: "★ ";
  color: #ffd23f;
}
.ws-icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 rgba(0, 0, 0, 0.4);
}
.ws-icon-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

/* Stage */
.ws-stage {
  position: relative;
  border-radius: 24px;
  background:
    radial-gradient(
      120% 90% at 50% 0%,
      rgba(104, 66, 255, 0.28),
      transparent 60%
    ),
    radial-gradient(
      80% 60% at 50% 110%,
      rgba(54, 169, 255, 0.16),
      transparent 70%
    ),
    linear-gradient(180deg, #1d1e30, #15162a);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 40px rgba(0, 0, 0, 0.35);
  padding: 14px 8px 12px;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ws-board {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  column-gap: 0;
  row-gap: 4px;
  width: 100%;
}
.ws-row-break {
  flex-basis: 100%;
  height: 0;
}

/* Tube */
.ws-tube {
  position: relative;
  width: calc(var(--tw) + var(--gap));
  min-width: 40px;
  padding: calc(var(--tw) * 0.55) 0 4px;
  border: 0;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ws-tube:focus-visible {
  outline: none;
}
.ws-tube:focus-visible .ws-num {
  background: #ffd23f;
  color: #1a1b28;
}
.ws-tube:focus-visible .ws-vessel {
  box-shadow:
    0 0 0 3px #ffd23f,
    0 10px 18px rgba(0, 0, 0, 0.35);
}
.ws-vessel {
  position: relative;
  display: block;
  width: var(--tw);
  height: var(--th);
  border-radius: 8px 8px calc(var(--tw) / 2) calc(var(--tw) / 2);
  transform-origin: 50% 0;
  transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.35);
  z-index: 1;
}
.ws-glass {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.03) 40%,
    rgba(255, 255, 255, 0.08)
  );
  border: 3px solid rgba(220, 230, 255, 0.42);
  border-top: 0;
}
.ws-vessel::before {
  /* rim */
  content: "";
  position: absolute;
  left: -5px;
  right: -5px;
  top: -5px;
  height: 9px;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.75),
    rgba(200, 212, 255, 0.35)
  );
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 3;
}
.ws-vessel::after {
  /* glossy highlight */
  content: "";
  position: absolute;
  left: 18%;
  top: 10px;
  width: 14%;
  bottom: 18%;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.6),
    rgba(255, 255, 255, 0.08)
  );
  z-index: 3;
  pointer-events: none;
}
.ws-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 86%;
  display: flex;
  flex-direction: column-reverse;
}
.ws-layer {
  position: relative;
  flex: none;
  height: 25%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
  overflow: visible;
  background: linear-gradient(
    90deg,
    var(--d) 0%,
    var(--c) 30%,
    var(--l) 55%,
    var(--c) 75%,
    var(--d) 100%
  );
  transition: height 0.4s ease-in-out;
  color: rgba(255, 255, 255, 0.92);
  font-size: calc(var(--tw) * 0.36);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.ws-layer:last-child::before {
  /* liquid surface */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -3px;
  height: 6px;
  border-radius: 50%;
  background: var(--l);
  opacity: 0.9;
}
.ws-glyph {
  display: none;
  position: relative;
  flex: 1;
  place-items: center;
}
.symbols .ws-glyph {
  display: grid;
}
.ws-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.ws-num {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 20px;
}

.ws-tube.is-selected .ws-vessel {
  transform: translateY(calc(var(--tw) * -0.45));
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.85),
    0 0 24px rgba(139, 107, 255, 0.9),
    0 16px 24px rgba(0, 0, 0, 0.4);
}
.ws-tube.is-selected .ws-num {
  background: var(--accent);
  color: #fff;
}
.ws-tube.is-hint .ws-vessel {
  animation: ws-hint 0.9s ease-in-out 2;
}
.ws-tube.is-done .ws-glass {
  border-color: rgba(255, 236, 150, 0.8);
}
.ws-tube.is-done .ws-vessel::before {
  background: linear-gradient(180deg, #ffe9a3, #f2b33d);
}
.ws-tube.is-pouring .ws-vessel {
  z-index: 10;
  transition: transform 0.28s ease-in-out;
}
.ws-tube.is-shake .ws-vessel {
  animation: ws-shake 0.36s ease;
}
.ws-tube.is-pop .ws-vessel {
  animation: ws-pop 0.42s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@keyframes ws-shake {
  0%,
  100% {
    translate: 0;
  }
  20% {
    translate: -7px;
  }
  40% {
    translate: 6px;
  }
  60% {
    translate: -4px;
  }
  80% {
    translate: 2px;
  }
}
@keyframes ws-pop {
  0% {
    scale: 1;
  }
  45% {
    scale: 1.1 0.94;
  }
  100% {
    scale: 1;
  }
}
@keyframes ws-hint {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: drop-shadow(0 0 10px #ffd23f) brightness(1.2);
  }
}

/* Effects layer */
.ws-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
.ws-stream {
  position: absolute;
  width: 7px;
  border-radius: 4px;
  transform-origin: 50% 0;
  animation: ws-stream 0.42s ease-in-out forwards;
}
@keyframes ws-stream {
  0% {
    scale: 1 0;
  }
  18%,
  82% {
    scale: 1 1;
    opacity: 1;
  }
  100% {
    scale: 0.4 1;
    opacity: 0;
  }
}
.ws-particle {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  animation: ws-burst 0.75s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes ws-burst {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}
.ws-confetti {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation: ws-fall var(--t, 1.8s) linear forwards;
}
@keyframes ws-fall {
  to {
    transform: translate(var(--dx), 640px) rotate(var(--r));
    opacity: 0.2;
  }
}

.ws-toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(15, 16, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  z-index: 25;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Overlays */
.ws-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 12, 28, 0.72);
  backdrop-filter: blur(6px);
}
.ws-overlay[hidden] {
  display: none;
}
.ws-card {
  width: min(380px, 100%);
  padding: 22px 20px 20px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #2a2b44, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.5);
  animation: ws-card-in 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes ws-card-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
.ws-card p {
  margin: 6px 0 16px;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
}
.ws-card .ws-kicker {
  margin: 0;
  color: #ffd23f;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 13px;
}
.ws-logo {
  margin: 4px 0 0;
  font-size: 44px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow:
    0 3px 0 #3d5afe,
    0 6px 0 #2b1f8f,
    0 12px 20px rgba(0, 0, 0, 0.45);
}
.ws-hero-tubes {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}
.ws-mini {
  width: 30px;
  height: 78px;
  border: 3px solid rgba(220, 230, 255, 0.5);
  border-top: 0;
  border-radius: 5px 5px 15px 15px;
  background: linear-gradient(
    0deg,
    var(--a) 0 42%,
    var(--b) 42% 84%,
    transparent 84%
  );
  box-shadow:
    inset 6px 0 0 rgba(255, 255, 255, 0.25),
    0 8px 14px rgba(0, 0, 0, 0.35);
}
.ws-mini:nth-child(2) {
  transform: translateY(-10px) rotate(-8deg);
}
.ws-win-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 0;
  font-size: 40px;
  line-height: 1;
}
.ws-win-stars span {
  color: #3a3b55;
}
.ws-win-stars span.on {
  color: #ffd23f;
  text-shadow:
    0 3px 0 #c98a12,
    0 0 16px rgba(255, 210, 63, 0.6);
  animation: ws-star 0.45s cubic-bezier(0.3, 1.8, 0.5, 1) backwards;
}
.ws-win-stars span:nth-child(2) {
  font-size: 50px;
  animation-delay: 0.12s;
}
.ws-win-stars span:nth-child(3) {
  animation-delay: 0.24s;
}
@keyframes ws-star {
  from {
    transform: scale(0);
  }
}
.ws-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Buttons */
.ws-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.ws-btn {
  position: relative;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--secondary);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 0 #161724;
  transition:
    transform 0.08s,
    box-shadow 0.08s,
    filter 0.15s;
}
.ws-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 0 #161724;
}
.ws-btn-primary {
  background: linear-gradient(180deg, #8264ff, var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 4px 0 #3d22b5;
}
.ws-btn-primary:active {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 1px 0 #3d22b5;
}
.ws-btn-big {
  min-height: 54px;
  font-size: 20px;
  padding: 0 34px;
}
.ws-btn:disabled {
  filter: grayscale(0.8) brightness(0.7);
  cursor: default;
  transform: none;
}
.ws-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #ffd23f;
  color: #1a1b28;
  font-size: 12px;
  line-height: 20px;
  padding: 0 5px;
}
.ws-help {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 5px;
  background: var(--secondary);
  border-bottom: 2px solid #111;
  color: #fff;
  font: inherit;
  font-size: 11px;
}

@media (max-width: 560px) {
  body {
    padding: 8px;
  }
  .ws-brand {
    display: none;
  }
  .ws-chips {
    margin-left: 0;
    flex: 1;
  }
  .ws-chip {
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 4px 6px;
    border-radius: 14px;
  }
  .ws-chip span {
    font-size: 10px;
  }
  .ws-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .ws-actions .ws-btn {
    padding: 0 6px;
    font-size: 14px;
    gap: 4px;
  }
  .ws-stage {
    min-height: 340px;
  }
  .ws-logo {
    font-size: 36px;
  }
}
@media (max-width: 380px) {
  .ws-help {
    display: none;
  }
  .ws-actions .ws-btn svg {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ws-tube.is-shake .ws-vessel {
    box-shadow: 0 0 0 3px #ff4d6d;
  }
}
