/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a1628;
  color: #e8eef8;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Auth overlay ──────────────────────────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 60%, #0d2444 0%, #0a1628 70%);
  z-index: 1000;
  transition: opacity .5s ease, visibility .5s;
}
#auth-overlay.fade-out { opacity: 0; visibility: hidden; pointer-events: none; }

#auth-card {
  width: 100%; max-width: 420px;
  background: rgba(10, 20, 45, 0.96);
  border: 1px solid rgba(80, 160, 255, 0.18);
  border-radius: 18px;
  padding: 36px 32px 32px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(40,100,255,.07);
  backdrop-filter: blur(14px);
}

#auth-logo { text-align: center; margin-bottom: 28px; }
.logo-fish {
  font-size: 52px; display: block; margin-bottom: 10px;
  animation: float-fish 3.2s ease-in-out infinite;
}
@keyframes float-fish {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-10px) rotate(4deg); }
}
#auth-logo h1 {
  font-size: 30px; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(130deg, #6ab8ff, #4fd1c5);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
#auth-logo p { color: #6677aa; font-size: 14px; margin-top: 5px; }

/* Tabs */
#auth-tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: rgba(255,255,255,.05); border-radius: 10px; padding: 4px;
}
.tab {
  flex: 1; padding: 9px;
  background: transparent; border: none;
  color: #6677aa; border-radius: 7px;
  cursor: pointer; font-size: 14px; font-weight: 600;
  transition: all .2s;
}
.tab.active { background: rgba(100,180,255,.18); color: #6ab8ff; }

/* Forms */
.auth-form { display: none; flex-direction: column; gap: 15px; }
.auth-form.active { display: flex; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #7788aa;
}
.field input {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(80,160,255,.2);
  border-radius: 10px; padding: 12px 14px;
  color: #ddeeff; font-size: 15px; outline: none;
  transition: border-color .2s, background .2s;
}
.field input:focus {
  border-color: #6ab8ff;
  background: rgba(100,180,255,.08);
}
.field input::placeholder { color: #344466; }
.hint { font-size: 11px; color: #445566; }

.auth-error { min-height: 18px; font-size: 13px; color: #ff7070; }

.auth-form button[type="submit"] {
  padding: 14px; border: none; border-radius: 11px;
  background: linear-gradient(135deg, #1e5fcc, #3b8fff);
  color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 4px;
  transition: transform .15s, filter .15s;
}
.auth-form button[type="submit"]:hover  { filter: brightness(1.12); transform: translateY(-1px); }
.auth-form button[type="submit"]:active { transform: translateY(0); }
.auth-form button[type="submit"]:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ─── Game root ─────────────────────────────────────────────────────────────── */
#game-root { position: fixed; inset: 0; }
#game-canvas { position: absolute; inset: 0; }
#game-canvas canvas { display: block; }

/* ─── HUD ───────────────────────────────────────────────────────────────────── */
#hud {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: center;
  background: rgba(0,0,0,.52);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 30px; padding: 7px 22px;
  backdrop-filter: blur(10px);
  font-size: 14px; font-weight: 600;
  pointer-events: none; white-space: nowrap;
}
#hud strong { color: #ffffff; }

/* ─── Online count ──────────────────────────────────────────────────────────── */
#online-count {
  position: absolute; top: 14px; left: 14px;
  font-size: 12px; color: rgba(255,255,255,.4);
  pointer-events: none;
}

/* ─── Bag button ────────────────────────────────────────────────────────────── */
#btn-bag {
  position: absolute; top: 14px; right: 14px;
  background: rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; color: #cce4ff;
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; cursor: pointer;
  backdrop-filter: blur(8px); transition: all .2s;
}
#btn-bag:hover { background: rgba(100,180,255,.2); border-color: rgba(100,180,255,.35); }
#bag-count {
  display: inline-block;
  background: #ff6644; color: #fff;
  border-radius: 10px; font-size: 11px; font-weight: 800;
  padding: 1px 6px; margin-left: 4px; vertical-align: middle;
}

/* ─── Shared panel shell ────────────────────────────────────────────────────── */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.panel-header h3 { font-size: 15px; }
.panel-header button {
  background: none; border: none; color: #6677aa;
  cursor: pointer; font-size: 17px; padding: 2px 6px;
  border-radius: 6px; transition: all .15s; line-height: 1;
}
.panel-header button:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ─── Inventory panel (view-only, [I] key) ──────────────────────────────────── */
#inv-panel {
  position: absolute; top: 54px; right: 14px; width: 300px; max-height: 70vh;
  background: rgba(8,15,35,.97);
  border: 1px solid rgba(80,160,255,.22);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  backdrop-filter: blur(14px);
  display: flex; flex-direction: column;
}
#inv-fish-list {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
}
#inv-empty {
  text-align: center; color: #667; padding: 28px 16px;
  font-style: italic; font-size: 13px;
}
#inv-hint {
  padding: 10px 14px; font-size: 11px; color: #f0b030;
  text-align: center; border-top: 1px solid rgba(255,255,255,.07);
}

