/* ══════════════════════════════════════════════════
   JURN: NECROPOLIS RISING  v2.0  —  style.css
   ══════════════════════════════════════════════════ */

/* ── TITLE SCREEN ── */
#title-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#title-screen.hidden { display: none; }
#title-img {
  width: 100%;
  max-width: 960px;
  max-height: calc(100vh - 60px);
  object-fit: contain;
  display: block;
}
#title-footer {
  width: 100%;
  max-width: 960px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #0a0a14;
  border-top: 1px solid #1a1a2a;
  box-sizing: border-box;
}
#title-return {
  font-family: var(--font);
  font-size: 6px;
  color: #8855ff;
  text-decoration: none;
  letter-spacing: 1px;
  opacity: 0.8;
  transition: opacity 0.2s;
}
#title-return:hover { opacity: 1; color: #aa88ff; }
#title-click {
  font-family: var(--font);
  font-size: 7px;
  color: #c8a84b;
  letter-spacing: 2px;
  animation: blink-cta 1.2s step-end infinite;
}
@keyframes blink-cta { 0%,100%{opacity:1} 50%{opacity:0.1} }

:root {
  --bg:        #07070f;
  --panel:     #0e0e1a;
  --border:    #2a1a3a;
  --accent:    #c8a84b;
  --green:     #00e87a;
  --purple:    #8855ff;
  --red:       #ff3344;
  --orange:    #ff8c00;
  --cyan:      #00ccff;
  --text:      #d8d0c8;
  --dim:       #666677;
  --font:      'Press Start 2P', monospace;
}

/* ── SKINS ── */
body.skin-crimson  { --bg:#150505; --panel:#1a0808; --border:#3a0a0a; --accent:#ff3344; }
body.skin-void     { --bg:#000008; --panel:#080810; --border:#0a0a2a; --accent:#8855ff; }
body.skin-cosmic   { --bg:#000520; --panel:#000a30; --border:#001060; --accent:#00ccff; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 8px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── TOP BAR ── */
#top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #08080f;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
}

#title-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 160px;
}

#game-title {
  font-size: 7px;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent);
  letter-spacing: 1px;
  white-space: nowrap;
}

#skin-label {
  font-size: 5px;
  color: var(--purple);
}

#prestige-badge {
  font-size: 5px;
  color: var(--purple);
  background: rgba(136,85,255,0.12);
  border: 1px solid var(--purple);
  padding: 2px 6px;
  border-radius: 3px;
}

#resources {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

.res-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  min-width: 80px;
  transition: border-color 0.3s;
}
.res-pill:hover { border-color: var(--accent); }
.res-icon { font-size: 14px; line-height: 1; }
.res-nums { display: flex; flex-direction: column; gap: 1px; }
.res-val { font-size: 7px; color: var(--accent); }
.res-rate { font-size: 5px; color: var(--dim); }
.hidden { display: none !important; }

/* ── SCENE ── */
#scene-wrap {
  position: relative;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;

}

#world-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

/* ── BPC overlay — top of scene ── */
#bpc-overlay {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 5px;
  color: var(--dim);
  text-align: center;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* ── EFFECTS BAR ── */
#effects-bar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
  pointer-events: none;
}
.effect-pill {
  background: rgba(0,0,0,0.8);
  border: 1px solid;
  border-radius: 3px;
  padding: 3px 7px;
  font-size: 5px;
  text-shadow: 0 0 6px currentColor;
}

/* ── CZ TICKER ── */
#cz-ticker-bar {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: rgba(0,0,0,0.7);
  border-top: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 5px;
  color: var(--red);
  text-shadow: 0 0 6px var(--red);
  overflow: hidden;
  white-space: nowrap;
  z-index: 20;
}

/* ── CZ EVENT OVERLAY ── */
#cz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cz-content {
  position: relative;
  background: #080812;
  border: 2px solid var(--accent);
  border-radius: 4px;
  padding: 28px 32px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 0 40px rgba(200,168,75,0.3);
}
#cz-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(transparent, transparent 2px, rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px);
  pointer-events: none;
  z-index: 1;
}
#cz-event-title {
  font-size: 10px;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent);
  margin-bottom: 16px;
  position: relative; z-index: 2;
}
#cz-event-msg {
  font-size: 7px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 12px;
  position: relative; z-index: 2;
}
#cz-event-sub {
  font-size: 6px;
  color: var(--green);
  margin-bottom: 16px;
  position: relative; z-index: 2;
}
.btn-cz { position: relative; z-index: 2; }

