:root {
  --bg: #05101a;
  --panel: #0c1a26;
  --panel-2: #142434;
  --line: #1f3346;
  --text: #d6e7f3;
  --muted: #6b8aa3;
  --accent: #4fd0ff;
  --gold: #ffcc66;
  --good: #6effa3;
  --bad: #ff7a7a;
  --font-sans: "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Block accidental highlighting across the whole game UI. Inputs and
   textareas explicitly opt back in below so account/leaderboard fields
   still work normally. */
body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

#app {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
}

/* Sidebar ------------------------------------------------------- */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}
#sidebar > .panel { min-width: 0; }

#sidebar header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.header-level {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}
.header-level #headerLevel {
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
}
.header-level #headerBiome {
  color: var(--muted);
}
.header-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
#sidebar header .bar {
  margin-top: 4px;
  height: 5px;
}
.next-biome-info {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}
.next-biome-info strong {
  color: var(--biome-accent, var(--accent));
  font-weight: 700;
}

.event-link-banner {
  display: block;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-align: center;
  text-decoration: none;
  color: #ffe0ee;
  background: linear-gradient(90deg, rgba(255,154,196,0.18), rgba(255,216,112,0.18));
  border: 1px solid rgba(255,154,196,0.4);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.event-link-banner:hover {
  background: linear-gradient(90deg, rgba(255,154,196,0.32), rgba(255,216,112,0.32));
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255,154,196,0.25);
}

.account-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: lowercase;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.account-badge.anon   { color: var(--muted); }
.account-badge.linked { color: var(--good); border-color: rgba(110,255,163,0.4); }

/* Account modal — single form, two action buttons. */
.account-modal { max-width: 380px; }
.account-state {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(79,208,255,0.06), rgba(79,208,255,0.02));
  border: 1px solid var(--line);
}
.account-state-line {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.account-state-blurb {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.account-auth-form input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin: 6px 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.account-auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,208,255,0.15);
}
.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.account-btn {
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
}
.account-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(79,208,255,0.10);
}
.account-btn:disabled { opacity: 0.55; cursor: progress; }
.account-btn.primary {
  background: var(--accent);
  color: #00131c;
  border-color: var(--accent);
}
.account-btn.primary:hover:not(:disabled) {
  background: #87dfff;
  border-color: #87dfff;
}
.account-btn.ghost-btn { width: 100%; }
.account-help {
  font-size: 11.5px;
  margin-top: 10px;
  line-height: 1.45;
}
.account-signed-in { margin-top: 4px; }
.account-msg {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  min-height: 16px;
  line-height: 1.4;
}
.account-msg.ok  { background: rgba(110,255,163,0.10); color: var(--good); border: 1px solid rgba(110,255,163,0.3); }
.account-msg.bad { background: rgba(255,122,122,0.10); color: var(--bad);  border: 1px solid rgba(255,122,122,0.3); }
.account-msg:empty { display: none; }

.account-skip {
  display: block;
  margin: 12px auto 0;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 120ms ease;
}
.account-skip:hover { color: var(--text); }

#sidebar h1 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #aef0ff 0%, #4fd0ff 60%, #1c7da8 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  text-shadow: 0 0 12px rgba(79, 208, 255, 0.25);
}

.cash {
  position: relative;
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff1c2 0%, #ffcc66 50%, #c98e2a 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  text-shadow: 0 0 14px rgba(255, 200, 80, 0.3);
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  transition: transform 120ms ease;
}
.cash::before {
  content: "$";
  font-size: 20px;
  background: inherit;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.cash.bump { animation: cashBump 280ms ease-out; }
@keyframes cashBump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.cash-pop {
  position: absolute;
  right: 0;
  top: -4px;
  font-size: 13px;
  font-weight: 700;
  color: #6effa3;
  text-shadow: 0 0 6px rgba(110,255,163,0.6);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  animation: cashPop 1.1s ease-out forwards;
  white-space: nowrap;
}
@keyframes cashPop {
  0%   { transform: translateY(8px); opacity: 0; }
  20%  { transform: translateY(0);   opacity: 1; }
  100% { transform: translateY(-32px); opacity: 0; }
}

.cash-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prestige-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  background: linear-gradient(180deg, rgba(199,155,255,0.14), rgba(199,155,255,0.04));
  border: 1px solid rgba(199,155,255,0.55);
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  color: #d8b8ff;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(199,155,255,0.35);
  box-shadow: 0 0 6px rgba(199,155,255,0.10);
}
.prestige-badge:empty { display: none; }

.panel {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}
.panel h2:hover { color: var(--text); }
.panel h2::after {
  content: "▾";
  font-size: 10px;
  margin-left: auto;
  transition: transform 180ms ease;
}
.panel.collapsed { padding-bottom: 8px; }
.panel.collapsed h2 { margin-bottom: 0; }
.panel.collapsed h2::after { transform: rotate(-90deg); }
/* !important so an ID-scoped display rule (e.g., #lastHaul { display: flex })
   can't out-specific the collapse and leave the body visible. */
.panel.collapsed > :not(h2) { display: none !important; }

/* Pop-out / dock toggle button — sits on the right of each panel h2. */
.panel-pop-btn {
  margin-left: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  user-select: none;
  -webkit-user-select: none;
}
.panel-pop-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(79,208,255,0.08);
}
.panel.floating .panel-pop-btn {
  color: var(--accent);
  border-color: var(--accent);
}

/* Floating panel — torn off the sidebar, free to move anywhere on screen. */
.panel.floating {
  position: fixed;
  width: 320px;
  z-index: 60;
  margin: 0;
  padding: 14px 16px 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(79, 208, 255, 0.15),
    0 0 22px rgba(79, 208, 255, 0.10);
}
.panel.floating h2 {
  cursor: grab;
  margin: -4px -4px 10px;
  padding: 4px;
  border-radius: 6px;
}
.panel.floating h2::after { display: none; } /* no collapse caret on floating */
.panel.floating h2:hover  { background: rgba(79,208,255,0.06); }
.panel.floating.dragging,
.panel.floating.dragging h2 { cursor: grabbing; }
.panel.floating.dragging {
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.7),
    0 0 0 1px var(--accent),
    0 0 30px rgba(79, 208, 255, 0.25);
}

.stat {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}

.stat span:first-child { color: var(--muted); }

.bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--good));
  transition: width 120ms linear;
}
.bar-fill-level {
  background: linear-gradient(90deg, #c79bff, #ffcc66);
}

/* Upgrades ------------------------------------------------------ */
/* Whole row is the buy button — full-bar click target, the price lives inside.
   Button-element-as-row carries focus, hover, disabled, and active states. */
.upgrade {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  /* Rapid clicks were selecting the price text — disable selection on the
     whole button so spam-buying doesn't highlight anything. */
  user-select: none;
  -webkit-user-select: none;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.upgrade:hover:not(:disabled) {
  background: rgba(79,208,255,0.10);
  border-color: var(--accent);
}
.upgrade:active:not(:disabled) { transform: scale(0.99); }
.upgrade:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.upgrade .info { line-height: 1.35; min-width: 0; flex: 1 1 auto; }
.upgrade .name { font-weight: 600; }
.upgrade .meta { color: var(--muted); font-size: 11px; }

.upgrade .price {
  flex: 0 0 auto;
  margin-left: 12px;
  padding: 6px 12px;
  border-radius: 4px;
  background: var(--accent);
  color: #00131c;
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: center;
  transition: background 120ms ease, color 120ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.1;
}
.upgrade .price .price-count {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.85;
}
.upgrade .price .price-count:empty { display: none; }
.upgrade:disabled .price {
  background: var(--line);
  color: var(--muted);
}

/* Buy-mode picker — three pills at the top of the Outfitting panel. */
.buy-mode-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.buy-mode-btn {
  flex: 1 1 auto;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.buy-mode-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(79,208,255,0.06);
}
.buy-mode-btn.active {
  background: var(--accent);
  color: #00131c;
  border-color: var(--accent);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
button.ghost:hover { color: var(--bad); border-color: var(--bad); }

#sidebar footer {
  padding: 14px 20px;
  margin-top: auto;
}

/* Active-effect stack (encounters) ----------------------------- */
/* Lives inside .slot-stack — sits right below the slot at the same width.
   Each running bonus is a child .active-effect row so multiple buffs stack
   instead of only showing the longest-remaining one. */
#activeEffect:empty { display: none; }
#activeEffect:not(:empty) {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.active-effect {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 36px 6px 10px; /* extra right padding for the timer pop-out */
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  animation: effectPulse 1.4s ease-in-out infinite alternate;
  border: 1px solid currentColor;
  box-sizing: border-box;
  /* Opaque dark base so the bar reads against any biome (pink Spring Bloom,
     bright Lava Vents, etc.) — per-tier rules layer a colored tint on top. */
  background: linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
}
.active-effect .ae-label {
  flex: 1 1 auto;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
}
/* Timer chip pops out the right edge — futuristic neon-LED feel: monospace,
   sharp clipped corners, currentColor inner/outer glow, blinking caret feel
   from the inherited effectPulse animation. */
.active-effect .ae-timer {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 3px 7px;
  min-width: 38px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: currentColor;
  background: linear-gradient(180deg, #050a12, #02060c);
  border: 1px solid currentColor;
  border-radius: 2px;
  /* Hexagonal-ish notched chip — the cut corners give it the "hardware
     readout" look without needing SVG. */
  clip-path: polygon(8% 0, 100% 0, 100% 100%, 8% 100%, 0 50%);
  box-shadow:
    0 0 8px currentColor,
    inset 0 0 6px rgba(255,255,255,0.10);
  text-shadow: 0 0 6px currentColor, 0 0 2px rgba(0,0,0,0.9);
}
.active-effect.eff-map     {
  color: var(--gold);
  background:
    linear-gradient(90deg, rgba(255,200,80,0.28), rgba(255,200,80,0.04)),
    linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
}
.active-effect.eff-kiss    {
  color: #c79bff;
  background:
    linear-gradient(90deg, rgba(199,155,255,0.28), rgba(199,155,255,0.04)),
    linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
}
.active-effect.eff-current {
  color: var(--accent);
  background:
    linear-gradient(90deg, rgba(79,208,255,0.28), rgba(79,208,255,0.04)),
    linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
}
.active-effect.eff-shark {
  color: var(--bad);
  background:
    linear-gradient(90deg, rgba(255,122,122,0.28), rgba(255,122,122,0.04)),
    linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
}
@keyframes effectPulse {
  from { box-shadow: 0 0 4px  currentColor, inset 0 0 4px rgba(255,255,255,0.04); }
  to   { box-shadow: 0 0 14px currentColor, inset 0 0 8px rgba(255,255,255,0.08); }
}

/* Current cargo ------------------------------------------------- */
.cargo-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 3px;
  /* Reserve space for ~7 typical loot rows + a Total row so the Outfitting
     panel below doesn't jump around as the dive fills cargo. */
  min-height: 196px;
}
.cargo-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  border-left: 3px solid currentColor;
  background: rgba(255,255,255,0.025);
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
  min-width: 0;
}
.cargo-list li > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cargo-list li > span:last-child {
  color: var(--gold);
  font-weight: 700;
  text-shadow: 0 0 6px rgba(255,200,80,0.25);
  flex: 0 0 auto;
  white-space: nowrap;
}
.cargo-list li.rarity-common   { color: #d6e7f3; }
.cargo-list li.rarity-uncommon { color: var(--good);    background: rgba(110,255,163,0.06); }
.cargo-list li.rarity-rare {
  color: var(--accent);
  background: rgba(79,208,255,0.07);
  animation: cargoRarePulse 1.8s ease-in-out infinite alternate;
}
.cargo-list li.rarity-epic {
  color: #c79bff;
  background: rgba(199,155,255,0.09);
  animation: cargoEpicPulse 1.6s ease-in-out infinite alternate;
}
@keyframes cargoRarePulse {
  from { box-shadow: 0 0 2px rgba(79,208,255,0.15); }
  to   { box-shadow: 0 0 10px rgba(79,208,255,0.45); }
}
@keyframes cargoEpicPulse {
  from { box-shadow: 0 0 3px rgba(199,155,255,0.2);  }
  to   { box-shadow: 0 0 12px rgba(199,155,255,0.5); }
}
.cargo-list li.rarity-legend   {
  color: var(--gold);
  background: linear-gradient(90deg, rgba(255,200,80,0.18), rgba(255,200,80,0.02));
  box-shadow: 0 0 8px rgba(255,200,80,0.25);
  animation: cargoLegendPulse 1.6s ease-in-out infinite alternate;
}
@keyframes cargoLegendPulse {
  from { box-shadow: 0 0 4px  rgba(255,200,80,0.2); }
  to   { box-shadow: 0 0 14px rgba(255,200,80,0.55); }
}
.cargo-list li.muted {
  border-left-color: var(--line);
  color: var(--muted);
  background: transparent;
  text-shadow: none;
  font-weight: 500;
}

/* Last haul ----------------------------------------------------- */
#lastHaul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  /* Mirror the cargo-list reservation — 7 rows + Total at this row height. */
  min-height: 168px;
}
#lastHaul li {
  padding: 2px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
#lastHaul li > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lastHaul li > span:last-child {
  flex: 0 0 auto;
  white-space: nowrap;
}
.muted { color: var(--muted); }

.rarity-common   { color: #b8c6d2; }
.rarity-uncommon { color: var(--good); }
.rarity-rare     { color: var(--accent); }
.rarity-epic     { color: #c79bff; }
.rarity-legend   { color: var(--gold); }

/* Ocean --------------------------------------------------------- */
@property --biome-color {
  syntax: '<color>';
  inherits: true;
  initial-value: #7fc6e8;
}
@property --biome-accent {
  syntax: '<color>';
  inherits: true;
  initial-value: #aef0ff;
}

#ocean {
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--biome-color) 0%,
    #000507 100%
  );
  transition: --biome-color 3s ease;
}

#surface {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6%;
  background: linear-gradient(180deg, #7fc6e8, #2a8fc4);
  border-bottom: 2px solid #cfe9f7;
}

#water { position: absolute; inset: 0; }

#sub {
  position: absolute;
  left: 50%;
  top: 4%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 36px;
  transition: top 100ms linear;
  z-index: 5;
}

#sub {
  --sub-c1: #ffe089;
  --sub-c2: #d8941f;
  --sub-c3: #8a5510;
  --sub-border: #4a2e08;
  --sub-glow: rgba(255, 200, 100, 0.4);
}