.inv-row, .store-fish-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.05); border-radius: 8px;
  padding: 7px 10px; font-size: 13px;
}
.inv-emoji  { font-size: 18px; flex-shrink: 0; }
.inv-name   { flex: 1; font-weight: 600; }
.inv-weight { color: #7799bb; font-size: 12px; min-width: 36px; text-align: right; }
.inv-value  { color: #f0b030; font-size: 12px; min-width: 42px; text-align: right; }
.inv-total  {
  margin-top: 6px; padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px; color: #99bbdd; text-align: right;
}

/* ─── Store proximity prompt ────────────────────────────────────────────────── */
#store-prompt {
  position: absolute;
  bottom: 125px; left: 50%; transform: translateX(-50%);
  background: rgba(10,20,40,.88); border: 1px solid rgba(240,176,48,.3);
  border-radius: 10px; padding: 10px 22px;
  font-size: 14px; font-weight: 600; color: #ffe090;
  backdrop-filter: blur(8px);
  cursor: pointer;
  animation: prompt-bob .8s ease-in-out infinite alternate;
  pointer-events: auto;
}
#store-prompt kbd {
  display: inline-block; background: rgba(255,255,255,.15);
  border-radius: 4px; padding: 1px 6px; font-size: 12px;
  border: 1px solid rgba(255,255,255,.3);
}
@keyframes prompt-bob {
  from { transform: translateX(-50%) translateY(0); }
  to   { transform: translateX(-50%) translateY(-4px); }
}

/* ─── Store panel ────────────────────────────────────────────────────────────── */
#store-panel {
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 360px; max-height: 75vh;
  background: rgba(8,15,35,.97);
  border: 1px solid rgba(240,176,48,.25);
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.8), 0 0 40px rgba(240,176,48,.06);
  backdrop-filter: blur(14px);
  flex-direction: column;
}
#store-tabs {
  display: flex; border-bottom: 1px solid rgba(255,255,255,.07);
}
.s-tab {
  flex: 1; padding: 11px; background: none; border: none;
  color: #7799bb; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.s-tab.active { color: #ffe090; border-bottom: 2px solid #f0b030; }
.s-tab:hover:not(.active) { background: rgba(255,255,255,.05); color: #cce; }

#store-sell-tab, #store-buy-tab {
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden;
}
#store-fish-list {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 5px;
  max-height: 340px;
}
#store-empty-msg {
  text-align: center; color: #667;
  padding: 28px 16px; font-style: italic; font-size: 13px;
}
#store-sell-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.08);
}
#store-total-value { font-size: 13px; color: #f0b030; font-weight: 700; }
#store-sell-all {
  background: linear-gradient(135deg, #1e6e2a, #2ea040);
  border: none; border-radius: 8px;
  padding: 8px 16px; color: #fff;
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: transform .15s;
}
#store-sell-all:hover:not(:disabled) { transform: scale(1.05); }
#store-sell-all:disabled { opacity: .4; cursor: not-allowed; }

