:root {
  --ink: #092a4a;
  --blue: #087cc1;
  --deep: #064f94;
  --aqua: #17c9dd;
  --yellow: #ffd735;
  --orange: #ff8a24;
  --white: #fff;
  --panel: rgba(255,255,255,.94);
  --shadow: 0 12px 30px rgba(3,57,105,.24);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color: var(--ink);
  background: #0786c7;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; user-select: none; }
button, select { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: linear-gradient(#bcecf9 0 17%, #06c9df 17% 23%, #087ec2 60%, #0759a6 100%);
  isolation: isolate;
}

.sky { position: absolute; inset: 0 0 auto; height: 24%; background: url("images/sky.png") center/cover no-repeat; z-index: -3; }
.water { position: absolute; inset: 17% 0 0; background: url("images/background.png") top center/cover no-repeat; z-index: -2; }
.water::after { content: ""; position: absolute; inset: auto 0 0; height: 34%; background: url("images/underwater.png") bottom center/cover no-repeat; opacity: .85; }
.sun-rays { position: absolute; inset: 17% 0 auto; height: 48%; background: radial-gradient(ellipse at 50% 0, rgba(255,255,255,.35), transparent 64%); pointer-events: none; z-index: -1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: relative; z-index: 20; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 8px; color: #064b87; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; text-shadow: 0 2px #fff; }
.brand img { width: 64px; height: 44px; object-fit: contain; }
.stats { display: flex; gap: 6px; }
.pill { min-width: 64px; padding: 8px 10px; border: 2px solid rgba(255,255,255,.86); border-radius: 999px; background: rgba(5,91,158,.84); color: white; font-weight: 900; text-align: center; box-shadow: 0 4px 0 rgba(4,65,121,.25); }
.icon-btn { width: 44px; height: 44px; padding: 0; border: 2px solid white; border-radius: 50%; background: #0775b8; color: white; box-shadow: 0 4px 0 #034d86; font-size: 1.25rem; cursor: pointer; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #034d86; }

.screen { position: absolute; inset: 68px 0 0; display: grid; place-items: center; padding: 16px; z-index: 5; }
.panel { width: min(92vw, 520px); max-height: calc(100dvh - 100px); overflow: auto; padding: 22px; border: 4px solid #fff; border-radius: 28px; background: var(--panel); box-shadow: var(--shadow), inset 0 -5px rgba(5,114,172,.1); text-align: center; }
.logo { width: min(94%, 460px); height: auto; max-height: 310px; object-fit: contain; margin: -8px auto 4px; display: block; }
.game-name { margin: -3px 0 0; color: #075c99; font-size: clamp(1.45rem, 5vw, 2rem); font-weight: 950; text-transform: uppercase; letter-spacing: .035em; text-shadow: 0 2px #fff; }
.subtitle { margin: 2px 0 16px; color: #1b648e; font-weight: 800; }
.label { display: block; margin: 12px 0 6px; text-align: left; font-weight: 900; }
.select { width: 100%; min-height: 52px; padding: 10px 14px; border: 3px solid #6fd9ed; border-radius: 16px; background: #f7fdff; color: var(--ink); font-weight: 800; outline: none; }
.select:focus { border-color: #007fc5; }
.primary, .secondary { width: 100%; min-height: 54px; margin-top: 12px; border: 0; border-radius: 18px; cursor: pointer; font-weight: 950; letter-spacing: .02em; }
.primary { color: #663900; background: linear-gradient(#fff068, #ffc51c); box-shadow: 0 6px 0 #df850d, 0 10px 22px rgba(124,72,0,.2); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #df850d; }
.secondary { color: white; background: linear-gradient(#22b9db, #0875bb); box-shadow: 0 5px 0 #04558f; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.mini-stats div { padding: 10px 4px; border-radius: 14px; background: #e7faff; font-weight: 800; font-size: .84rem; }
.mini-stats strong { display: block; color: #0876b9; font-size: 1.25rem; }

.game-screen { position: absolute; inset: 68px 0 0; z-index: 4; }
.prompt-card { position: absolute; z-index: 10; top: 6px; left: 50%; transform: translateX(-50%); width: min(92vw, 590px); padding: 10px 72px 12px 16px; border: 3px solid white; border-radius: 19px; background: rgba(255,255,255,.94); box-shadow: 0 8px 22px rgba(1,58,100,.2); text-align: center; }
.prompt-kicker { color: #1676aa; font-size: clamp(.62rem, 2.7vw, .78rem); font-weight: 900; line-height: 1.15; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
.prompt-word { margin: 2px 0 0; color: #e24b3c; font-size: clamp(1.35rem, 4vw, 2rem); font-weight: 950; line-height: 1.05; }
.prompt-hint { margin-top: 2px; color: #236b91; font-size: .85rem; font-weight: 800; }
.speak-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border: 0; border-radius: 50%; background: #1fc5d7; color: white; font-size: 1.4rem; box-shadow: 0 4px 0 #078a9d; cursor: pointer; }

.ocean { position: absolute; inset: 94px 0 0; overflow: hidden; }
.boat { position: absolute; top: -8px; left: 50%; width: min(42vw, 285px); transform: translateX(-50%); filter: drop-shadow(0 8px 4px rgba(0,59,100,.22)); pointer-events: none; z-index: 5; }
.fish-layer { position: absolute; inset: 118px 0 64px; }
.fish-choice { position: absolute; display: grid; place-items: center; width: 154px; height: 96px; border: 0; padding: 0; background: none; cursor: pointer; animation: swim var(--speed, 11s) linear infinite; will-change: transform; }
.fish-choice.reverse { animation-name: swim-reverse; }
.fish-choice:focus-visible { outline: 4px solid #fff; outline-offset: 5px; border-radius: 40px; }
.fish-sprite { position: absolute; left: 50%; top: 50%; width: var(--fw); height: var(--fh); transform: translate(-50%,-50%) scaleX(-1) scale(var(--fish-scale, .76)); transform-origin: center; background-image: url("images/fishmenu-sheet0.png"); background-position: calc(var(--fx) * -1px) calc(var(--fy) * -1px); background-repeat: no-repeat; filter: drop-shadow(0 6px 4px rgba(0,47,93,.25)); }
.reverse .fish-sprite { transform: translate(-50%,-50%) scale(var(--fish-scale, .76)); }
.fish-card { position: relative; z-index: 2; display: grid; place-items: center; width: 82px; height: 82px; margin-top: 82px; padding: 3px; overflow: hidden; border: 4px solid white; border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: 0 5px 0 rgba(2,49,97,.65), 0 7px 16px rgba(1,49,92,.25); }
.word-picture { display: block; width: 74px; height: 74px; object-fit: contain; user-select: none; pointer-events: none; }
.word-picture.fallback { display: grid; place-items: center; font-size: 2.6rem; line-height: 1; }
.fish-choice.locked { animation-play-state: paused; }
.fish-choice.caught { animation: none; z-index: 9; transition: left .48s ease, top .48s ease, transform .48s ease; }
.fish-choice.wrong { animation-play-state: paused; filter: grayscale(.6); }
.fish-choice.correct-fx .fish-sprite { animation: correct-pop .7s ease both; filter: drop-shadow(0 0 13px #fff56a) drop-shadow(0 0 20px #24e4ff); }
.fish-choice.reverse.correct-fx .fish-sprite { animation-name: correct-pop-reverse; }
.fish-choice.correct-fx .fish-card { animation: correct-card .7s ease both; border-color: #fff45c; }
.fish-choice.wrong-fx { animation: wrong-shake .42s ease both !important; }
.fish-choice.wrong-fx .fish-card { border-color: #ff7373; background: #fff1f1; }
.fx-burst { position: absolute; z-index: 20; left: 50%; top: 50%; width: 1px; height: 1px; pointer-events: none; }
.fx-burst::before { content: ""; position: absolute; inset: -18px; border: 5px solid #fff45c; border-radius: 50%; animation: fx-ring .65s ease-out both; }
.fx-burst.bad::before { border-color: #ff7373; }
.fx-particle { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; font-size: 1.05rem; animation: fx-fly .7s ease-out both; transform: rotate(var(--angle)) translateY(0) rotate(calc(var(--angle) * -1)); }

.feedback { position: absolute; z-index: 30; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 24px) scale(.9); opacity: 0; width: min(88vw, 460px); padding: 13px 18px; border: 3px solid white; border-radius: 18px; color: white; background: #12a96b; box-shadow: var(--shadow); text-align: center; font-weight: 900; pointer-events: none; transition: .22s ease; }
.feedback.show { transform: translate(-50%,0) scale(1); opacity: 1; }
.feedback.bad { background: #e84b4b; }
.feedback small { display: block; margin-top: 2px; font-weight: 700; }
.bubbles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.bubble { position: absolute; bottom: -30px; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.65); border-radius: 50%; animation: bubble-up 5s linear forwards; }

.result-badge { display: inline-grid; place-items: center; width: 120px; height: 120px; border: 6px solid #fff; border-radius: 50%; background: linear-gradient(#ffe96a,#ffae21); color: #a44d00; box-shadow: 0 8px 0 #d47b10; font-size: 2rem; font-weight: 950; }
.result-title { margin: 18px 0 4px; color: #075f9d; }
.result-copy { margin: 6px 0 16px; color: #3b6b84; }
.result-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.result-grid div { padding: 10px 4px; border-radius: 14px; background: #e8faff; font-size: .78rem; font-weight: 800; }
.result-grid strong { display: block; font-size: 1.35rem; color: #0879ba; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translate(-50%,16px); padding: 10px 16px; border-radius: 999px; background: #072f50; color: white; opacity: 0; pointer-events: none; transition: .2s; font-weight: 800; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@keyframes swim { from { transform: translateX(calc(-180px - 10vw)); } to { transform: translateX(calc(100vw + 180px)); } }
@keyframes swim-reverse { from { transform: translateX(calc(100vw + 180px)); } to { transform: translateX(calc(-180px - 10vw)); } }
@keyframes bubble-up { to { transform: translateY(-110vh) translateX(25px); opacity: 0; } }
@keyframes correct-pop { 0% { transform: translate(-50%,-50%) scaleX(-1) scale(.7); } 45% { transform: translate(-50%,-50%) scaleX(-1) scale(1.14); } 100% { transform: translate(-50%,-50%) scaleX(-1) scale(.9); } }
@keyframes correct-pop-reverse { 0% { transform: translate(-50%,-50%) scale(.7); } 45% { transform: translate(-50%,-50%) scale(1.14); } 100% { transform: translate(-50%,-50%) scale(.9); } }
@keyframes correct-card { 50% { transform: scale(1.25) rotate(5deg); } }
@keyframes wrong-shake { 0%,100% { margin-left: 0; } 25% { margin-left: -14px; } 50% { margin-left: 12px; } 75% { margin-left: -7px; } }
@keyframes fx-ring { from { transform: scale(.35); opacity: 1; } to { transform: scale(3); opacity: 0; } }
@keyframes fx-fly { 0% { transform: rotate(var(--angle)) translateY(0) rotate(calc(var(--angle) * -1)) scale(.4); opacity: 1; } 100% { transform: rotate(var(--angle)) translateY(-68px) rotate(calc(var(--angle) * -1)) scale(1.15); opacity: 0; } }

@media (max-width: 560px) {
  .brand span { display: none; }
  .stats .pill { min-width: 55px; padding-inline: 8px; font-size: .88rem; }
  .screen { padding: 10px; }
  .panel { padding: 18px; border-radius: 24px; }
  .fish-choice { width: 134px; }
  .fish-card { width: 74px; height: 74px; margin-top: 76px; border-radius: 20px; }
  .word-picture { width: 66px; height: 66px; }
  .word-picture.fallback { font-size: 2.3rem; }
  .prompt-card { padding-left: 8px; padding-right: 64px; }
}

@media (max-height: 650px) {
  .topbar { padding-top: 6px; }
  .screen, .game-screen { inset-block-start: 58px; }
  .brand img { width: 54px; height: 38px; }
  .icon-btn { width: 38px; height: 38px; }
  .pill { padding-block: 6px; }
  .panel { padding: 14px 18px; }
  .logo { width: 58%; max-height: 120px; object-fit: contain; }
  .game-name { font-size: 1.25rem; }
  .mini-stats { margin-top: 10px; }
  .prompt-card { top: 2px; padding-block: 7px; }
  .ocean { inset-block-start: 76px; }
  .boat { width: min(34vw,230px); }
  .fish-layer { inset-block: 72px 64px; }
  .fish-card { width: 58px; height: 58px; margin-top: 56px; padding: 3px; }
  .word-picture { width: 50px; height: 50px; font-size: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .fish-choice { animation-duration: 24s; }
  .bubble { display: none; }
}