.sub-body {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sub-c1) 0%, var(--sub-c2) 55%, var(--sub-c3) 100%);
  border-radius: 60% 60% 50% 50% / 70% 70% 35% 35%;
  border: 2px solid var(--sub-border);
  box-shadow:
    inset 0 -5px 8px rgba(0,0,0,0.45),
    0 0 14px var(--sub-glow);
  transition: background 1.2s ease, border-color 1.2s ease, box-shadow 1.2s ease, transform 200ms ease;
}

/* Sub evolution stages — one per biome (index 0..9). */
#sub[data-stage="2"] {
  --sub-c1: #ff9b3a; --sub-c2: #a04020; --sub-c3: #4a1808;
  --sub-border: #2a0c00; --sub-glow: rgba(255, 130, 50, 0.65);
}
#sub[data-stage="3"] {
  --sub-c1: #f0f4f8; --sub-c2: #5a6878; --sub-c3: #1a2230;
  --sub-border: #0a1018; --sub-glow: rgba(190, 220, 240, 0.7);
}
#sub[data-stage="4"] {
  --sub-c1: #b88ff0; --sub-c2: #5a3088; --sub-c3: #1a0840;
  --sub-border: #0a0420; --sub-glow: rgba(160, 120, 255, 0.85);
}
#sub[data-stage="5"] {
  --sub-c1: #ff5050; --sub-c2: #802020; --sub-c3: #300808;
  --sub-border: #1a0202; --sub-glow: rgba(255, 80, 80, 0.85);
}
#sub[data-stage="6"] {
  --sub-c1: #ffe060; --sub-c2: #ff4020; --sub-c3: #4a0a08;
  --sub-border: #200200; --sub-glow: rgba(255, 90, 30, 1);
}
#sub[data-stage="7"] {
  --sub-c1: #f0c0ff; --sub-c2: #8040d8; --sub-c3: #1a0850;
  --sub-border: #08001a; --sub-glow: rgba(220, 120, 255, 1);
}
#sub[data-stage="8"] {
  --sub-c1: #d0f8ff; --sub-c2: #4090d8; --sub-c3: #082a4a;
  --sub-border: #021020; --sub-glow: rgba(120, 220, 255, 1);
}
#sub[data-stage="9"] {
  --sub-c1: #fff5b0; --sub-c2: #ffa800; --sub-c3: #5a2808;
  --sub-border: #2a1004; --sub-glow: rgba(255, 200, 50, 1);
}
#sub[data-stage="10"] {
  --sub-c1: #ff66ff; --sub-c2: #4408a0; --sub-c3: #050010;
  --sub-border: #2a006a;
  --sub-glow: rgba(200, 80, 255, 1);
}
#sub[data-stage="10"] .sub-body {
  animation: stage10Pulse 1.4s ease-in-out infinite alternate;
}
@keyframes stage10Pulse {
  from { filter: hue-rotate(0deg) brightness(1); }
  to   { filter: hue-rotate(60deg) brightness(1.2); }
}
#sub[data-stage="10"] .sub-body {
  animation: stage10Pulse 1.4s ease-in-out infinite alternate;
}
@keyframes stage10Pulse {
  from { filter: hue-rotate(0deg); }
  to   { filter: hue-rotate(40deg) brightness(1.1); }
}

.sub-window {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #c5f0ff 0%, #5aa6cc 40%, #1a4868 75%, #08172a 100%);
  border: 2px solid #4a2e08;
  box-shadow: inset 0 0 3px rgba(0,0,0,0.7);
}

.sub-stripe {
  position: absolute;
  left: 0;
  right: 0;
  top: 62%;
  height: 3px;
  background: #4a2e08;
  opacity: 0.6;
}

.sub-fin {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 12px;
  background: linear-gradient(180deg, #d8941f, #8a5510);
  border: 2px solid #4a2e08;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.sub-prop {
  position: absolute;
  left: -10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: #2a1a04;
  border: 2px solid #4a2e08;
  overflow: hidden;
}
.sub-prop::before {
  content: "";
  position: absolute;
  inset: 1px;
  background:
    linear-gradient(0deg,  transparent 42%, #ffd966 42% 58%, transparent 58%),
    linear-gradient(90deg, transparent 42%, #ffd966 42% 58%, transparent 58%);
  border-radius: 50%;
  animation: subSpin 0.18s linear infinite;
}
@keyframes subSpin { to { transform: rotate(360deg); } }

#sub.boosted .sub-body {
  box-shadow:
    inset 0 -5px 8px rgba(0,0,0,0.45),
    0 0 24px rgba(255, 220, 120, 0.95),
    0 0 60px rgba(255, 180, 60, 0.6);
}
#sub.boosted .sub-prop::before { animation-duration: 0.05s; }

#sub.collecting .sub-body {
  animation: collectPulse 0.28s ease-out;
}
@keyframes collectPulse {
  0%   { transform: scale(1); filter: brightness(1); }
  50%  { transform: scale(1.18); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}

.sub-light {
  position: absolute;
  left: 50%;
  top: 90%;
  width: 110px;
  height: 180px;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at top,
    rgba(255, 240, 180, 0.4) 0%,
    rgba(255, 240, 180, 0.1) 45%,
    rgba(255, 240, 180, 0) 75%
  );
  pointer-events: none;
  filter: blur(2px);
}

#depthMarkers {
  position: absolute;
  left: 8px;
  top: 6%;
  bottom: 0;
  width: 90px;
  pointer-events: none;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  font-variant-numeric: tabular-nums;
}
.marker {
  position: absolute;
  left: 0;
  border-top: 1px dashed rgba(255,255,255,0.15);
  width: 100%;
  padding-left: 4px;
  text-align: left;
  line-height: 1;
}

#log {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 320px;
  max-height: 220px;
  overflow: hidden;
  pointer-events: none;
}
.log-line {
  background: rgba(0, 0, 0, 0.55);
  border-left: 2px solid var(--accent);
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 12px;
  border-radius: 0 4px 4px 0;
  animation: logEnter 0.3s ease-out;
  transition: opacity 2s ease-out, transform 2s ease-out;
}
.log-line.fading {
  opacity: 0;
  transform: translateY(-8px);
}
@keyframes logEnter {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* How to Play modal -------------------------------------------- */
.howto-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 16, 0.78);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: howtoFade 220ms ease-out;
}
.howto-overlay[hidden] { display: none; }
@keyframes howtoFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.howto-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #0f1f2e 0%, #081522 100%);
  border: 1px solid rgba(79, 208, 255, 0.45);
  border-radius: 12px;
  padding: 28px 32px 24px;
  box-shadow: 0 0 40px rgba(79, 208, 255, 0.18), inset 0 1px 0 rgba(255,255,255,0.04);
  animation: howtoPop 240ms cubic-bezier(0.2, 0.8, 0.4, 1);
}
@keyframes howtoPop {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.howto-modal h2 {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
  text-shadow: 0 0 12px rgba(79, 208, 255, 0.35);
}
.howto-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.howto-close:hover {
  color: var(--text);
  border-color: var(--accent);
}
.howto-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.howto-body section {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}
.howto-body h3 {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.5px;
}
.howto-body p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  opacity: 0.92;
}
.howto-body strong { color: var(--gold); font-weight: 700; }