.sell-one-btn {
  background: linear-gradient(135deg, #1a5a28, #28883a);
  border: none; border-radius: 6px;
  padding: 5px 10px; color: #aaffcc;
  font-size: 11px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s;
}
.sell-one-btn:hover { transform: scale(1.07); }

/* ─── Rod shop inside store ─────────────────────────────────────────────────── */
#store-rod-list {
  overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
  max-height: 380px;
}
.rod-row {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.05); border-radius: 9px;
  padding: 10px 12px;
}
.rod-row.rod-current { border: 1px solid rgba(240,176,48,.4); background: rgba(240,176,48,.07); }
.rod-row.rod-owned   { opacity: .55; }
.rod-info { display: flex; flex-direction: column; gap: 2px; }
.rod-name { font-size: 13px; font-weight: 700; }
.rod-desc { font-size: 11px; color: #7799bb; }
.rod-owned-badge    { font-size: 12px; color: #77aa77; }
.rod-equipped-badge { font-size: 12px; color: #f0b030; font-weight: 700; }
.rod-buy-btn {
  background: linear-gradient(135deg, #b07520, #f0b030);
  border: none; border-radius: 7px;
  padding: 7px 13px; color: #1a0e00;
  font-size: 12px; font-weight: 700;
  cursor: pointer; transition: transform .15s;
}
.rod-buy-btn:hover:not(:disabled) { transform: scale(1.06); }
.rod-buy-btn.rod-cant-afford,
.rod-buy-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ─── Fishing controls ──────────────────────────────────────────────────────── */
#fishing-controls {
  position: absolute; bottom: 110px; right: 18px;
  display: flex; flex-direction: column; gap: 9px;
}
#fishing-controls button {
  padding: 14px 22px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
#btn-cast {
  background: linear-gradient(135deg, #1d7a40, #2ecc71);
  color: #fff; box-shadow: 0 4px 18px rgba(46,204,113,.35);
}
#btn-cast:hover { transform: scale(1.05); }

#btn-reel {
  background: linear-gradient(135deg, #b07520, #f0b030);
  color: #fff; box-shadow: 0 4px 18px rgba(240,176,48,.4);
  animation: reel-pulse .7s ease-in-out infinite;
}
@keyframes reel-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.09); box-shadow: 0 4px 28px rgba(240,176,48,.7); }
}

#btn-cancel {
  background: rgba(255,255,255,.12); color: #aab8cc;
  font-size: 13px; padding: 10px 18px;
}

/* ─── Bite notification ─────────────────────────────────────────────────────── */
#bite-notif {
  position: absolute; top: 35%; left: 50%; transform: translateX(-50%);
  background: rgba(240,176,48,.96); color: #1a0e00;
  font-size: 18px; font-weight: 800;
  padding: 13px 30px; border-radius: 30px;
  box-shadow: 0 8px 35px rgba(240,176,48,.55);
  pointer-events: none;
  animation: bite-shake .25s ease-in-out infinite alternate;
}
@keyframes bite-shake {
  from { transform: translateX(-50%) rotate(-2deg); }
  to   { transform: translateX(-50%) rotate(2deg); }
}

