* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --common: #B0BEC5;
  --uncommon: #66BB6A;
  --rare: #42A5F5;
  --legendary: #FFA726;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0a1a;
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}

@media (min-width: 1024px) {
  body {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  #game {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 800px;
  }
}

/* ========== TOP BAR ========== */

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  z-index: 20;
  flex-shrink: 0;
}

#coin-display {
  font-size: 20px;
  font-weight: 700;
}

#tabs { display: flex; gap: 6px; }

.tab {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #aaa;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.tab:hover { background: rgba(255, 255, 255, 0.15); color: #ddd; }
.tab.active { background: rgba(255, 255, 255, 0.2); color: #fff; border-color: rgba(255,255,255,0.25); }

/* ========== SCREENS ========== */

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.screen.active { display: flex; }

.screen-title {
  padding: 16px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

/* ========== POND SCENE ========== */

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

#sky {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to bottom, #3a7bd5, #6db3f2, #a8d8f0);
}

#sky::after {
  content: '☀️';
  position: absolute;
  top: 12%;
  right: 12%;
  font-size: 42px;
}

#water {
  position: absolute;
  top: 40%; left: 0; right: 0; bottom: 0;
  background: linear-gradient(to bottom, #1976D2, #0D47A1, #072a5c);
  overflow: hidden;
}

.wave {
  position: absolute;
  top: calc(-12px + var(--i) * 8px);
  left: -100%;
  width: 300%;
  height: 24px;
  border-radius: 45%;
  background: rgba(255, 255, 255, calc(0.07 - var(--i) * 0.015));
  animation: wave-drift calc(4s + var(--i) * 2s) ease-in-out infinite alternate;
}

@keyframes wave-drift {
  from { transform: translateX(0); }
  to { transform: translateX(3%); }
}

/* Scene decorations */
#scene-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.decor-land {
  position: absolute;
}

.decor-item {
  position: absolute;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.decor-item.anchor-bottom {
  transform: translate(-50%, -100%);
}

.decor-item.anchor-top {
  transform: translate(-50%, 0%);
}

.decor-float {
  animation: decor-bob 3s ease-in-out infinite;
}

.decor-drift {
  animation: decor-drift 14s ease-in-out infinite alternate;
}

@keyframes decor-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, calc(-50% - 6px)); }
}

.decor-float.anchor-top {
  animation: decor-bob-top 3s ease-in-out infinite;
}

@keyframes decor-bob-top {
  0%, 100% { transform: translate(-50%, 0%); }
  50% { transform: translate(-50%, -6px); }
}

@keyframes decor-drift {
  0% { transform: translate(-50%, -50%); }
  100% { transform: translate(calc(-50% + 15px), calc(-50% - 2px)); }
}

/* ========== GAME UI OVERLAY ========== */

#game-ui {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 20px;
  z-index: 10;
}

.game-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.game-state.hidden { display: none; }

.prompt {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  text-align: center;
}

/* ========== ACTION BUTTONS ========== */

.action-btn {
  background: linear-gradient(135deg, #43A047, #2E7D32);
  color: white;
  border: none;
  padding: 16px 44px;
  font-size: 20px;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.action-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ========== EQUIPMENT DISPLAY ========== */

#equipment-display {
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ========== LOCATION SELECTOR ========== */

#location-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 8px;
}

.loc-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.loc-btn:hover { background: rgba(255, 255, 255, 0.16); color: #eee; }
.loc-btn.active {
  background: rgba(33, 150, 243, 0.25);
  border-color: rgba(33, 150, 243, 0.5);
  color: #64B5F6;
  font-weight: 600;
}
.loc-btn.locked {
  opacity: 0.4;
  cursor: default;
}

/* ========== DIFFICULTY SELECTOR ========== */

#difficulty-selector {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.diff-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.diff-btn:hover { background: rgba(255, 255, 255, 0.14); color: #ddd; }
.diff-btn.active {
  background: rgba(76, 175, 80, 0.25);
  border-color: rgba(76, 175, 80, 0.5);
  color: #66BB6A;
  font-weight: 600;
}

/* ========== CASTING POWER METER ========== */

#casting-ui {
  justify-content: center;
  flex: 1;
}

#power-meter {
  width: 85%;
  height: 32px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
  position: relative;
}

