:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --night: #080e2a;
  --night-soft: #101942;
  --panel: rgba(22, 32, 73, 0.82);
  --glass: rgba(221, 236, 247, 0.72);
  --glass-soft: rgba(221, 236, 247, 0.2);
  --cream: #f6e9c9;
  --muted: #a9b2ce;
  --gold: #efc978;
  --gold-soft: rgba(239, 201, 120, 0.18);
  --bottle-h: clamp(72px, calc((100dvh - 144px) / 5.05), 132px);
  --bottle-w: calc(var(--bottle-h) * 0.57);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overflow: clip;
  background: var(--night);
  overscroll-behavior: none;
}

body {
  color: var(--cream);
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 480px;
  overflow: hidden;
  overflow: clip;
  background:
    radial-gradient(circle at 50% 12%, rgba(91, 105, 164, 0.22), transparent 34%),
    linear-gradient(180deg, #0d1538 0%, #080e2a 58%, #070b20 100%);
}

#app::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 16% 14%, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle at 79% 20%, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle at 63% 7%, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle at 30% 32%, #fff 0 0.8px, transparent 1.2px);
}

.ambient {
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  filter: blur(75px);
  opacity: 0.11;
  pointer-events: none;
}

.ambient-one {
  top: -130px;
  left: -90px;
  background: #8176c4;
}

.ambient-two {
  right: -120px;
  bottom: -120px;
  background: #d59a69;
}

.screen {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

.screen.active {
  display: flex;
  animation: screen-in 360ms ease-out;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.start-screen,
.home-screen,
.result-screen,
.settings-screen {
  flex-direction: column;
  align-items: center;
}

.start-screen {
  justify-content: center;
  padding-inline: 28px;
  text-align: center;
}

.moon-logo {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 22px;
  border-radius: 50%;
  background: rgba(239, 201, 120, 0.08);
  box-shadow: 0 0 70px rgba(239, 201, 120, 0.15);
}

.moon-logo::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 27px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 28px rgba(239, 201, 120, 0.35);
}

.moon-logo::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 45px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #111941;
}

.moon-logo span::before,
.moon-logo span::after {
  content: "✦";
  position: absolute;
  color: var(--cream);
}

.moon-logo span::before {
  right: 7px;
  bottom: 16px;
  font-size: 15px;
}

.moon-logo span::after {
  left: 10px;
  top: 9px;
  font-size: 9px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(34px, 10vw, 46px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.subtitle {
  max-width: 280px;
  margin-bottom: 42px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.tiny-note {
  margin-top: 20px;
  color: rgba(169, 178, 206, 0.72);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.primary-button,
.secondary-button {
  width: min(82vw, 320px);
  min-height: 50px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.primary-button {
  color: #1b2140;
  background: linear-gradient(180deg, #f4d995, #dcb76a);
  box-shadow: 0 12px 32px rgba(222, 182, 104, 0.16), inset 0 1px rgba(255, 255, 255, 0.5);
}

.primary-button:active,
.secondary-button:active,
.control-button:active {
  transform: scale(0.98);
}

.primary-button:disabled {
  opacity: 0.5;
}

.large-button {
  min-height: 58px;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--cream);
}

.simple-header,
.game-header {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  padding: 4px 10px;
  flex: 0 0 auto;
}

.simple-header h2 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  letter-spacing: 0.08em;
}

.icon-button {
  width: 44px;
  height: 44px;
  margin: auto;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
}

.icon-button.invisible {
  visibility: hidden;
}

.back-button,
#game-back,
#settings-back {
  font-size: 34px;
  font-family: serif;
  line-height: 1;
}

.home-screen {
  justify-content: flex-start;
}

.home-art {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 230px;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.hero-bottle {
  position: relative;
  width: 90px;
  height: 206px;
  overflow: hidden;
  border: 3px solid rgba(222, 236, 245, 0.72);
  border-top-width: 16px;
  border-radius: 25px 25px 31px 31px;
  box-shadow: inset 8px 0 14px rgba(255, 255, 255, 0.07), 0 24px 45px rgba(0, 0, 0, 0.25);
}

.hero-bottle::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -16px;
  left: 14px;
  width: 55px;
  height: 10px;
  border-radius: 5px;
  background: rgba(222, 236, 245, 0.7);
}

.hero-bottle i {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: calc(var(--i, 0) * 25%);
  height: 25%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.24) 0 1px, transparent 1.5px),
    var(--sand);
}

.hero-bottle i:nth-child(1) { bottom: 0; }
.hero-bottle i:nth-child(2) { bottom: 25%; }
.hero-bottle i:nth-child(3) { bottom: 50%; }
.hero-bottle i:nth-child(4) { bottom: 75%; }

.sleep-stars {
  position: absolute;
  top: 20%;
  left: 54%;
  color: var(--gold);
  opacity: 0.75;
  letter-spacing: 0.5em;
}

.home-actions {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
}

.progress-copy {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
}

.map-screen,
.game-screen {
  flex-direction: column;
}

.map-pagination {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  width: min(calc(100% - 32px), 430px);
  margin: 4px auto 8px;
}

.map-pagination button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  font-family: serif;
  font-size: 28px;
}

