/* Angler 3D — cinematic UI */
:root {
  --gold: #f5c453;
  --gold-deep: #c9922e;
  --ink: #0b1020;
  --glass: rgba(10, 14, 26, 0.55);
  --glass-border: rgba(245, 196, 83, 0.35);
  --text: #f4efe4;
  --text-dim: rgba(244, 239, 228, 0.65);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--font);
  color: var(--text);
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-container, #game-container canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ---------- cinematic overlays ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 20;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(4,6,12,0.55) 100%);
}
#grain {
  position: fixed; inset: -100px; pointer-events: none; z-index: 21; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-30px, 20px); }
  50% { transform: translate(20px, -25px); }
  75% { transform: translate(-15px, -10px); }
  100% { transform: translate(0, 0); }
}
.letterbox {
  position: fixed; left: 0; right: 0; height: 0; background: #000;
  z-index: 22; pointer-events: none;
  transition: height 0.9s cubic-bezier(0.6, 0, 0.3, 1);
}
#letterbox-top { top: 0; }
#letterbox-bottom { bottom: 0; }
body.cinema .letterbox { height: 9vh; }

#flash {
  position: fixed; inset: 0; background: #fff8e8; opacity: 0;
  pointer-events: none; z-index: 23; transition: opacity 0.12s ease-out;
}
#flash.on { opacity: 0.55; }

#input-layer {
  position: fixed; inset: 0; z-index: 30;
  touch-action: none; display: none;
}
#input-layer.active { display: block; }

/* ---------- generic overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  background: radial-gradient(ellipse at center, rgba(6,9,18,0.25) 0%, rgba(6,9,18,0.78) 100%);
  transition: opacity 0.5s ease;
}
.hidden { display: none !important; }

/* ---------- intro ---------- */
.intro-title {
  font-size: clamp(15px, 2.6vw, 24px);
  letter-spacing: 0.55em; text-indent: 0.55em;
  color: var(--text-dim);
  animation: fade-pulse 3s ease-in-out infinite;
}
.intro-skip {
  position: absolute; bottom: 11vh;
  font-size: 12px; letter-spacing: 0.35em; text-indent: 0.35em;
  color: var(--text-dim);
  animation: fade-pulse 1.6s ease-in-out infinite;
}
@keyframes fade-pulse { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ---------- title ---------- */
.title-kicker {
  font-size: clamp(10px, 1.6vw, 14px);
  letter-spacing: 0.5em; text-indent: 0.5em;
  color: var(--gold); margin-bottom: 18px;
}
.game-title {
  font-size: clamp(52px, 12vw, 130px);
  font-weight: 800; letter-spacing: 0.08em;
  line-height: 0.95;
  background: linear-gradient(180deg, #fff7e0 20%, var(--gold) 55%, #8a5c14 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 60px rgba(245, 196, 83, 0.25);
  filter: drop-shadow(0 4px 18px rgba(0,0,0,0.6));
}
.game-title span { font-weight: 200; }
.title-sub {
  margin-top: 10px; font-size: clamp(12px, 2vw, 17px);
  letter-spacing: 0.42em; text-indent: 0.42em; color: var(--text-dim);
}
.btn-gold {
  margin-top: 34px;
  font-family: var(--font); font-weight: 700;
  font-size: clamp(15px, 2.4vw, 20px); letter-spacing: 0.22em; text-indent: 0.22em;
  color: #1a1206; background: linear-gradient(180deg, #ffe9a8, var(--gold) 60%, var(--gold-deep));
  border: none; border-radius: 999px;
  padding: 16px 46px; cursor: pointer;
  box-shadow: 0 6px 30px rgba(245,196,83,0.35), inset 0 1px 0 rgba(255,255,255,0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-gold:active { transform: scale(0.96); box-shadow: 0 2px 14px rgba(245,196,83,0.3); }
.btn-ghost {
  margin-top: 14px;
  font-family: var(--font); font-weight: 600; font-size: 14px;
  letter-spacing: 0.2em; text-indent: 0.2em;
  color: var(--text); background: var(--glass);
  border: 1px solid var(--glass-border); border-radius: 999px;
  padding: 12px 34px; cursor: pointer; backdrop-filter: blur(8px);
}
.btn-ghost:active { transform: scale(0.96); }
.best-catch {
  margin-top: 26px; font-size: 14px; letter-spacing: 0.12em; color: var(--text-dim);
}
.best-catch b { color: var(--gold); }
.title-hint { margin-top: 26px; font-size: 11px; letter-spacing: 0.2em; color: rgba(244,239,228,0.35); }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 35;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
.hud-chip {
  pointer-events: auto;
  font-size: 14px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--text); background: var(--glass);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 999px;
  padding: 9px 16px; backdrop-filter: blur(10px);
  font-family: var(--font);
}
button.hud-chip { cursor: pointer; }
button.hud-chip:active { transform: scale(0.94); }
#mute-btn { margin-left: auto; margin-right: 8px; }
#collection-btn { color: var(--gold); border-color: var(--glass-border); }

/* ---------- cast UI ---------- */
#cast-ui {
  position: fixed; inset: 0; z-index: 34; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: calc(9vh + env(safe-area-inset-bottom));
}
#cast-hint {
  font-size: clamp(12px, 2vw, 16px); letter-spacing: 0.3em; text-indent: 0.3em;
  color: var(--text); text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  margin-bottom: 18px; animation: fade-pulse 1.8s ease-in-out infinite;
}
#power-wrap { width: min(72vw, 420px); }
#power-label { font-size: 11px; letter-spacing: 0.4em; text-indent: 0.4em; color: var(--gold); margin-bottom: 8px; text-align: center; }
#power-track {
  position: relative; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  overflow: hidden; backdrop-filter: blur(6px);
}
#power-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #7de08a, #f5c453 60%, #ff5a3c);
  border-radius: 999px;
}
#power-sweet {
  position: absolute; top: 0; bottom: 0; left: 72%; width: 12%;
  background: rgba(255,255,255,0.35); border-left: 1px dashed #fff; border-right: 1px dashed #fff;
}

