/* ==========================================================================
   Cartoon Ocean Fishing - Arcade Game Stylesheet
   Optimized for iPad Safari touch devices and Desktop browsers.
   ========================================================================== */

:root {
  --primary-blue: #0284c7;
  --dark-blue: #0369a1;
  --vibrant-green: #22c55e;
  --dark-green: #15803d;
  --vibrant-orange: #f97316;
  --dark-orange: #c2410c;
  --vibrant-red: #ef4444;
  --dark-red: #b91c1c;
  --gold: #f59e0b;
  --dark-gold: #b45309;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-border: #38bdf8;
  --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0284c7;
  font-family: var(--font-family);
  color: #ffffff;
  touch-action: none;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  z-index: 1;
}

/* ==========================================================================
   HUD Overlay Layout
   ========================================================================== */

 #game-hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  z-index: 10;
  pointer-events: none; /* children enable pointer events */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  padding: 12px 16px;
  gap: 12px;
}

.hud-top-left, .hud-top-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.hud-top-right {
  align-items: flex-end;
}

/* Badges & Pills */
.hud-pill {
  background: var(--panel-bg);
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.money-pill {
  border-color: #fde047;
  color: #fef08a;
  font-size: 1.25rem;
}

.zone-pill {
  border-color: #38bdf8;
  color: #bae6fd;
}

.cooler-pill {
  border-color: #a7f3d0;
  color: #d1fae5;
}

.hud-icon-btn {
  background: var(--panel-bg);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.hud-icon-btn:active {
  transform: scale(0.92);
}

.hud-menu-button {
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255,255,255,0.45);
  border-radius: 14px;
  background: rgba(15,23,42,0.78);
  color: #fff;
  font-size: 1.45rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  pointer-events: auto;
}
.hud-menu-button:active { transform: scale(0.92); }

.hud-center-spacer {
  flex: 1;
  pointer-events: none;
}

.menu-modal-content {
  max-width: 620px;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.menu-card {
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 16px;
  background: rgba(15,23,42,0.86);
  color: #fff;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 42px 1fr;
  column-gap: 10px;
  align-items: center;
}
.menu-card span { grid-row: 1 / span 2; font-size: 1.8rem; text-align:center; }
.menu-card strong { font-size: 1rem; font-weight: 900; }
.menu-card small { color: #cbd5e1; font-weight: 700; margin-top: 3px; }
.menu-card:active { transform: scale(0.98); }

@media (max-width: 520px) {
  .menu-grid { grid-template-columns: 1fr; }
  .hud-pill { font-size: 0.9rem; padding: 7px 10px; }
  .hud-top-left .zone-pill, .hud-top-left .cooler-pill { display:none; }
}

/* ==========================================================================
   Bottom Controls (Joystick + Main Buttons + Nav)
   ========================================================================== */

.hud-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  padding: 12px 16px;
  position: relative;
}

/* Left: Virtual Joystick */
.joystick-container {
  width: 150px;
  height: 150px;
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  border: 4px solid rgba(255, 255, 255, 0.4);
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.joystick-knob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  border: 3px solid #ffffff;
  position: absolute;
  top: 47px;
  left: 47px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.joystick-hint {
  position: absolute;
  bottom: -22px;
  left: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 2px black;
  white-space: nowrap;
}

/* Center Bottom: Navigation Toolbar (Inventory, Shop, Boats) */
.hud-center-nav {
  display: flex;
  gap: 12px;
  pointer-events: auto;
  margin-bottom: 8px;
}

.nav-btn {
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border: 3px solid #93c5fd;
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 1.05rem;
  font-weight: 900;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 0 #1e3a8a, 0 8px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.08s ease;
  white-space: nowrap;
}

.nav-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #1e3a8a, 0 4px 8px rgba(0, 0, 0, 0.35);
}

.nav-btn.shop-btn {
  background: linear-gradient(180deg, #eab308, #ca8a04);
  border-color: #fef08a;
  box-shadow: 0 6px 0 #854d0e, 0 8px 16px rgba(0,0,0,0.35);
}
.nav-btn.shop-btn:active {
  box-shadow: 0 2px 0 #854d0e;
}

.nav-btn.boat-btn {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  border-color: #ddd6fe;
  box-shadow: 0 6px 0 #4c1d95, 0 8px 16px rgba(0,0,0,0.35);
}
.nav-btn.boat-btn:active {
  box-shadow: 0 2px 0 #4c1d95;
}

/* Right: Action Buttons (Cast, Reel, Chum) */
.hud-action-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-end;
  pointer-events: auto;
}

.action-btn-large {
  width: 140px;
  height: 80px;
  border-radius: 24px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 4px solid #ffffff;
  transition: transform 0.08s ease;
}

.action-btn-large:active {
  transform: translateY(4px);
}

.btn-cast {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  box-shadow: 0 8px 0 #14532d, 0 10px 20px rgba(0, 0, 0, 0.4);
}
.btn-cast:active {
  box-shadow: 0 4px 0 #14532d;
}

.btn-reel {
  background: linear-gradient(180deg, #f97316, #ea580c);
  box-shadow: 0 8px 0 #9a3412, 0 10px 20px rgba(0, 0, 0, 0.4);
  animation: pulse-reel 0.8s infinite alternate;
}
.btn-reel:active {
  box-shadow: 0 4px 0 #9a3412;
}

.btn-cancel {
  background: linear-gradient(180deg, #64748b, #475569);
  box-shadow: 0 8px 0 #1e293b, 0 10px 20px rgba(0, 0, 0, 0.4);
  font-size: 1.15rem;
}

@keyframes pulse-reel {
  0% { transform: scale(1.0); }
  100% { transform: scale(1.06); }
}

.action-btn-sub {
  background: linear-gradient(180deg, #f43f5e, #e11d48);
  border: 3px solid #ffe4e6;
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 800;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 5px 0 #9f1239;
}
.action-btn-sub:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #9f1239;
}

/* ==========================================================================
   Interactive Reeling Minigame HUD Overlay
   ========================================================================== */

#reel-minigame-hud {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.92);
  border: 4px solid #f97316;
  border-radius: 24px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  min-width: 320px;
}

.reel-header {
  font-size: 1.2rem;
  font-weight: 900;
  color: #fef08a;
  text-align: center;
}

/* Tension Bar */
.tension-bar-track {
  width: 280px;
  height: 28px;
  background: #1e293b;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  border: 2px solid #64748b;
}

.tension-sweet-spot {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(34, 197, 94, 0.55);
  border-left: 3px solid #4ade80;
  border-right: 3px solid #4ade80;
  transition: left 0.05s linear, width 0.1s ease;
}

.tension-indicator {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 0 8px #ffffff;
  transform: translateX(-50%);
  transition: left 0.04s linear;
}

/* Catch Progress Bar */
.catch-progress-track {
  width: 280px;
  height: 16px;
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #38bdf8;
}

.catch-progress-fill {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  border-radius: 8px;
  transition: width 0.08s ease;
}

.reel-instruction {
  font-size: 0.95rem;
  font-weight: 700;
  color: #94a3b8;
}

/* ==========================================================================
   Modals (Inventory, Shop, Boats, Catch Celebration)
   ========================================================================== */

.game-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}

.modal-content {
  background: #0f172a;
  border: 4px solid var(--panel-border);
  border-radius: 28px;
  width: 92%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header {
  background: #1e293b;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: #ef4444;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: white;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.modal-footer {
  padding: 16px 20px;
  background: #1e293b;
  border-top: 3px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Inventory Fish Grid */
.fish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.fish-card {
  background: #1e293b;
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  border: 3px solid #334155;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.fish-card.common { border-color: #10b981; }
.fish-card.uncommon { border-color: #3b82f6; }
.fish-card.rare { border-color: #8b5cf6; }
.fish-card.legendary { border-color: #f59e0b; }

.fish-icon {
  font-size: 2.2rem;
}

.fish-name {
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.fish-meta {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 700;
}

.fish-value {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fde047;
}

/* Sell All Button */
.btn-sell-all {
  background: linear-gradient(180deg, #22c55e, #16a34a);
  border: 3px solid #86efac;
  border-radius: 20px;
  padding: 12px 28px;
  font-size: 1.2rem;
  font-weight: 900;
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 0 #14532d;
}
.btn-sell-all:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #14532d;
}

/* Shop Category Tabs */
.shop-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.shop-tab-btn {
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 14px;
  padding: 8px 16px;
  color: #cbd5e1;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.shop-tab-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
  color: white;
}

/* Shop Item Row */
.shop-item-card {
  background: #1e293b;
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border: 3px solid #334155;
  gap: 12px;
}

.shop-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.shop-item-name {
  font-size: 1.15rem;
  font-weight: 900;
}

.shop-item-desc {
  font-size: 0.85rem;
  color: #94a3b8;
}

.shop-item-stats {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: 800;
}

.shop-item-btn {
  background: linear-gradient(180deg, #f59e0b, #d97706);
  border: 2px solid #fde047;
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 900;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 0 #92400e;
  white-space: nowrap;
}
.shop-item-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #92400e;
}
.shop-item-btn.equipped {
  background: #334155;
  border-color: #64748b;
  box-shadow: none;
  cursor: default;
}
.shop-item-btn.disabled {
  background: #475569;
  opacity: 0.6;
  box-shadow: none;
  cursor: not-allowed;
}

/* ==========================================================================
   Fish Caught Celebration Card
   ========================================================================== */

#catch-modal .modal-content {
  max-width: 420px;
  text-align: center;
  border-color: #f59e0b;
}

.catch-splash-art {
  font-size: 4.5rem;
  margin: 12px 0;
  animation: float-fish 2s infinite ease-in-out;
}

@keyframes float-fish {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(4deg); }
}

.catch-fish-name {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.rarity-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: white;
}

.catch-details-box {
  background: #1e293b;
  border-radius: 16px;
  padding: 14px;
  margin: 12px 0;
  display: flex;
  justify-content: space-around;
}

.catch-stat-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 700;
}

.catch-stat-val {
  font-size: 1.25rem;
  font-weight: 900;
  color: #fde047;
}

/* Toast Notifications */
#toast-container {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #38bdf8;
  border-radius: 20px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes toast-in {
  0% { transform: translateY(-20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Landscape / iPad Optimization */
@media (max-height: 500px) {
  .hud-top-bar { padding: 4px 12px; }
  .hud-pill { padding: 4px 10px; font-size: 0.9rem; }
  .action-btn-large { height: 60px; width: 110px; font-size: 1.1rem; }
  .joystick-container { width: 110px; height: 110px; }
  .joystick-base { width: 100px; height: 100px; }
  .joystick-knob { width: 44px; height: 44px; top: 35px; left: 35px; }
}

/* Account / cloud save */
.account-input {
  width: 100%;
  box-sizing: border-box;
  margin: 6px 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.35);
  background: rgba(15,23,42,0.85);
  color: #fff;
  font: 800 1rem 'Nunito', sans-serif;
  outline: none;
}
.account-input:focus { border-color: #38bdf8; }

.custom-label { display:block; margin-top:12px; margin-bottom:6px; color:#e2e8f0; font-weight:900; }
.custom-row { display:flex; gap:10px; flex-wrap:wrap; }
.color-choice { width:44px; height:44px; border-radius:50%; border:3px solid rgba(255,255,255,.35); box-shadow:0 3px 8px rgba(0,0,0,.25); cursor:pointer; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
.color-choice.active { border-color:#fff; transform:scale(1.08); }

/* ==========================================================================\n   RESPONSIVE PHONE / TABLET / DESKTOP LAYOUT\n   ========================================================================== */
html, body, #canvas-container, #game-hud {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

#canvas-container,
#game-hud {
  height: 100dvh;
  min-height: 100dvh;
}

#canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

.hud-top-bar {
  flex: 0 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
}

.hud-top-left {
  min-width: 0;
  max-width: min(62vw, 520px);
}

.hud-top-right {
  flex: 0 0 auto;
}

.hud-menu-button {
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
}

.hud-bottom-bar {
  flex: 0 0 auto;
  min-height: 0;
  padding: 8px max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 10px;
}

.joystick-container {
  flex: 0 0 auto;
}

.hud-action-group {
  flex: 0 0 auto;
  max-width: 42vw;
}

.action-btn-large,
.action-btn-sub {
  max-width: 100%;
}

/* Portrait phones: keep every control inside the viewport. */
@media (orientation: portrait) and (max-width: 700px) {
  .hud-top-bar {
    align-items: flex-start;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .hud-top-left {
    max-width: calc(100vw - 72px);
  }

  .hud-pill {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .money-pill {
    font-size: 1.05rem;
  }

  .hud-top-left .zone-pill,
  .hud-top-left .cooler-pill {
    display: flex;
  }

  .zone-pill,
  .cooler-pill {
    font-size: 0.78rem;
    padding: 6px 9px;
  }

  .hud-bottom-bar {
    align-items: flex-end;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .joystick-container {
    width: clamp(112px, 31vw, 145px);
    height: clamp(112px, 31vw, 145px);
  }

  .joystick-base {
    width: clamp(100px, 27vw, 130px);
    height: clamp(100px, 27vw, 130px);
    top: 6px;
    left: 6px;
  }

  .joystick-knob {
    width: clamp(46px, 13vw, 56px);
    height: clamp(46px, 13vw, 56px);
    top: 50%;
    left: 50%;
    margin-left: calc(clamp(46px, 13vw, 56px) / -2);
    margin-top: calc(clamp(46px, 13vw, 56px) / -2);
  }

  .joystick-hint {
    bottom: -16px;
    left: 5px;
    font-size: 0.68rem;
  }

  .hud-action-group {
    width: min(43vw, 190px);
    gap: 8px;
  }

  .action-btn-large {
    width: 100%;
    height: clamp(68px, 13vw, 82px);
    border-radius: 20px;
    font-size: clamp(1.05rem, 4.5vw, 1.4rem);
  }

  .action-btn-sub {
    width: 100%;
    justify-content: center;
    padding: 8px 8px;
    font-size: clamp(0.7rem, 3vw, 0.95rem);
  }

  .reel-instruction {
    font-size: 0.72rem;
  }
}

/* Very narrow portrait phones. */
@media (orientation: portrait) and (max-width: 420px) {
  .hud-top-left .zone-pill,
  .hud-top-left .cooler-pill {
    display: none;
  }

  .hud-top-left {
    max-width: calc(100vw - 68px);
  }

  .hud-bottom-bar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .joystick-container {
    width: 112px;
    height: 112px;
  }

  .joystick-base {
    width: 100px;
    height: 100px;
  }

  .hud-action-group {
    width: 44vw;
    max-width: 176px;
  }
}

/* Landscape phones/tablets. */
@media (orientation: landscape) {
  .hud-top-bar {
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .hud-top-left {
    max-width: 58vw;
  }

  .hud-bottom-bar {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .joystick-container {
    width: 118px;
    height: 118px;
  }

  .joystick-base {
    width: 108px;
    height: 108px;
    top: 5px;
    left: 5px;
  }

  .joystick-knob {
    width: 48px;
    height: 48px;
    top: 35px;
    left: 35px;
  }

  .hud-action-group {
    max-width: 220px;
  }

  .action-btn-large {
    width: 125px;
    height: 64px;
    border-radius: 18px;
    font-size: 1.15rem;
  }

  .action-btn-sub {
    font-size: 0.8rem;
    padding: 7px 10px;
  }
}

/* Short landscape displays, including iPhone landscape Safari. */
@media (orientation: landscape) and (max-height: 520px) {
  .hud-pill {
    padding: 5px 9px;
    font-size: 0.78rem;
  }

  .money-pill {
    font-size: 0.9rem;
  }

  .zone-pill,
  .cooler-pill {
    display: none !important;
  }

  .hud-menu-button {
    width: 40px;
    height: 40px;
  }

  .joystick-container {
    width: 100px;
    height: 100px;
  }

  .joystick-base {
    width: 92px;
    height: 92px;
  }

  .joystick-knob {
    width: 42px;
    height: 42px;
    top: 30px;
    left: 30px;
  }

  .action-btn-large {
    width: 112px;
    height: 56px;
    font-size: 1rem;
  }
}

/* Respect iOS safe-area insets without creating a white strip. */
@supports (height: 100svh) {
  #canvas-container,
  #game-hud {
    height: 100svh;
  }
}
@supports (height: 100dvh) {
  #canvas-container,
  #game-hud {
    height: 100dvh;
  }
}


@media (orientation: portrait) and (max-width: 700px) {
  .game-modal {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .modal-content {
    width: 96%;
    max-width: none;
    max-height: 92dvh;
    border-width: 3px;
    border-radius: 22px;
  }
  .modal-title { font-size: 1.1rem; }
  .modal-header { padding: 12px 14px; }
  .modal-body { padding: 14px; }
}


.choice-chip { border:2px solid rgba(255,255,255,.18); border-radius:12px; padding:10px 12px; background:#1e293b; color:#fff; font:800 .9rem var(--font-family); cursor:pointer; touch-action:manipulation; }
.choice-chip.active { border-color:#38bdf8; background:#075985; transform:translateY(-1px); }
.locked-choice { border-style:dashed; }
.calendar-summary { display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap; background:#1e293b; padding:12px; border-radius:14px; margin-bottom:12px; }
.calendar-summary span { color:#94a3b8; font-weight:700; }
.calendar-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.calendar-weekday { text-align:center; color:#7dd3fc; font-weight:900; font-size:.78rem; padding:4px 0; }
.calendar-empty { min-height:58px; }
.calendar-day { min-height:58px; border:2px solid rgba(255,255,255,.12); border-radius:10px; background:#111827; padding:6px; display:flex; flex-direction:column; justify-content:space-between; }
.calendar-day.played { border-color:#22c55e; }
.calendar-day.claimed { background:#14532d; }
.calendar-day.today { box-shadow:0 0 0 2px #facc15 inset; }
.calendar-day small { font-size:1.1rem; }
.calendar-day span { color:#86efac; font-weight:900; align-self:flex-end; }
.calendar-bonus { margin-top:12px; padding:14px; border-radius:14px; background:linear-gradient(135deg,#312e81,#78350f); color:#fff; }
.calendar-bonus strong { display:block; font-size:1.05rem; margin-bottom:4px; }
.calendar-bonus div { color:#e2e8f0; font-weight:700; }
.calendar-progress { height:10px; background:#0f172a; border-radius:999px; overflow:hidden; margin:10px 0 5px; }
.calendar-progress span { display:block; height:100%; background:#f59e0b; border-radius:999px; }
@media (max-width:520px){ .calendar-day{min-height:50px;padding:5px;font-size:.85rem}.calendar-weekday{font-size:.68rem}.choice-chip{padding:9px 10px;font-size:.82rem;} }

/* Start screen */
#start-screen {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #fff; text-align: center; font-family: var(--font-family);
  transition: opacity .25s ease, visibility .25s ease;
}
#start-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#start-screen .start-fish { font-size: clamp(4rem, 18vw, 7rem); animation: float-fish 1.8s infinite ease-in-out; }
#start-screen h1 { margin: 8px 0 2px; font-size: clamp(2.8rem, 12vw, 5rem); font-weight: 900; text-shadow: 0 4px 10px rgba(0,0,0,.3); }
#start-screen p { margin: 0 0 24px; font-size: clamp(1rem, 4vw, 1.35rem); font-weight: 800; opacity: .95; }
#btn-start-game { min-width: 210px; min-height: 58px; padding: 14px 24px; border: 3px solid rgba(255,255,255,.7); border-radius: 18px; background: #16a34a; color: #fff; font: 900 1.15rem var(--font-family); box-shadow: 0 8px 18px rgba(0,0,0,.28); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#btn-start-game:active { transform: scale(.97); }
#start-screen small { margin-top: 10px; font-weight: 800; opacity: .85; }

/* Reliable touch controls for customization/menu/settings */
.choice-chip, .color-choice, .menu-card, .shop-item-btn, .hud-menu-button, .modal-close-btn { touch-action: manipulation; -webkit-user-select: none; user-select: none; }

/* Character visual-choice cards */
.custom-choice-grid.visual-choice-grid { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 10px; }
.visual-choice { position:relative; min-height:92px; padding:7px; border:2px solid rgba(148,163,184,.28); border-radius:16px; background:rgba(15,23,42,.72); color:#e2e8f0; font-weight:900; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; cursor:pointer; touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
.visual-choice .choice-preview { width:62px; height:56px; display:flex; align-items:center; justify-content:center; border-radius:12px; overflow:hidden; background:rgba(2,6,23,.45); }
.visual-choice .choice-preview svg { width:58px; height:52px; display:block; }
.visual-choice .choice-label { font-size:.72rem; line-height:1.05; text-align:center; }
.visual-choice.active { border-color:#fde047; box-shadow:0 0 0 3px rgba(253,224,71,.35), 0 0 18px rgba(253,224,71,.2); transform:translateY(-1px); }
.visual-choice.active::after { content:'✓'; position:absolute; top:5px; right:6px; width:21px; height:21px; border-radius:50%; background:#22c55e; color:#fff; font-size:13px; line-height:21px; text-align:center; box-shadow:0 2px 6px rgba(0,0,0,.35); }
.color-choice.visual-color { position:relative; width:58px; height:58px; padding:0; border-radius:50%; border:3px solid rgba(255,255,255,.35); cursor:pointer; touch-action:manipulation; }
.color-choice.visual-color.active { border-color:#fde047; box-shadow:0 0 0 4px rgba(253,224,71,.32), 0 0 16px rgba(253,224,71,.18); transform:scale(1.08); }
.color-choice.visual-color.active::after { content:'✓'; position:absolute; inset:12px; border-radius:50%; background:rgba(15,23,42,.72); color:#fff; font-weight:900; line-height:28px; text-align:center; }
#hud-level { min-width:92px; }
.auto-fish-active { border-color:#4ade80 !important; box-shadow:0 0 0 3px rgba(74,222,128,.25) !important; }
.level-progress-wrap { margin:8px 0 14px; padding:10px 12px; border-radius:14px; background:rgba(15,23,42,.72); }
.level-progress-head { display:flex; justify-content:space-between; gap:8px; color:#e2e8f0; font-weight:900; font-size:.84rem; }
.level-progress-track { height:9px; border-radius:999px; background:rgba(148,163,184,.2); overflow:hidden; margin-top:7px; }
.level-progress-fill { height:100%; border-radius:999px; background:linear-gradient(90deg,#22c55e,#38bdf8,#a78bfa); width:0%; transition:width .25s ease; }

/* Customization option layout: horizontal choices that wrap cleanly to the next row. */
.custom-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 58px));
  justify-content: start;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.custom-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  align-items: stretch;
}
.custom-choice-grid .visual-choice {
  min-width: 0;
}
.color-choice {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.color-choice.active {
  border-color: #fde047;
  box-shadow: 0 0 0 4px rgba(253,224,71,.32), 0 0 16px rgba(253,224,71,.18);
  transform: scale(1.08);
}
.color-choice.active::after {
  content: '✓';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: rgba(15,23,42,.72);
  color: #fff;
  font-weight: 900;
  line-height: 28px;
  text-align: center;
}
@media (max-width: 520px) {
  .custom-row { grid-template-columns: repeat(5, 52px); gap: 8px; }
  .color-choice { width: 52px; height: 52px; }
  .custom-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

/* FINAL MOBILE HUD OVERRIDES — keep the menu and action controls inside the viewport. */
#game-hud { z-index: 50; overflow: hidden; }
/* The compact top bar is absolutely positioned, so the bottom controls must
   also be explicitly anchored to the viewport. Otherwise the flex container
   can place the only remaining flex child at the top of the screen. */
#game-hud > .hud-bottom-bar {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: max(12px, env(safe-area-inset-bottom)) !important;
  width: 100% !important;
  box-sizing: border-box !important;
  z-index: 100 !important;
}

.hud-top-bar {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
}
.hud-top-left {
  width: min(520px, calc(100% - 58px));
  max-width: calc(100% - 58px);
  min-width: 0;
}
.hud-top-left .hud-pill {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.hud-top-right {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 200;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-menu-button {
  position: relative;
  z-index: 201;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
}

.hud-bottom-bar {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding-left: max(8px, env(safe-area-inset-left));
  padding-right: max(8px, env(safe-area-inset-right));
}
.hud-action-group {
  width: min(42vw, 210px);
  max-width: min(42vw, 210px);
  min-width: 0;
  margin-left: auto;
}
.hud-action-group .action-btn-large,
.hud-action-group .action-btn-sub {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (orientation: portrait) and (max-width: 700px) {
  #game-hud > .hud-bottom-bar { bottom: max(10px, env(safe-area-inset-bottom)) !important; }
  .hud-top-bar { padding-top: max(8px, env(safe-area-inset-top)); }
  .hud-top-left { width: calc(100vw - 66px); max-width: calc(100vw - 66px); }
  .hud-top-right { top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .hud-action-group {
    width: min(44vw, 190px);
    max-width: min(44vw, 190px);
  }
}

@media (orientation: portrait) and (max-width: 420px) {
  #game-hud > .hud-bottom-bar { bottom: max(8px, env(safe-area-inset-bottom)) !important; }
  .hud-top-left { width: calc(100vw - 62px); max-width: calc(100vw - 62px); }
  .hud-top-right { width: 44px; height: 44px; }
  .hud-menu-button { width: 42px; height: 42px; flex-basis: 42px; font-size: 1.15rem; }
  .hud-action-group { width: min(46vw, 176px); max-width: min(46vw, 176px); }
}

@media (orientation: landscape) {
  #game-hud > .hud-bottom-bar { bottom: max(8px, env(safe-area-inset-bottom)) !important; }
  .hud-top-left { width: min(58vw, 520px); max-width: calc(100% - 62px); }
  .hud-top-right { top: max(6px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .hud-action-group { width: min(32vw, 220px); max-width: min(32vw, 220px); }
}

/* Account password visibility control */
.password-field { position: relative; width: 100%; }
.password-field .account-input { width: 100%; padding-right: 52px; box-sizing: border-box; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; padding: 0; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.10); color: rgba(255,255,255,.78);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  z-index: 3;
}
.password-toggle:hover { background: rgba(255,255,255,.16); color: #fff; }
.password-toggle:active { transform: translateY(-50%) scale(.94); }
.password-toggle[aria-pressed="true"] { background: rgba(255,255,255,.18); color: #fff; }
.password-eye-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.password-eye-icon.is-hidden { opacity: .72; }

\n/* FINAL COMPACT HUD OVERRIDE */\n.compact-hud-top-bar {\n  display: flex !important;\n  flex-direction: row !important;\n  align-items: center !important;\n  justify-content: space-between !important;\n  gap: 8px !important;\n  padding: 8px !important;\n  width: 100% !important;\n  box-sizing: border-box !important;\n}\n.compact-hud-top-bar .hud-summary-bar {\n  display: flex !important;\n  align-items: center !important;\n  gap: 4px !important;\n  min-width: 0 !important;\n  flex: 1 1 auto !important;\n  width: auto !important;\n  max-width: calc(100% - 54px) !important;\n  padding: 5px 7px !important;\n  background: rgba(15, 23, 42, 0.86) !important;\n  border: 2px solid rgba(255,255,255,.20) !important;\n  border-radius: 14px !important;\n  box-shadow: 0 3px 10px rgba(0,0,0,.30) !important;\n  backdrop-filter: blur(8px) !important;\n  -webkit-backdrop-filter: blur(8px) !important;\n}\n.compact-hud-top-bar .hud-summary-item {\n  min-width: 0 !important;\n  flex: 1 1 0 !important;\n  overflow: hidden !important;\n  text-overflow: ellipsis !important;\n  white-space: nowrap !important;\n  text-align: center !important;\n  color: #fff !important;\n  font-size: .78rem !important;\n  line-height: 1.1 !important;\n  font-weight: 900 !important;\n  padding: 3px 4px !important;\n}\n.compact-hud-top-bar .money-summary { color: #fef08a !important; }\n.compact-hud-top-bar .hud-menu-button {\n  width: 44px !important;\n  height: 44px !important;\n  flex: 0 0 44px !important;\n}\n@media (max-width: 420px) {\n  .compact-hud-top-bar { padding: 6px !important; }\n  .compact-hud-top-bar .hud-summary-bar { gap: 1px !important; padding: 4px !important; border-radius: 12px !important; }\n  .compact-hud-top-bar .hud-summary-item { font-size: .68rem !important; padding: 3px 2px !important; }\n  .compact-hud-top-bar .hud-menu-button { width: 42px !important; height: 42px !important; flex-basis: 42px !important; }\n}\n
/* Fish Book */
.fish-book-modal-content { max-width: 900px; }
.fish-book-summary {
  background: linear-gradient(135deg, #172554, #0f172a);
  border: 2px solid #334155; border-radius: 16px; padding: 12px 14px;
  text-align: center; margin-bottom: 12px; color: #e2e8f0;
}
.fish-book-summary strong { color: #facc15; font-size: 1.2rem; }
.fish-book-summary-sub { color:#94a3b8; font-size:.85rem; font-weight:700; margin-top:3px; }
.fish-book-zone-tabs { display:flex; gap:8px; overflow-x:auto; padding-bottom:10px; }
.fish-book-zone-tab { flex:0 0 auto; border:2px solid #334155; background:#1e293b; color:#e2e8f0; border-radius:12px; padding:9px 12px; font-weight:900; cursor:pointer; }
.fish-book-zone-tab span { color:#94a3b8; margin-left:4px; }
.fish-book-zone-tab.active { background:#075985; border-color:#38bdf8; color:white; }
.fish-book-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:12px; }
.fish-book-card { background:#1e293b; border:3px solid #334155; border-radius:18px; padding:12px; text-align:center; min-height:235px; display:flex; flex-direction:column; align-items:center; box-shadow:0 5px 12px rgba(0,0,0,.25); }
.fish-book-card.common { border-color:#10b981; } .fish-book-card.uncommon { border-color:#3b82f6; } .fish-book-card.rare { border-color:#8b5cf6; } .fish-book-card.legendary { border-color:#f59e0b; }
.fish-book-card.locked { filter:saturate(.45); opacity:.78; }
.fish-book-art { width:78px; height:78px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:2.7rem; margin-bottom:6px; background:radial-gradient(circle at 35% 30%, var(--fish-color), #0f172a 72%); box-shadow:inset 0 0 0 3px rgba(255,255,255,.08); }
.fish-book-card.locked .fish-book-art { background:#111827; filter:grayscale(1); }
.fish-book-name { font-weight:900; font-size:1rem; color:white; min-height:2.2em; display:flex; align-items:center; justify-content:center; }
.fish-book-rarity { font-size:.72rem; font-weight:900; letter-spacing:.08em; color:#94a3b8; margin:2px 0 7px; }
.fish-book-stat { width:100%; font-size:.82rem; color:#cbd5e1; text-align:left; margin-top:3px; }
.fish-book-stat strong { color:#f8fafc; }
.fish-book-desc { font-size:.72rem; color:#94a3b8; line-height:1.25; margin-top:7px; }
.fish-book-locked-text { color:#64748b; font-size:.8rem; font-weight:800; margin-top:8px; line-height:1.3; }
@media (max-width:520px) { .fish-book-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; } .fish-book-card { min-height:225px; padding:9px; } .fish-book-art { width:64px; height:64px; font-size:2.2rem; } .fish-book-name { font-size:.9rem; } }

/* FINAL HUD / FISH BOOK FIX — single full-width bar across the top. */
#game-hud { z-index: 50; }
#game-hud > .compact-hud-top-bar {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: none !important;
  min-height: 56px !important;
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left)) !important;
  background: rgba(15, 23, 42, 0.90) !important;
  border-bottom: 2px solid rgba(255,255,255,.18) !important;
  box-shadow: 0 4px 14px rgba(0,0,0,.28) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}
#game-hud > .compact-hud-top-bar .hud-summary-bar {
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 0 !important;
}
#game-hud > .compact-hud-top-bar .hud-summary-item {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  text-align: center !important;
  font-size: .82rem !important;
  padding: 5px 6px !important;
  border-right: 1px solid rgba(255,255,255,.10) !important;
}
#game-hud > .compact-hud-top-bar .hud-summary-item:last-child { border-right: 0 !important; }
#game-hud > .compact-hud-top-bar .hud-menu-button {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  width: 42px !important;
  height: 42px !important;
  flex: 0 0 42px !important;
}
.game-modal { z-index: 500 !important; }
#fish-book-modal { z-index: 600 !important; }
.fish-book-zone-tab { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (max-width: 420px) {
  #game-hud > .compact-hud-top-bar { min-height: 52px !important; }
  #game-hud > .compact-hud-top-bar .hud-summary-item { font-size: .68rem !important; padding: 4px 2px !important; }
  #game-hud > .compact-hud-top-bar .hud-menu-button { width: 40px !important; height: 40px !important; flex-basis: 40px !important; }
}