.map-pagination button:disabled {
  opacity: .28;
}

.map-pagination label {
  position: relative;
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid rgba(239, 201, 120, .14);
  border-radius: 14px;
  background: rgba(239, 201, 120, .07);
}

.map-pagination span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.map-pagination select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.level-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  width: 100%;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  scrollbar-width: none;
}

.level-map::-webkit-scrollbar {
  display: none;
}

.level-node {
  aspect-ratio: 1;
  min-height: 62px;
  border: 1px solid rgba(239, 201, 120, 0.2);
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.055);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.level-node strong {
  font-size: 19px;
}

.level-node span {
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.level-node.current {
  background: var(--gold-soft);
  box-shadow: 0 0 22px rgba(239, 201, 120, 0.12);
}

.level-node.locked {
  border-color: rgba(255,255,255,.05);
  color: #6d7593;
  background: rgba(255, 255, 255, 0.025);
}

.game-header {
  min-height: 55px;
}

.level-heading {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.level-heading span {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.15em;
}

.level-heading strong {
  margin-top: 2px;
  font-size: 16px;
}

.tutorial-hint {
  height: 0;
  flex: 0 0 0;
  overflow: hidden;
  color: #d9d8e7;
  text-align: center;
  font-size: 11px;
  line-height: 26px;
  transition: 220ms ease;
}

.tutorial-hint.visible {
  height: 26px;
  flex-basis: 26px;
}

.game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  flex: 1 1 auto;
  width: min(100%, 470px);
  min-height: 0;
  margin: 0 auto;
  padding: 2px clamp(8px, 2.5vw, 15px) 3px;
  align-items: center;
  justify-items: center;
  gap: clamp(0px, 0.6vh, 5px) clamp(1px, 0.7vw, 5px);
  isolation: isolate;
}

.game-board::before {
  content: "";
  position: absolute;
  inset: 2px 0 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 8%, rgba(42, 65, 124, .32), transparent 42%),
    linear-gradient(180deg, rgba(11, 25, 67, .24), rgba(4, 9, 30, .08) 72%, rgba(0,0,0,.16));
  border-radius: 28px;
}

.board-slot {
  --slot-x: 0px;
  --slot-y: 0px;
  --slot-scale: 1;
  --slot-z: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: var(--slot-z);
}

