:root {
  --navy: #083452;
  --ocean: #0798c7;
  --cyan: #55e8e0;
  --sun: #ffdb57;
  --coral: #ff6f72;
  --paper: #fffdf1;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #b9edf2; }
body { color: var(--navy); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
button, a { font: inherit; }
button { touch-action: manipulation; cursor: pointer; }
[hidden] { display: none !important; }

.game-shell { position: relative; width: 100%; height: 100%; height: 100dvh; min-height: 0; margin: 0; overflow: hidden; background: #087fac; isolation: isolate; }
.screen { position: absolute; z-index: 1; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; animation: screen-in .34s cubic-bezier(.2,.8,.2,1) both; }
@keyframes screen-in { from { opacity: 0; transform: scale(1.018); } to { opacity: 1; transform: scale(1); } }

.loading-screen { color: #fff; background: linear-gradient(180deg,#22cce1 0%,#087faf 58%,#064c78 100%); }
.loading-water { position: absolute; inset: 0; overflow: hidden; background: radial-gradient(circle at 50% -10%,rgba(221,255,252,.5),transparent 42%),linear-gradient(115deg,transparent 15%,rgba(215,255,250,.1) 28%,transparent 42%); }
.loading-water::before { content: ""; position: absolute; right: -12%; bottom: -18%; left: -12%; height: 48%; border-radius: 50% 50% 0 0; background: linear-gradient(180deg,rgba(2,73,106,.1),rgba(3,49,78,.48)),url("../../assets/game-art/reef-chomp-world.webp") center bottom/cover no-repeat; opacity: .56; }
.loading-water i { position: absolute; bottom: -30px; width: 16px; height: 16px; border: 2px solid rgba(226,255,252,.5); border-radius: 50%; animation: loading-bubble 3.4s linear infinite; }
.loading-water i:nth-child(1) { left: 17%; animation-delay: -.4s; }
.loading-water i:nth-child(2) { left: 72%; width: 9px; height: 9px; animation-delay: -1.7s; }
.loading-water i:nth-child(3) { left: 44%; width: 22px; height: 22px; animation-delay: -2.6s; }
@keyframes loading-bubble { to { bottom: 108%; transform: translateX(25px); } }
.loading-content { position: absolute; z-index: 2; left: 50%; top: 48%; width: min(310px,76vw); text-align: center; transform: translate(-50%,-50%); }
.loading-shark { position: relative; width: 146px; height: 92px; margin: 0 auto 20px; filter: drop-shadow(0 14px 18px rgba(1,36,61,.24)); animation: loading-swim 1.7s ease-in-out infinite; }
@keyframes loading-swim { 50% { transform: translateY(-8px) rotate(-2deg); } }
.loading-shark::before { content: ""; position: absolute; left: 27px; top: 24px; width: 101px; height: 53px; border-radius: 62% 48% 50% 56%; background: linear-gradient(180deg,#6af0e5 0%,#1288b4 58%,#eef7de 59%); box-shadow: inset 0 4px 6px rgba(255,255,255,.3); }
.loading-shark::after { content: ""; position: absolute; left: 4px; top: 31px; width: 48px; height: 48px; background: #147da6; clip-path: polygon(100% 45%,7% 0,35% 49%,4% 100%,100% 62%); }
.loading-shark i { position: absolute; z-index: 2; right: 21px; top: 36px; width: 18px; height: 20px; border: 4px solid #fff; border-radius: 50%; background: #123d55; box-shadow: inset 3px 0 #5ce9dc; }
.loading-shark b { position: absolute; z-index: 3; right: 8px; top: 55px; width: 47px; height: 17px; border-radius: 50%; background: #652337; clip-path: ellipse(50% 42% at 48% 36%); }
.loading-content > p { margin: 0 0 5px; font-size: 7px; font-weight: 900; letter-spacing: .23em; }
.loading-content > h1 { margin: 0 0 30px; font-size: clamp(40px,12vw,56px); line-height: .86; letter-spacing: -.07em; text-shadow: 0 5px 0 rgba(2,54,80,.22); }
.loading-content > h1 span { color: var(--sun); }
.loading-track { width: 100%; height: 12px; padding: 3px; overflow: hidden; border-radius: 99px; background: rgba(2,45,73,.38); box-shadow: inset 0 2px 4px rgba(1,33,57,.2),0 1px rgba(255,255,255,.2); }
.loading-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#5ef0db,#ffe05a,#ff8172); box-shadow: 0 0 13px rgba(128,255,228,.5); transition: width .28s cubic-bezier(.2,.8,.2,1); }
.loading-meta { display: flex; justify-content: space-between; margin-top: 9px; font-size: 8px; font-weight: 900; letter-spacing: .06em; }
.loading-meta strong { color: rgba(255,255,255,.77); }
.loading-meta b { color: var(--sun); }
.loading-content > small { display: block; margin-top: 30px; color: rgba(255,255,255,.48); font-size: 7px; font-weight: 800; letter-spacing: .04em; }

.menu-screen { background: #087fac; }
.menu-ocean { position: absolute; inset: 0; background: linear-gradient(180deg,rgba(0,34,77,.03),rgba(0,35,70,.1)), url("../../assets/game-covers/reef-chomp.webp") 49% 16% / auto 58% no-repeat, url("../../assets/game-art/reef-chomp-world.webp") center/cover no-repeat; transform: scale(1.01); }
.menu-ocean::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg,rgba(3,47,91,.06) 0%,rgba(3,48,82,.02) 35%,rgba(4,37,64,.74) 67%,rgba(3,35,58,.9) 100%); }
.top-actions { position: absolute; z-index: 5; top: 0; right: 0; left: 0; display: flex; justify-content: space-between; padding: max(12px,env(safe-area-inset-top)) 14px 0; }
.round-button, .hud-button { display: grid; width: 43px; height: 43px; place-items: center; border: 1px solid rgba(255,255,255,.7); border-radius: 50%; color: #fff; background: rgba(4,43,72,.33); box-shadow: 0 6px 20px rgba(3,31,55,.15),inset 0 1px rgba(255,255,255,.32); text-decoration: none; font-size: 20px; font-weight: 900; backdrop-filter: blur(10px); }
.round-button:active, .hud-button:active { transform: scale(.9); }
.title-lockup { position: absolute; z-index: 3; top: max(64px,calc(env(safe-area-inset-top) + 52px)); left: 0; width: 100%; padding: 0 18px; color: #fff; text-align: center; text-shadow: 0 4px 17px rgba(2,35,63,.42); }
.title-lockup p { margin: 0 0 5px; font-size: 8px; font-weight: 900; letter-spacing: .24em; }
.title-lockup h1 { margin: 0; font-size: clamp(39px,11.8vw,58px); line-height: .88; letter-spacing: -.07em; }
.title-lockup h1 span { color: var(--sun); }
.title-lockup strong { display: block; margin-top: 8px; font-size: 10px; letter-spacing: .06em; }

.menu-card { position: absolute; z-index: 4; right: 10px; bottom: max(9px,env(safe-area-inset-bottom)); left: 10px; padding: 16px 16px 11px; border: 1px solid rgba(255,255,255,.88); border-radius: 25px; background: rgba(255,253,242,.965); box-shadow: 0 20px 55px rgba(2,35,59,.36),inset 0 1px #fff; backdrop-filter: blur(18px); }
.trail-heading { display: flex; align-items: center; justify-content: space-between; }
.trail-heading small, .save-row small, .hud-card small, .growth-copy small { display: block; color: #82909b; font-size: 7px; font-weight: 900; letter-spacing: .14em; }
.trail-heading strong { display: block; margin-top: 2px; font-size: 17px; }
.trail-heading > span { padding: 7px 10px; border-radius: 99px; color: #fff; background: linear-gradient(180deg,#41d7bd,#1eb69c); box-shadow: 0 4px 0 #159681; font-size: 10px; font-weight: 900; }
.save-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr; margin: 11px 0; padding: 9px 0; border-top: 1px solid #e6e5da; border-bottom: 1px solid #e6e5da; }
.save-row > div { padding: 0 8px; border-right: 1px solid #e6e5da; }
.save-row > div:first-child { padding-left: 0; }
.save-row > div:last-child { border: 0; }
.save-row strong { display: block; margin-top: 3px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.level-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 8px; }
.level-button { position: relative; aspect-ratio: 1.16; border: 0; border-radius: 12px; color: #fff; background: linear-gradient(145deg,#38d4be,#18a98f); box-shadow: 0 4px 0 #12836f,inset 0 1px rgba(255,255,255,.53); font-size: 12px; font-weight: 900; }
.level-button.selected { outline: 3px solid var(--sun); outline-offset: 2px; }
.level-button.completed::after { content: "★"; position: absolute; right: -3px; top: -6px; display: grid; width: 16px; height: 16px; place-items: center; border-radius: 50%; color: #a86f17; background: var(--sun); box-shadow: 0 2px 4px rgba(67,44,7,.18); font-size: 8px; }
.level-button.locked { color: transparent; background: #e5e6e0; box-shadow: 0 4px 0 #c9cbc5; }
.level-button.locked::before { content: ""; position: absolute; left: 50%; top: 50%; width: 15px; height: 12px; border-radius: 4px; background: linear-gradient(145deg,#ffdc62,#e7a63d); box-shadow: inset 0 1px rgba(255,255,255,.7),0 2px 0 #b37d31; transform: translate(-50%,-30%); }
.level-button.locked::after { content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border: 3px solid #ac8245; border-bottom: 0; border-radius: 8px 8px 0 0; transform: translate(-50%,-105%); }
.level-button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #12836f; }
.primary-button { display: flex; width: 100%; min-height: 49px; align-items: center; justify-content: center; gap: 11px; margin-top: 13px; border: 0; border-radius: 15px; color: #fff; background: linear-gradient(180deg,#ff7d79,#f05568); box-shadow: 0 6px 0 #c83d53,0 11px 22px rgba(210,62,82,.21),inset 0 1px rgba(255,255,255,.48); font-size: 13px; font-weight: 900; letter-spacing: .04em; }
.primary-button b { display: grid; min-width: 28px; height: 28px; place-items: center; padding: 0 7px; border-radius: 99px; color: #ef5466; background: #fff; }
.primary-button:active { transform: translateY(4px); box-shadow: 0 2px 0 #c83d53; }
.menu-tip { margin: 10px 5px 4px; color: #77818c; text-align: center; font-size: 8.5px; font-weight: 800; line-height: 1.35; }
.signature { margin: 5px 0 0; color: #949ba1; text-align: center; font-size: 7px; font-weight: 800; letter-spacing: .04em; }

.play-screen { background: #068dbd; }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.game-header { position: absolute; z-index: 12; top: 0; right: 0; left: 0; display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 10px; padding: max(9px,env(safe-area-inset-top)) 12px 6px; pointer-events: none; }
.game-header > * { pointer-events: auto; }
.hud-button { width: 40px; height: 40px; background: rgba(3,43,71,.48); font-size: 18px; }
.level-copy { color: #fff; text-align: center; text-shadow: 0 2px 10px rgba(2,28,51,.38); }
.level-copy small { display: block; font-size: 7px; font-weight: 900; letter-spacing: .18em; }
.level-copy strong { display: block; margin-top: 2px; font-size: 15px; }
.hud-row { position: absolute; z-index: 11; top: max(59px,calc(env(safe-area-inset-top) + 50px)); right: 10px; left: 10px; display: grid; grid-template-columns: 1fr 1.15fr .85fr; gap: 7px; pointer-events: none; }
.hud-card { min-height: 48px; padding: 8px 10px 6px; border: 1px solid rgba(255,255,255,.5); border-radius: 14px; color: #fff; background: rgba(3,45,75,.45); box-shadow: 0 8px 24px rgba(2,40,67,.15),inset 0 1px rgba(255,255,255,.18); backdrop-filter: blur(9px); }
.hud-card small { color: rgba(255,255,255,.72); }
.hud-card strong { display: block; margin-top: 1px; font-size: 18px; line-height: 1; }
.heart-card { text-align: center; }
.heart-card div { margin-top: 2px; color: #ff8090; font-size: 17px; letter-spacing: 1px; text-shadow: 0 2px 0 rgba(94,22,36,.18); }
.time-card { text-align: right; }
.time-card.urgent strong { color: #ffe167; animation: urgent .55s ease-in-out infinite alternate; }
@keyframes urgent { to { transform: scale(1.12); } }
.growth-card { position: absolute; z-index: 11; top: max(115px,calc(env(safe-area-inset-top) + 106px)); right: 10px; left: 10px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; min-height: 42px; padding: 7px 9px 7px 11px; border: 1px solid rgba(255,255,255,.44); border-radius: 14px; color: #fff; background: rgba(3,46,75,.42); box-shadow: 0 8px 20px rgba(2,39,66,.12); backdrop-filter: blur(8px); pointer-events: none; }
.growth-copy { min-width: 58px; }
.growth-copy small { color: rgba(255,255,255,.7); }
.growth-copy strong { font-size: 11px; }
.growth-track { position: relative; height: 10px; overflow: visible; border: 2px solid rgba(255,255,255,.38); border-radius: 99px; background: rgba(1,35,61,.4); }
.growth-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#65f0c7,#ffe266,#ff8b72); box-shadow: 0 0 12px rgba(101,240,199,.48); transition: width .3s cubic-bezier(.2,.8,.2,1); }
.grow-mark { position: absolute; top: -3px; width: 2px; height: 12px; background: rgba(255,255,255,.7); }
.grow-mark.one { left: 33%; }
.grow-mark.two { left: 66%; }
.size-badge { min-width: 45px; padding: 5px 6px; border-radius: 8px; color: #0b5070; background: var(--sun); box-shadow: 0 3px 0 #d6a933; text-align: center; font-size: 7px; font-weight: 900; }
.combo-pill { position: absolute; z-index: 14; left: 50%; top: 172px; padding: 8px 13px; border-radius: 99px; color: #683c0c; background: linear-gradient(180deg,#fff176,#ffc947); box-shadow: 0 6px 20px rgba(50,31,5,.2); font-size: 10px; font-weight: 900; opacity: 0; transform: translate(-50%,-12px) scale(.7); pointer-events: none; }
.combo-pill.show { animation: combo-pop .72s cubic-bezier(.2,1.25,.3,1) both; }
@keyframes combo-pop { 25%,72% { opacity: 1; transform: translate(-50%,0) scale(1); } 100% { opacity: 0; transform: translate(-50%,-11px) scale(.9); } }
.level-banner, .warning-banner { position: absolute; z-index: 18; left: 50%; top: 48%; padding: 13px 19px; border: 2px solid rgba(255,255,255,.7); border-radius: 16px; color: #fff; background: rgba(4,44,74,.76); box-shadow: 0 15px 40px rgba(1,24,44,.3); font-size: 20px; font-weight: 900; letter-spacing: .04em; opacity: 0; transform: translate(-50%,-50%) scale(.75); pointer-events: none; backdrop-filter: blur(9px); }
.level-banner.show { animation: banner-pop 1.25s ease both; }
@keyframes banner-pop { 15%,72% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-62%) scale(.92); } }
.warning-banner { top: 41%; color: #fff; background: rgba(213,57,71,.88); }
.warning-banner.show { animation: warning-pop .7s ease both; }
@keyframes warning-pop { 20%,70% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-55%) scale(.9); } }
.touch-hint { position: absolute; z-index: 10; left: 50%; bottom: max(24px,env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; color: rgba(255,255,255,.92); font-size: 8px; font-weight: 900; letter-spacing: .15em; text-shadow: 0 2px 8px rgba(3,38,66,.5); transform: translateX(-50%); pointer-events: none; transition: opacity .25s; }
.touch-hint i { position: relative; width: 43px; height: 43px; margin-bottom: 7px; border: 2px solid rgba(255,255,255,.75); border-radius: 50%; background: rgba(255,255,255,.13); animation: touch-drift 1.35s ease-in-out infinite; }
.touch-hint i::after { content: ""; position: absolute; left: 15px; top: 10px; width: 10px; height: 17px; border-radius: 8px; background: #fff; box-shadow: 0 5px 0 -2px #fff; }
@keyframes touch-drift { 50% { transform: translate(22px,-12px); } }
.touch-hint.hide { opacity: 0; }

.result-screen { padding: max(65px,calc(env(safe-area-inset-top) + 48px)) 24px max(18px,env(safe-area-inset-bottom)); color: #fff; text-align: center; background: #087fac; }
.result-ocean { position: absolute; inset: 0; background: linear-gradient(180deg,rgba(1,49,88,.14),rgba(1,41,72,.65)),url("../../assets/game-art/reef-chomp-world.webp") center/cover no-repeat; }
.result-ocean.dark { filter: saturate(.65) brightness(.65); }
.result-screen > *:not(.result-ocean) { position: relative; z-index: 2; }
.result-kicker { margin: 0 0 8px; color: #c8fff4; font-size: 9px; font-weight: 900; letter-spacing: .2em; }
.result-screen h2 { margin: 0; font-size: clamp(40px,12vw,58px); line-height: .9; letter-spacing: -.06em; text-shadow: 0 5px 0 rgba(3,52,77,.25); }
.hero-shark { position: relative; width: 205px; height: 145px; margin: 32px auto 20px; filter: drop-shadow(0 18px 16px rgba(0,28,51,.25)); animation: shark-float 1.8s ease-in-out infinite; }
@keyframes shark-float { 50% { transform: translateY(-9px) rotate(-2deg); } }
.hero-shark::before { content: ""; position: absolute; left: 34px; top: 37px; width: 142px; height: 75px; border-radius: 62% 48% 50% 56%; background: linear-gradient(180deg,#42d6dd 0%,#1281ad 58%,#f8f4d6 59%); box-shadow: inset 0 5px 7px rgba(255,255,255,.28); }
.hero-shark::after { content: ""; position: absolute; left: 4px; top: 48px; width: 62px; height: 60px; background: linear-gradient(135deg,#1484ad,#085f8d); clip-path: polygon(100% 44%,10% 0,36% 48%,7% 100%,100% 62%); }
.hero-shark i { position: absolute; z-index: 2; right: 33px; top: 53px; width: 24px; height: 27px; border: 5px solid #fff; border-radius: 50%; background: #123d55; box-shadow: inset 4px 0 #61e9dc; }
.hero-shark b { position: absolute; z-index: 3; right: 13px; top: 79px; width: 67px; height: 28px; border-radius: 10% 60% 65% 40%; background: #5c2034; clip-path: ellipse(50% 43% at 48% 37%); }
.hero-shark b::before { content: ""; position: absolute; inset: 1px 7px auto; height: 7px; background: repeating-linear-gradient(90deg,#fff 0 7px,transparent 7px 10px); clip-path: polygon(0 0,100% 0,93% 100%,5% 100%); }
.hero-shark em { position: absolute; z-index: 1; left: 95px; top: 13px; width: 50px; height: 48px; background: #168bad; clip-path: polygon(15% 100%,55% 0,100% 100%); }
.hero-shark.dizzy { animation: dizzy-float .5s ease-in-out infinite alternate; filter: grayscale(.18) drop-shadow(0 18px 16px rgba(0,28,51,.3)); }
.hero-shark.dizzy i { border: 0; background: transparent; box-shadow: none; }
.hero-shark.dizzy i::before { content: "×"; position: absolute; color: #fff; font-size: 28px; font-weight: 900; }
@keyframes dizzy-float { to { transform: translateY(-3px) rotate(5deg); } }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; max-width: 320px; margin: 0 auto 22px; overflow: hidden; border: 1px solid rgba(255,255,255,.4); border-radius: 18px; background: rgba(3,45,75,.4); backdrop-filter: blur(10px); }
.result-stats > div { padding: 12px; }
.result-stats > div + div { border-left: 1px solid rgba(255,255,255,.25); }
.result-stats small { display: block; color: rgba(255,255,255,.68); font-size: 7px; font-weight: 900; letter-spacing: .14em; }
.result-stats strong { display: block; margin-top: 3px; font-size: 22px; }
.result-screen .primary-button { max-width: 330px; margin: 12px auto 14px; }
.text-button { display: block; margin: 10px auto 0; border: 0; color: rgba(255,255,255,.82); background: transparent; font-size: 10px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.result-screen .signature { margin-top: 20px; color: rgba(255,255,255,.5); }
.fail-copy { min-height: 38px; margin: 2px auto 18px; font-size: 12px; font-weight: 800; line-height: 1.5; }

@media (max-height: 720px) {
  .title-lockup { top: 53px; }
  .title-lockup strong { display: none; }
  .menu-card { padding-top: 13px; }
  .save-row { margin: 8px 0; padding: 7px 0; }
  .level-grid { gap: 6px; }
  .primary-button { min-height: 45px; margin-top: 10px; }
  .menu-tip { margin-top: 7px; }
  .result-screen { padding-top: 44px; }
  .hero-shark { margin-top: 20px; margin-bottom: 12px; transform: scale(.88); }
}

@media (min-width: 700px) {
  html, body { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
  body { background: linear-gradient(180deg,#d9f5f5,#b9edf2); }
  .game-shell { width: min(480px,100%); height: 860px; min-height: 860px; margin: 0 auto; }
}

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