* { 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.clickable { cursor: pointer; }
.ability-slot.clickable:hover {
  border-color: #9B59B6;
  box-shadow: 0 0 8px #6A0DAD;
}
.ability-tooltip {
  position: absolute;
  bottom: 118%;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  background: rgba(8,8,18,0.97);
  border: 2px solid #6A0DAD;
  padding: 6px 8px;
  display: none;
  z-index: 30;
  text-align: left;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(106,13,173,0.6);
}
.ability-slot:hover .ability-tooltip { display: block; }
.ab-tip-name {
  font-size: 7px;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.3;
}
.ab-tip-type {
  font-size: 5px;
  color: #9B59B6;
  margin-bottom: 4px;
}
.ab-tip-desc {
  font-size: 5px;
  color: #bbb;
  line-height: 1.5;
  margin-bottom: 4px;
  white-space: normal;
}
.ab-tip-line {
  font-size: 5px;
  color: #ff8866;
}

.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;
}
.skillcheck-bar {
  position: relative;
  height: 12px;
  background: #1a1a1a;
  margin-top: 4px;
  border: 1px solid #444;
  overflow: hidden;
}
.skillcheck-zone {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(68,255,136,0.5);
  border-left: 1px solid #44ff88;
  border-right: 1px solid #44ff88;
}
.skillcheck-indicator {
  position: absolute;
  top: -1px; bottom: -1px;
  width: 3px;
  background: #ffcc33;
  box-shadow: 0 0 4px #ffcc33;
}

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;
}

.settings-panel {
  width: 380px;
  max-width: 92%;
  max-height: 88%;
  background: rgba(13,13,26,0.97);
  border: 2px solid #4B0082;
  box-shadow: 0 0 30px rgba(75,0,130,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 2px solid #4B0082;
  flex-shrink: 0;
}
.settings-header span {
  font-size: 12px;
  color: #9B59B6;
  text-shadow: 0 0 8px #4B0082;
}
.settings-close {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  padding: 2px 6px;
}
.settings-close:hover { color: #cc3333; }
.settings-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}
.settings-body::-webkit-scrollbar { width: 8px; }
.settings-body::-webkit-scrollbar-track { background: #111; }
.settings-body::-webkit-scrollbar-thumb { background: #4B0082; border-radius: 4px; }
.settings-body::-webkit-scrollbar-thumb:hover { background: #6A0DAD; }
.settings-body { scrollbar-width: thin; scrollbar-color: #4B0082 #111; }
.settings-section-title {
  font-size: 7px;
  color: #6A0DAD;
  margin: 14px 0 8px;
  letter-spacing: 1px;
}
.settings-section-title:first-child { margin-top: 0; }
.settings-controls { display: flex; flex-direction: column; gap: 7px; }
.settings-ctrl-row {
  font-size: 7px;
  color: #aaa;
  line-height: 1.4;
  word-break: break-word;
}
.settings-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 7px;
  color: #ccc;
  cursor: pointer;
}
.settings-check-row input { accent-color: #6A0DAD; width: 14px; height: 14px; cursor: pointer; }
.settings-hint {
  font-size: 5px;
  color: #555;
  margin: 5px 0 0 2px;
  line-height: 1.4;
}
.settings-stats { display: flex; flex-direction: column; gap: 6px; }
.settings-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 6px;
  color: #aaa;
  border-bottom: 1px solid #1e1e34;
  padding-bottom: 4px;
}
.settings-stat-row span:last-child { color: #fff; }
.settings-reset {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  margin: 18px auto 0;
  display: block;
  padding: 10px 20px;
  background: #3a0000;
  border: 1px solid #8B0000;
  color: #ddd;
  cursor: pointer;
}
.settings-reset:hover { background: #8B0000; color: #fff; }

.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); }
}