#power-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4CAF50 0%, #FFC107 50%, #F44336 100%);
  border-radius: 14px;
}

#power-labels {
  display: flex;
  justify-content: space-between;
  width: 85%;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  margin-top: 4px;
}

/* ========== WAITING / BOBBER ========== */

#waiting-ui {
  justify-content: center;
  flex: 1;
}

#bobber-area {
  font-size: 52px;
  animation: bobber-float 2s ease-in-out infinite;
}
#bobber-area.bite {
  animation: bobber-shake 0.12s ease-in-out infinite;
}

@keyframes bobber-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

@keyframes bobber-shake {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(-6px) translateY(-10px); }
  75% { transform: translateX(6px) translateY(-6px); }
}

#wait-text {
  color: rgba(255, 255, 255, 0.65);
  font-size: 16px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

#bite-alert {
  font-size: 28px;
  font-weight: 800;
  color: #FF5722;
  text-shadow: 0 0 20px rgba(255, 87, 34, 0.7);
  animation: bite-pulse 0.3s ease-in-out infinite alternate;
}
#bite-alert.hidden { display: none; }

@keyframes bite-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

/* ========== REELING MINI-GAME ========== */

#reeling-ui {
  justify-content: center;
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 16px;
  padding: 16px;
  margin: 0 8px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#reel-fish-info {
  font-size: 22px;
  color: #fff;
  text-align: center;
  margin-bottom: 10px;
}
#reel-emoji { margin-right: 6px; }

#reel-area {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: stretch;
  height: 300px;
}

#reel-bar {
  width: 52px;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 26px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

#catch-zone {
  position: absolute;
  left: 2px;
  right: 2px;
  background: rgba(76, 175, 80, 0.35);
  border: 2px solid rgba(76, 175, 80, 0.6);
  border-radius: 14px;
  will-change: top;
}

#fish-marker {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  z-index: 2;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
  will-change: top;
}

#reel-progress {
  width: 22px;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 11px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

#reel-progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to top, #F44336, #FFC107, #4CAF50);
  border-radius: 9px;
  will-change: height;
}

/* ========== RESULT ========== */

#result-ui {
  justify-content: center;
  flex: 1;
}

#result-card {
  background: rgba(0, 0, 0, 0.65);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

#result-card .fish-emoji {
  font-size: 68px;
  display: block;
  margin-bottom: 12px;
  animation: catch-pop 0.5s ease-out;
}

@keyframes catch-pop {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

#result-card .escaped-emoji {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
}

#result-card .fish-name {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

#result-card .fish-rarity {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
  padding: 3px 12px;
  border-radius: 6px;
  display: inline-block;
}

#result-card .fish-details {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 6px;
}

#result-card .coins-earned {
  font-size: 24px;
  font-weight: 700;
  color: #FFD700;
  margin-top: 14px;
}

#result-card .new-badge {
  background: #E91E63;
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 10px;
  animation: new-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes new-bounce {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* Rarity colors */
.rarity-common { color: var(--common); }
.rarity-uncommon { color: var(--uncommon); }
.rarity-rare { color: var(--rare); }
.rarity-legendary { color: var(--legendary); text-shadow: 0 0 10px rgba(255, 167, 38, 0.5); }

.rarity-bg-common { background: rgba(176, 190, 197, 0.15); border-color: rgba(176, 190, 197, 0.3); }
.rarity-bg-uncommon { background: rgba(102, 187, 106, 0.15); border-color: rgba(102, 187, 106, 0.3); }
.rarity-bg-rare { background: rgba(66, 165, 245, 0.15); border-color: rgba(66, 165, 245, 0.3); }
.rarity-bg-legendary {
  background: rgba(255, 167, 38, 0.15);
  border-color: rgba(255, 167, 38, 0.4);
  animation: legendary-glow 2s ease-in-out infinite alternate;
}

@keyframes legendary-glow {
  from { box-shadow: 0 0 8px rgba(255, 167, 38, 0.2); }
  to { box-shadow: 0 0 24px rgba(255, 167, 38, 0.5); }
}

/* ========== SHOP ========== */

#shop-screen {
  background: linear-gradient(to bottom, #1a1a2e, #16213e);
}

#shop-items {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1;
}

