:root {
  --ink: #173235;
  --muted: #6a7d7c;
  --paper: #f5f1e8;
  --paper-deep: #e7e1d5;
  --card: #fffdf7;
  --teal: #2d7471;
  --teal-deep: #102b2d;
  --coral: #e9453c;
  --yellow: #f4c42b;
  --blue: #2589de;
  --lavender: #9067ba;
  --green: #68b733;
  --shadow: 0 18px 50px rgba(26, 48, 46, .12);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 12% 8%, #fffdf6 0, transparent 30%), linear-gradient(135deg, #f5f1e8 0%, #e7eee7 100%); }
button { font: inherit; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }

.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; padding: 24px clamp(18px, 5vw, 54px) 32px; }
.topbar, .game-header, .board-meta, .game-controls, .drawer-heading { display: flex; align-items: center; justify-content: space-between; }
.topbar { margin-bottom: clamp(42px, 8vh, 76px); }
.brand-mark { display: flex; align-items: center; gap: 10px; color: var(--teal-deep); font-weight: 700; letter-spacing: .03em; text-transform: lowercase; }
.brand-mark strong { color: var(--coral); }
.brand-drop { width: 18px; height: 24px; border-radius: 70% 30% 65% 35% / 45% 55% 45% 55%; transform: rotate(35deg); background: var(--coral); }
.top-actions { display: flex; gap: 8px; }
.icon-button, .close-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--teal-deep); background: rgba(255, 253, 247, .72); cursor: pointer; font-weight: 700; }
.icon-button:hover, .close-button:hover { background: white; transform: translateY(-1px); }