/* Boost button -------------------------------------------------- */
.boost-hint {
  position: absolute;
  left: 20px;
  bottom: 108px;
  width: 140px;
  box-sizing: border-box;
  padding: 5px 8px;
  text-align: center;
  background: linear-gradient(180deg, rgba(255,200,80,0.22), rgba(255,200,80,0.05));
  border: 1px solid rgba(255,200,80,0.55);
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #ffe6a8;
  text-shadow: 0 0 6px rgba(255,200,80,0.45), 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 0 10px rgba(255,200,80,0.18), inset 0 0 6px rgba(255,220,140,0.08);
  pointer-events: none;
  user-select: none;
  transition: background 220ms ease, border-color 220ms ease, color 220ms ease, box-shadow 220ms ease;
}
.boost-hint::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: linear-gradient(135deg, rgba(255,200,80,0.18), rgba(255,200,80,0.05));
  border-right: 1px solid rgba(255,200,80,0.55);
  border-bottom: 1px solid rgba(255,200,80,0.55);
}
.boost-hint.active {
  background: linear-gradient(180deg, rgba(110,255,163,0.25), rgba(110,255,163,0.05));
  border-color: rgba(110,255,163,0.65);
  color: #d6ffe6;
  text-shadow: 0 0 6px rgba(110,255,163,0.5), 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 0 12px rgba(110,255,163,0.25), inset 0 0 6px rgba(180,255,210,0.1);
}
.boost-hint.active::after {
  background: linear-gradient(135deg, rgba(110,255,163,0.20), rgba(110,255,163,0.05));
  border-right-color: rgba(110,255,163,0.65);
  border-bottom-color: rgba(110,255,163,0.65);
}
.boost-hint.cooling {
  background: linear-gradient(180deg, rgba(107,138,163,0.18), rgba(107,138,163,0.04));
  border-color: rgba(107,138,163,0.45);
  color: var(--muted);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: none;
}
.boost-hint.cooling::after {
  background: linear-gradient(135deg, rgba(107,138,163,0.18), rgba(107,138,163,0.04));
  border-right-color: rgba(107,138,163,0.45);
  border-bottom-color: rgba(107,138,163,0.45);
}
.boost-btn {
  position: absolute;
  left: 20px;
  bottom: 20px;
  width: 140px;
  height: 80px;
  background: linear-gradient(180deg, #ffe089 0%, #ffcc66 50%, #c98e2a 100%);
  color: #2a1500;
  border: 1px solid #ffe9b3;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow:
    0 0 18px rgba(255, 200, 100, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset 0 -3px 0 rgba(140, 80, 0, 0.35);
  overflow: hidden;
  transition: transform 80ms ease, box-shadow 200ms ease, background 200ms ease;
  user-select: none;
}
.boost-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    0 0 24px rgba(255, 220, 130, 0.75),
    inset 0 1px 0 rgba(255,255,255,0.6),
    inset 0 -3px 0 rgba(140, 80, 0, 0.35);
}
.boost-btn:active:not(:disabled) { transform: translateY(1px); }
.boost-btn:disabled {
  background: linear-gradient(180deg, #2c3a4a 0%, #1a2734 100%);
  color: var(--muted);
  border-color: #2a3d50;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    inset 0 -2px 0 rgba(0,0,0,0.4);
  cursor: not-allowed;
}
.boost-btn.active {
  background: linear-gradient(180deg, #b6ffd2 0%, #6effa3 50%, #2bb86c 100%);
  color: #001a0c;
  border-color: #d3ffe2;
  animation: boostFlash 0.5s ease-in-out infinite alternate;
}
@keyframes boostFlash {
  from { box-shadow:
    0 0 18px rgba(110, 255, 163, 0.55),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 -3px 0 rgba(0,60,30,0.35); }
  to   { box-shadow:
    0 0 36px rgba(110, 255, 163, 0.95),
    inset 0 1px 0 rgba(255,255,255,0.6),
    inset 0 -3px 0 rgba(0,60,30,0.4); }
}
.boost-label {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  line-height: 1;
}
.boost-sub {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  opacity: 0.85;
  line-height: 1.1;
  min-height: 11px;
}
.boost-cooldown {
  position: absolute;
  left: 0; bottom: 0;
  height: 4px;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,255,255,0.85), rgba(255,255,255,0.4));
  transition: width 100ms linear;
  box-shadow: 0 0 6px rgba(255,255,255,0.4);
}
.boost-btn.active .boost-cooldown {
  background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(180,255,210,0.55));
}
.boost-btn:disabled .boost-cooldown {
  background: linear-gradient(90deg, rgba(120,160,200,0.45), rgba(120,160,200,0.2));
  box-shadow: none;
}

/* Loot effects -------------------------------------------------- */
.loot-fx {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  animation: lootFly 0.6s cubic-bezier(0.4, 0, 0.6, 1) forwards;
  z-index: 4;
}
.loot-fx.rarity-common   { background: #b8c6d2; box-shadow: 0 0 8px #b8c6d2; }
.loot-fx.rarity-uncommon { background: #6effa3; box-shadow: 0 0 10px #6effa3; }
.loot-fx.rarity-rare     { background: #4fd0ff; box-shadow: 0 0 12px #4fd0ff; }
.loot-fx.rarity-epic     { background: #c79bff; box-shadow: 0 0 14px #c79bff; }
.loot-fx.rarity-legend   { background: #ffcc66; box-shadow: 0 0 18px #ffcc66; }

@keyframes lootFly {
  0%   { transform: translate(0, 0) scale(1); opacity: 0; }
  10%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.value-pop {
  position: absolute;
  pointer-events: none;
  font-size: 14.5px;
  font-weight: 800;
  text-shadow: 0 0 6px rgba(0,0,0,0.95), 0 1px 2px rgba(0,0,0,0.95);
  animation: valueFloat 1.2s ease-out forwards;
  z-index: 6;
  white-space: nowrap;
  letter-spacing: 0.3px;
}
@keyframes valueFloat {
  0%   { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  20%  { transform: translate(-50%, -10px) scale(1.05); opacity: 1; }
  100% { transform: translate(-50%, -55px) scale(1); opacity: 0; }
}

.sale-burst {
  position: absolute;
  left: 50%;
  top: 28%;
  pointer-events: none;
  animation: saleBurst 1.6s cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
  z-index: 10;
  text-align: center;
  white-space: nowrap;
}
.sale-burst .label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 8px rgba(255,200,80,0.9), 0 2px 4px rgba(0,0,0,0.9);
  opacity: 0.9;
  margin-bottom: 4px;
}
.sale-burst .amount {
  display: block;
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(180deg, #ffffe6 0%, #ffe89a 45%, #ffd166 80%, #ffb84a 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  text-shadow:
    0 0 24px rgba(255, 220, 120, 0.7),
    0 4px 10px rgba(0, 0, 0, 0.85);
  filter: drop-shadow(0 0 14px rgba(255,220,120,0.55));
}
@keyframes saleBurst {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(-3deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.3)  rotate(2deg);  opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1)    rotate(0deg); }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(1)   rotate(0deg); opacity: 0; }
}

/* Prestige ------------------------------------------------------ */
.prestige-btn {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(180deg, #c79bff, #6a3ec1);
  color: #fff;
  border: 0;
  padding: 10px;
  border-radius: 6px;
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  text-transform: uppercase;
  font-size: 13px;
  box-shadow: 0 0 14px rgba(199,155,255,0.4);
}
.prestige-btn:hover:not(:disabled) { filter: brightness(1.15); }
.prestige-btn:disabled {
  background: var(--line);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}
.prestige-hint { font-size: 10.5px; margin-top: 4px; }

/* Codex --------------------------------------------------------- */
.codex-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.codex-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
  cursor: help;
  opacity: 0.45;
  filter: grayscale(0.9);
}
.codex-cell.found {
  opacity: 1;
  filter: none;
}
.codex-cell.found.rarity-uncommon { border-color: var(--good); }
.codex-cell.found.rarity-rare     { border-color: var(--accent); }
.codex-cell.found.rarity-epic     { border-color: #c79bff; }
.codex-cell.found.rarity-legend   {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(255,200,80,0.5);
}
.codex-cell .codex-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
}
.codex-biome-row { font-size: 10px; color: var(--muted); margin: 8px 0 3px; letter-spacing: 1px; text-transform: uppercase; }

/* Encounter banner --------------------------------------------- */
.encounter-banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0.85), rgba(0,0,0,0.65));
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  z-index: 11;
  animation: encounterPop 3s ease-out forwards;
  white-space: nowrap;
  box-shadow: 0 0 16px rgba(79,208,255,0.4);
}
.encounter-banner .enc-icon { font-size: 28px; }
.encounter-banner .enc-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}
.encounter-banner .enc-desc {
  font-size: 11px;
  color: var(--text);
}
.encounter-banner.hazard {
  border-color: var(--bad);
  box-shadow: 0 0 18px rgba(255, 122, 122, 0.55);
}
.encounter-banner.hazard .enc-name { color: var(--bad); }
@keyframes encounterPop {
  0%   { transform: translate(-50%, -20px) scale(0.4); opacity: 0; }
  15%  { transform: translate(-50%, 0) scale(1.1); opacity: 1; }
  25%  { transform: translate(-50%, 0) scale(1); }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -30px) scale(1); opacity: 0; }
}