.shop-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.shop-card-info h3 {
  font-size: 17px;
  margin-bottom: 3px;
}

.shop-card-info p {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

.shop-card-info .level {
  font-size: 12px;
  color: #66BB6A;
  margin-top: 4px;
}

.shop-buy-btn {
  background: linear-gradient(135deg, #1976D2, #1565C0);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.shop-buy-btn:active { opacity: 0.85; }
.shop-buy-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.shop-buy-btn.maxed {
  background: rgba(76, 175, 80, 0.25);
  cursor: default;
}

.shop-section-header {
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* ========== JOURNAL ========== */

#journal-screen {
  background: linear-gradient(to bottom, #1a1a2e, #16213e);
}

#journal-count {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.45);
}

#journal-items {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.journal-section-header {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  padding: 8px 0 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.journal-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 8px 10px;
  text-align: center;
  color: #fff;
  transition: border-color 0.2s;
}

.journal-card .emoji {
  font-size: 34px;
  display: block;
  margin-bottom: 6px;
}

.journal-card .name {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 2px;
}

.journal-card .stats {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.journal-card.undiscovered {
  opacity: 0.25;
}

.journal-card.undiscovered .emoji {
  filter: brightness(0) invert(0.3);
}

/* ========== AUTH OVERLAY ========== */

#auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#auth-card {
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 32px 28px;
  width: 90%;
  max-width: 340px;
  text-align: center;
}

#auth-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 24px;
}

.auth-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.auth-btn:hover { background: rgba(255, 255, 255, 0.14); }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-btn.guest {
  background: linear-gradient(135deg, #43A047, #2E7D32);
  border-color: transparent;
}

.auth-btn.back {
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  border-color: transparent;
  font-size: 14px;
}

#auth-form-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}

#auth-form-el input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 15px;
  outline: none;
}
#auth-form-el input:focus {
  border-color: rgba(66, 165, 245, 0.5);
}

#auth-error {
  color: #EF5350;
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 6px;
}

/* User display in topbar */
#user-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.username {
  color: #66BB6A;
  font-weight: 600;
}

/* ========== UTILITY ========== */

.hidden { display: none !important; }

/* ========== GUEST BANNER ========== */

#guest-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 152, 0, 0.15);
  border-bottom: 1px solid rgba(255, 152, 0, 0.25);
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.guest-banner-btn {
  background: linear-gradient(135deg, #1976D2, #1565C0);
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

/* ========== BAIT SELECTOR ========== */

#bait-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 6px;
}

.bait-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bait-btn:hover { background: rgba(255, 255, 255, 0.16); color: #eee; }
.bait-btn.active {
  background: rgba(255, 152, 0, 0.25);
  border-color: rgba(255, 152, 0, 0.5);
  color: #FFB74D;
  font-weight: 600;
}

#no-fish-hint {
  color: #EF5350;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  text-align: center;
}

/* ========== SHOP EXTRAS ========== */

.shop-owned-badge {
  color: #66BB6A;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.shop-card-owned {
  opacity: 0.7;
}

.snap-hint {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.45) !important;
  font-size: 13px;
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ========== MOBILE ========== */

@media (max-height: 600px) {
  #reel-area { height: 220px; }
  .action-btn { padding: 12px 32px; font-size: 18px; }
}
