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

body {
  background: #050510;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
}

#game-wrapper {
  position: relative;
  width: 800px;
  height: 600px;
  max-width: 100vw;
  max-height: calc(100vh - 30px);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 10;
}

#hud > div { pointer-events: auto; }

#hud-top-left {
  position: absolute;
  top: 10px; left: 10px;
}

#hud-top-center {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#hud-top-right {
  position: absolute;
  top: 10px; right: 10px;
}

#hud-right {
  position: absolute;
  top: 80px; right: 10px;
  max-height: 400px;
  overflow-y: auto;
}

#hud-bottom {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

#hud-interact {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

#ui-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden { display: none !important; }

.hp-bar {
  height: 18px;
  background: #1a1a1a;
  border: 2px solid #333;
  position: relative;
  min-width: 180px;
}
.hp-bar-fill {
  height: 100%;
  transition: width 0.25s ease-out;
}
.hp-bar-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 7px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.stamina-bar {
  height: 10px;
  background: #0f0f0f;
  border: 2px solid #2a2200;
  position: relative;
  min-width: 180px;
  margin-top: 2px;
}
.stamina-bar-fill {
  height: 100%;
  transition: width 0.15s ease-out;
}
.stamina-bar-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6px;
  color: #ffe090;
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.timer-display {
  font-size: 20px;
  color: #ddd;
  text-shadow: 0 0 8px #4B0082;
  padding: 4px 12px;
  background: rgba(13,13,26,0.85);
  border: 2px solid #4B0082;
}
.timer-display.urgent {
  color: #ff3333;
  animation: pulse-red 0.5s infinite alternate;
}

@keyframes pulse-red {
  from { text-shadow: 0 0 8px #8B0000; }
  to { text-shadow: 0 0 20px #ff0000; }
}

.survivor-icons {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 4px;
}
.survivor-icon {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid #555;
}
.survivor-icon.dead {
  opacity: 0.3;
  position: relative;
}

.ability-slot {
  width: 52px; height: 52px;
  background: rgba(13,13,26,0.9);
  border: 2px solid #4B0082;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.ability-slot.ready { border-color: #6A0DAD; box-shadow: 0 0 6px #6A0DAD; }
.ability-slot .key-label {
  font-size: 6px;
  color: #aaa;
  position: absolute;
  top: 2px; left: 50%;
  transform: translateX(-50%);
}
.ability-slot .ability-name {
  font-size: 5px;
  color: #ccc;
  text-align: center;
  margin-top: 8px;
}
.ability-slot .cd-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.7);
  transition: height 0.1s linear;
}
.ability-slot .cd-text {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6px;
  color: #ff6666;
}
.ability-slot.passive {
  width: 36px; height: 36px;
  border-color: #333;
}

.effect-item {
  font-size: 6px;
  padding: 3px 6px;
  margin-bottom: 2px;
  background: rgba(13,13,26,0.85);
  border-left: 3px solid;
  color: #ccc;
  white-space: nowrap;
}

.interact-prompt {
  font-size: 8px;
  color: #6fa8ff;
  padding: 6px 12px;
  background: rgba(13,13,26,0.9);
  border: 2px solid #00008B;
}
.interact-bar {
  height: 6px;
  background: #1a1a1a;
  margin-top: 4px;
  border: 1px solid #333;
}
.interact-bar-fill {
  height: 100%;
  background: #00008B;
  transition: width 0.05s;
}

footer {
  padding: 6px;
  text-align: center;
}
footer a {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #6A0DAD;
  text-decoration: none;
}
footer a:hover { color: #9B59B6; }

.overlay-panel {
  background: rgba(13,13,26,0.95);
  border: 2px solid #4B0082;
  padding: 20px;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  color: #ccc;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 10px 18px;
  border: 2px solid #4B0082;
  background: #1A1A5E;
  color: #ddd;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: #4B0082; color: #fff; }
.btn.red { border-color: #8B0000; background: #3a0000; }
.btn.red:hover { background: #8B0000; }
.btn.green { border-color: #006600; background: #003300; }
.btn.green:hover { background: #006600; }
.btn:disabled { opacity: 0.4; cursor: default; }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.shop-card {
  background: rgba(20,20,40,0.9);
  border: 2px solid #333;
  padding: 10px;
  text-align: center;
}
.shop-card.equipped { border-color: #6A0DAD; }
.shop-card .char-name { font-size: 8px; color: #fff; margin: 6px 0 2px; }
.shop-card .char-role { font-size: 6px; color: #888; }
.shop-card .char-diff { font-size: 8px; color: #DAA520; margin: 4px 0; }
.shop-card .char-cost { font-size: 7px; color: #FFD700; margin: 4px 0; }

.results-stat {
  font-size: 8px;
  margin: 6px 0;
  color: #bbb;
}
.results-stat span { color: #fff; }

@keyframes float-up {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-40px); }
}