/* Spider Arena — UI-Styles (self-hosted, system fonts) */

:root {
  --bg: #14180c;
  --panel: rgba(20, 24, 12, 0.92);
  --panel-border: rgba(140, 170, 90, 0.35);
  --text: #e8ecdc;
  --muted: #9aa882;
  --accent: #aadd44;
  --accent-dark: #6a9a20;
  --danger: #d62828;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}

#game { display: block; cursor: crosshair; }

.hidden { display: none !important; }

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, rgba(30, 40, 16, 0.88), rgba(8, 10, 4, 0.96));
  z-index: 20;
  padding: 24px;
}

.overlay h1 {
  font-size: clamp(2.2rem, 6vw, 4rem);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 4px 24px rgba(170, 221, 68, 0.35);
}

.overlay h2 { font-size: clamp(1.4rem, 4vw, 2.2rem); color: var(--accent); }

.subtitle { color: var(--muted); font-size: 1.1rem; }

.btn {
  min-width: 220px;
  min-height: 52px;
  padding: 14px 32px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #182006;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(170, 221, 68, 0.3); }
.btn:active { transform: translateY(0); }
.btn.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--panel-border);
}

/* ---------- Artenwahl & Dex ---------- */

#dex-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  max-width: 1100px;
  width: 100%;
  max-height: 65vh;
  overflow-y: auto;
  padding: 6px;
}

.dex-stats .stat-row span:last-child { color: var(--accent); }

#species-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  max-width: 1100px;
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}

.species-card {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.species-card:hover { transform: translateY(-3px); }
.species-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 18px rgba(170, 221, 68, 0.25);
}

.species-name { font-weight: 700; font-size: 1.02rem; }

.species-stats { width: 100%; display: flex; flex-direction: column; gap: 2px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}
.stat-row .dots { color: var(--accent); letter-spacing: 2px; }

.species-special {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
  min-height: 2.6em;
}

.menu-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.menu-home-link {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
}
.menu-home-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud-top {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 240px;
}

.bar {
  width: 100%;
  height: 14px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 7px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 7px; transition: width 0.15s ease; }
#hud-hp-fill { background: linear-gradient(90deg, #6abe30, #aadd44); width: 100%; }
#hud-special-fill { background: linear-gradient(90deg, #7a4ddd, #b06ee8); width: 100%; }

.hud-label { font-size: 0.75rem; color: var(--muted); margin-bottom: -4px; }

#hud-row-stats {
  display: flex;
  gap: 14px;
  font-size: 0.88rem;
  color: var(--text);
}

#hud-values {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--panel-border);
  padding-top: 6px;
}
#hud-values b { color: var(--accent); font-weight: 700; }
#hud-values:empty { display: none; }

#hud-feed {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.feed-msg {
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 14px;
  font-size: 0.86rem;
  color: var(--text);
}
.feed-msg.feed-event {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: 0 0 16px rgba(170, 221, 68, 0.25);
  animation: tip-pop 0.3s ease;
}

#minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  border-radius: 10px;
}

#hud-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 14px;
}
#hud-hint:empty { display: none; }

#btn-hud-menu {
  position: absolute;
  top: 14px;
  right: 14px;
  pointer-events: auto;
  min-width: unset;
  min-height: 44px;
  padding: 8px 20px;
  font-size: 0.95rem;
}

#hud-daynight {
  position: absolute;
  right: 14px;
  bottom: 186px;
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 0.85rem;
  color: var(--text);
}

/* ---------- Gesperrte Arten & Erfolge ---------- */

.species-card.locked {
  opacity: 0.45;
  filter: grayscale(0.9);
  cursor: not-allowed;
}
.species-card.locked .species-special { color: #d8a948; }

#ach-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px 18px;
  max-width: 1100px;
  width: 100%;
  padding: 6px;
}
.ach-row {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 12px;
}
.ach-row.done { color: var(--accent); }

/* ---------- Metamorphose ---------- */