/* ---------- strike ---------- */
#strike-ui {
  position: fixed; inset: 0; z-index: 36; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#strike-text {
  font-size: clamp(56px, 13vw, 120px); font-weight: 900; letter-spacing: 0.1em;
  color: #fff; text-shadow: 0 0 30px rgba(255,120,40,0.9), 0 4px 0 #b33c00;
  animation: strike-pop 0.45s ease-out infinite alternate;
}
#strike-sub { font-size: 18px; letter-spacing: 0.5em; text-indent: 0.5em; color: var(--gold); margin-top: 6px; }
@keyframes strike-pop { from { transform: scale(1); } to { transform: scale(1.12); } }

/* ---------- tension minigame ---------- */
#tension-ui {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 34; pointer-events: none;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: calc(6vh + env(safe-area-inset-bottom));
}
#tension-title {
  font-size: 12px; letter-spacing: 0.32em; text-indent: 0.32em; color: var(--text);
  text-shadow: 0 2px 10px rgba(0,0,0,0.9); margin-bottom: 10px;
}
#tension-track {
  position: relative; width: min(80vw, 480px); height: 22px; border-radius: 999px;
  background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.25);
  overflow: hidden; backdrop-filter: blur(6px);
}
#tension-danger {
  position: absolute; top: 0; bottom: 0; right: 0; width: 12%;
  background: linear-gradient(90deg, transparent, rgba(255,60,40,0.75));
}
#tension-zone {
  position: absolute; top: 0; bottom: 0;
  background: rgba(110, 230, 130, 0.5);
  border-left: 2px solid #6ee682; border-right: 2px solid #6ee682;
}
#tension-marker {
  position: absolute; top: -3px; bottom: -3px; width: 6px; border-radius: 3px;
  background: #fff; box-shadow: 0 0 12px #fff;
  transform: translateX(-3px);
}
#tension-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; width: min(80vw, 480px); }
#progress-track {
  flex: 1; height: 10px; border-radius: 999px;
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.2); overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}
#fish-name { font-size: 13px; font-weight: 700; letter-spacing: 0.14em; color: var(--gold); white-space: nowrap; }
#reel-hint {
  margin-top: 12px; font-size: 12px; letter-spacing: 0.3em; text-indent: 0.3em;
  color: var(--text); text-shadow: 0 2px 10px rgba(0,0,0,0.9);
  animation: fade-pulse 1.6s ease-in-out infinite;
}