.board-slot:nth-child(1) { --slot-x: -6px; --slot-y: -3px; --slot-z: 8; }
.board-slot:nth-child(2) { --slot-x: 1px; --slot-y: 3px; --slot-scale: .98; --slot-z: 7; }
.board-slot:nth-child(3) { --slot-x: -4px; --slot-y: -1px; --slot-scale: .98; --slot-z: 7; }
.board-slot:nth-child(4) { --slot-x: 4px; --slot-y: 4px; --slot-scale: .99; --slot-z: 7; }
.board-slot:nth-child(5) { --slot-x: 7px; --slot-y: -3px; --slot-z: 8; }
.board-slot:nth-child(6) { --slot-x: -8px; --slot-y: 3px; --slot-scale: .98; --slot-z: 6; }
.board-slot:nth-child(7) { --slot-x: 2px; --slot-y: -4px; --slot-z: 7; }
.board-slot:nth-child(8) { --slot-x: -5px; --slot-y: 4px; --slot-scale: .98; --slot-z: 6; }
.board-slot:nth-child(9) { --slot-x: 4px; --slot-y: -3px; --slot-scale: .99; --slot-z: 7; }
.board-slot:nth-child(10) { --slot-x: 8px; --slot-y: 3px; --slot-z: 6; }
.board-slot:nth-child(11) { --slot-x: -6px; --slot-y: -4px; --slot-z: 6; }
.board-slot:nth-child(12) { --slot-x: 3px; --slot-y: 4px; --slot-scale: .98; --slot-z: 5; }
.board-slot:nth-child(13) { --slot-x: -2px; --slot-y: -4px; --slot-z: 6; }
.board-slot:nth-child(14) { --slot-x: 6px; --slot-y: 3px; --slot-scale: .98; --slot-z: 5; }
.board-slot:nth-child(15) { --slot-x: -7px; --slot-y: -2px; --slot-z: 6; }
.board-slot:nth-child(16) { --slot-x: -8px; --slot-y: 4px; --slot-z: 5; }
.board-slot:nth-child(17) { --slot-x: 2px; --slot-y: -3px; --slot-scale: .99; --slot-z: 6; }
.board-slot:nth-child(18) { --slot-x: -4px; --slot-y: 3px; --slot-z: 5; }
.board-slot:nth-child(19) { --slot-x: 6px; --slot-y: -4px; --slot-scale: .98; --slot-z: 6; }
.board-slot:nth-child(20) { --slot-x: -6px; --slot-y: 3px; --slot-z: 5; }
.board-slot:nth-child(21) { grid-column: 2; --slot-x: -5px; --slot-y: -2px; --slot-z: 4; }
.board-slot:nth-child(22) { --slot-x: 2px; --slot-y: 4px; --slot-z: 4; }
.board-slot:nth-child(23) { --slot-x: 7px; --slot-y: -3px; --slot-z: 4; }

.board-slot.unused {
  visibility: hidden;
}

.bottle-visual {
  position: relative;
  display: block;
  width: var(--bottle-w);
  height: var(--bottle-h);
  max-width: 54px;
  min-width: 30px;
  transform: translate(var(--slot-x), var(--slot-y)) scale(var(--slot-scale));
  transform-origin: 50% 82%;
  transition: transform 180ms ease, filter 180ms ease;
  filter:
    drop-shadow(0 11px 6px rgba(0, 0, 0, 0.44))
    drop-shadow(0 1px 1px rgba(220, 239, 255, 0.58));
  transform-style: preserve-3d;
}

.bottle-visual::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -8px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.42), transparent 68%);
  transform: scaleX(1.15);
}

.board-slot.selected .bottle-visual {
  transform: translate(var(--slot-x), calc(var(--slot-y) - 8px)) scale(var(--slot-scale));
  filter: drop-shadow(0 0 9px rgba(239, 201, 120, 0.52)) brightness(1.08);
  animation: selected-bottle-wobble 1150ms ease-in-out infinite;
}

.board-slot.selected .svg-sand-layer {
  transform-box: fill-box;
  transform-origin: 50% 72%;
  animation: selected-sand-wobble 1150ms ease-in-out infinite;
}

@keyframes selected-bottle-wobble {
  0%,
  100% {
    transform: translate(var(--slot-x), calc(var(--slot-y) - 8px)) scale(var(--slot-scale)) rotate(0deg);
  }
  25% {
    transform: translate(calc(var(--slot-x) - 1px), calc(var(--slot-y) - 9px)) scale(var(--slot-scale)) rotate(-1.05deg);
  }
  52% {
    transform: translate(calc(var(--slot-x) + .6px), calc(var(--slot-y) - 7px)) scale(var(--slot-scale)) rotate(.82deg);
  }
  78% {
    transform: translate(calc(var(--slot-x) - .4px), calc(var(--slot-y) - 8.6px)) scale(var(--slot-scale)) rotate(-.48deg);
  }
}

@keyframes selected-sand-wobble {
  0%,
  100% {
    transform: translateX(0) skewX(0deg);
  }
  25% {
    transform: translateX(-.75px) skewX(-.8deg);
  }
  52% {
    transform: translateX(.65px) skewX(.65deg);
  }
  78% {
    transform: translateX(-.35px) skewX(-.35deg);
  }
}

.bottle-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.svg-glass-fill {
  fill: rgba(16, 29, 67, .42);
}

.svg-empty-glass {
  fill: #15244f;
  opacity: .68;
}

