/* ====================================================================
   TITAN CLICKER - FEATURES: zone themes, titan reactions, combo
   ==================================================================== */

/* ---- Zone themes (colors per world) ---- */
body { --zone-a: #f59e0b; --zone-b: #ef4444; }
body[data-world="1"] { --zone-a: #f59e0b; --zone-b: #b45309; }
body[data-world="2"] { --zone-a: #ef4444; --zone-b: #f97316; }
body[data-world="3"] { --zone-a: #06b6d4; --zone-b: #6366f1; }
body[data-world="4"] { --zone-a: #7c3aed; --zone-b: #1e1b4b; }
body[data-world="5"] { --zone-a: #fde047; --zone-b: #f43f5e; }
body[data-world="6"] { --zone-a: #fbbf24; --zone-b: #fef3c7; }
body[data-world="7"] { --zone-a: #d946ef; --zone-b: #22d3ee; }
body[data-world="8"] { --zone-a: #f8fafc; --zone-b: #a855f7; }

body {
  background-image:
    radial-gradient(ellipse at 15% 0%, color-mix(in srgb, var(--zone-a) 22%, transparent), transparent 55%),
    radial-gradient(ellipse at 85% 100%, color-mix(in srgb, var(--zone-b) 22%, transparent), transparent 55%);
  background-attachment: fixed;
  transition: background-image 0.6s ease;
}

.clicker-container { border-color: color-mix(in srgb, var(--zone-a) 55%, transparent); }
.clicker-container::before {
  background: radial-gradient(circle, color-mix(in srgb, var(--zone-a) 35%, transparent) 0%, color-mix(in srgb, var(--zone-b) 18%, transparent) 50%, transparent 75%);
}
.clicker-orb { border-color: var(--zone-a); }
.orb-ring { border-color: color-mix(in srgb, var(--zone-a) 60%, transparent); }

/* ---- Ambient floating particles ---- */
#zone-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
#zone-ambient span {
  position: absolute;
  bottom: -50px;
  opacity: 0;
  animation: ambientRise linear infinite;
  filter: blur(0.4px);
}
@keyframes ambientRise {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.35; }
  90% { opacity: 0.2; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}
.app-header, .main-layout { position: relative; z-index: 1; }

/* ---- Titan reactions ---- */
.clicker-orb.hit { animation: titanHit 0.16s ease-out; }
.clicker-orb.crit-hit { animation: titanCrit 0.28s ease-out; }

@keyframes titanHit {
  0% { transform: scale(0.9) rotate(var(--tilt, 2deg)); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes titanCrit {
  0% { transform: scale(0.86) rotate(var(--tilt, 4deg)); filter: brightness(2.2) saturate(1.6); }
  60% { transform: scale(1.12) rotate(0); filter: brightness(1.4); }
  100% { transform: scale(1); filter: none; }
}

/* ---- Titan evolution by rank (tier 0..7) ---- */
.orb-wrapper[data-tier="1"] .clicker-orb { box-shadow: 0 16px 40px rgba(0,0,0,.8), 0 0 40px color-mix(in srgb, var(--zone-a) 55%, transparent); }
.orb-wrapper[data-tier="2"] .clicker-orb { box-shadow: 0 16px 40px rgba(0,0,0,.8), 0 0 55px color-mix(in srgb, var(--zone-a) 70%, transparent); }
.orb-wrapper[data-tier="3"] .orb-mascot-img { filter: saturate(1.25) contrast(1.05); }
.orb-wrapper[data-tier="4"] .orb-mascot-img { filter: saturate(1.4) contrast(1.1) hue-rotate(-12deg); }
.orb-wrapper[data-tier="5"] .orb-mascot-img { filter: saturate(1.5) contrast(1.15) hue-rotate(20deg); }
.orb-wrapper[data-tier="6"] .orb-mascot-img { filter: saturate(1.7) contrast(1.2) hue-rotate(55deg); }
.orb-wrapper[data-tier="7"] .orb-mascot-img { filter: saturate(1.9) contrast(1.25) hue-rotate(120deg) brightness(1.1); }
.orb-wrapper[data-tier="5"] .orb-ring,
.orb-wrapper[data-tier="6"] .orb-ring,
.orb-wrapper[data-tier="7"] .orb-ring { border-style: solid; border-width: 3px; animation-duration: 12s; }
.orb-wrapper[data-tier="7"] .clicker-orb { animation: titanAura 2.4s ease-in-out infinite; }
@keyframes titanAura {
  0%, 100% { box-shadow: 0 0 40px var(--zone-a), 0 0 80px color-mix(in srgb, var(--zone-b) 60%, transparent); }
  50% { box-shadow: 0 0 70px var(--zone-b), 0 0 120px color-mix(in srgb, var(--zone-a) 60%, transparent); }
}

.titan-rank {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--zone-a);
  text-shadow: 0 0 12px color-mix(in srgb, var(--zone-a) 60%, transparent);
  margin-top: 4px;
}

/* ---- Combo bar ---- */
.combo-wrap { width: min(320px, 90%); margin: 6px 0 4px; }
.combo-label {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 900; color: var(--text-muted);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px;
}
.combo-label #combo-bonus { color: var(--accent-gold); }
.combo-bar {
  height: 10px; border-radius: 9999px; overflow: hidden;
  background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border-subtle);
}
#combo-fill {
  height: 100%; width: 0; border-radius: 9999px;
  background: linear-gradient(90deg, var(--zone-b), var(--zone-a));
  transition: width 0.08s linear;
}
#combo-fill.maxed { animation: comboMax 0.5s ease-in-out infinite alternate; }
@keyframes comboMax { from { filter: brightness(1); } to { filter: brightness(1.8); } }

@media (prefers-reduced-motion: reduce) {
  #zone-ambient { display: none; }
  .clicker-orb.hit, .clicker-orb.crit-hit { animation: none; }
}

/* ---- Toasts ---- */
#toast-stack { position: fixed; top: 76px; right: 16px; z-index: 12000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 320px;
  background: rgba(15, 23, 42, 0.96); border: 2px solid var(--accent-gold); border-radius: var(--radius-md);
  padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.6), 0 0 18px rgba(251,191,36,.3);
  animation: toastIn .35s cubic-bezier(.34,1.56,.64,1);
}
.toast.out { opacity: 0; transform: translateX(30px); transition: all .5s ease; }
.toast-icon { font-size: 26px; }
.toast-title { font-size: 13px; font-weight: 900; color: var(--accent-gold); }
.toast-text { font-size: 11px; font-weight: 700; color: var(--text-muted); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.9); } to { opacity: 1; transform: none; } }

/* ---- Glory tab ---- */
.glory-section { background: rgba(15, 23, 42, 0.8); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 14px; margin-bottom: 12px; }
.glory-title { font-size: 14px; font-weight: 900; color: #fff; margin-bottom: 8px; }
.glory-sub { font-size: 11px; color: var(--text-muted); }
.mission-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.mission-row.claimed { opacity: .5; }
.mission-icon { font-size: 22px; }
.mission-info { flex: 1; min-width: 0; }
.mission-desc { font-size: 12px; font-weight: 800; color: #fff; }
.mission-bar { height: 6px; background: rgba(2,6,23,.9); border-radius: 9999px; overflow: hidden; margin: 5px 0 2px; }
.mission-bar div { height: 100%; background: linear-gradient(90deg, var(--zone-b), var(--zone-a)); border-radius: 9999px; }
.mission-count { font-size: 10px; color: var(--text-dim); font-weight: 800; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-grid div { background: rgba(2,6,23,.6); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; }
.stats-grid span { font-size: 10px; color: var(--text-dim); font-weight: 800; text-transform: uppercase; }
.stats-grid b { font-size: 14px; color: var(--accent-gold); }
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ach-card { background: rgba(2,6,23,.6); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 10px; text-align: center; opacity: .55; }
.ach-card.done { opacity: 1; border-color: var(--accent-gold); box-shadow: 0 0 12px rgba(251,191,36,.2); }
.ach-icon { font-size: 24px; }
.ach-name { font-size: 12px; font-weight: 900; color: #fff; margin-top: 2px; }
.ach-desc { font-size: 10px; color: var(--text-muted); margin: 2px 0; }
.ach-reward { font-size: 11px; font-weight: 900; color: var(--accent-crimson); }
@media (max-width: 600px) { #toast-stack { right: 8px; left: 8px; top: 64px; } .toast { max-width: none; } }

/* ---- Boss panel ---- */
.boss-panel {
  width: min(360px, 94%); margin-bottom: 10px; padding: 10px 14px;
  background: rgba(69, 10, 10, 0.85); border: 2px solid var(--accent-crimson);
  border-radius: var(--radius-md); box-shadow: 0 0 24px rgba(239, 68, 68, .35); z-index: 3; position: relative;
}
.boss-panel.hidden { display: none; }
.boss-panel.boss-hit { animation: bossShake .12s ease-out; }
@keyframes bossShake { 0% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 100% { transform: none; } }
.boss-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 900; color: #fff; }
.boss-hp { height: 12px; background: rgba(2,6,23,.9); border-radius: 9999px; overflow: hidden; margin: 6px 0 4px; border: 1px solid var(--accent-crimson); }
.boss-hp div { height: 100%; background: linear-gradient(90deg, #dc2626, #f97316); transition: width .1s linear; }
.boss-sub { font-size: 10px; font-weight: 800; color: #fca5a5; text-align: center; }

/* ---- Golden relic & frenzy ---- */
.golden-relic {
  position: fixed; z-index: 9000; width: 64px; height: 64px; font-size: 38px; cursor: pointer;
  border-radius: 50%; border: 3px solid var(--accent-gold);
  background: radial-gradient(circle, rgba(251,191,36,.45), rgba(15,23,42,.9));
  animation: relicFloat 1.6s ease-in-out infinite, relicGlow 1s ease-in-out infinite alternate;
}
@keyframes relicFloat { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-14px) rotate(6deg); } }
@keyframes relicGlow { from { box-shadow: 0 0 14px rgba(251,191,36,.5); } to { box-shadow: 0 0 36px rgba(251,191,36,1); } }
.frenzy-chip { border-color: var(--accent-crimson); color: #fca5a5; animation: comboMax .5s ease-in-out infinite alternate; }
.frenzy-chip.hidden { display: none; }

/* ---- Tutorial ---- */
.tutorial-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; }
.tutorial-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.tutorial-dots span.on { background: var(--accent-gold); width: 22px; border-radius: 9999px; }
#tutorial-overlay { z-index: 13000; }

/* ---- Mobile / touch ---- */
html, body { -webkit-tap-highlight-color: transparent; }
.orb-wrapper, .tab-btn, .btn-rounded { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.bestiary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bestiary-card { background: rgba(2,6,23,.6); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.bestiary-card img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.bestiary-card.locked img { filter: brightness(0) contrast(0.6); opacity: .5; }
.bestiary-card .b-name { font-size: 10px; font-weight: 900; margin-top: 4px; color: #fff; }

@media (max-width: 980px) {
  .main-layout { padding: 0 12px 16px; gap: 14px; }
  .clicker-container { padding: 20px 12px; }
}
@media (max-width: 600px) {
  .app-header { padding: 10px 12px; gap: 8px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); margin-bottom: 12px; }
  .brand-title { font-size: 16px; }
  .header-center-controls { order: 3; width: 100%; justify-content: space-between; }
  .currencies-bar { width: 100%; justify-content: space-between; gap: 6px; }
  .currency-badge { padding: 5px 10px; flex: 1; }
  .clicker-orb { width: 170px; height: 170px; border-radius: 38px; }
  .orb-mascot-img { border-radius: 32px; }
  .stats-strip { flex-wrap: wrap; justify-content: center; }
  .tab-nav { gap: 2px; padding: 6px; }
  .tab-btn { font-size: 10px; padding: 8px 0; }
  .sidebar-panel { max-height: none; }
  .modal-card { max-width: 94vw; }
}