/* ── SHOP PANEL ── */
#shop-panel {
  max-width: 960px;
  margin: 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

#shop-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.stab {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--dim);
  font-family: var(--font);
  font-size: 6px;
  padding: 12px 4px;
  cursor: pointer;
  transition: all 0.15s;
}
.stab:last-child { border-right: none; }
.stab:hover { color: var(--accent); background: rgba(200,168,75,0.05); }
.stab.active { color: var(--accent); background: rgba(200,168,75,0.1); border-bottom: 2px solid var(--accent); }

.shop-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.shop-content::-webkit-scrollbar { width: 4px; }
.shop-content::-webkit-scrollbar-track { background: var(--bg); }
.shop-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── BUILDING CARDS ── */
.bld-card {
  background: #0b0b18;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  transition: border-color 0.2s;
  opacity: 0.45;
  overflow: hidden;
  min-width: 0;
}
.bld-card.unlocked { opacity: 1; }
.bld-card.can-afford { border-color: rgba(200,168,75,0.5); }
.bld-card.can-afford:hover { border-color: var(--accent); box-shadow: 0 0 8px rgba(200,168,75,0.15); }

.bld-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.bld-icon-name { display: flex; align-items: center; gap: 6px; }
.bld-icon { font-size: 16px; }
.bld-name { font-size: 6px; color: var(--accent); line-height: 1.4; }
.bld-owned { font-size: 9px; color: var(--accent); min-width: 24px; text-align: right; font-weight: bold; }
.bld-desc { font-size: 5px; color: var(--dim); line-height: 1.7; margin-bottom: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bld-flavor { font-size: 5px; color: #2a2a3a; line-height: 1.5; margin-bottom: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bld-cost { font-size: 5px; color: var(--text); margin-bottom: 3px; min-height: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }
.bld-production { font-size: 5px; color: var(--green); margin-bottom: 6px; overflow: hidden; }
.bld-buy-btns { display: flex; gap: 4px; overflow: hidden; min-width: 0; }
.bld-buy-btns .btn { flex: 1; min-width: 0; overflow: hidden; white-space: normal; text-align: center; }

/* ── UPGRADE CARDS ── */
.upg-card {
  background: #0b0b18;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0.4;
  cursor: default;
  overflow: hidden;
  min-width: 0;
}
.upg-card.unlocked { opacity: 1; }
.upg-card.can-afford { border-color: rgba(200,168,75,0.4); }
.upg-card.bought { opacity: 0.3; cursor: default; background: rgba(0,232,122,0.03); border-color: rgba(0,232,122,0.2); }
.upg-card.bought:hover { border-color: rgba(0,232,122,0.2); background: rgba(0,232,122,0.03); }
.upg-header { display: flex; align-items: center; gap: 6px; }
.upg-icon { font-size: 14px; }
.upg-name { font-size: 6px; color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.upg-desc { font-size: 5px; color: var(--dim); overflow: hidden; }
.upg-cost { font-size: 5px; color: var(--accent); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }
.upg-bought-label { font-size: 5px; color: var(--green); }
.upg-locked-label { font-size: 4.5px; color: #444; letter-spacing: 1px; }
.upg-buy-btn { width: 100%; white-space: normal; text-align: center; overflow: hidden; box-sizing: border-box; }

/* ── BAND CARDS ── */
.band-card {
  background: #0b0b18;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  opacity: 0.4;
}
.band-card.unlocked { opacity: 1; border-color: rgba(200,168,75,0.3); }
.band-icon { font-size: 24px; }
.band-info { flex: 1; }
.band-name { font-size: 7px; margin-bottom: 3px; }
.band-title { font-size: 5px; color: var(--dim); margin-bottom: 5px; }
.band-lore { font-size: 5px; color: var(--text); line-height: 1.7; margin-bottom: 5px; }
.band-bonus { font-size: 5px; color: var(--green); }
.band-locked { font-size: 5px; color: var(--dim); font-style: italic; }

/* ── STATS ── */
.stat-grid { padding: 8px; }
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-label { font-size: 5px; color: var(--dim); }
.stat-val { font-size: 5px; color: var(--accent); }

/* ── LORE SECTION ── */
#lore-section { padding: 8px; }
.lore-entry { 
  background: rgba(136,85,255,0.05);
  border: 1px solid rgba(136,85,255,0.2);
  border-radius: 3px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 5px;
  color: var(--text);
  line-height: 1.8;
}
.lore-entry .lore-title { color: var(--purple); margin-bottom: 4px; }

/* ── FOOTER ── */
#footer-bar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: #05050e;
  border-top: 1px solid var(--border);
  max-width: 960px;
  margin: 0 auto;
  flex-wrap: wrap;
}

/* ── BUTTONS ── */
.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 6px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
  white-space: nowrap;
  min-height: 30px;
  line-height: 1.3;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.btn-cost {
  display: block;
  font-size: 4.5px;
  color: var(--dim);
  opacity: 0.85;
  margin-top: 2px;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
}
.btn:hover .btn-cost { color: var(--accent); }
.btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(200,168,75,0.07); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-save { border-color: #2a3a2a; color: var(--green); }
.btn-save:hover { border-color: var(--green); background: rgba(0,232,122,0.07); }
.btn-danger { border-color: var(--purple); color: var(--purple); }
.btn-danger:hover { background: rgba(136,85,255,0.1); }
.btn-prestige { animation: pulse-prestige 2s infinite; }
.btn-newgame { border-color: #ff3344; color: #ff3344; opacity: 0.7; font-size: 5px; }
.btn-newgame:hover { background: rgba(255,51,68,0.12); opacity: 1; }
@keyframes pulse-prestige {
  0%,100%{ box-shadow: 0 0 6px rgba(136,85,255,0.3); }
  50%{ box-shadow: 0 0 16px rgba(136,85,255,0.7); }
}

/* ── MODALS ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px 28px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}
.modal-title { font-size: 10px; color: var(--accent); margin-bottom: 16px; }
.modal-body { font-size: 6px; color: var(--text); line-height: 2; margin-bottom: 12px; }
.modal-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ── MILESTONE TOAST ── */
#milestone-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(7,7,15,0.95);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 20px 28px;
  text-align: center;
  z-index: 700;
  box-shadow: 0 0 30px rgba(200,168,75,0.4);
  animation: toastIn 0.3s ease;
  min-width: 280px;
}
@keyframes toastIn {
  from{ opacity:0; transform:translate(-50%,-50%) scale(0.85) }
  to{ opacity:1; transform:translate(-50%,-50%) scale(1) }
}
#ms-icon { font-size: 28px; margin-bottom: 8px; }
#ms-msg { font-size: 7px; color: var(--accent); line-height: 1.6; }

/* ── FLOAT LAYER ── */
#float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 800; overflow: hidden; }
.float-val {
  position: absolute;
  font-family: var(--font);
  font-size: 7px;
  font-weight: bold;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  animation: floatUp 1.2s ease forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0%{ opacity:1; transform: translateY(0) }
  100%{ opacity:0; transform: translateY(-60px) }
}
.float-msg {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 12px;
  font-family: var(--font);
  font-size: 6px;
  z-index: 900;
  animation: msgPop 1.5s ease forwards;
  white-space: nowrap;
}
@keyframes msgPop {
  0%{ opacity:0; transform:translateX(-50%) translateY(8px) }
  20%{ opacity:1; transform:translateX(-50%) translateY(0) }
  80%{ opacity:1 }
  100%{ opacity:0; transform:translateX(-50%) translateY(-8px) }
}

/* ── RESPONSIVE ── */
@media(max-width:640px){
  #game-title{ font-size:5px }
  .res-pill{ min-width:60px; padding:3px 5px; }
  .res-val{ font-size:6px }
  .shop-content{ max-height:280px; }
}

/* ── ATMOSPHERE OVERLAY ─────────────────────────────────── */
#atmo-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 50;
  border-radius: 4px;
  overflow: hidden;
}

/* CRT: scanlines + vignette */
.atmo-crt {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px, transparent 3px,
      rgba(0,0,0,0.14) 3px, rgba(0,0,0,0.14) 4px
    );
  box-shadow: inset 0 0 80px 20px rgba(0,0,0,0.55);
  animation: crt-flicker 8s infinite;
}
@keyframes crt-flicker {
  0%,95%,100%{ opacity:1 }
  96%{ opacity:0.96 }
  97%{ opacity:0.88 }
  98%{ opacity:0.97 }
}

/* VHS: color fringe + horizontal bands + wobble */
.atmo-vhs {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 49px,
    rgba(180,0,0,0.04) 49px, rgba(180,0,0,0.04) 51px,
    transparent 51px
  );
  animation: vhs-wobble 4s infinite;
}
@keyframes vhs-wobble {
  0%,100%{ filter: none; }
  2%{ filter: hue-rotate(5deg) saturate(1.3) blur(0.4px); transform: translateX(1.5px); }
  4%{ filter: none; transform: translateX(0); }
  40%{ filter: hue-rotate(-3deg); }
  42%{ filter: none; }
  70%{ transform: translateX(-1px) skewX(-0.3deg); }
  71%{ transform: translateX(0) skewX(0); }
}

/* STATIC: noise via animated gradient */
.atmo-static {
  animation: static-noise 0.08s steps(1) infinite;
  background-size: 3px 3px;
}
@keyframes static-noise {
  0%  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E"); }
  25% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='1' stitchTiles='stitch' seed='7'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"); }
  50% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='1' stitchTiles='stitch' seed='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E"); }
  75% { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.88' numOctaves='1' stitchTiles='stitch' seed='12'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E"); }
}

/* GLOW: neon bloom */
.atmo-glow {
  background: radial-gradient(ellipse at 30% 70%, rgba(0,232,122,0.07) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 30%, rgba(200,168,75,0.07) 0%, transparent 55%),
              radial-gradient(ellipse at 50% 50%, rgba(136,85,255,0.05) 0%, transparent 70%);
  animation: glow-pulse 3s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes glow-pulse {
  0%,100%{ opacity:0.7 }
  50%{ opacity:1.2 }
}

/* FOG: drifting mist */
.atmo-fog {
  background: radial-gradient(ellipse at 50% 100%, rgba(120,140,160,0.18) 0%, transparent 70%);
  animation: fog-drift 12s ease-in-out infinite alternate;
}
@keyframes fog-drift {
  0%{ background-position: 0% 100%; opacity:0.6; }
  50%{ opacity:1; }
  100%{ background-position: 30% 90%; opacity:0.7; }
}

/* ── ATMOSPHERE CONTROLS ─────────────────────────────────── */
#atmo-controls {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 60;
}
.atmo-label {
  font-family: var(--font);
  font-size: 5px;
  color: #555;
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.atmo-btn {
  font-family: var(--font);
  font-size: 5px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #333;
  color: #555;
  padding: 4px 7px;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 1px;
  transition: color 0.15s, border-color 0.15s;
  min-width: 46px;
}
.atmo-btn:hover { color: #aaa; border-color: #666; }
.atmo-btn.active { color: var(--gold); border-color: var(--gold); }


/* ─── Debug Panel ─── */
#debug-panel {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: rgba(0,0,0,0.85);
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 9999;
  font-family: 'Courier New', monospace;
}
.debug-title {
  font-size: 10px;
  color: #666;
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.dbtn {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 3px;
  text-align: center;
  transition: background 0.15s;
}
.dbtn:hover { background: #2a2a2a; border-color: #555; color: #fff; }
.dbtn-all { color: #c8a84b; border-color: #c8a84b66; }
.dbtn-all:hover { background: #1a1600; color: #ffdd77; }
.dbtn-res { color: #7ec870; border-color: #7ec87066; }
.dbtn-res:hover { background: #0d1a0d; color: #a0f098; }