.svg-side-shade {
  fill: rgba(0, 0, 0, .12);
}

.svg-left-shine {
  fill: rgba(255,255,255,.22);
  filter: blur(.15px);
}

.svg-small-shine {
  fill: rgba(255,255,255,.16);
}

.svg-glass-edge-back {
  fill: none;
  stroke: rgba(42, 48, 64, .5);
  stroke-width: 7.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.svg-glass-edge {
  fill: none;
  stroke: rgba(235, 242, 248, .84);
  stroke-width: 4.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(255,255,255,.32));
}

.svg-inner-glass-edge {
  fill: none;
  stroke: rgba(255,255,255,.18);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.svg-shoulder-highlight {
  fill: none;
  stroke: rgba(255,255,255,.34);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.svg-bottom-rim {
  fill: none;
  stroke: rgba(255,255,255,.38);
  stroke-width: .9;
}

.svg-mouth-outer {
  stroke: rgba(255,255,255,.92);
  stroke-width: 1.25;
  filter: drop-shadow(0 1.5px 1px rgba(0,0,0,.42));
}

.svg-mouth-inner {
  stroke: rgba(255,255,255,.52);
  stroke-width: .7;
}

.svg-mouth-depth {
  fill: rgba(42, 49, 67, .78);
  filter: drop-shadow(0 1.1px 1px rgba(0,0,0,.42));
}

.svg-mouth-wall {
  fill: rgba(202, 216, 229, .72);
  stroke: rgba(255,255,255,.4);
  stroke-width: .45;
  filter: drop-shadow(0 1px .8px rgba(0,0,0,.34));
}

.svg-mouth-back-lip {
  fill: rgba(255,255,255,.42);
  opacity: .82;
}

.svg-mouth-gloss {
  fill: rgba(255,255,255,.62);
  opacity: .78;
}

.svg-mouth-front-lip {
  fill: rgba(246,250,255,.34);
  stroke: rgba(255,255,255,.36);
  stroke-width: .55;
  filter: drop-shadow(0 .7px .45px rgba(0,0,0,.28));
}

.svg-neck-flash {
  fill: none;
  stroke: rgba(255,255,255,.34);
  stroke-width: 1.25;
  stroke-linecap: round;
}

.svg-sand-layer {
  filter: saturate(1.08) brightness(1.01);
}

.svg-grains {
  opacity: .34;
  mix-blend-mode: soft-light;
}

.svg-hidden-layer {
  filter: none;
}

.svg-hidden-layer .svg-grains {
  opacity: .32;
}

.svg-question {
  fill: rgba(255, 255, 255, .92);
  font-family: "Arial Rounded MT Bold", "Microsoft YaHei", sans-serif;
  font-size: 21px;
  font-weight: 900;
  paint-order: stroke;
  stroke: rgba(0,0,0,.64);
  stroke-width: 1.5px;
  text-shadow: 0 2px 2px rgba(0,0,0,.8);
}

.svg-reserve-plus {
  fill: rgba(240, 247, 255, .78);
  font-family: "Arial Rounded MT Bold", "Microsoft YaHei", sans-serif;
  font-size: 30px;
  font-weight: 900;
  paint-order: stroke;
  stroke: rgba(0,0,0,.28);
  stroke-width: 1.8px;
}

.board-slot.reserve .svg-empty-glass {
  opacity: .24;
}

.board-slot.reserve .svg-glass-edge,
.board-slot.reserve .svg-mouth-outer,
.board-slot.reserve .svg-bottom-rim {
  opacity: .56;
}

.complete-badge {
  position: absolute;
  z-index: 8;
  left: 47%;
  top: 34%;
  display: grid;
  place-items: center;
  width: calc(var(--bottle-w) * .58);
  height: calc(var(--bottle-w) * .58);
  border-radius: 50%;
  color: #fff9ec;
  background:
    radial-gradient(circle at 34% 28%, #fff8c7 0 10%, #f65b46 11% 47%, #c92324 62%, #8b171e 100%);
  border: 2px solid rgba(255, 221, 125, .72);
  box-shadow: 0 2px 4px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.44);
  transform: translateX(-50%) rotate(-8deg);
}

.complete-badge::before,
.complete-badge::after {
  content: "";
  position: absolute;
  top: 72%;
  width: 34%;
  height: 72%;
  background: linear-gradient(180deg, #f04438, #bb1820);
  clip-path: polygon(0 0, 100% 0, 76% 100%, 48% 76%, 18% 100%);
  z-index: -1;
}

.complete-badge::before {
  left: 16%;
  transform: rotate(20deg);
}

.complete-badge::after {
  right: 13%;
  transform: rotate(-20deg);
}

.complete-badge b {
  font-size: calc(var(--bottle-w) * .28);
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.55);
}

.bottle-neck {
  position: absolute;
  z-index: 4;
  top: 2%;
  left: 30%;
  width: 40%;
  height: 20%;
  border: 2.5px solid rgba(225, 237, 246, 0.9);
  border-bottom: 0;
  border-radius: 32% 32% 8% 8% / 26% 26% 8% 8%;
  background:
    radial-gradient(ellipse at 47% 5%, rgba(255,255,255,.72), transparent 48%),
    linear-gradient(90deg,
      rgba(54, 80, 123, 0.5) 0%,
      rgba(239, 249, 255, 0.42) 18%,
      rgba(255, 255, 255, 0.06) 48%,
      rgba(30, 48, 88, 0.34) 78%,
      rgba(222, 238, 250, 0.34) 100%);
  box-shadow:
    inset 2px 0 2px rgba(255,255,255,.42),
    inset -2px 0 2px rgba(18,28,57,.55),
    0 1px 2px rgba(4,7,20,.44);
}

.bottle-neck::before {
  content: "";
  position: absolute;
  top: -7px;
  left: -7px;
  width: calc(100% + 14px);
  height: 9px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 48% 32%, rgba(255,255,255,.95), rgba(205,221,236,.78) 34%, rgba(83,101,134,.75) 68%, rgba(240,248,255,.75) 100%);
  box-shadow:
    0 2px 3px rgba(0,0,0,.5),
    inset 0 2px rgba(255,255,255,.78),
    inset 0 -2px rgba(42,56,86,.42);
}

.bottle-neck::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 20%;
  width: 60%;
  height: 4px;
  border-radius: 50%;
  background: rgba(21, 28, 54, .42);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.5);
}

