:root,
:root .app[data-theme="forest"] {
  --bg1: #f0faf0;
  --bg2: #6bbf82;
  --ink: #1a3d2e;
  --muted: #4d7260;
  --aqua: #2ea86a;
  --accent: #4ade80;
  --gold: #eab308;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(255, 255, 255, 0.97);
  --btn-shadow: #1f7a48;
  --btn-secondary-bg: rgba(255, 255, 255, 0.95);
  --btn-secondary-shadow: rgba(80, 130, 95, 0.25);
  --ambient: rgba(220, 255, 230, 0.4);
  --hero-glow: rgba(74, 222, 128, 0.32);
  --modal-bg: linear-gradient(150deg, #f7fdf7, #e3f6e8);
  --shadow: 0 16px 38px rgba(22, 52, 71, 0.16);
  --radius: 26px;
  --font: "Nunito", "Noto Sans Khmer", "Segoe UI", system-ui, sans-serif;
}
.app[data-theme="classic"] {
  --bg1: #eef8ff;
  --bg2: #6ec8e8;
  --ink: #163447;
  --muted: #5b7282;
  --aqua: #1aabca;
  --accent: #22c3e5;
  --gold: #ffb830;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(255, 255, 255, 0.95);
  --btn-shadow: #1284a8;
  --btn-secondary-bg: rgba(255, 255, 255, 0.94);
  --btn-secondary-shadow: rgba(88, 130, 150, 0.28);
  --ambient: rgba(255, 255, 255, 0.32);
  --hero-glow: rgba(34, 195, 229, 0.35);
  --modal-bg: linear-gradient(
    150deg,
    rgba(255, 255, 255, 0.98),
    rgba(230, 247, 252, 0.96)
  );
  --shadow: 0 16px 38px rgba(22, 52, 71, 0.16);
}
.app[data-theme="sunset"] {
  --bg1: #fff6ef;
  --bg2: #f4a574;
  --ink: #4a2a24;
  --muted: #8a6358;
  --aqua: #e8654a;
  --accent: #ff8f5a;
  --gold: #ffc940;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(255, 255, 255, 0.98);
  --btn-shadow: #c44b2e;
  --btn-secondary-bg: rgba(255, 255, 255, 0.95);
  --btn-secondary-shadow: rgba(180, 110, 80, 0.25);
  --ambient: rgba(255, 240, 220, 0.4);
  --hero-glow: rgba(255, 143, 90, 0.35);
  --modal-bg: linear-gradient(150deg, #fffaf5, #ffe8d6);
}
.app[data-theme="ocean"] {
  --bg1: #e8f7ff;
  --bg2: #3d9fd4;
  --ink: #0f3550;
  --muted: #4f7188;
  --aqua: #1d8fd4;
  --accent: #38bdf8;
  --gold: #fbbf24;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(255, 255, 255, 0.96);
  --btn-shadow: #1565a0;
  --btn-secondary-bg: rgba(255, 255, 255, 0.94);
  --btn-secondary-shadow: rgba(70, 120, 160, 0.28);
  --ambient: rgba(200, 240, 255, 0.45);
  --hero-glow: rgba(56, 189, 248, 0.38);
  --modal-bg: linear-gradient(150deg, #f0f9ff, #dbeafe);
}
.app[data-theme="forest"] {
  --bg1: #f0faf0;
  --bg2: #6bbf82;
  --ink: #1a3d2e;
  --muted: #4d7260;
  --aqua: #2ea86a;
  --accent: #4ade80;
  --gold: #eab308;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(255, 255, 255, 0.97);
  --btn-shadow: #1f7a48;
  --btn-secondary-bg: rgba(255, 255, 255, 0.95);
  --btn-secondary-shadow: rgba(80, 130, 95, 0.25);
  --ambient: rgba(220, 255, 230, 0.4);
  --hero-glow: rgba(74, 222, 128, 0.32);
  --modal-bg: linear-gradient(150deg, #f7fdf7, #e3f6e8);
}
.app[data-theme="night"] {
  --bg1: #1a2248;
  --bg2: #4c3d8f;
  --ink: #f0eeff;
  --muted: #b8b4d8;
  --aqua: #7c6cf0;
  --accent: #a78bfa;
  --gold: #fbbf24;
  --panel: rgba(32, 38, 72, 0.82);
  --panel-border: rgba(255, 255, 255, 0.14);
  --btn-shadow: #4c3d99;
  --btn-secondary-bg: rgba(255, 255, 255, 0.12);
  --btn-secondary-shadow: rgba(0, 0, 0, 0.25);
  --ambient: rgba(167, 139, 250, 0.15);
  --hero-glow: rgba(167, 139, 250, 0.4);
  --modal-bg: linear-gradient(150deg, #2a3060, #3d3570);
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.35);
}
.app[data-theme="candy"] {
  --bg1: #fff5fb;
  --bg2: #c4b5fd;
  --ink: #4a1d4e;
  --muted: #8b5a8f;
  --aqua: #ec4899;
  --accent: #f472b6;
  --gold: #facc15;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(255, 255, 255, 0.98);
  --btn-shadow: #be3d82;
  --btn-secondary-bg: rgba(255, 255, 255, 0.95);
  --btn-secondary-shadow: rgba(180, 120, 170, 0.22);
  --ambient: rgba(255, 220, 240, 0.45);
  --hero-glow: rgba(244, 114, 182, 0.35);
  --modal-bg: linear-gradient(150deg, #fff5fb, #fce7f3);
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg2);
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  outline: none;
}
button:focus-visible {
  outline: 3px solid rgba(37, 184, 190, 0.72);
  outline-offset: 3px;
}
.cup:focus-visible {
  outline: none;
}
.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, var(--ambient), transparent 42%),
    radial-gradient(circle at 85% 90%, var(--ambient), transparent 38%),
    linear-gradient(165deg, var(--bg1), var(--bg2));
  isolation: isolate;
  transition:
    background 0.45s ease,
    color 0.3s ease;
}
.app[data-theme="night"] .game-button.secondary,
.app[data-theme="night"] .menu-card,
.app[data-theme="night"] .home-stat {
  color: var(--ink);
}
.app[data-theme="night"] .menu-card b,
.app[data-theme="night"] .home-stat b {
  color: var(--ink);
}
.app[data-theme="night"] .modal {
  color: var(--ink);
}
.app[data-theme="night"] .modal p {
  color: var(--muted);
}
.app[data-theme="night"] .game-title {
  background: linear-gradient(135deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
}
.loading-screen .game-title {
  -webkit-text-fill-color: var(--ink);
  background: none;
}
.app[data-theme="night"] .logo-badge {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.app[data-theme="night"] .home-panel {
  background: rgba(32, 38, 72, 0.72);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}
.app[data-theme="night"] .language-buttons button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}
.ambient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}
.ambient i {
  position: absolute;
  border-radius: 50%;
  background: var(--ambient);
  animation: float 9s ease-in-out infinite;
  filter: blur(1px);
}
.ambient i:nth-child(1) {
  width: 200px;
  height: 200px;
  left: -70px;
  top: 12%;
}
.ambient i:nth-child(2) {
  width: 110px;
  height: 110px;
  right: 6%;
  top: 8%;
  animation-delay: -2s;
}
.ambient i:nth-child(3) {
  width: 280px;
  height: 280px;
  right: -130px;
  bottom: 5%;
  animation-delay: -4s;
}
.ambient i:nth-child(4) {
  width: 50px;
  height: 50px;
  left: 20%;
  bottom: 15%;
  animation-delay: -1s;
}
.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.985);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
  padding: max(20px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
}
.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
}
.loading-screen,
.home-screen {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.loading-screen {
  align-items: center;
  justify-content: center;
}
.home-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.home-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(10px);
}
.home-level-stat {
  gap: 8px;
}
.home-stat b {
  font-size: 16px;
  color: var(--aqua);
}
.home-diff-badge {
  margin-left: 0;
  padding: 3px 8px;
  font-size: 10px;
}
.coin-stat .sprite {
  width: 24px;
  height: 24px;
}
.home-settings {
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 12px;
  min-height: 0;
  gap: 6px;
}
.logo-badge {
  width: clamp(108px, 26vw, 132px);
  height: clamp(108px, 26vw, 132px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 40%, var(--hero-glow), transparent 62%),
    var(--panel);
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  margin-bottom: 4px;
}
.logo-ring {
  width: clamp(120px, 28vw, 150px);
  height: clamp(120px, 28vw, 150px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, var(--hero-glow), transparent 68%);
  margin-bottom: 6px;
}
.logo-mark {
  width: clamp(72px, 18vw, 92px) !important;
  height: clamp(72px, 18vw, 92px) !important;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.12));
}
.game-title {
  font-size: clamp(28px, 7vw, 40px);
  line-height: 1.08;
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.4px;
  font-family: var(--font);
  background: linear-gradient(135deg, var(--ink), var(--aqua));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  font-weight: 800;
  color: var(--muted);
  margin: 0;
  font-size: clamp(13px, 3.4vw, 16px);
  letter-spacing: 0.04em;
}
.loading-dots {
  display: flex;
  gap: 9px;
  margin-top: 34px;
}
.loading-dots b {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--aqua);
  animation: dots 1.2s infinite;
}
.loading-dots b:nth-child(2) {
  animation-delay: 0.15s;
}
.loading-dots b:nth-child(3) {
  animation-delay: 0.3s;
}
.home-panel {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 14px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(12px);
}
.play-btn {
  min-height: 58px;
  font-size: 20px;
  letter-spacing: 0.08em;
}
.difficulty-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}
.difficulty-tab {
  min-height: 44px;
  padding: 8px 4px;
  border-radius: 16px;
  font-weight: 800;
  font-size: clamp(10px, 2.6vw, 12px);
  letter-spacing: 0.02em;
  background: var(--btn-secondary-bg);
  color: var(--ink);
  border: 2px solid var(--panel-border);
  box-shadow: 0 4px 0 var(--btn-secondary-shadow);
  transition:
    transform 0.15s,
    background 0.15s,
    border-color 0.15s;
}
.difficulty-tab.active {
  background: linear-gradient(145deg, var(--accent), var(--aqua));
  color: #fff;
  border-color: transparent;
  box-shadow:
    0 5px 0 var(--btn-shadow),
    0 8px 18px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
.difficulty-tab:active {
  transform: scale(0.96);
}
.level-difficulty-tabs {
  margin: 0 4px 12px;
  padding: 0 2px;
}
.difficulty-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(145deg, var(--accent), var(--aqua));
  color: #fff;
  vertical-align: middle;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}
