@font-face {
  font-family: 'Fredoka';
  src: url('fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
:root { --u: 1; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden; background: #0b3d5c; color: #fff;
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; z-index: 5; pointer-events: none;
  top: calc(8px * var(--u)); left: calc(8px * var(--u)); right: calc(8px * var(--u));
  display: flex; justify-content: space-between; align-items: flex-start;
}
#hud > * { pointer-events: auto; }
.pill {
  display: flex; align-items: center; gap: calc(7px * var(--u));
  background: rgba(8, 30, 56, 0.55); border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px; padding: calc(4px * var(--u)) calc(16px * var(--u)) calc(4px * var(--u)) calc(5px * var(--u));
  font-weight: 700; font-size: calc(21px * var(--u)); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  min-width: calc(96px * var(--u)); backdrop-filter: blur(4px);
}
.pill.bump { animation: bump 0.22s ease-out; }
@keyframes bump { 50% { transform: scale(1.1); } }
.coin {
  display: inline-block; width: 1.2em; height: 1.2em; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 32%, #fff6b8 0 16%, #ffd23f 17% 58%, #e6a100 59% 100%);
  box-shadow: inset 0 -2px 0 rgba(150, 90, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.hud-btns { display: flex; gap: calc(6px * var(--u)); }
.icon-btn {
  width: calc(42px * var(--u)); height: calc(42px * var(--u)); border-radius: calc(13px * var(--u));
  background: rgba(8, 30, 56, 0.55); border: 2px solid rgba(255, 255, 255, 0.2);
  display: grid; place-items: center; position: relative; backdrop-filter: blur(4px);
}
.icon-btn svg { width: 58%; height: 58%; }
.icon-btn:active { transform: translateY(2px); }
.badge {
  position: absolute; top: -5px; right: -5px; background: #ff4d6d; border-radius: 999px;
  font-size: 12px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; text-align: center;
  animation: bump 1s ease-in-out infinite;
}

/* ---------- dive HUD ---------- */
#dive {
  position: absolute; z-index: 4; left: 0; right: 0; top: calc(58px * var(--u));
  text-align: center; pointer-events: none; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.depth { font-weight: 700; font-size: calc(46px * var(--u)); line-height: 1; }
.depth small { font-size: 0.5em; margin-left: 3px; opacity: 0.85; }
.dive-sub {
  margin-top: calc(4px * var(--u)); display: flex; gap: calc(12px * var(--u)); justify-content: center; align-items: center;
  font-weight: 600; font-size: calc(17px * var(--u));
}
.fishc { display: inline-flex; align-items: center; gap: 6px; background: rgba(8, 30, 56, 0.45); border-radius: 999px; padding: 2px 10px; }
.dive-sub.full .fishc { background: #22c55e; }
.fish-ic {
  display: inline-block; width: 1.3em; height: 0.75em; background: #ffd23f;
  clip-path: polygon(0 50%, 22% 0, 22% 30%, 70% 0, 100% 50%, 70% 100%, 22% 70%, 22% 100%);
}
.sh {
  vertical-align: -0.15em;
  display: inline-block; width: 0.9em; height: 1.05em; margin: 0 1px; background: #7ff6ff;
  clip-path: polygon(50% 0, 100% 18%, 92% 62%, 50% 100%, 8% 62%, 0 18%);
  filter: drop-shadow(0 0 4px #7ff6ff);
}

/* ---------- bottom panel ---------- */
#panel {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  padding: calc(10px * var(--u)) calc(10px * var(--u)) calc(12px * var(--u) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: calc(10px * var(--u));
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.15), opacity 0.25s;
}
#panel.away { transform: translateY(130%); opacity: 0; pointer-events: none; }
.cast {
  font-weight: 700; font-size: calc(30px * var(--u)); letter-spacing: 0.05em; color: #fff;
  padding: calc(9px * var(--u)) calc(50px * var(--u)); border-radius: calc(18px * var(--u));
  background: linear-gradient(#66f7a2, #1fc25e);
  box-shadow: 0 calc(5px * var(--u)) 0 #128a41, 0 calc(9px * var(--u)) calc(18px * var(--u)) rgba(0, 0, 0, 0.28);
  text-shadow: 0 2px 0 rgba(0, 90, 40, 0.55);
  animation: pulse 1.6s ease-in-out infinite;
}
.cast:active { transform: translateY(3px) scale(0.98); box-shadow: 0 2px 0 #128a41; animation: none; }
@keyframes pulse { 50% { transform: scale(1.05); } }
#upgrades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(8px * var(--u)); width: min(100%, calc(560px * var(--u))); }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: calc(1px * var(--u));
  padding: calc(8px * var(--u)) calc(4px * var(--u)) calc(6px * var(--u));
  border-radius: calc(15px * var(--u)); color: #2b3a4a;
  background: linear-gradient(#fffdf6, #efe7d1);
  box-shadow: 0 calc(4px * var(--u)) 0 #c6b996, 0 6px 14px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s;
}
.card:active { transform: translateY(3px); box-shadow: 0 1px 0 #c6b996; }
.card .ic { width: calc(30px * var(--u)); height: calc(30px * var(--u)); }
.card .ic svg { width: 100%; height: 100%; }
.card .nm { font-weight: 700; font-size: calc(12px * var(--u)); letter-spacing: 0.08em; text-transform: uppercase; color: #7a8796; }
.card .val { font-weight: 700; font-size: calc(15px * var(--u)); color: #1f3550; white-space: nowrap; }
.card .lvl { position: absolute; top: calc(5px * var(--u)); right: calc(7px * var(--u)); font-size: calc(10px * var(--u)); font-weight: 700; color: #9aa5b1; }
.card .price {
  margin-top: calc(3px * var(--u)); width: 94%; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: calc(3px * var(--u)) 0; border-radius: calc(9px * var(--u));
  font-weight: 700; font-size: calc(15px * var(--u)); background: #ffd23f; color: #5a3d00;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}
.card .price .coin { width: 1em; height: 1em; }
.card.poor .price { background: #d8dce1; color: #7b8794; }
.card.poor .price .coin { filter: grayscale(1) opacity(0.6); }
.card.max .price { background: #7bd88f; color: #0e4a20; }
.card.max .price .coin { display: none; }
.card.can { animation: canbuy 1.4s ease-in-out infinite; }
@keyframes canbuy { 50% { box-shadow: 0 calc(4px * var(--u)) 0 #c6b996, 0 0 0 3px rgba(255, 210, 63, 0.85), 0 6px 14px rgba(0, 0, 0, 0.25); } }
.card.flash { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { transform: scale(1.1); filter: brightness(1.25); } }
.card.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- toasts / banner / hints ---------- */
#toasts {
  position: absolute; z-index: 8; top: calc(60px * var(--u)); left: 50%; transform: translateX(-50%);
  width: min(92%, 420px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px;
  background: rgba(10, 28, 52, 0.88); border: 2px solid rgba(255, 255, 255, 0.2); border-radius: 16px;
  font-weight: 600; font-size: calc(15px * var(--u)); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toast img { width: 58px; height: 41px; object-fit: contain; }
.toast .tt { font-size: 0.8em; letter-spacing: 0.12em; text-transform: uppercase; color: #7ff6ff; }
.toast b { color: #ffd23f; }
.toast .haul { padding: 2px 6px; font-size: 1.1em; }
.toast.out { animation: toastOut 0.3s forwards; }
@keyframes toastIn { from { transform: translateY(-16px) scale(0.9); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-10px); opacity: 0; } }
.banner { position: absolute; z-index: 7; top: 30%; left: 0; right: 0; text-align: center; pointer-events: none; opacity: 0; }
.banner.show { animation: banner 2.6s ease forwards; }
.banner .b1 { font-size: calc(15px * var(--u)); letter-spacing: 0.35em; font-weight: 600; opacity: 0.9; }
.banner .b2 { font-size: calc(40px * var(--u)); font-weight: 700; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), 0 0 26px rgba(127, 246, 255, 0.55); }
@keyframes banner { 0% { opacity: 0; transform: scale(0.8); } 12% { opacity: 1; transform: scale(1.05); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.hint {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: 40%;
  display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 88%;
  padding: 10px 18px; border-radius: 16px; background: rgba(10, 28, 52, 0.82);
  font-weight: 600; font-size: calc(17px * var(--u)); text-align: center; pointer-events: none;
  animation: toastIn 0.35s;
}
.hint-hand { width: calc(34px * var(--u)); height: calc(40px * var(--u)); }
.hint-hand svg { width: 100%; height: 100%; }
.hint.swipe .hint-hand { animation: swipe 1.3s ease-in-out infinite; }
.hint.tap .hint-hand, .hint.cast .hint-hand, .hint.up .hint-hand { animation: tap 0.9s ease-in-out infinite; }
.hint.cast { bottom: calc(190px * var(--u)); }
.hint.swipe { bottom: 14%; }
.hint.up { bottom: calc(150px * var(--u)); }
@keyframes swipe { 0%, 100% { transform: translateX(-46px) rotate(-8deg); } 50% { transform: translateX(46px) rotate(8deg); } }
@keyframes tap { 50% { transform: translateY(6px) scale(0.92); } }

/* ---------- title ---------- */
#title {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(14px * var(--u)); background: radial-gradient(ellipse at 50% 45%, rgba(10, 50, 90, 0.05), rgba(4, 20, 40, 0.55));
  transition: opacity 0.4s;
}
#title.gone { opacity: 0; pointer-events: none; }
.logo {
  display: flex; flex-direction: column; align-items: center; line-height: 0.86;
  font-weight: 700; font-size: calc(78px * var(--u)); transform: rotate(-4deg);
  text-shadow: 0 calc(6px * var(--u)) 0 #0d5f8f, 0 calc(12px * var(--u)) calc(22px * var(--u)) rgba(0, 0, 0, 0.35);
  animation: float 3s ease-in-out infinite;
}
.logo span:last-child { color: #ffd23f; text-shadow: 0 calc(6px * var(--u)) 0 #c47a00, 0 calc(12px * var(--u)) calc(22px * var(--u)) rgba(0, 0, 0, 0.35); }
@keyframes float { 50% { transform: rotate(-4deg) translateY(-8px); } }
.tagline { font-weight: 600; font-size: calc(17px * var(--u)); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.cast.big { font-size: calc(32px * var(--u)); padding: calc(11px * var(--u)) calc(64px * var(--u)); }
.title-best { font-weight: 600; font-size: calc(14px * var(--u)); opacity: 0.9; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }

/* ---------- modal ---------- */
.modal { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 12px; background: rgba(3, 12, 26, 0.6); animation: fade 0.2s; }
.sheet {
  width: min(100%, 580px); max-height: 92%; overflow: auto; touch-action: pan-y;
  padding: 16px; border-radius: 22px; border: 2px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(#173a63, #0f2747); box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.sheet::-webkit-scrollbar { width: 8px; }
.sheet::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.25); border-radius: 8px; }
.sheet h2 { display: flex; justify-content: space-between; align-items: center; font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.sheet .sub { font-size: 14px; opacity: 0.8; }
.x { width: 36px; height: 36px; border-radius: 11px; background: rgba(255, 255, 255, 0.12); display: grid; place-items: center; }
.x svg { width: 55%; height: 55%; }
.progress { height: 10px; margin: 8px 0 12px; border-radius: 99px; overflow: hidden; background: rgba(255, 255, 255, 0.12); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #4dff9a, #ffd23f); }
.fact { min-height: 46px; margin-bottom: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); font-size: 14px; line-height: 1.45; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.dex .cell { padding: 6px; border-radius: 13px; text-align: center; background: rgba(255, 255, 255, 0.06); border: 2px solid transparent; }
.dex .cell.on { background: rgba(127, 246, 255, 0.1); }
.dex .cell.sel { border-color: #ffd23f; }
.dex img { width: 100%; height: auto; aspect-ratio: 120 / 84; }
.dex .n { font-weight: 600; font-size: 13px; }
.dex .m { font-size: 11px; opacity: 0.75; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); font-weight: 600; }
.toggle { position: relative; width: 52px; height: 30px; border-radius: 99px; background: #5b6b7d; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.toggle.on { background: #22c55e; }
.toggle.on::after { left: 25px; }
.btn { padding: 10px 22px; border-radius: 12px; font-weight: 700; background: #ffd23f; color: #4a3300; box-shadow: 0 4px 0 #c49a00; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #c49a00; }
.btn.red { background: #ff5d6c; color: #fff; box-shadow: 0 4px 0 #b3303d; }
.center { text-align: center; }
.offline-amt { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px 0 18px; font-size: 42px; font-weight: 700; color: #ffd23f; }
.small { font-size: 12px; opacity: 0.75; font-weight: 500; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