/* ─── Catch popup ───────────────────────────────────────────────────────────── */
#catch-popup {
  position: absolute; top: 28%; left: 50%; transform: translateX(-50%);
  z-index: 50; pointer-events: none;
  animation: popup-in .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popup-in {
  from { opacity: 0; transform: translateX(-50%) scale(.5) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) scale(1) translateY(0); }
}
#catch-inner {
  background: linear-gradient(160deg, rgba(10,22,50,.97), rgba(15,32,70,.97));
  border: 2px solid rgba(80,160,255,.3);
  border-radius: 18px; padding: 22px 36px; text-align: center;
  box-shadow: 0 24px 70px rgba(0,0,0,.8); min-width: 220px;
}
.fish-emoji  { font-size: 58px; display: block; margin-bottom: 4px; }
#catch-inner h3   { font-size: 22px; margin-bottom: 4px; }
#catch-inner p    { color: #8899bb; font-size: 13px; margin-top: 2px; }
.coins-earned { display: block; color: #f0b030; font-weight: 800; font-size: 18px; margin-top: 8px; }
.rarity-common    { color: #7acc7a; }
.rarity-uncommon  { color: #88aaff; }
.rarity-rare      { color: #cc88ff; }
.rarity-legendary { color: #f0c040; text-shadow: 0 0 12px rgba(240,192,64,.6); }

/* ─── Chat ──────────────────────────────────────────────────────────────────── */
#chat-box {
  position: absolute; bottom: 14px; left: 14px;
  width: 310px; max-width: calc(100vw - 28px);
}
#chat-messages {
  max-height: 160px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  padding-bottom: 6px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent;
}
.chat-msg {
  background: rgba(0,0,0,.6); border-radius: 6px;
  padding: 4px 9px; font-size: 13px; word-break: break-word;
  backdrop-filter: blur(6px);
}
.chat-msg .chat-name { font-weight: 700; color: #6ab8ff; }
.chat-msg.system { color: #7a9a7a; font-style: italic; background: rgba(0,0,0,.35); }

#chat-input {
  width: 100%; margin-top: 5px;
  background: rgba(0,0,0,.6); border: 1px solid rgba(80,160,255,.22);
  border-radius: 9px; padding: 9px 13px;
  color: #ddeeff; font-size: 13px; outline: none;
  backdrop-filter: blur(8px); transition: border-color .2s;
}
#chat-input:focus { border-color: #6ab8ff; }
#chat-input::placeholder { color: #344466; }

/* ─── Controls hint ─────────────────────────────────────────────────────────── */
#controls-hint {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: rgba(255,255,255,.3);
  pointer-events: none; white-space: nowrap;
}

/* ─── Fishing mini-game ─────────────────────────────────────────────────────── */
#minigame {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(5,12,30,.96);
  border: 2px solid rgba(80,180,255,.35);
  border-radius: 18px; padding: 22px 30px 18px;
  min-width: 320px; max-width: 420px; width: 90vw;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 0 60px rgba(0,0,0,.8), 0 0 30px rgba(80,180,255,.12);
  z-index: 200;
  animation: mg-in .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes mg-in {
  from { opacity:0; transform: translate(-50%,-50%) scale(.8); }
  to   { opacity:1; transform: translate(-50%,-50%) scale(1); }
}

#mg-header { display: flex; align-items: center; gap: 14px; }
#mg-fish-icon { font-size: 44px; line-height: 1; }
#mg-fish-name { font-size: 20px; font-weight: 800; }
#mg-rarity    { font-size: 11px; font-weight: 700; letter-spacing: .12em; margin-top: 2px; opacity: .9; }

#mg-instructions {
  font-size: 13px; color: #8899bb; text-align: center;
}
#mg-instructions kbd {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 12px;
}

#mg-bar-track {
  height: 28px; background: rgba(255,255,255,.08);
  border-radius: 14px; overflow: hidden; position: relative;
  border: 1px solid rgba(255,255,255,.12);
}
#mg-bar-fill {
  height: 100%; width: 30%; background: #44cc88;
  border-radius: 14px;
  transition: width .06s linear, background-color .3s;
  box-shadow: 0 0 12px currentColor;
}
#mg-pct {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; font-weight: 700; color: rgba(255,255,255,.7);
  pointer-events: none;
}

#mg-surge {
  text-align: center; font-size: 15px; font-weight: 800;
  color: #ff6644;
  animation: surge-flash .25s ease-in-out infinite alternate;
}
@keyframes surge-flash {
  from { opacity: .6; } to { opacity: 1; transform: scale(1.05); }
}

#mg-reel-btn {
  padding: 16px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #1a5fcc, #3b8fff);
  color: #fff; font-size: 17px; font-weight: 800;
  cursor: pointer; user-select: none; touch-action: none;
  transition: transform .1s, filter .1s;
  box-shadow: 0 4px 20px rgba(59,143,255,.4);
}
#mg-reel-btn:active, #mg-reel-btn.holding {
  transform: scale(.96); filter: brightness(1.25);
  box-shadow: 0 2px 30px rgba(59,143,255,.7);
}

/* ─── Fish images & show feature ───────────────────────────────────────────── */
.fish-thumb {
  width: 36px; height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
}
.fish-catch-img {
  width: 96px; height: 96px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block; margin: 0 auto 6px;
}
.show-fish-btn {
  background: linear-gradient(135deg, #1a2855, #2244aa);
  border: none; border-radius: 6px;
  padding: 4px 9px; color: #99bbff;
  font-size: 11px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: transform .12s, filter .15s;
  margin-left: 4px; flex-shrink: 0;
}
.show-fish-btn:hover { transform: scale(1.08); filter: brightness(1.3); }

/* ─── Mobile joystick ───────────────────────────────────────────────────────── */
#mobile-controls { display: none; position: absolute; bottom: 22px; left: 22px; }

@media (pointer: coarse), (max-width: 680px) {
  #mobile-controls { display: block; }
  #controls-hint   { display: none; }
  #fishing-controls { bottom: 22px; right: 18px; }
  #chat-box { width: 200px; }
  #chat-messages { max-height: 90px; }
  #hud { font-size: 12px; padding: 6px 16px; gap: 12px; }
}

#joystick-base {
  width: 84px; height: 84px;
  background: rgba(255,255,255,.09);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative; touch-action: none;
}
#joystick-stick {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.35);
  border-radius: 50%; position: absolute;
  touch-action: none;
  transition: transform .04s linear;
}