.bottle-body {
  position: absolute;
  z-index: 2;
  left: 5%;
  right: 5%;
  bottom: 0;
  height: 81%;
  overflow: hidden;
  border: 2.6px solid rgba(229, 240, 248, 0.9);
  border-radius: 34% 34% 24% 24% / 12% 12% 7% 7%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.34), transparent 38%),
    linear-gradient(90deg,
      rgba(46, 69, 111, .58) 0%,
      rgba(234, 246, 255, .38) 11%,
      rgba(255,255,255,.045) 30%,
      rgba(8,13,35,.08) 59%,
      rgba(9,18,50,.42) 79%,
      rgba(231,244,255,.4) 100%);
  box-shadow:
    inset 3px 0 5px rgba(255,255,255,.34),
    inset -5px 0 6px rgba(8,15,39,.56),
    inset 0 -5px 6px rgba(12,19,43,.48),
    0 0 0 1px rgba(103,125,157,.3),
    0 1px 0 rgba(255,255,255,.32);
}

.bottle-body::before,
.bottle-body::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.bottle-body::before {
  z-index: 0;
  inset: 5px 4px 4px;
  border-radius: 29% 29% 18% 18% / 10% 10% 6% 6%;
  background:
    radial-gradient(ellipse at 45% 11%, rgba(255,255,255,.12), transparent 34%),
    linear-gradient(180deg, rgba(16, 31, 73, .74), rgba(3, 8, 27, .8));
  box-shadow: inset 0 0 18px rgba(11,22,58,.78);
}

.bottle-body::after {
  z-index: 4;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg,
      rgba(255,255,255,.55) 0 3px,
      rgba(255,255,255,.08) 8px,
      transparent 28%,
      transparent 72%,
      rgba(255,255,255,.12) 82%,
      rgba(255,255,255,.42) 100%),
    radial-gradient(ellipse at 50% 100%, rgba(255,255,255,.28), transparent 46%);
  opacity: .46;
}

