* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a0a12; font-family: 'Press Start 2P', monospace; }
#canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; z-index: 1; }
#ui-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
#ui-overlay > * { pointer-events: auto; }

@keyframes wobble { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }
@keyframes slideIn { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }
@keyframes tvStatic { 0%{opacity:0} 10%{opacity:0.3} 20%{opacity:0} 50%{opacity:0.1} 60%{opacity:0} 80%{opacity:0.2} 100%{opacity:0} }
@keyframes popIn { 0%{transform:scale(0.5);opacity:0} 50%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
@keyframes fadeInUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
@keyframes scanlines { 0%{background-position:0 0} 100%{background-position:0 4px} }

.pixel-border {
  border: 3px solid;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='6'%3E%3Crect width='6' height='6' fill='%23443355'/%3E%3Crect x='1' y='1' width='4' height='4' fill='%231a1a2e'/%3E%3C/svg%3E") 2 stretch;
  image-rendering: pixelated;
}

.menu-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 12px 24px;
  background: #1a1a2e;
  color: #e0d0ff;
  border: 2px solid #443355;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  display: block;
  width: 260px;
  position: relative;
  letter-spacing: 1px;
}
.menu-btn:hover {
  background: #2a1a4e;
  border-color: #8855cc;
  color: #fff;
  transform: scale(1.03);
  box-shadow: 0 0 12px rgba(136,85,204,0.4);
}
.menu-btn:active { transform: scale(0.98); }
.menu-btn-icon { margin-right: 8px; }

.hud-panel {
  background: rgba(10,10,18,0.85);
  border: 2px solid #332244;
  padding: 6px 10px;
  backdrop-filter: blur(2px);
}