/* ---------- toast ---------- */
#toast {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  z-index: 38; pointer-events: none;
  font-size: clamp(16px, 3vw, 24px); font-weight: 700; letter-spacing: 0.2em; text-indent: 0.2em;
  color: #fff; text-shadow: 0 2px 16px rgba(0,0,0,0.9);
  background: var(--glass); border: 1px solid rgba(255,255,255,0.18);
  padding: 12px 28px; border-radius: 999px; backdrop-filter: blur(10px);
  animation: toast-in 0.35s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ---------- catch card ---------- */
#catch-card { background: radial-gradient(ellipse at center, rgba(6,9,18,0.35) 0%, rgba(6,9,18,0.88) 100%); }
#card-inner {
  background: var(--glass); backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border); border-radius: 24px;
  padding: 34px 44px; max-width: min(88vw, 420px);
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
  animation: card-in 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
  --rarity: #c0c8d0;
  border-top: 3px solid var(--rarity);
}
@keyframes card-in { from { opacity: 0; transform: translateY(40px) scale(0.92); } to { opacity: 1; transform: none; } }
#card-rarity {
  font-size: 13px; font-weight: 800; letter-spacing: 0.5em; text-indent: 0.5em;
  color: var(--rarity); margin-bottom: 8px;
  text-shadow: 0 0 18px var(--rarity);
}
#card-name { font-size: clamp(30px, 7vw, 44px); font-weight: 800; letter-spacing: 0.04em; }
#card-fish { font-size: 64px; margin: 12px 0 4px; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.5)); }
#card-weight { font-size: 16px; color: var(--text-dim); letter-spacing: 0.2em; }
#card-new {
  display: inline-block; margin-top: 12px; font-size: 12px; font-weight: 800; letter-spacing: 0.3em; text-indent: 0.3em;
  color: #1a1206; background: var(--gold); border-radius: 999px; padding: 6px 18px;
  animation: fade-pulse 1.4s ease-in-out infinite;
}
.card-buttons { display: flex; flex-direction: column; align-items: center; }

/* ---------- collection ---------- */
#collection-inner {
  background: var(--glass); backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 24px;
  padding: 26px; width: min(92vw, 560px); max-height: 84vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6);
}
#collection-inner h2 { letter-spacing: 0.4em; text-indent: 0.4em; font-size: 20px; color: var(--gold); }
#collection-stats { margin: 10px 0 16px; font-size: 13px; color: var(--text-dim); letter-spacing: 0.1em; }
#collection-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px; overflow-y: auto; margin-bottom: 18px; padding-right: 4px;
}
.fish-cell {
  background: rgba(255,255,255,0.05); border-radius: 14px; padding: 12px 8px;
  border: 1px solid rgba(255,255,255,0.1); border-top: 3px solid var(--rarity, #888);
}
.fish-cell .fc-emoji { font-size: 34px; }
.fish-cell .fc-name { font-size: 12px; font-weight: 700; margin-top: 6px; }
.fish-cell .fc-rarity { font-size: 10px; letter-spacing: 0.2em; color: var(--rarity, #888); font-weight: 800; }
.fish-cell .fc-weight { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
#collection-empty { color: var(--text-dim); font-size: 14px; padding: 30px 10px; letter-spacing: 0.06em; }

.error-box {
  background: var(--glass); border: 1px solid rgba(255,90,90,0.5); border-radius: 16px;
  padding: 30px 40px; font-size: 16px; line-height: 1.7; backdrop-filter: blur(10px);
}

@media (max-height: 500px) {
  .game-title { font-size: clamp(44px, 9vw, 80px); }
  .btn-gold { margin-top: 20px; padding: 12px 36px; }
  #card-inner { padding: 22px 30px; }
}