#morph-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 16px 18px;
  pointer-events: auto;
  box-shadow: 0 0 40px rgba(170, 221, 68, 0.35);
  max-width: 480px;
}
#morph-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  text-align: center;
}
#morph-buttons { display: flex; flex-direction: column; gap: 8px; }
#morph-buttons button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 6px 12px;
  text-align: left;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
}
#morph-buttons button:hover { border-color: var(--accent); }
#morph-buttons button small { color: var(--muted); }
#morph-buttons .morph-skip { justify-content: center; color: var(--muted); }

/* ---------- Skill-Panel ---------- */

#skill-panel {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  pointer-events: auto;
  box-shadow: 0 0 24px rgba(170, 221, 68, 0.25);
}

#skill-count {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 0.92rem;
}

#skill-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

#skill-buttons button {
  min-height: 44px;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
#skill-buttons button:hover {
  border-color: var(--accent);
  background: rgba(170, 221, 68, 0.12);
}
#skill-buttons button b {
  color: var(--accent);
  margin-right: 4px;
}

/* ---------- Überblendung ---------- */

#fade {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1c2410, #060803);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 50;
}
#fade.active { opacity: 1; pointer-events: auto; }
#fade-spider {
  font-size: 3rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  animation: fade-spin 0.9s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6));
}
#fade.active #fade-spider { opacity: 1; }
@keyframes fade-spin {
  0%, 100% { transform: scale(1) rotate(-12deg); }
  50% { transform: scale(1.25) rotate(12deg); }
}

/* ---------- Loading ---------- */

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 1.1rem;
  color: var(--muted);
  z-index: 30;
  background: radial-gradient(ellipse at center, #1c2410, #0a0d05);
}

.load-stage { position: relative; height: 140px; width: 80px; }
.load-thread {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  background: linear-gradient(180deg, rgba(240,244,255,0.7), rgba(240,244,255,0.15));
  animation: thread-grow 1.6s ease-in-out infinite alternate;
}
.load-spider {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.6rem;
  animation: spider-bob 1.6s ease-in-out infinite alternate;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5));
}
@keyframes thread-grow { from { height: 30px; } to { height: 95px; } }
@keyframes spider-bob { from { top: 18px; } to { top: 83px; } }
#load-text { animation: load-pulse 1.4s ease-in-out infinite; letter-spacing: 1px; }
@keyframes load-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Menü-Deko: Spinnennetze in den Ecken + Glühwürmchen */
.web-deco {
  position: absolute;
  width: min(34vw, 340px);
  height: min(34vw, 340px);
  color: rgba(220, 232, 200, 0.14);
  pointer-events: none;
}
.web-tl { top: 0; left: 0; }
.web-br { bottom: 0; right: 0; }

.firefly {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cdf07a;
  box-shadow: 0 0 12px 4px rgba(190, 255, 120, 0.55);
  pointer-events: none;
  animation: firefly-float 9s ease-in-out infinite, firefly-blink 2.3s ease-in-out infinite;
}
.f1 { top: 22%; left: 14%; animation-delay: 0s, 0.4s; }
.f2 { top: 64%; left: 78%; animation-delay: -3s, 1.1s; }
.f3 { top: 78%; left: 28%; animation-delay: -6s, 0s; }
.f4 { top: 30%; left: 66%; animation-delay: -1.5s, 1.7s; }
@keyframes firefly-float {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(34px, -28px); }
  50% { transform: translate(-22px, -52px); }
  75% { transform: translate(-40px, 14px); }
}
@keyframes firefly-blink { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }

#tip-banner {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 86vw);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 10px 22px;
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  box-shadow: 0 0 24px rgba(170, 221, 68, 0.3);
  animation: tip-pop 0.35s ease;
}
@keyframes tip-pop {
  from { transform: translateX(-50%) scale(0.85); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

#hud-fps {
  position: absolute;
  left: 14px;
  bottom: 14px;
  background: var(--panel);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--accent);
}

#pause-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 20px 36px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Touch ---------- */

#btn-touch-special {
  display: none;
  position: absolute;
  right: 24px;
  bottom: 200px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 1.8rem;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border: none;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
@media (pointer: coarse) {
  #btn-touch-special { display: block; }
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  #hud-top { min-width: 180px; padding: 10px 12px; }
  #minimap { width: 110px; height: 110px; }
  #species-list { max-height: 50vh; }
}