/* Background creatures ----------------------------------------- */
.creature {
  position: absolute;
  font-size: 24px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.4));
  animation: creatureSwim linear forwards;
}
.creature.flip { transform: scaleX(-1); }
@keyframes creatureSwim {
  from { transform: translateX(-60px); }
  to   { transform: translateX(110vw); }
}

/* Achievements -------------------------------------------------- */
.achievement-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#achClaimAll {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--good);
  color: #00261a;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(110, 255, 163, 0.55);
  animation: achUnclaimedPulse 1.4s ease-in-out infinite alternate;
}
#achClaimAll:hover { filter: brightness(1.1); }
.achievement {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  opacity: 0.5;
  align-items: center;
}
.achievement.unlocked {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(255, 200, 80, 0.10), rgba(255, 200, 80, 0));
}
.achievement.unclaimed {
  cursor: pointer;
  border-color: var(--good);
  background: linear-gradient(180deg, rgba(110, 255, 163, 0.16), rgba(110, 255, 163, 0.02));
  animation: achUnclaimedPulse 1.4s ease-in-out infinite alternate;
}
.achievement.unclaimed:hover { filter: brightness(1.1); }
.achievement.claimed { opacity: 0.65; }
.achievement .ach-icon {
  font-size: 18px;
  text-align: center;
  filter: grayscale(1);
}
.achievement.unlocked .ach-icon { filter: none; }
.achievement .ach-name { font-weight: 700; line-height: 1.1; }
.achievement.unlocked .ach-name { color: var(--gold); }
.achievement.unclaimed .ach-name { color: var(--good); }
.achievement .ach-desc { color: var(--muted); font-size: 11px; }
.ach-reward {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.achievement.unclaimed .ach-reward {
  background: var(--good);
  color: #00261a;
  box-shadow: 0 0 10px rgba(110, 255, 163, 0.55);
}
.achievement.claimed .ach-reward { color: var(--gold); }
@keyframes achUnclaimedPulse {
  from { box-shadow: 0 0 4px rgba(110, 255, 163, 0.20); }
  to   { box-shadow: 0 0 14px rgba(110, 255, 163, 0.55); }
}

.achievement-toast {
  position: absolute;
  top: 60px;
  right: 20px;
  background: linear-gradient(180deg, rgba(0,0,0,0.88), rgba(0,0,0,0.7));
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
  z-index: 12;
  animation: achToast 4.2s ease-out forwards;
  min-width: 240px;
  max-width: 280px;
  box-shadow: 0 0 18px rgba(255, 200, 80, 0.45);
  transition: transform 90ms ease;
}
.achievement-toast:hover  { transform: translateX(-4px); box-shadow: 0 0 24px rgba(255, 200, 80, 0.7); }
.achievement-toast:active { transform: translateX(0)    scale(0.97); }
.achievement-toast .ach-cta {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 700;
}
.achievement.ach-flash { animation: achFlash 1.6s ease-out; }
@keyframes achFlash {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255, 204, 102, 0.9); }
  10%  { transform: scale(1.04); box-shadow: 0 0 24px rgba(255, 204, 102, 0.85); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(255, 204, 102, 0); }
}
.achievement-toast .ach-tier {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2.5px;
  margin-bottom: 6px;
}
.achievement-toast .ach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.achievement-toast .ach-icon { font-size: 22px; }
.achievement-toast .ach-name {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}
.achievement-toast .ach-desc {
  font-size: 11px;
  color: var(--muted);
}
@keyframes achToast {
  0%   { transform: translateX(120%); opacity: 0; }
  8%   { transform: translateX(0);    opacity: 1; }
  88%  { transform: translateX(0);    opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* Boost tap cue ------------------------------------------------- */
.boost-tap-cue {
  position: absolute;
  pointer-events: none;
  font-size: 14px;
  font-weight: 700;
  color: #6effa3;
  text-shadow: 0 0 6px rgba(110,255,163,0.7);
  animation: boostTapCue 600ms ease-out forwards;
  transform: translateX(-50%);
  z-index: 12;
}
@keyframes boostTapCue {
  0%   { transform: translate(-50%, 4px) scale(0.7); opacity: 0; }
  20%  { transform: translate(-50%, -8px) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -36px) scale(1);  opacity: 0; }
}

/* Sold-item popups (top-center stack) -------------------------- */
.sold-item {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 12px;
  background: rgba(0,0,0,0.55);
  border-left: 3px solid currentColor;
  border-radius: 0 4px 4px 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  pointer-events: none;
  white-space: nowrap;
  animation: soldItemFloat 2.2s ease-out forwards;
  z-index: 9;
}
.sold-item .sold-val { color: var(--gold); }
@keyframes soldItemFloat {
  0%   { transform: translate(-50%, 18px) scale(0.7); opacity: 0; }
  12%  { transform: translate(-50%, 0)    scale(1.05); opacity: 1; }
  22%  { transform: translate(-50%, 0)    scale(1); }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -28px) scale(1); opacity: 0; }
}