.level-heading {
  flex-wrap: wrap;
  row-gap: 4px;
}
.modal-diff {
  display: flex;
  align-items: center;
  width: fit-content;
  margin: 0 auto 16px;
  padding: 6px 6px 6px 16px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(22, 52, 71, 0.1);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #163447;
}
.modal-diff-label {
  color: #163447;
  font-weight: 800;
}
.modal-diff b {
  margin-left: 6px;
  color: var(--aqua);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
}
.modal-diff .difficulty-badge {
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 11px;
  box-shadow: none;
}
.app[data-theme="night"] .modal-diff {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  color: var(--ink);
}
.app[data-theme="night"] .modal-diff-label {
  color: var(--ink);
}
.home-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.menu-card {
  min-height: 78px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow:
    0 4px 0 var(--btn-secondary-shadow),
    0 6px 14px rgba(0, 0, 0, 0.05);
  transition:
    transform 0.16s ease,
    filter 0.16s ease;
}
.menu-card .sprite {
  width: 36px;
  height: 36px;
}
.menu-card b {
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
  text-align: center;
}
.menu-card:active {
  transform: scale(0.94);
}
.sprite {
  display: block;
  width: 58px;
  height: 58px;
  background-image: url("assets/ui-icons.png");
  background-size: 400% 400%;
  background-repeat: no-repeat;
}
.sprite-coin {
  background-position: 0 0;
}
.sprite-settings {
  background-position: 33.333% 0;
}
.sprite-back {
  background-position: 66.666% 0;
}
.sprite-undo {
  background-position: 100% 0;
}
.sprite-restart {
  background-position: 0 33.333%;
}
.sprite-hint {
  background-position: 33.333% 33.333%;
}
.sprite-add {
  background-position: 66.666% 33.333%;
}
.sprite-grid {
  background-position: 100% 33.333%;
}
.sprite-theme {
  background-position: 0 66.666%;
}
.sprite-sound {
  background-position: 33.333% 66.666%;
}
.sprite-music {
  background-position: 66.666% 66.666%;
}
.sprite-vibrate {
  background-position: 100% 66.666%;
}
.sprite-lock {
  background-position: 0 100%;
}
.sprite-star {
  background-position: 33.333% 100%;
}
.sprite-trophy {
  background-position: 66.666% 100%;
}
.sprite-drop {
  background-position: 100% 100%;
}
.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  transition: transform 0.16s;
}
.icon-button .sprite {
  width: 36px;
  height: 36px;
}
.icon-button.home-settings {
  width: 48px;
  height: 48px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}