.game-header { align-items: flex-end; gap: 18px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 8px; color: var(--coral); font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 470px; margin-bottom: 0; font-family: Georgia, serif; font-size: clamp(2.2rem, 7vw, 4.2rem); font-weight: 500; line-height: .98; letter-spacing: 0; }
h2 { margin-bottom: 10px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.level-badge { display: grid; gap: 2px; min-width: 72px; padding: 10px 12px; border: 1px solid rgba(23, 50, 53, .15); border-radius: 10px; text-align: center; }
.level-badge span { color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .15em; }
.level-badge strong { font-size: 1.35rem; }
.progress-track { height: 5px; margin-bottom: 24px; overflow: hidden; border-radius: 5px; background: rgba(23, 50, 53, .1); }
.progress-fill { width: 20%; height: 100%; border-radius: inherit; background: var(--coral); transition: width .4s ease; }

.game-card { position: relative; padding: clamp(22px, 5vw, 42px); border: 1px solid rgba(23, 50, 53, .08); border-radius: 18px; background: radial-gradient(ellipse at 17% 115%, rgba(86, 158, 53, .52) 0 32%, transparent 65%), radial-gradient(ellipse at 82% 110%, rgba(85, 158, 68, .55) 0 34%, transparent 67%), linear-gradient(180deg, #c8e9f2 0%, #e4f1d6 57%, #bddb81 100%); box-shadow: var(--shadow); }
.board-meta { margin-bottom: 30px; color: var(--muted); font-size: .82rem; font-weight: 700; letter-spacing: .02em; }
.board-meta span:first-child { color: var(--ink); font-family: Georgia, serif; font-size: 1.1rem; font-weight: 500; }
.board-meta strong { color: var(--coral); font-size: 1.1rem; }
.bottle-grid { position: relative; display: grid; grid-template-columns: repeat(var(--bottle-columns, 4), minmax(40px, 72px)); justify-content: center; align-items: end; gap: clamp(8px, 2.3vw, 18px); min-height: 220px; padding: 14px 10px 30px; }
.bottle-grid::before { content: ""; position: absolute; right: 0; bottom: 8px; left: 0; height: 23px; border-radius: 6px; background: linear-gradient(180deg, #ffc251 0%, #ef8d1b 56%, #cf6715 100%); box-shadow: 0 9px 0 rgba(112, 74, 21, .17), 0 15px 16px rgba(30, 80, 36, .22); }
.animation-layer { position: absolute; inset: 0; z-index: 3; overflow: visible; pointer-events: none; }
.bottle-button { position: relative; z-index: 1; display: block; width: 100%; aspect-ratio: .49; padding: 0; border: 0; background: transparent; cursor: pointer; transition: transform .2s ease; }
.bottle-button:hover, .bottle-button.selected { transform: translateY(-8px); }
.bottle-button.selected .bottle-body { box-shadow: inset 7px 0 8px rgba(255,255,255,.47), inset -6px 0 8px rgba(38,64,69,.15), 0 0 0 3px rgba(233,69,60,.7), 0 11px 15px rgba(31,67,62,.18); }
.bottle-button.complete .bottle-body { box-shadow: inset 7px 0 8px rgba(255,255,255,.47), inset -6px 0 8px rgba(38,64,69,.15), 0 0 0 3px rgba(88,177,55,.72), 0 8px 12px rgba(31,67,62,.16); }
.bottle-neck { position: absolute; z-index: 2; top: 4%; left: 30%; width: 40%; height: 17%; border: 2px solid rgba(225,242,241,.95); border-bottom: 0; border-radius: 5px 5px 0 0; background: linear-gradient(90deg, rgba(255,255,255,.52), rgba(208,234,228,.2) 60%, rgba(255,255,255,.5)); box-shadow: inset -2px 0 3px rgba(46,76,76,.15); }
.bottle-rim { position: absolute; z-index: 4; top: 0; left: 23%; width: 54%; height: 10%; border: 3px solid #eef7f1; border-radius: 50% / 42%; background: linear-gradient(180deg, #fff 0%, #cbdcd5 62%, #f7fffa 100%); box-shadow: 0 2px 3px rgba(27,58,54,.2), inset 0 2px 0 rgba(119,151,145,.35); }
.bottle-body { position: absolute; top: 15%; right: 3%; bottom: 0; left: 3%; overflow: hidden; border: 3px solid rgba(232,248,243,.95); border-radius: 40% 40% 16% 16% / 22% 22% 8% 8%; background: linear-gradient(90deg, rgba(255,255,255,.42), rgba(238,255,249,.1) 44%, rgba(75,112,108,.2) 100%); box-shadow: inset 7px 0 8px rgba(255,255,255,.47), inset -6px 0 8px rgba(38,64,69,.15), 0 8px 12px rgba(31,67,62,.16); }
.liquid-stack { position: absolute; inset: 5px 4px 4px; display: flex; flex-direction: column-reverse; overflow: hidden; border-radius: 32% 32% 11px 11px / 22% 22% 8px 8px; }
.liquid { position: relative; flex: 0 0 25%; min-height: 0; background: var(--liquid-color); box-shadow: inset 7px 0 5px rgba(255,255,255,.1), inset -5px 0 7px rgba(0,0,0,.09); }
.liquid:last-child::before { content: ""; position: absolute; z-index: 1; top: -3px; left: 0; width: 100%; height: 8px; border-radius: 50%; background: var(--liquid-color); filter: brightness(1.11); }
.glass-shine { position: absolute; z-index: 2; top: 13%; bottom: 16%; left: 13%; width: 10%; border-radius: 99px; background: linear-gradient(180deg, rgba(255,255,255,.67), rgba(255,255,255,.15)); pointer-events: none; }
.color-coral { --liquid-color: var(--coral); }.color-yellow { --liquid-color: var(--yellow); }.color-blue { --liquid-color: var(--blue); }.color-lavender { --liquid-color: var(--lavender); }.color-green { --liquid-color: var(--green); }
.bottle-button.source-away { visibility: hidden; }
.bottle-button.flying-bottle { position: absolute; z-index: 2; margin: 0; pointer-events: none; transform-origin: 50% 50%; will-change: transform; animation: bottle-transfer 1.08s linear both; }
.flying-bottle .outgoing-liquid { animation: liquid-drain 1.08s linear both; }
.bottle-button.receiving { animation: receive-pulse 1.08s ease-out both; }
.bottle-button.receiving .liquid:last-child { animation: fill-rise .34s cubic-bezier(.16, 1, .3, 1) both; transform-origin: 50% 100%; }
.pour-effect { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.pour-stream { fill: none; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; filter: drop-shadow(0 2px 2px rgba(23,50,53,.16)); animation: stream-flow 1.08s ease-in-out both; }
.color-stroke-coral { stroke: var(--coral); }.color-stroke-yellow { stroke: var(--yellow); }.color-stroke-blue { stroke: var(--blue); }.color-stroke-lavender { stroke: var(--lavender); }.color-stroke-green { stroke: var(--green); }
.hint { min-height: 22px; margin: 30px 0 0; color: var(--muted); text-align: center; font-size: .82rem; }

.game-controls { justify-content: center; gap: 10px; margin-top: 22px; }
.control-button { min-height: 44px; padding: 0 16px; border: 1px solid rgba(23,50,53,.14); border-radius: 10px; color: var(--ink); background: rgba(255,253,247,.64); cursor: pointer; font-size: .82rem; font-weight: 800; }
.control-button:hover:not(:disabled) { border-color: var(--teal); background: white; transform: translateY(-1px); }.control-button:disabled { cursor: not-allowed; opacity: .38; }.control-button span { margin-right: 5px; color: var(--coral); font-size: 1.1rem; }.control-button.primary { border-color: var(--teal); color: white; background: var(--teal); }.control-button.primary:hover { background: var(--teal-deep); }
.level-drawer { margin-top: 22px; padding: 22px; border: 1px solid rgba(23,50,53,.1); border-radius: 14px; background: rgba(255,253,247,.9); box-shadow: var(--shadow); }.drawer-heading { margin-bottom: 18px; }.drawer-heading h2 { margin: 0; font-size: 1.4rem; }.level-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }.level-choice { padding: 13px 5px; border: 1px solid rgba(23,50,53,.14); border-radius: 9px; color: var(--ink); background: var(--paper); cursor: pointer; }.level-choice.current { border-color: var(--coral); box-shadow: inset 0 -3px var(--coral); }.level-choice.locked { cursor: not-allowed; opacity: .4; }.level-choice small { display: block; color: var(--muted); font-size: .62rem; }
.level-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }.level-choice { min-width: 0; }.level-choice small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.level-pages { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }.level-pages .control-button { min-height: 38px; }.level-pages span { color: var(--muted); font-size: .75rem; text-align: center; }
.modal-backdrop { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 22px; background: rgba(16,43,45,.48); }.modal { position: relative; width: min(100%, 390px); max-height: calc(100vh - 44px); overflow-y: auto; padding: 34px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }.modal .close-button { position: absolute; top: 15px; right: 15px; }.modal p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }.modal .control-button { width: 100%; margin-top: 14px; }.win-modal { text-align: center; }.win-spark { margin-bottom: 12px; color: var(--coral); font-size: 2.5rem; animation: float .9s ease infinite alternate; }
@keyframes settle { from { transform: translateY(-10px); opacity: .4; } to { transform: translateY(0); opacity: 1; } } @keyframes float { to { transform: translateY(-5px) rotate(8deg); } }
@keyframes bottle-transfer { 0% { transform: translate(0, 0) rotate(0); animation-timing-function: cubic-bezier(.2, .8, .2, 1); } 14% { transform: translate(0, -18px) rotate(0); animation-timing-function: cubic-bezier(.45, 0, .2, 1); } 38% { transform: translate(var(--travel-x), var(--travel-y)) rotate(0); animation-timing-function: cubic-bezier(.2, .8, .2, 1); } 50%, 73% { transform: translate(var(--travel-x), var(--travel-y)) rotate(var(--tilt)); animation-timing-function: cubic-bezier(.4, 0, .2, 1); } 84% { transform: translate(var(--travel-x), var(--travel-y)) rotate(0); animation-timing-function: cubic-bezier(.3, 0, .6, 1); } 100% { transform: translate(0, var(--settle-y)) rotate(0); } }
@keyframes stream-flow { 0%, 49% { stroke-dashoffset: 1; opacity: 0; } 54% { opacity: 1; } 72% { stroke-dashoffset: 0; opacity: 1; } 77%, 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes receive-pulse { 0%, 55%, 100% { filter: brightness(1); } 78% { filter: brightness(1.14); } }
@keyframes fill-rise { from { transform: scaleY(.15); opacity: .45; } to { transform: scaleY(1); opacity: 1; } }
@keyframes liquid-drain { 0%, 52% { opacity: 1; } 75%, 100% { opacity: 0; } }
@media (max-width: 520px) { .app-shell { padding-top: 18px; }.topbar { margin-bottom: 42px; }.bottle-grid { grid-template-columns: repeat(4, minmax(43px, 1fr)); gap: 12px 8px; min-height: 220px; }.game-card { padding: 20px 14px; }.level-list { gap: 5px; }.level-choice { font-size: .75rem; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