.health-heart { display: inline-block; width: 14px; height: 14px; margin: 1px; }
.health-heart-full { background: #cc2244; clip-path: polygon(50% 15%, 100% 0, 100% 60%, 50% 100%, 0 60%, 0 0); }
.health-heart-empty { background: #331122; clip-path: polygon(50% 15%, 100% 0, 100% 60%, 50% 100%, 0 60%, 0 0); }
.health-heart-half { background: linear-gradient(90deg, #cc2244 50%, #331122 50%); clip-path: polygon(50% 15%, 100% 0, 100% 60%, 50% 100%, 0 60%, 0 0); }

.tv-frame {
  width: 90px; height: 90px;
  background: #222;
  border: 3px solid #555;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(0,0,0,0.8), inset 0 0 15px rgba(0,0,0,0.5);
}
.tv-frame::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px);
  animation: tvStatic 0.3s infinite;
  pointer-events: none;
}
.tv-antenna { position:absolute; top:-12px; left:50%; transform:translateX(-50%); }
.tv-antenna::before,.tv-antenna::after { content:''; position:absolute; width:2px; height:12px; background:#555; }
.tv-antenna::before { left:-8px; transform:rotate(-20deg); }
.tv-antenna::after { left:6px; transform:rotate(20deg); }

.ability-slot {
  width: 48px; height: 48px;
  background: rgba(20,15,30,0.9);
  border: 2px solid #443355;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.ability-slot:hover { border-color: #8855cc; }
.ability-cooldown {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.7);
  color: #aaa;
  font-size: 7px;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
}
.ability-key {
  position: absolute; top: -1px; right: 2px;
  font-size: 6px;
  color: #887;
  font-family: 'Press Start 2P', monospace;
}

.dialogue-box {
  position: absolute;
  bottom: 20px;
  left: 50%; transform: translateX(-50%);
  width: min(700px, 90vw);
  background: rgba(15,10,25,0.95);
  border: 3px solid #554477;
  padding: 16px;
  animation: slideIn 0.3s;
}

.notification {
  animation: fadeInUp 0.3s, fadeInUp 0.3s reverse forwards 2.5s;
  font-size: 9px;
  padding: 6px 12px;
  background: rgba(15,10,25,0.9);
  border: 1px solid #554477;
  color: #e0d0ff;
  margin-bottom: 4px;
  white-space: nowrap;
}

.minimap-room {
  width: 14px; height: 14px;
  border: 1px solid #443355;
  display: inline-block;
  margin: 1px;
  transition: all 0.2s;
}
.minimap-room.current { background: #8855cc; border-color: #aa77ee; box-shadow: 0 0 4px #8855cc; }
.minimap-room.explored { background: #332244; }
.minimap-room.unexplored { background: #1a1a2e; }
.minimap-room.boss { background: #881133; border-color: #cc2255; }
.minimap-room.shop { background: #336633; border-color: #55aa55; }

.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeInUp 0.2s;
}
.modal-content {
  background: #12101e;
  border: 3px solid #443355;
  padding: 24px;
  max-width: min(600px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  width: 100%;
}
.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: #1a1a2e; }
.modal-content::-webkit-scrollbar-thumb { background: #443355; }

.tab-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 8px 14px;
  background: #1a1a2e;
  color: #887799;
  border: 2px solid #332244;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn.active { background: #2a1a4e; color: #e0d0ff; border-color: #8855cc; }
.tab-btn:hover { color: #ccbbee; }

.expression-slot {
  width: 80px; height: 80px;
  background: #1a1a2e;
  border: 2px dashed #443355;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  overflow: hidden;
}
.expression-slot:hover { border-color: #8855cc; background: #221a3e; }
.expression-slot img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.expression-remove {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: #cc2244;
  color: white;
  font-size: 8px;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Press Start 2P', monospace;
  z-index: 2;
}

.color-pick {
  width: 28px; height: 28px;
  border: 2px solid #443355;
  cursor: pointer;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  background: none;
}
.color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick::-webkit-color-swatch { border: none; }

.difficulty-card {
  padding: 12px;
  background: #1a1a2e;
  border: 2px solid #332244;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}
.difficulty-card:hover { border-color: #8855cc; }
.difficulty-card.selected { border-color: #aa77ee; background: #2a1a4e; box-shadow: 0 0 8px rgba(136,85,204,0.3); }

.modifier-card {
  padding: 8px;
  background: #1a1a2e;
  border: 2px solid #332244;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 7px;
  text-align: center;
  min-width: 80px;
}
.modifier-card:hover { border-color: #665588; }
.modifier-card.active { border-color: #88cc55; background: #1a2e1a; }

.currency-display {
  display: flex; gap: 12px; align-items: center;
  font-size: 9px; color: #ccbbdd;
}
.currency-item { display: flex; align-items: center; gap: 4px; }
.currency-icon { font-size: 14px; }
.currency-count { color: #ffd700; }

.rarity-common { color: #cccccc; }
.rarity-uncommon { color: #55cc55; }
.rarity-rare { color: #5588ff; }
.rarity-epic { color: #aa55cc; }
.rarity-legendary { color: #ffcc00; text-shadow: 0 0 6px rgba(255,204,0,0.5); }

.path-node {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid #443355;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  background: #1a1a2e;
}
.path-node:hover { border-color: #8855cc; transform: scale(1.15); }
.path-node.available { border-color: #88cc55; box-shadow: 0 0 8px rgba(136,204,85,0.3); }
.path-node.current { border-color: #ffcc00; box-shadow: 0 0 10px rgba(255,204,0,0.4); }
.path-node.completed { opacity: 0.5; }

.weapon-tooltip {
  position: absolute;
  background: rgba(15,10,25,0.95);
  border: 2px solid #554477;
  padding: 10px;
  font-size: 8px;
  color: #ccbbdd;
  z-index: 50;
  min-width: 180px;
  pointer-events: none;
}

.scanline-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 4px);
  pointer-events: none;
  z-index: 999;
}

/* Mobile controls */
.mobile-controls {
  position: fixed; bottom: 10px; left: 10px; right: 10px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 20;
}
@media (max-width: 768px) {
  .mobile-controls { display: flex; }
}
.dpad { position: relative; width: 120px; height: 120px; }
.dpad-btn {
  position: absolute;
  width: 38px; height: 38px;
  background: rgba(60,40,80,0.6);
  border: 2px solid rgba(136,85,204,0.4);
  color: #ccbbdd;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.dpad-btn:active { background: rgba(136,85,204,0.4); }
.dpad-up { top: 0; left: 50%; transform: translateX(-50%); border-radius: 6px 6px 0 0; }
.dpad-down { bottom: 0; left: 50%; transform: translateX(-50%); border-radius: 0 0 6px 6px; }
.dpad-left { left: 0; top: 50%; transform: translateY(-50%); border-radius: 6px 0 0 6px; }
.dpad-right { right: 0; top: 50%; transform: translateY(-50%); border-radius: 0 6px 6px 0; }
.action-btns { display: flex; gap: 8px; }
.action-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(60,40,80,0.6);
  border: 2px solid rgba(136,85,204,0.4);
  color: #ccbbdd;
  font-size: 10px;
  font-family: 'Press Start 2P', monospace;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.action-btn:active { background: rgba(136,85,204,0.5); }