.icon-button.home-settings .sprite {
  width: 34px;
  height: 34px;
}
.icon-button:active,
.game-button:active,
.control-button:active,
.menu-card:active {
  transform: scale(0.92);
}
.game-button {
  min-height: 76px;
  border-radius: 28px;
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow:
    0 8px 0 var(--btn-shadow),
    var(--shadow);
  transition:
    transform 0.16s,
    filter 0.16s,
    box-shadow 0.3s;
}
.game-button.primary,
.game-button.primary b {
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--aqua));
  font-size: 25px;
}
.game-button.primary b {
  background: none;
  font-size: inherit;
  line-height: inherit;
}
.game-button.primary.play-btn {
  position: relative;
  isolation: isolate;
  overflow: visible;
  min-height: 58px;
  width: 100%;
  border-radius: 22px;
  font-size: 21px;
  letter-spacing: 0.1em;
  padding: 8px 20px;
  box-shadow:
    0 6px 0 var(--btn-shadow),
    0 10px 22px rgba(0, 0, 0, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.play-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  background: #fff;
  clip-path: polygon(
    50% 0%,
    62% 38%,
    100% 50%,
    62% 62%,
    50% 100%,
    38% 62%,
    0% 50%,
    38% 38%
  );
  pointer-events: none;
  z-index: 2;
  animation: playTwinkle 1.6s ease-in-out infinite;
}
.play-spark:nth-child(1) {
  top: 7px;
  left: 18px;
}
.play-spark:nth-child(2) {
  top: 9px;
  right: 20px;
  animation-delay: 0.4s;
}
.play-spark:nth-child(3) {
  bottom: 10px;
  left: 26px;
  animation-delay: 0.8s;
}
.play-spark:nth-child(4) {
  bottom: 8px;
  right: 16px;
  animation-delay: 1.2s;
}
.game-button.primary.play-btn b {
  position: relative;
  z-index: 1;
  font-size: inherit;
}
.game-button.secondary {
  min-height: 58px;
  color: var(--ink);
  background: var(--btn-secondary-bg);
  box-shadow:
    0 6px 0 var(--btn-secondary-shadow),
    var(--shadow);
  font-size: 17px;
  border: 1px solid var(--panel-border);
}
.game-button.warn {
  min-height: 58px;
  color: #fff;
  background: linear-gradient(145deg, #ffe566 0%, #ffb020 52%, #ff8c00 100%);
  border: 0;
  font-size: 17px;
  box-shadow:
    0 7px 0 #c47a00,
    0 12px 24px rgba(255, 140, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.game-button.warn b {
  color: #fff;
  text-shadow: 0 1px 2px rgba(140, 60, 0, 0.45);
  background: none;
  font-size: inherit;
  line-height: inherit;
}
.game-button .sprite {
  width: 48px;
  height: 48px;
}
.topbar {
  height: 56px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
}
.topbar h2 {
  text-align: center;
  margin: 0;
  font-size: clamp(23px, 6vw, 32px);
}
.top-spacer {
  width: 44px;
}
.level-screen {
  display: flex;
  flex-direction: column;
}
.level-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-content: start;
  gap: 14px;
  padding: 20px 4px 30px;
  scrollbar-width: none;
}
.level-node {
  aspect-ratio: 1;
  border-radius: 23px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 6px 0 var(--btn-secondary-shadow),
    0 10px 20px rgba(0, 0, 0, 0.08);
  font-size: 21px;
  font-weight: 900;
  position: relative;
  color: var(--ink);
}
.level-node b {
  line-height: 1;
  font-size: inherit;
}
.level-node.current {
  outline: 4px solid var(--gold);
  transform: translateY(-3px);
}
.level-node.locked {
  background: rgba(255, 255, 255, 0.82);
  color: #3d4d58;
}
.level-node .sprite-lock {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: none;
}
.level-node .stars {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
}
.level-node .stars .sprite-star {
  width: 16px;
  height: 16px;
  filter: grayscale(1) brightness(1.2);
  opacity: 0.32;
}
.level-node .stars .sprite-star.on {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
  opacity: 1;
}
.game-screen {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: max(10px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}
.game-header {
  flex-shrink: 0;
  position: relative;
  z-index: 12;
  margin-bottom: 10px;
  padding: 6px 12px 10px;
  background: transparent;
  border: none;
  border-radius: 22px;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--ink);
}
.game-header .topbar {
  height: 48px;
  grid-template-columns: 44px 1fr 44px;
}
.game-header .icon-button {
  width: 40px;
  height: 40px;
}
.game-header .icon-button .sprite {
  width: 32px;
  height: 32px;
}
.level-heading {
  text-align: center;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.level-heading small {
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font);
}
.level-heading b {
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.03em;
  font-family: var(--font);
  color: var(--ink);
}
.game-prompt {
  text-align: center;
  padding-top: 2px;
  border-top: 1px solid color-mix(in srgb, var(--muted) 22%, transparent);
  margin-top: 2px;
}
.game-prompt h2 {
  font-size: clamp(16px, 4.2vw, 22px);
  margin: 6px 0 4px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-family: var(--font);
  color: var(--ink);
}
.game-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}
.game-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}
.game-stat b {
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
}
.game-stat.coin-stat .sprite {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}
.game-stat.coin-stat b {
  color: var(--gold);
}
#gameCoinStat {
  position: relative;
}
.coin-gain-pop {
  position: absolute;
  left: 50%;
  top: -2px;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 900;
  color: var(--gold);
  pointer-events: none;
  animation: coinGainPop 0.9s ease forwards;
}
.board-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 0;
}
.board-scaler {
  width: 100%;
  transform-origin: center center;
  will-change: transform;
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--cup-cols, 4), max-content);
  justify-content: center;
  align-content: start;
  gap: var(--cup-gap-y, clamp(10px, 2.4vw, 18px))
    var(--cup-gap-x, clamp(8px, 2vw, 14px));
  padding: 6px 4px 10px;
  width: 100%;
  --cup-w: clamp(34px, 8.6vw, 50px);
  --cup-h: clamp(78px, 19.5vw, 112px);
  --cup-gap-x: clamp(8px, 2vw, 14px);
  --cup-gap-y: clamp(10px, 2.4vw, 18px);
}
.board[data-count="13"],
.board[data-count="14"],
.board[data-count="15"],
.board[data-count="16"] {
  --cup-gap-x: clamp(5px, 1.3vw, 9px);
  --cup-gap-y: clamp(6px, 1.5vw, 10px);
}
.cup {
  position: relative;
  width: var(--cup-w);
  height: var(--cup-h);
  font-size: var(--cup-w);
  background: transparent;
  padding: 0;
  transition:
    transform 0.32s cubic-bezier(0.33, 1, 0.68, 1),
    filter 0.32s ease;
  filter: drop-shadow(0 8px 6px rgba(41, 83, 105, 0.14));
  touch-action: manipulation;
}
.cup::before {
  content: "";
  position: absolute;
  inset: 4% 5% 0;
  border: 0.08em solid rgba(255, 255, 255, 0.76);
  border-top: 0.12em solid rgba(255, 255, 255, 0.9);
  border-radius: 0.85em 0.85em 1.35em 1.35em;
  box-shadow:
    inset 0.1em 0 0.16em rgba(255, 255, 255, 0.4),
    inset -0.1em 0 0.16em rgba(49, 130, 166, 0.12);
  z-index: 4;
  pointer-events: none;
}
.cup::after {
  content: "";
  position: absolute;
  left: 22%;
  top: 11%;
  width: 0.1em;
  height: 58%;
  border-radius: 0.2em;
  background: rgba(255, 255, 255, 0.55);
  z-index: 5;
}
.cup.selected {
  transform: translateY(-8px) scale(1.03);
  filter: drop-shadow(0 12px 10px rgba(32, 192, 192, 0.35));
}
.cup.invalid {
  animation: shake 0.32s;
}
.cup.hint-source {
  animation: pulse 1s infinite;
}
.cup.hint-target {
  animation: pulseTarget 1s infinite;
}
.liquid-stack {
  position: absolute;
  inset: 9% 9% 6%;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  border-radius: 0.35em 0.35em 1em 1em;
}
.liquid {
  flex: 0 0 25%;
  position: relative;
  background: var(--liquid);
  box-shadow: inset 0 0.08em 0.14em rgba(255, 255, 255, 0.28);
  transition:
    transform 0.36s cubic-bezier(0.33, 1, 0.68, 1),
    opacity 0.36s ease;
}
.liquid:last-child::after {
  content: "";
  position: absolute;
  top: -0.06em;
  left: 0;
  width: 100%;
  height: 0.14em;
  background: color-mix(in srgb, var(--liquid), white 24%);
  border-radius: 50%;
  animation: wave 2.2s ease-in-out infinite;
}
.cup.complete {
  filter: drop-shadow(0 0 0.24em rgba(255, 218, 65, 0.75));
}
.complete-mark {
  position: absolute;
  right: -0.28em;
  top: -0.32em;
  width: 1.05em;
  height: 1.05em;
  background: var(--gold);
  border: 0.12em solid #fff;
  border-radius: 50%;
  z-index: 8;
  color: #fff;
  font-size: calc(var(--cup-w) * 0.36);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.game-controls {
  flex-shrink: 0;
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  align-items: end;
  margin-top: 8px;
  padding: 10px 8px 6px;
  background: transparent;
  border: none;
  border-radius: 20px;
  box-shadow: none;
  backdrop-filter: none;
}
.control-button {
  min-width: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  transition:
    transform 0.15s,
    opacity 0.15s;
  line-height: 1;
  border-radius: 14px;
}
.control-button[data-action="hint"],
.control-button[data-action="restart"],
.control-button[data-action="shuffle"],
.control-button[data-action="addCup"] {
  position: relative;
}
.hint-count,
.restart-count,
.shuffle-count,
.addcup-count {
  position: absolute;
  top: -10px;
  left: 70%;
  right: auto;
  transform: translateX(-50%);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  background: linear-gradient(145deg, var(--accent), var(--aqua));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
  letter-spacing: -0.02em;
  pointer-events: none;
  z-index: 5;
}
.control-button[data-action="hint"]:disabled .hint-count,
.control-button[data-action="restart"]:disabled .restart-count,
.control-button[data-action="shuffle"]:disabled .shuffle-count,
.control-button[data-action="addCup"]:disabled .addcup-count {
  opacity: 1;
}
.app[data-theme="night"] .hint-count,
.app[data-theme="night"] .restart-count,
.app[data-theme="night"] .shuffle-count,
.app[data-theme="night"] .addcup-count {
  background: linear-gradient(145deg, #e879f9, #818cf8);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.75);
  box-shadow: 0 4px 12px rgba(129, 140, 248, 0.5);
}
.control-button .sprite {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 3px 0 rgba(77, 143, 158, 0.18);
  filter: none;
}
.control-button b {
  font-size: clamp(9px, 2.2vw, 11px);
  white-space: nowrap;
  color: var(--muted);
  font-weight: 800;
  font-family: var(--font);
}
.control-button:disabled {
  filter: grayscale(1);
  opacity: 0.38;
}
.control-button:not(:disabled):active {
  transform: scale(0.92);
}
.modal-layer {
  position: absolute;
  inset: 0;
  background: rgba(15, 35, 50, 0.52);
  backdrop-filter: blur(12px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  opacity: 0;
  visibility: hidden;
  transition: 0.25s;
}
.modal-layer.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  width: min(92vw, 400px);
  max-height: 90vh;
  overflow: auto;
  background: var(--modal-bg);
  color: var(--ink);
  border: 2px solid var(--panel-border);
  border-radius: 28px;
  padding: 22px;
  text-align: center;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
  animation: pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal.modal--win {
  padding: 0;
  overflow: hidden;
  border-radius: 28px;
}
.modal-head {
  margin-bottom: 4px;
}
.modal-head .hero-icon {
  margin: 0 auto 8px;
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.12));
}
.modal-head h2 {
  font-size: clamp(22px, 5.5vw, 28px);
  margin: 0 0 8px;
  font-weight: 900;
  line-height: 1.15;
}
.modal-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.45;
}
.modal-body {
  text-align: left;
  margin: 8px 0 4px;
}
.modal p {
  color: var(--muted);
}
.modal h2 {
  font-size: 28px;
  margin: 2px 0 10px;
  font-weight: 900;
}
.modal-win {
  text-align: center;
}
.modal-win .modal-hero {
  padding: 26px 22px 8px;
  background: radial-gradient(
    ellipse 120% 80% at 50% 0%,
    var(--hero-glow),
    transparent 72%
  );
}
.modal-win .modal-hero .hero-icon {
  width: 108px;
  height: 108px;
  margin: 0 auto;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.14));
  animation: trophyBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-win .modal-tag {
  margin: 0;
  color: var(--aqua);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.modal-win h2 {
  font-size: clamp(24px, 6vw, 32px);
  margin: 6px 0 12px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.star-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin: 0 22px 18px;
}
.star-chip {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  box-shadow: none;
}
.star-chip .sprite-star {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  filter: grayscale(1) brightness(1.15);
  opacity: 0.38;
}
.star-chip.on {
  background: none;
  border: 0;
  box-shadow: none;
  animation: starPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.star-chip.on .sprite-star {
  filter: drop-shadow(0 4px 8px rgba(0, 80, 140, 0.28));
  opacity: 1;
}
.modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 22px 18px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}
.stat-card small {
  color: var(--muted);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-card b {
  font-size: 26px;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.1;
}
.coin-card {
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  text-align: left;
}
.coin-card .sprite {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.12));
}
.coin-card div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.modal-actions {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 0 22px 22px;
}
.modal--win .modal-actions {
  margin-top: 0;
  padding-bottom: 24px;
}
.modal-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-actions .game-button {
  min-height: 54px;
  border-radius: 20px;
  font-size: 17px;
}
.game-button.compact {
  min-height: 48px;
  font-size: 15px;
  border-radius: 18px;
  box-shadow:
    0 5px 0 var(--btn-secondary-shadow),
    0 6px 16px rgba(0, 0, 0, 0.06);
}
.game-button.warn.compact {
  box-shadow:
    0 7px 0 #c47a00,
    0 12px 24px rgba(255, 140, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.app[data-theme="night"] .star-chip,
.app[data-theme="night"] .star-chip.on {
  background: none;
  border: 0;
  box-shadow: none;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  border-bottom: 1px solid rgba(84, 137, 151, 0.16);
  font-weight: 800;
}
.toggle {
  width: 58px;
  height: 34px;
  border-radius: 20px;
  background: #aabdc3;
  padding: 4px;
  transition: 0.2s;
}
.toggle::after {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px #657b83;
  transition: 0.2s;
}
.toggle.on {
  background: var(--aqua);
}
.toggle.on::after {
  transform: translateX(24px);
}
.language-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}
.language-buttons button {
  padding: 12px;
  border-radius: 16px;
  background: var(--btn-secondary-bg);
  font-weight: 800;
  color: var(--ink);
  border: 1px solid var(--panel-border);
}
.language-buttons button.active {
  background: var(--aqua);
  color: #fff;
  border-color: transparent;
}
.theme-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}
.theme-choice {
  height: 72px;
  border-radius: 18px;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  border: 3px solid transparent;
  transition:
    transform 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.theme-choice.active {
  border-color: #fff;
  box-shadow:
    0 0 0 2px var(--aqua),
    0 8px 20px rgba(0, 0, 0, 0.15);
  transform: scale(1.03);
}
.theme-choice:active {
  transform: scale(0.96);
}
.theme-choice::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--aqua);
  font-size: 13px;
  line-height: 22px;
  opacity: 0;
  transform: scale(0.5);
  transition: 0.2s;
}
.theme-choice.active::after {
  opacity: 1;
  transform: scale(1);
}
.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.94);
  padding: 12px 20px;
  background: rgba(28, 54, 67, 0.92);
  color: #fff;
  border-radius: 18px;
  font-weight: 800;
  font-family: var(--font);
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.35;
  opacity: 0;
  transition: 0.22s;
  pointer-events: none;
  max-width: min(86vw, 320px);
  text-align: center;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(23, 56, 73, 0.28);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.confetti {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 18px;
  border-radius: 3px;
  animation: fall 1.8s linear forwards;
}
.level-intro {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(15, 35, 50, 0.42);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}
.level-intro.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  animation: introIn 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.level-intro.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.intro-card {
  min-width: min(72vw, 260px);
  padding: 22px 28px;
  background: var(--modal-bg);
  border: 2px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.intro-card--level {
  min-width: min(84vw, 300px);
  padding: 24px 28px 20px;
  gap: 10px;
}
.intro-card small {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.intro-colors {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.intro-colors b {
  font-size: clamp(36px, 10vw, 48px);
  font-weight: 900;
  color: var(--aqua);
  line-height: 1;
}
.intro-colors span {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.intro-goal {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.35;
  max-width: 240px;
}
.intro-meta {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}
.intro-meta span {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  border: 1px solid rgba(22, 52, 71, 0.12);
}
.intro-start.game-button.primary {
  min-width: min(72vw, 240px);
  min-height: 58px;
  margin-top: 12px;
  border-radius: 22px;
  font-size: 20px;
  letter-spacing: 0.1em;
  color: #fff;
  background: linear-gradient(145deg, #ffe566 0%, #ffb020 52%, #ff8c00 100%);
  box-shadow:
    0 7px 0 #c47a00,
    0 12px 24px rgba(255, 140, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.intro-start.game-button.primary b {
  color: #fff;
  text-shadow: 0 1px 2px rgba(140, 60, 0, 0.45);
  background: none;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}
.app[data-theme="night"] .intro-meta span {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.app[data-theme="night"] .intro-start.game-button.primary {
  box-shadow:
    0 7px 0 #9a5a00,
    0 14px 28px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.intro-go {
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 900;
  color: var(--ink);
  margin-top: 4px;
  animation: introGo 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s backwards;
}
.intro-hand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 4px;
  padding: 8px 14px 8px 8px;
  background: rgba(22, 52, 71, 0.08);
  border: 1px solid rgba(22, 52, 71, 0.12);
  border-radius: 18px;
  overflow: visible;
}
.intro-hand-row span {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  text-align: left;
  line-height: 1.3;
}
.hand-pointer {
  display: block;
  width: 78px;
  height: 68px;
  flex-shrink: 0;
  position: relative;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.28));
  animation: handTap 0.85s ease-in-out infinite;
  transform-origin: 12% 48%;
}
.hand-pointer svg {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(18deg);
}
.hand-pointer.intro-hand {
  width: 70px;
  height: 62px;
}
.hand-pointer.hero-hand {
  width: 108px;
  height: 96px;
  margin: 0 auto 10px;
}
.tap-ripple,
.tap-ripple::after {
  position: absolute;
  left: 4%;
  top: 36%;
  width: 16px;
  height: 16px;
  border: 2.5px solid #22c3e5;
  border-radius: 50%;
  pointer-events: none;
  animation: tapRipple 1.05s ease-out infinite;
}
.tap-ripple::after {
  content: "";
  left: -7px;
  top: -7px;
  width: 30px;
  height: 30px;
  animation-delay: 0.22s;
  border-color: #ffb020;
}
.app[data-theme="night"] .intro-hand-row {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}
.app[data-theme="night"] .intro-hand-row span {
  color: #fff;
}
.guide-head .hero-hand {
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.16));
}
.cup.tutorial-pulse {
  animation: pulseTarget 1s infinite;
}
.hand-tutorial {
  position: absolute;
  z-index: 26;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.hand-tutorial[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}
.hand-tutorial .hand-pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 92px;
  height: 80px;
}
.hand-tip {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 8px);
  min-width: max-content;
  max-width: 180px;
  padding: 8px 12px;
  background: rgba(23, 48, 68, 0.94);
  color: #fff;
  border-radius: 14px;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}
.hand-tip::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -8px;
  border: 6px solid transparent;
  border-top-color: rgba(23, 48, 68, 0.94);
}
.modal--guide .guide-head small {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.modal--guide .guide-head p {
  font-size: 15px;
  line-height: 1.45;
  max-width: 280px;
  margin: 0 auto;
}
.guide-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 4px;
}
.guide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--panel-border);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}
.guide-dot.on {
  background: var(--aqua);
  transform: scale(1.25);
}
.pour-layer {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  overflow: hidden;
}
.coin-fly-layer {
  position: absolute;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  overflow: visible;
}
.fly-coin {
  position: absolute;
  display: block;
  transform-origin: center center;
  backface-visibility: hidden;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
  will-change: transform, opacity;
  z-index: 1;
}
.coin-stat.coin-pulse .sprite {
  animation: coinPulse 0.5s ease;
}
.coin-stat.coin-pulse b {
  animation: coinNumPulse 0.5s ease;
}
.pour-wrap {
  will-change: left, top;
  backface-visibility: hidden;
  overflow: visible;
}
.pour-wrap .pour-clone {
  width: 100% !important;
  height: 100% !important;
}
.cup.pour-target {
  filter: drop-shadow(0 0 12px rgba(49, 217, 187, 0.42));
}
.pour-clone {
  filter: drop-shadow(0 12px 10px rgba(41, 83, 105, 0.22));
  backface-visibility: hidden;
}
.pour-clone::before,
.pour-clone::after {
  z-index: 4;
}
.pour-stream {
  position: absolute;
  width: 7px;
  border-radius: 5px;
  transform-origin: top center;
  z-index: 21;
  opacity: 0;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.25);
  transition: opacity 0.2s ease;
}
.pour-stream.active {
  opacity: 0.92;
  animation: streamFlow 1.1s ease-in-out infinite alternate;
}
.pour-stream.fade-out {
  opacity: 0 !important;
  animation: none;
}
.liquid.pouring-out {
  animation: liquidDrain 0.42s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}