.sand-stack {
  position: absolute;
  z-index: 1;
  inset: 7px 5px 5px;
  overflow: hidden;
  border-radius: 27% 27% 18% 18% / 9% 9% 6% 6%;
  box-shadow:
    inset 4px 0 5px rgba(0,0,0,.22),
    inset -5px 0 6px rgba(0,0,0,.28),
    inset 0 -3px 5px rgba(0,0,0,.24);
}

.sand-layer {
  position: absolute;
  z-index: 1;
  left: 1px;
  right: 1px;
  bottom: calc(var(--layer) * 25%);
  height: calc(25% + 2px);
  background:
    radial-gradient(circle at 18% 24%, rgba(255,255,255,.72) 0 .55px, transparent 1.15px),
    radial-gradient(circle at 79% 62%, rgba(0,0,0,.34) 0 .65px, transparent 1.25px),
    radial-gradient(circle at 47% 83%, rgba(255,255,255,.28) 0 .48px, transparent 1.05px),
    radial-gradient(circle at 58% 34%, rgba(255,255,255,.2) 0 .42px, transparent 1px),
    linear-gradient(90deg,
      color-mix(in srgb, var(--sand) 58%, #05091b) 0%,
      color-mix(in srgb, var(--sand) 96%, white) 18%,
      var(--sand) 48%,
      color-mix(in srgb, var(--sand) 88%, #ffffff) 61%,
      color-mix(in srgb, var(--sand) 67%, #020617) 100%);
  background-size: 4px 4px, 5px 5px, 6px 6px, 7px 7px, auto;
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,.24),
    inset 3px 0 3px rgba(255,255,255,.12),
    inset -4px 0 4px rgba(0,0,0,.22),
    inset 0 -3px 4px rgba(0,0,0,.24);
  filter: saturate(1.16) brightness(.96);
  overflow: visible;
}

.sand-layer::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -4px;
  left: -1%;
  width: 102%;
  height: 9px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 47% 28%, rgba(255,255,255,.45), transparent 58%),
    radial-gradient(circle at 26% 58%, rgba(255,255,255,.48) 0 .5px, transparent 1px),
    radial-gradient(circle at 76% 45%, rgba(0,0,0,.2) 0 .55px, transparent 1px),
    color-mix(in srgb, var(--sand) 88%, white);
  background-size: auto, 5px 3px, 6px 4px, auto;
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.28),
    inset 0 -2px 2px rgba(0,0,0,.18),
    0 1px 2px rgba(0,0,0,.22);
  opacity: .86;
}

.sand-layer::after {
  content: "";
  position: absolute;
  z-index: 3;
  top: 4px;
  bottom: 1px;
  left: 12%;
  width: 13%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.42), rgba(255,255,255,.07) 72%, transparent);
  opacity: .34;
}

.sand-layer.unknown {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 24% 26%, rgba(255,255,255,.08) 0 .8px, transparent 1.4px),
    radial-gradient(circle at 74% 66%, rgba(255,255,255,.05) 0 .7px, transparent 1.2px),
    linear-gradient(90deg, #050711, #111629 18%, #0b0f1e 70%, #02040a);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.06),
    inset -4px 0 5px rgba(0,0,0,.48),
    inset 0 -3px 4px rgba(0,0,0,.42);
}

.sand-layer.unknown b {
  color: rgba(246, 233, 201, 0.9);
  font-size: clamp(12px, calc(var(--bottle-h) * .18), 19px);
  line-height: 1;
  transform: translateY(1px);
  text-shadow: 0 1px 2px #000, 0 0 5px rgba(255,255,255,.18);
}

.glass-shine {
  position: absolute;
  z-index: 3;
  top: 13%;
  left: 14%;
  width: 14%;
  height: 66%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 12%, rgba(255,255,255,.94), transparent 24%),
    linear-gradient(180deg, rgba(255,255,255,.68), rgba(255,255,255,.1) 72%, transparent);
  opacity: .62;
}

.glass-shine::after {
  content: "";
  position: absolute;
  left: 125%;
  top: 14%;
  width: 42%;
  height: 38%;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
}

.glass-rim {
  position: absolute;
  z-index: 5;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 2px 0 2px rgba(255,255,255,.34),
    inset -2px 0 2px rgba(255,255,255,.26),
    inset 0 2px 2px rgba(255,255,255,.22),
    inset 0 -2px 2px rgba(255,255,255,.14);
}