/* Rare-find banner ---------------------------------------------- */
.rare-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 11;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  will-change: opacity, transform;
}
.rare-banner.playing { animation: rareBanner 2s cubic-bezier(0.2, 0.7, 0.4, 1) forwards; }
/* Legacy non-pooled banners (if any) still auto-animate. */
.rare-banner:not(.pooled):not(.playing) { animation: rareBanner 2s cubic-bezier(0.2, 0.7, 0.4, 1) forwards; opacity: 1; }
.rare-banner .tier {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
  opacity: 0.95;
  animation: rareLogoPulse 0.55s ease-in-out infinite alternate;
  text-shadow: 0 0 8px currentColor;
}
@keyframes rareLogoPulse {
  from { transform: scale(1);    opacity: 0.75; filter: drop-shadow(0 0 4px  currentColor); }
  to   { transform: scale(1.15); opacity: 1;    filter: drop-shadow(0 0 14px currentColor); }
}
.rare-banner .name {
  font-size: 26px;
  font-weight: 900;
  text-shadow:
    0 0 12px currentColor,
    0 2px 6px rgba(0,0,0,0.85);
  filter: drop-shadow(0 0 8px currentColor);
}
.rare-banner.rarity-rare   { color: var(--accent); }
.rare-banner.rarity-epic   { color: #c79bff; }
.rare-banner.rarity-legend { color: var(--gold); }
.rare-banner.rarity-legend .name { font-size: 32px; letter-spacing: 1px; }

@keyframes rareBanner {
  0%   { transform: translate(-50%, -50%) scale(0.4) rotate(-2deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.18) rotate(1deg);  opacity: 1; }
  35%  { transform: translate(-50%, -50%) scale(1)    rotate(0deg); }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1)   rotate(0deg); opacity: 0; }
}