.liquid.pouring-in {
  transform-origin: top center;
  animation: liquidFill 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.pour-layer {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  overflow: hidden;
}
@keyframes coinGainPop {
  0% {
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.8);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(1.1);
  }
}
@keyframes coinNumPulse {
  50% {
    transform: scale(1.18);
    color: var(--accent);
  }
}
@keyframes coinPulse {
  50% {
    transform: scale(1.15);
  }
}
@keyframes introIn {
  0% {
    opacity: 0;
    transform: scale(0.88);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes handTap {
  0%,
  100% {
    transform: translate(0, 0);
  }
  40% {
    transform: translate(-10px, 8px) scale(0.94);
  }
  58% {
    transform: translate(-4px, 3px) scale(0.98);
  }
}
@keyframes tapRipple {
  0% {
    transform: scale(0.45);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}
@keyframes streamFlow {
  0% {
    opacity: 0.78;
    filter: brightness(0.95);
  }
  100% {
    opacity: 1;
    filter: brightness(1.08);
  }
}
@keyframes liquidDrain {
  0% {
    transform: translateY(0) scaleY(1);
    opacity: 1;
  }
  100% {
    transform: translateY(70%) scaleY(0.25);
    opacity: 0;
  }
}
@keyframes liquidFill {
  0% {
    transform: scaleY(0);
    opacity: 0.25;
  }
  100% {
    transform: scaleY(1);
    opacity: 1;
  }
}
@keyframes float {
  50% {
    transform: translateY(-20px) scale(1.04);
  }
}
@keyframes dots {
  50% {
    transform: translateY(-10px);
    opacity: 0.5;
  }
}
@keyframes shake {
  25% {
    transform: translateX(-7px);
  }
  50% {
    transform: translateX(7px);
  }
  75% {
    transform: translateX(-4px);
  }
}
@keyframes wave {
  50% {
    transform: translateY(2px) scaleX(1.06);
  }
}
@keyframes pulse {
  50% {
    filter: drop-shadow(0 0 8px #ffd037);
    transform: translateY(-6px);
  }
}
@keyframes playTwinkle {
  0%,
  100% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  35% {
    transform: scale(1.15) rotate(18deg);
    opacity: 1;
  }
  65% {
    transform: scale(0.35) rotate(32deg);
    opacity: 0.35;
  }
}
@keyframes pulseTarget {
  50% {
    filter: drop-shadow(0 0 8px #31d9bb);
    transform: scale(1.03);
  }
}
@keyframes pop {
  0% {
    transform: scale(0.75);
    opacity: 0;
  }
  70% {
    transform: scale(1.04);
  }
}
@keyframes starPop {
  0% {
    transform: scale(0) rotate(-30deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}
@keyframes trophyBounce {
  0% {
    transform: scale(0.5) translateY(20px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}
@keyframes introGo {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes fall {
  to {
    transform: translateY(110vh) rotate(620deg);
  }
}
@keyframes intro {
  0% {
    opacity: 0;
    visibility: visible;
    transform: scale(0.8);
  }
  25%,
  70% {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.12);
  }
}
.modal--win .modal-actions .game-button.primary {
  min-height: 58px;
  border-radius: 22px;
  font-size: 18px;
  letter-spacing: 0.04em;
  box-shadow:
    0 7px 0 var(--btn-shadow),
    0 12px 28px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.modal--win .modal-actions .game-button.secondary.compact {
  min-height: 52px;
  border-radius: 20px;
  font-size: 15px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.96),
    rgba(255, 255, 255, 0.84)
  );
  color: var(--ink);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 5px 0 var(--btn-secondary-shadow),
    0 8px 18px rgba(0, 0, 0, 0.1);
}
.app[data-theme="night"]
  .modal--win
  .modal-actions
  .game-button.secondary.compact {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.26),
    rgba(255, 255, 255, 0.12)
  );
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow:
    0 5px 0 rgba(0, 0, 0, 0.38),
    0 8px 20px rgba(0, 0, 0, 0.22);
}
.app[data-theme="night"] .modal--win .modal-actions .game-button.primary {
  box-shadow:
    0 7px 0 var(--btn-shadow),
    0 14px 34px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.app[data-theme="night"] .stat-card {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
@media (min-width: 700px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #9ed7db, #b5b0df);
  }
  .app {
    position: relative;
    width: min(100%, 520px);
    height: min(100%, 900px);
    border-radius: 32px;
    box-shadow: 0 25px 90px rgba(25, 56, 71, 0.3);
    transform: none;
    top: auto;
  }
  .level-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (max-height: 650px) {
  .game-header .topbar {
    height: 48px;
  }
  .game-header {
    padding: 4px 10px 8px;
    margin-bottom: 6px;
  }
  .game-header .level-heading b {
    font-size: 22px;
  }
  .board {
    --cup-w: clamp(30px, 7.8vw, 44px);
    --cup-h: clamp(70px, 17.5vw, 100px);
  }
  .control-button .sprite {
    width: 40px;
    height: 40px;
  }
  .game-controls {
    padding: 8px 6px 4px;
    margin-top: 6px;
  }
  .game-prompt h2 {
    margin: 4px 0 0;
    font-size: 15px;
  }
  .home-hero {
    padding: 4px 0 8px;
  }
  .logo-badge {
    width: 88px;
    height: 88px;
  }
  .logo-ring {
    width: 88px;
    height: 88px;
  }
  .logo-mark {
    width: 62px !important;
    height: 62px !important;
  }
  .menu-card {
    min-height: 68px;
  }
  .game-button.primary.play-btn,
  .play-btn {
    min-height: 50px;
    font-size: 18px;
  }
  .home-panel {
    padding: 12px 12px 10px;
    gap: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