.bottle-base {
  position: absolute;
  z-index: 5;
  left: 12%;
  right: 12%;
  bottom: -2px;
  height: 8px;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(255,255,255,.86), rgba(189,205,220,.72) 38%, rgba(58,74,107,.64) 72%, rgba(232,242,250,.72));
  box-shadow:
    0 2px 3px rgba(0,0,0,.5),
    inset 0 2px rgba(255,255,255,.66),
    inset 0 -2px rgba(24,34,62,.36);
}

.bottle-cork {
  position: absolute;
  z-index: 6;
  top: -5px;
  left: 23%;
  width: 54%;
  height: 12%;
  border-radius: 50% 50% 18% 18% / 40% 40% 12% 12%;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255,231,175,.8), transparent 34%),
    linear-gradient(180deg, #c98246, #99603d 72%, #77452f);
  box-shadow:
    inset 0 1px rgba(255,255,255,.28),
    0 2px 2px rgba(0,0,0,.44);
  opacity: 0;
  transform: translateY(-12px);
}

.board-slot.sealing .bottle-cork {
  animation: cork-in 420ms ease-out forwards;
}

.board-slot.sealing .bottle-visual {
  animation: bottle-rest 620ms ease-in-out forwards;
}

@keyframes cork-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bottle-rest {
  0% {
    filter: drop-shadow(0 0 0 rgba(239,201,120,0));
    opacity: 1;
    transform: translate(var(--slot-x), var(--slot-y)) scale(var(--slot-scale));
  }
  35% {
    filter: drop-shadow(0 0 15px rgba(239,201,120,.75)) brightness(1.18);
    transform: translate(var(--slot-x), calc(var(--slot-y) - 5px)) scale(var(--slot-scale));
  }
  100% {
    filter: drop-shadow(0 0 22px rgba(239,201,120,.12));
    opacity: .12;
    transform: translate(var(--slot-x), calc(var(--slot-y) - 9px)) scale(calc(var(--slot-scale) * .93));
  }
}

.reserve-outline {
  position: relative;
  width: var(--bottle-w);
  height: var(--bottle-h);
  max-width: 54px;
  min-width: 30px;
  opacity: 0.62;
  transform: translate(var(--slot-x), var(--slot-y)) scale(var(--slot-scale));
  filter: drop-shadow(0 8px 5px rgba(0,0,0,.35));
}

.reserve-outline::before {
  content: "";
  display: none;
}

.reserve-outline::after {
  content: "";
  display: none;
}

.reserve-outline i {
  display: none;
}

.resting-glow {
  color: rgba(239, 201, 120, 0.22);
  font-size: 13px;
  transform: translate(var(--slot-x), var(--slot-y)) scale(var(--slot-scale));
  animation: resting 2.8s ease-in-out infinite;
}

@keyframes resting {
  50% { opacity: .4; transform: translate(var(--slot-x), var(--slot-y)) scale(calc(var(--slot-scale) * 1.12)); }
}

.game-controls {
  display: grid;
  grid-template-columns: 1fr 1.35fr 1fr;
  gap: 8px;
  flex: 0 0 auto;
  width: 100%;
  min-height: 70px;
  padding: 6px 10px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.045);
  background: linear-gradient(180deg, rgba(7, 11, 32, 0.35), rgba(7, 11, 32, 0.82));
}

.control-button {
  position: relative;
  min-height: 52px;
  padding: 4px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 16px;
  background: rgba(255,255,255,.055);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #d9dfef;
  font-size: 11px;
}

.control-button:disabled {
  opacity: 0.35;
}

.control-icon {
  font-size: 20px;
  line-height: 1;
}

