@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: #0a0a0f;
  --surface: #14141c;
  --surface-2: #1c1c28;
  --text: #f2f2f5;
  --text-dim: #9a9aa8;
  --accent: #e9d6b9;

  --bronze: #b08d57;
  --silver: #c0c0c0;
  --gold: #ffd700;
  --legendary-1: #ff5f6d;
  --legendary-2: #ffc371;
  --legendary-3: #47cf73;
  --legendary-4: #4fa8ff;
  --legendary-5: #c04fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .display {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.04em;
  margin: 0;
}

/* ---------- Auth screen ---------- */

.auth-screen {
  max-width: 400px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-screen[hidden] { display: none; }

.auth-logo { width: 72px; height: auto; margin-bottom: 16px; }

.auth-screen h1.display { font-size: 48px; margin-bottom: 12px; }

.auth-tagline {
  color: var(--text-dim);
  font-size: 15px;
  margin: 0 0 32px;
}

.auth-screen form { width: 100%; text-align: left; }

.auth-error {
  color: #ff8080;
  font-size: 13px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 128, 128, 0.1);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.auth-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}

.settings-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  min-width: 44px;
  min-height: 44px;
}

.topbar-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* ---------- App shell ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 96px;
}

.app[hidden] { display: none; }

.topbar {
  padding: 24px 20px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  width: 28px;
  height: auto;
}

.topbar h1 {
  font-size: 32px;
}

.topbar .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- Empty state ---------- */

.empty-banner {
  margin: 0 20px 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  text-align: center;
}

.empty-banner p {
  margin: 0 0 12px;
  color: var(--text-dim);
  font-size: 15px;
}

.load-error-banner {
  margin: 0 20px 16px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 128, 128, 0.1);
  text-align: center;
}

.load-error-banner p {
  margin: 0;
  color: #ff8080;
  font-size: 14px;
}

.load-error-banner button {
  background: none;
  border: none;
  color: #ff8080;
  text-decoration: underline;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}

/* ---------- Dex grid ---------- */

.dex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 0 20px;
}

.dex-card {
  aspect-ratio: 4 / 5;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  /* No justify-content here on purpose — the icon below is a flex item that
     grows to fill whatever space the name (and, when present, the tier badge)
     don't need, so it always fills "the rest of the card" while name/badge
     stay anchored to the bottom, however tall that bottom block happens to be. */
  gap: 8px;
  padding: 14px 10px 12px;
  text-align: center;
  min-height: 44px;
  border: 1px solid var(--surface-2);
}

.dex-card.locked {
  background: var(--surface);
  color: var(--surface-2);
}

.dex-card .fish-icon {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Before the catch: the same 3D model, forced to solid black via `brightness(0)`
   so it reads as a silhouette rather than showing its real colors/textures. */
.dex-card.locked .fish-icon {
  filter: brightness(0);
}

/* Interactive (drag to rotate) like the detail-page hero; a plain tap without
   drag still bubbles up and opens the species page. */
model-viewer.fish-icon {
  --poster-color: transparent;
  background-color: transparent;
}

.dex-card-name {
  flex: 0 0 auto;
}

.dex-card-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.length-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 999px;
}

.dex-card.locked .dex-card-name {
  font-size: 15px;
  color: var(--text-dim);
  opacity: 0.7;
}

.dex-card.unlocked {
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.dex-card.unlocked .dex-card-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.dex-card.unlocked .tier-badge {
  flex: 0 0 auto;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 3px 12px;
  border-radius: 999px;
}

.dex-card.unlocked.tier-bronze { box-shadow: 0 0 14px -4px var(--bronze) inset; }
.dex-card.unlocked.tier-bronze .tier-badge { background: var(--bronze); color: #241a0d; }

.dex-card.unlocked.tier-silver { box-shadow: 0 0 14px -4px var(--silver) inset; }
.dex-card.unlocked.tier-silver .tier-badge { background: var(--silver); color: #1a1a1a; }

.dex-card.unlocked.tier-gold { box-shadow: 0 0 16px -3px var(--gold) inset; }
.dex-card.unlocked.tier-gold .tier-badge { background: var(--gold); color: #241a0d; }

.dex-card.unlocked.tier-legendary {
  box-shadow: 0 0 18px -2px var(--legendary-5) inset;
}
.dex-card.unlocked.tier-legendary .tier-badge {
  background: linear-gradient(90deg, var(--legendary-1), var(--legendary-2), var(--legendary-3), var(--legendary-4), var(--legendary-5));
  color: #10101a;
}

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  max-width: 440px;
  min-height: 52px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #241a0d;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.fab:active { opacity: 0.85; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
}

.modal h2 { font-size: 26px; margin-bottom: 16px; }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field select,
.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--surface-2);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.field input[type="number"],
.field input[type="date"] {
  font-family: 'JetBrains Mono', monospace;
}

.field .error {
  color: #ff8080;
  font-size: 13px;
  margin-top: 6px;
  display: none;
}

.field.invalid .error { display: block; }
.field.invalid input { border-color: #ff8080; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  min-height: 44px;
  border-radius: 999px;
  border: none;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  cursor: pointer;
  flex: 1;
}

.btn-primary { background: var(--accent); color: #241a0d; }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--surface-2); color: var(--text); }

/* ---------- Unlock screen ---------- */

.unlock-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #16161f 0%, #05050a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  text-align: center;
  padding: 24px;
}

.unlock-overlay[hidden] { display: none; }

.unlock-eyebrow {
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
  opacity: 0;
  animation: fadeUp 0.4s ease forwards 0.1s;
}

.unlock-card {
  width: 220px;
  height: 300px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface-2);
  transform: scale(0.6) rotateY(90deg);
  opacity: 0;
  animation: cardFlip 0.7s cubic-bezier(.2,.8,.2,1) forwards 0.2s;
}

.unlock-fish-icon {
  width: 140px;
  height: 140px;
}

.unlock-model {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background-color: transparent;
}

.unlock-card .species-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 0.03em;
}