/* Screen flash on epic/legend ----------------------------------- */
.screen-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  will-change: opacity;
}
.screen-flash.playing { animation: screenFlash 500ms ease-out forwards; }
/* Tighter radial = smaller area to repaint = cheaper compositing. */
.screen-flash.flash-epic   { background: radial-gradient(circle at center, rgba(199,155,255,0.42) 0%, transparent 55%); }
.screen-flash.flash-legend { background: radial-gradient(circle at center, rgba(255,204,102,0.55) 0%, transparent 55%); }
@keyframes screenFlash {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Item reveal popup (bonus clicks) ----------------------------- */
.item-reveal {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 12;
  animation: itemReveal 2.6s ease-out forwards;
  white-space: nowrap;
}
.item-reveal .reveal-tier {
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 700;
}
.item-reveal .reveal-icon {
  font-size: 64px;
  filter: drop-shadow(0 0 18px currentColor);
  animation: itemRevealIcon 2.6s ease-out forwards;
}
.item-reveal .reveal-name {
  font-size: 22px;
  font-weight: 800;
  color: currentColor;
  text-shadow: 0 0 14px currentColor, 0 2px 6px rgba(0,0,0,0.85);
  margin-top: 4px;
}
.item-reveal .reveal-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  margin-top: 6px;
  text-shadow: 0 0 10px rgba(255,200,80,0.7), 0 2px 4px rgba(0,0,0,0.85);
}
.item-reveal.rarity-common   { color: #d6e7f3; }
.item-reveal.rarity-uncommon { color: var(--good); }
.item-reveal.rarity-rare     { color: var(--accent); }
.item-reveal.rarity-epic     { color: #c79bff; }
.item-reveal.rarity-legend   { color: var(--gold); }
@keyframes itemReveal {
  0%   { transform: translate(-50%, -50%) scale(0.3) rotate(-5deg); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.25) rotate(2deg); opacity: 1; }
  28%  { transform: translate(-50%, -50%) scale(1) rotate(0); }
  88%  { opacity: 1; }
  100% { transform: translate(-50%, -90%) scale(1); opacity: 0; }
}
@keyframes itemRevealIcon {
  from { transform: scale(1) rotate(0); }
  to   { transform: scale(1) rotate(360deg); }
}

/* Treasure chests (clickable in ocean) ------------------------- */
.treasure-chest {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  cursor: pointer;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  pointer-events: auto;
  user-select: none;
  border: 2px solid currentColor;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.35), rgba(0,0,0,0.55) 70%);
  animation:
    chestEnter 0.4s ease-out backwards,
    chestBob 3s ease-in-out infinite alternate,
    chestGlow 0.9s ease-in-out infinite alternate;
  transition: transform 90ms ease;
}
.treasure-chest:hover  { transform: scale(1.12); }
.treasure-chest:active { transform: scale(0.94); }
.treasure-chest.tier-common    { color: #b8c6d2; animation-duration: 0.4s, 4s, 1.4s; }
.treasure-chest.tier-rare      { color: var(--accent); animation-duration: 0.4s, 3s, 1.0s; }
.treasure-chest.tier-epic {
  color: #c79bff;
  animation-duration: 0.4s, 2.5s, 0.7s;
}
.treasure-chest.tier-epic::before {
  /* Faint sparkle layer that rotates above an epic chest. */
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 12px;
  background: conic-gradient(from 0deg, transparent 0%, rgba(199,155,255,0.35) 25%, transparent 50%, rgba(199,155,255,0.35) 75%, transparent 100%);
  animation: chestSpin 3s linear infinite;
  z-index: -1;
  filter: blur(4px);
}
.treasure-chest.tier-legendary {
  color: var(--gold);
  animation-duration: 0.4s, 2s, 0.5s;
  border-width: 3px;
}
.treasure-chest.tier-legendary::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 14px;
  background: conic-gradient(from 0deg, rgba(255,204,102,0.55), rgba(255,255,180,0.85), rgba(255,204,102,0.55), rgba(255,160,80,0.7), rgba(255,204,102,0.55));
  animation: chestSpin 1.6s linear infinite;
  z-index: -1;
  filter: blur(5px);
}
@keyframes chestSpin { to { transform: rotate(360deg); } }
@keyframes chestEnter {
  from { opacity: 0; transform: scale(0.2); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes chestBob {
  from { translate: 0 -4px; }
  to   { translate: 0  4px; }
}
@keyframes chestGlow {
  from { box-shadow: 0 0 12px currentColor, inset 0 0 6px rgba(255,255,255,0.2); }
  to   { box-shadow: 0 0 28px currentColor, inset 0 0 12px rgba(255,255,255,0.5); }
}
.treasure-chest.fading { animation: chestExit 0.5s ease-out forwards; }
@keyframes chestExit {
  from { opacity: 1; transform: scale(1) rotate(0); }
  to   { opacity: 0; transform: scale(0.4) rotate(180deg); }
}

/* Chest tray (header, next to cash) ---------------------------- */
/* Chest tray sits in the bottom-left of the ocean, above the boost-hint.
   Boost-hint occupies bottom: 108 → ~140px from bottom; tray sits above
   it with a small gap. */
.chest-tray {
  position: absolute;
  left: 20px;
  bottom: 156px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  z-index: 10;
}
.chest-tray:empty { display: none; }
.chest-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.chest-slot-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: currentColor;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  font-variant-numeric: tabular-nums;
}
.chest-slot.tier-common    { color: #b8c6d2; }
.chest-slot.tier-rare      { color: var(--accent); }
.chest-slot.tier-epic      { color: #c79bff; }
.chest-slot.tier-legendary { color: var(--gold); }
.chest-btn {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid currentColor;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms ease;
  animation: chestTrayPulse 1.4s ease-in-out infinite alternate;
}
.chest-btn:hover  { transform: scale(1.12); }
.chest-btn:active { transform: scale(0.92); }
.chest-btn.tier-common    { color: #b8c6d2; animation-duration: 1.6s; }
.chest-btn.tier-rare      { color: var(--accent); animation-duration: 1.2s; }
.chest-btn.tier-epic      { color: #c79bff;   animation-duration: 0.9s; }
.chest-btn.tier-legendary { color: var(--gold);animation-duration: 0.6s; }
@keyframes chestTrayPulse {
  from { box-shadow: 0 0 4px  currentColor;                                filter: brightness(0.95); }
  to   { box-shadow: 0 0 14px currentColor, 0 0 22px currentColor;         filter: brightness(1.25); }
}
.chest-btn-count {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background: #0f1c28;
  border: 1px solid currentColor;
  border-radius: 9px;
  font-family: var(--font-sans, system-ui);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.chest-btn-count:empty { display: none; }

/* Inventory panel ---------------------------------------------- */
#inventoryPanel.has-chests {
  background: linear-gradient(180deg, rgba(255,200,80,0.06), rgba(255,200,80,0));
  border-left: 3px solid var(--gold);
  animation: invPanelGlow 2.2s ease-in-out infinite alternate;
}
#inventoryPanel.has-chests h2 {
  color: var(--gold);
}
@keyframes invPanelGlow {
  from { box-shadow: inset 0 0 8px rgba(255,200,80,0.10); }
  to   { box-shadow: inset 0 0 22px rgba(255,200,80,0.30); }
}
#invCount:not(:empty) {
  background: var(--gold);
  color: #2a1a00;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.inventory-list { display: flex; flex-direction: column; gap: 6px; }
.inventory-list .small { font-size: 11px; }
.inv-chest {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid currentColor;
  font-size: 12px;
}
.inv-chest.tier-bronze { color: #c98e2a; }
.inv-chest.tier-silver { color: #c4d3df; }
.inv-chest.tier-gold   {
  color: var(--gold);
  box-shadow: 0 0 8px rgba(255,200,80,0.3);
  animation: invGoldPulse 1.6s ease-in-out infinite alternate;
}
@keyframes invGoldPulse {
  from { box-shadow: 0 0 4px  rgba(255,200,80,0.25); }
  to   { box-shadow: 0 0 16px rgba(255,200,80,0.55); }
}
.inv-icon  { font-size: 20px; text-align: center; }
.inv-name  { color: var(--text); font-weight: 600; }
.inv-count { color: var(--muted); font-weight: 700; }
.inv-open {
  background: var(--accent);
  color: #00131c;
  border: 0;
  padding: 5px 10px;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
  font-size: 11px;
}
.inv-open:hover  { filter: brightness(1.15); }

/* Bonus loot (clickable popups) -------------------------------- */
.bonus-loot {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  pointer-events: auto;
  user-select: none;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), transparent 60%);
  border: 2px solid currentColor;
  animation:
    bonusEnter 0.4s ease-out backwards,
    bonusBob 2.6s ease-in-out infinite alternate,
    bonusGlow 0.7s ease-in-out infinite alternate;
  transition: transform 90ms ease;
}
.bonus-loot:hover { transform: scale(1.15); }
.bonus-loot:active { transform: scale(0.92); }
.bonus-loot.rarity-rare   { color: var(--accent); }
.bonus-loot.rarity-epic   { color: #c79bff; }
.bonus-loot.rarity-legend { color: var(--gold); }
@keyframes bonusEnter {
  from { opacity: 0; transform: scale(0.2); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes bonusBob {
  from { translate: 0 -3px; }
  to   { translate: 0  3px; }
}
@keyframes bonusGlow {
  from { box-shadow: 0 0 10px currentColor, inset 0 0 6px rgba(255,255,255,0.2); }
  to   { box-shadow: 0 0 28px currentColor, inset 0 0 12px rgba(255,255,255,0.4); }
}
.bonus-loot.fading { animation: bonusExit 0.6s ease-out forwards; }
@keyframes bonusExit {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.4); }
}

/* Salvage Slot ------------------------------------------------- */
/* The slot + bonus stack share a single absolutely-positioned column so the
   active-effect bars sit directly under the slot at the same width. */
.slot-stack {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 200px;
  z-index: 8;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--font-sans);
}
.slot-machine {
  width: 100%;
  padding: 7px 10px 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(8, 18, 28, 0.92), rgba(4, 10, 18, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  user-select: none;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.slot-title {
  font-size: 9px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  margin-bottom: 5px;
}
.slot-reels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.slot-reel {
  height: 32px;
  border-radius: 5px;
  background: linear-gradient(180deg, #182838, #0c1620);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}
.slot-strip {
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.slot-reel.spinning .slot-strip {
  animation: slotSpin 0.18s linear infinite;
  filter: blur(0.6px);
  opacity: 0.92;
}
@keyframes slotSpin {
  0%   { transform: translateY(-10px); }
  100% { transform: translateY(10px); }
}
.slot-reel.settle .slot-strip {
  animation: slotSettle 0.28s ease-out;
}
@keyframes slotSettle {
  0%   { transform: translateY(-12px); opacity: 0.4; }
  60%  { transform: translateY(2px);   opacity: 1;   }
  100% { transform: translateY(0);     opacity: 1;   }
}
.slot-status {
  margin-top: 6px;
  font-size: 10.5px;
  text-align: center;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.65);
  min-height: 14px;
}
.slot-machine.win {
  border-color: var(--good);
  box-shadow: 0 0 20px rgba(110, 255, 163, 0.35), 0 4px 14px rgba(0, 0, 0, 0.55);
}
.slot-machine.win .slot-status { color: var(--good); font-weight: 700; }
.slot-machine.win-major {
  border-color: #c79bff;
  box-shadow: 0 0 26px rgba(199, 155, 255, 0.55), 0 4px 14px rgba(0, 0, 0, 0.55);
  animation: slotShake 0.4s ease-in-out 2;
}
.slot-machine.win-major .slot-status { color: #c79bff; }
.slot-machine.win-jackpot {
  border-color: var(--gold);
  box-shadow: 0 0 36px rgba(255, 204, 102, 0.7), 0 4px 14px rgba(0, 0, 0, 0.55);
  animation: slotShake 0.35s ease-in-out 4;
}
.slot-machine.win-jackpot .slot-status {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 204, 102, 0.7);
}
.slot-machine.win-shark {
  border-color: var(--bad);
  box-shadow: 0 0 22px rgba(255, 122, 122, 0.55), 0 4px 14px rgba(0, 0, 0, 0.55);
  animation: slotShake 0.35s ease-in-out 2;
}
.slot-machine.win-shark .slot-status { color: var(--bad); }
.slot-machine.lose .slot-status { color: rgba(255, 255, 255, 0.45); }
@keyframes slotShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* Biome change banner + flash ---------------------------------- */
.biome-banner {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 13;
  animation: biomeBanner 3.5s ease-out forwards;
  white-space: nowrap;
}
.biome-banner .biome-prefix {
  display: block;
  font-size: 12px;
  letter-spacing: 6px;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  margin-bottom: 8px;
  text-shadow: 0 0 8px rgba(0,0,0,0.85);
}
.biome-banner .biome-title {
  display: block;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow:
    0 0 24px currentColor,
    0 4px 10px rgba(0,0,0,0.9);
  filter: drop-shadow(0 0 14px currentColor);
}
@keyframes biomeBanner {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  12%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  28%  { transform: translate(-50%, -50%) scale(1); }
  85%  { opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(1); opacity: 0; }
}

.biome-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  animation: biomeFlash 1.3s ease-out forwards;
}
@keyframes biomeFlash {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Bubbles --------------------------------------------------------- */
.bubble {
  position: absolute;
  bottom: -12px;
  width: 8px;
  height: 8px;
  background: var(--biome-accent, rgba(255,255,255,0.25));
  border-radius: 50%;
  animation: rise linear forwards;
  pointer-events: none;
  opacity: 0.45;
  box-shadow: 0 0 4px var(--biome-accent, rgba(255,255,255,0.15));
}
@keyframes rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0.7; }
  100% { transform: translateY(-100vh) translateX(20px); opacity: 0; }
}

/* Mobile / narrow viewports ------------------------------------- */
@media (max-width: 720px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
    height: 100dvh; /* prefer dynamic viewport on mobile */
  }
  #ocean { grid-row: 1; grid-column: 1; }
  #sidebar {
    grid-row: 2; grid-column: 1;
    border-right: none;
    border-top: 1px solid var(--line);
  }
  #sidebar header { padding: 14px 16px 10px; }
  #sidebar h1 { font-size: 18px; }
  .cash { font-size: 24px; }
  .panel { padding: 12px 16px; }
  .panel h2 { font-size: 13.5px; }
  .header-level { font-size: 12px; }
  .next-biome-info { font-size: 11px; }
  /* Touch-friendly tap targets */
  .upgrade button,
  .prestige-btn,
  .achievement.unclaimed .ach-reward,
  footer button {
    min-height: 40px;
  }
  /* Bigger chest tray buttons for fingertips */
  .chest-btn { width: 40px; height: 40px; font-size: 24px; }
  /* Boost button shifts a bit so the cooldown bar isn't off-screen */
  .boost-btn {
    width: 124px;
    height: 72px;
    left: 12px;
    bottom: 12px;
  }
  .boost-hint {
    width: 124px;
    left: 12px;
    bottom: 92px;
    font-size: 9.5px;
    padding: 4px 6px;
  }
  .boost-label { font-size: 14px; letter-spacing: 1.1px; }
  .boost-sub { font-size: 9px; letter-spacing: 1.1px; }
  /* Reveal popup smaller on phone */
  .item-reveal .reveal-icon { font-size: 48px; }
  .item-reveal .reveal-name { font-size: 18px; }
  .item-reveal .reveal-value { font-size: 16px; }
  /* Sale burst smaller too */
  .sale-burst .amount { font-size: 40px; }
  /* How to Play modal — fit narrow screens */
  .howto-overlay { padding: 12px; }
  .howto-modal { padding: 22px 18px 18px; max-height: 92dvh; }
  .howto-modal h2 { font-size: 18px; }
  .howto-body { gap: 10px; }
  .howto-body section { padding: 10px 12px; }
  .howto-body p { font-size: 12px; line-height: 1.5; }
  /* Footer admin buttons wrap onto multiple rows */
  #sidebar footer { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
  #sidebar footer button { flex: 1 1 calc(50% - 3px); font-size: 11px; }
  /* Active-effect banner inside On Deck doesn't need to be big */
  .active-effect { font-size: 11px; padding: 6px 8px; }
  /* Activity log stays compact */
  #log { font-size: 11px; }
  /* Slot machine — keep it tucked into corner on phones */
  .slot-stack { width: 156px; top: 8px; left: 8px; gap: 5px; }
  .slot-machine { padding: 5px 8px 6px; }
  .slot-title { font-size: 9px; letter-spacing: 1.3px; }
  .slot-reel { height: 30px; }
  .slot-strip { font-size: 20px; }
  .slot-status { font-size: 9.5px; }
}

@media (max-width: 380px) {
  #sidebar header { padding: 12px 12px 8px; }
  .cash { font-size: 22px; }
  #sidebar h1 { font-size: 16px; }
  .panel { padding: 10px 12px; }
  .boost-btn { width: 112px; height: 64px; }
  .boost-hint { width: 112px; bottom: 84px; }
  .boost-label { font-size: 13px; }
  .chest-tray { bottom: 132px; left: 14px; }
  .chest-haul { bottom: 200px; width: 220px; left: 14px; }
  .chest-haul-row { font-size: 13px; padding: 7px 10px; }
  .chest-haul:has(.chest-haul-row)::after { left: 14px; }
}

/* Haul totals -------------------------------------------------- */
.haul-total {
  /* margin-top: auto pushes Total to the bottom of the reserved cargo-list /
     lastHaul space so items stay top-aligned even when the list isn't full. */
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* Leaderboard panel -------------------------------------------- */
.lb-name-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.lb-name-row input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12.5px;
}
.lb-name-row input::placeholder { color: var(--muted); }
.lb-name-row input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.lb-name-row button {
  padding: 0 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #00131c;
  border: 0;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
.lb-name-row button:disabled { opacity: 0.5; cursor: default; }
.lb-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.lb-tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.lb-tab.active { background: var(--accent); color: #00131c; border-color: var(--accent); }
.lb-tab:hover:not(.active) { color: var(--text); }
.lb-board {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 320px;
  overflow-y: auto;
}
.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.025);
  border-radius: 5px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lb-row.me {
  background: rgba(79, 208, 255, 0.12);
  border-left: 3px solid var(--accent);
  padding-left: 5px;
  font-weight: 700;
}
.lb-rank { color: var(--muted); font-weight: 700; text-align: center; }
.lb-row .lb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row .lb-val { color: var(--gold); font-weight: 700; }
.lb-empty { padding: 14px 8px; text-align: center; font-size: 12px; }

/* Admin modal -------------------------------------------------- */
.admin-modal { max-width: 360px; }
.admin-modal h2 { margin-bottom: 12px; }
#adminGate {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#adminPw {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.5px;
}
#adminPw:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
#adminPw.shake { animation: pwShake 0.4s ease-in-out; border-color: var(--bad); }
@keyframes pwShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}
#adminTools { display: flex; flex-direction: column; gap: 8px; }

/* Log-line stacking bump --------------------------------------- */
.log-line.bumped { animation: logBump 220ms ease-out; }
@keyframes logBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Chest opening haul (left side of ocean, separate from dive log) */
/* Chest-haul rolls upward out of the chest tray. The container sits just
   above the tray; rows pile from the bottom up. The ::after caret hangs
   below the bottom of the listing, pointing down at the chest that
   produced it (visual "this loot came from here" indicator). */
.chest-haul {
  position: absolute;
  left: 20px;
  /* Bottom = chest-tray bottom (156) + slot height (~71 = btn 56 + label 12 + gap 3) + arrow gap (12). */
  bottom: 240px;
  top: 130px;
  width: 280px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: none;
  z-index: 9;
}
/* Visible only when the container has at least one row of loot. */
.chest-haul:has(.chest-haul-row)::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -10px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--gold);
  filter: drop-shadow(0 0 8px rgba(255,204,102,0.55));
}
.chest-haul-row {
  background: rgba(8, 16, 24, 0.92);
  border-left: 4px solid var(--gold);
  border-radius: 5px;
  padding: 9px 12px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  animation: chestHaulIn 380ms ease-out, chestHaulFade 700ms ease-in 2.8s forwards;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
}
.chest-haul-row .ch-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chest-haul-row .ch-val  { color: var(--good); font-weight: 800; flex-shrink: 0; }
.chest-haul-row.rarity-rare   { color: var(--accent); border-left-color: var(--accent); }
.chest-haul-row.rarity-epic   { color: #c79bff;       border-left-color: #c79bff; }
.chest-haul-row.rarity-legend { color: var(--gold);   border-left-color: var(--gold); box-shadow: 0 0 14px rgba(255, 204, 102, 0.45); }
@keyframes chestHaulIn {
  from { opacity: 0; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes chestHaulFade {
  to { opacity: 0; }
}