.add-button {
  color: #17203b;
  background: linear-gradient(180deg, #ecd18e, #cfaa63);
  font-weight: 700;
}

.add-button small {
  position: absolute;
  top: 4px;
  right: 7px;
  font-size: 8px;
  opacity: .65;
}

.flying-grain {
  position: fixed;
  z-index: 92;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    0 0 3px currentColor,
    inset 0 1px 1px rgba(255,255,255,.55);
}

.pour-stream {
  position: fixed;
  z-index: 91;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
  transition: opacity 80ms linear;
}

.pour-stream-line,
.pour-stream-glow {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 6 7;
  animation: pour-stream-flow 260ms linear infinite;
}

.pour-stream-line {
  stroke-width: 3.2;
  opacity: .9;
}

.pour-stream-glow {
  stroke-width: 7;
  opacity: .2;
  filter: blur(1.4px);
}

@keyframes pour-stream-flow {
  to { stroke-dashoffset: -13; }
}

.pouring-clone {
  position: fixed !important;
  z-index: 90;
  margin: 0 !important;
  pointer-events: none;
  transform-origin: 50% 18%;
  filter:
    drop-shadow(0 12px 8px rgba(0,0,0,.5))
    drop-shadow(0 0 3px rgba(210,235,255,.38));
}

.svg-pour-level {
  pointer-events: none;
  transform-box: fill-box;
  opacity: .92;
}

.svg-pour-level.fill {
  transform-origin: center bottom;
  filter: saturate(1.06);
}

.svg-pour-level.drain {
  transform-origin: center top;
  opacity: .88;
}

.result-screen {
  justify-content: center;
  padding-inline: 22px;
  text-align: center;
}

.result-card {
  width: min(100%, 360px);
  padding: 34px 24px 24px;
  border: 1px solid rgba(239, 201, 120, 0.16);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(27, 39, 82, 0.88), rgba(14, 22, 55, 0.9));
  box-shadow: 0 28px 70px rgba(0,0,0,.3);
}

.result-seal {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 18px;
  border-radius: 50%;
  color: #27304f;
  background: var(--gold);
  font-size: 31px;
  box-shadow: 0 0 36px rgba(239,201,120,.24);
}

.result-card h2 {
  margin-bottom: 16px;
  font-size: 27px;
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.result-stars span {
  color: rgba(255,255,255,.12);
  font-size: 35px;
}

.result-stars span.earned {
  color: var(--gold);
  text-shadow: 0 0 16px rgba(239,201,120,.25);
  animation: star-in 500ms backwards;
}

.result-stars span:nth-child(2) { animation-delay: 120ms; }
.result-stars span:nth-child(3) { animation-delay: 240ms; }

@keyframes star-in {
  from { opacity: 0; transform: scale(.4) rotate(-20deg); }
}

.result-time {
  margin-bottom: 6px;
  font-size: 15px;
}

.result-best {
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 11px;
}

.result-card .primary-button {
  width: 100%;
}

.result-secondary {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-top: 18px;
}

.text-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.settings-card {
  width: min(calc(100% - 32px), 380px);
  margin-top: 24px;
  padding: 8px 20px;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 24px;
  background: var(--panel);
}

.setting-row,
.slider-setting {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.setting-row strong,
.slider-setting strong {
  display: block;
  font-size: 14px;
}

.setting-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  border: 0;
  border-radius: 20px;
  background: rgba(255,255,255,.1);
}

.toggle span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #b7bfd4;
  transition: 180ms ease;
}

.toggle.on {
  background: rgba(239, 201, 120, 0.5);
}

.toggle.on span {
  left: 26px;
  background: var(--cream);
}

.slider-setting {
  display: block;
  padding: 17px 0 14px;
}

.slider-setting > span {
  display: flex;
  justify-content: space-between;
}

.slider-setting output {
  color: var(--muted);
  font-size: 11px;
}

.slider-setting input {
  width: 100%;
  margin-top: 14px;
  accent-color: var(--gold);
}

.settings-note {
  margin: 16px 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.rotate-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 14, 42, 0.97);
}

.rotate-phone {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 54px;
  transform: rotate(90deg);
}

.rotate-overlay strong {
  font-size: 18px;
}

.rotate-overlay span {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: calc(100% - 40px);
  padding: 9px 15px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(19, 28, 64, .94);
  color: #e7e7ee;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: 180ms ease;
}

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

@media (orientation: landscape) and (max-height: 600px) {
  .rotate-overlay {
    display: flex;
  }
}

@media (max-height: 620px) {
  :root {
    --bottle-h: clamp(52px, calc((100dvh - 150px) / 5), 76px);
  }
  .game-header {
    min-height: 48px;
  }
  .game-controls {
    min-height: 62px;
    padding-top: 4px;
  }
  .control-button {
    min-height: 48px;
  }
  .tutorial-hint.visible {
    height: 22px;
    flex-basis: 22px;
    line-height: 22px;
  }
}

@media (min-width: 520px) {
  .game-board {
    padding-inline: 24px;
  }
}

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