.unlock-card .tier-badge {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 0.08em;
  padding: 4px 16px;
  border-radius: 999px;
}

.unlock-card.tier-bronze { box-shadow: 0 0 50px 0 var(--bronze); }
.unlock-card.tier-bronze .tier-badge { background: var(--bronze); color: #241a0d; }

.unlock-card.tier-silver { box-shadow: 0 0 50px 0 var(--silver); }
.unlock-card.tier-silver .tier-badge { background: var(--silver); color: #1a1a1a; }

.unlock-card.tier-gold { box-shadow: 0 0 60px 5px var(--gold); }
.unlock-card.tier-gold .tier-badge { background: var(--gold); color: #241a0d; }

.unlock-card.tier-legendary {
  box-shadow: 0 0 70px 10px var(--legendary-5);
  animation: cardFlip 0.7s cubic-bezier(.2,.8,.2,1) forwards 0.2s, legendaryPulse 2s ease-in-out infinite 0.9s;
}
.unlock-card.tier-legendary .tier-badge {
  background: linear-gradient(90deg, var(--legendary-1), var(--legendary-2), var(--legendary-3), var(--legendary-4), var(--legendary-5));
  color: #10101a;
}

.unlock-caption {
  margin-top: 24px;
  font-size: 15px;
  color: var(--text-dim);
  opacity: 0;
  animation: fadeUp 0.4s ease forwards 0.9s;
}

.unlock-dismiss {
  margin-top: 28px;
  min-height: 44px;
  padding: 0 28px;
  border-radius: 999px;
  border: 1px solid var(--surface-2);
  background: transparent;
  color: var(--text);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0;
  animation: fadeUp 0.4s ease forwards 1.1s;
}

@keyframes cardFlip {
  to { transform: scale(1) rotateY(0deg); opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes legendaryPulse {
  0%, 100% { box-shadow: 0 0 70px 10px var(--legendary-5); }
  50% { box-shadow: 0 0 90px 20px var(--legendary-3); }
}

/* ---------- Settings screen ---------- */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 25;
  overflow-y: auto;
}

.settings-overlay[hidden] { display: none; }

.settings-panel {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.settings-header h2 { font-size: 26px; }

.settings-back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.settings-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--surface-2);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.settings-section h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.lang-toggle {
  display: flex;
  gap: 8px;
}

.lang-option {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text-dim);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.lang-option.active {
  border-color: var(--accent);
  background: rgba(233, 214, 185, 0.12);
  color: var(--text);
}

.settings-message {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(233, 214, 185, 0.1);
}

.settings-message.error {
  color: #ff8080;
  background: rgba(255, 128, 128, 0.1);
}

.settings-logout {
  width: 100%;
}

.settings-danger-zone h3 {
  color: #ff8080;
}

.btn-danger {
  width: 100%;
  background: transparent;
  color: #ff8080;
  border: 1px solid rgba(255, 128, 128, 0.4);
}

/* ---------- Species detail view ---------- */
/* Lives inside #app (normal document flow), not a fixed overlay like Settings
   — the FAB is a sibling in #app and stays visible/clickable on top of it. */

.species-view {
  padding: 20px 20px 32px;
}

.species-view[hidden] { display: none; }

.species-view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.species-view-header h2 {
  font-size: 26px;
}

.species-hero {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  margin-bottom: 20px;
}

.species-hero-model {
  width: 100%;
  height: 260px;
  --poster-color: transparent;
  background-color: transparent;
}

/* Before the catch: same model, forced to solid black to read as a silhouette. */
.species-hero-model.locked {
  filter: brightness(0);
}

.species-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.species-stat {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.species-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.species-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
}

.species-thresholds {
  margin-bottom: 28px;
}

.species-thresholds h3,
.species-log h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.species-threshold-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.species-threshold {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
}

.species-threshold-tier {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 2px 10px;
  border-radius: 999px;
}

.species-threshold-tier.tier-silver { background: var(--silver); color: #1a1a1a; }
.species-threshold-tier.tier-gold { background: var(--gold); color: #241a0d; }
.species-threshold-tier.tier-legendary {
  background: linear-gradient(90deg, var(--legendary-1), var(--legendary-2), var(--legendary-3), var(--legendary-4), var(--legendary-5));
  color: #10101a;
}

.species-threshold-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-dim);
}

.species-log-empty {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 16px;
}

.species-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catch-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: 10px;
}

.catch-entry-info {
  flex: 1;
  min-width: 0;
}

.catch-entry-length {
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
}

.catch-entry-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.catch-entry-tier {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 2px 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.catch-entry-tier.tier-bronze { background: var(--bronze); color: #241a0d; }
.catch-entry-tier.tier-silver { background: var(--silver); color: #1a1a1a; }
.catch-entry-tier.tier-gold { background: var(--gold); color: #241a0d; }
.catch-entry-tier.tier-legendary {
  background: linear-gradient(90deg, var(--legendary-1), var(--legendary-2), var(--legendary-3), var(--legendary-4), var(--legendary-5));
  color: #10101a;
}

.catch-entry-actions {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.catch-entry-actions button {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
}

.catch-entry-actions button:active {
  background: var(--surface-2);
}
