/* ───── Base / Reset ───── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0d0d1a;
  color: #c8c8d8;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
}

/* ───── Typography ───── */
.game-title {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #cc2222;
  text-shadow:
    0 0 10px rgba(200, 30, 30, 0.6),
    0 0 30px rgba(200, 30, 30, 0.3),
    2px 2px 0 #1a0000;
  text-align: center;
}

.game-title-small {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #cc2222;
  text-shadow: 0 0 8px rgba(200, 30, 30, 0.4);
  white-space: nowrap;
}

.subtitle {
  text-align: center;
  color: #666;
  font-size: 1rem;
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

/* ───── Setup Screen ───── */
#setup-screen {
  max-width: 460px;
  margin: 0 auto;
  padding: 4rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.setup-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.setup-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.setup-section label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
}

.setup-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.setup-x {
  color: #666;
  font-size: 0.85rem;
}

.player-name-input,
.setup-input,
.setup-select {
  background: #1a1a2e;
  border: 1px solid #333348;
  color: #c8c8d8;
  padding: 0.55rem 0.75rem;
  border-radius: 4px;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

.player-name-input:focus,
.setup-input:focus,
.setup-select:focus {
  border-color: #4a9eff;
}

.setup-select {
  cursor: pointer;
}

.setup-select option {
  background: #1a1a2e;
}

.setup-input {
  width: 100%;
}

.setup-row .setup-input {
  flex: 1;
}

/* ───── Difficulty Buttons ───── */
.difficulty-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.65rem 0.5rem;
  text-align: center;
  border: 1px solid #333348;
  background: #1a1a2e;
  transition: border-color 0.2s, background 0.2s;
}

.difficulty-btn .diff-name {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.difficulty-btn .diff-desc {
  font-size: 0.65rem;
  color: #666;
  text-transform: none;
  letter-spacing: 0;
}

.difficulty-btn.active {
  border-color: #4a9eff;
  background: #1a3a5c;
}

.difficulty-btn.active .diff-desc {
  color: #88b8e8;
}

.difficulty-btn:hover:not(.active) {
  border-color: #555;
  background: #252540;
}

/* ───── Modal ───── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: #12121f;
  border: 1px solid #333348;
  border-radius: 8px;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #c8c8d8;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.modal-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-buttons .btn {
  flex: 1;
}

/* ───── Buttons ───── */
.btn {
  background: #1a1a2e;
  color: #c8c8d8;
  border: 1px solid #444;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-transform: uppercase;
}

.btn:hover {
  background: #252540;
  border-color: #666;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #1a3a5c;
  border-color: #4a9eff;
  color: #4a9eff;
}

.btn-primary:hover {
  background: #254a72;
}

.btn-danger {
  border-color: #cc4444;
  color: #cc4444;
}

.btn-danger:hover {
  background: #2e1a1a;
}

.btn-secondary {
  border-color: #6b6;
  color: #6b6;
}

.btn-secondary:hover {
  background: #1a2e1a;
}

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-large {
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* ───── Game Screen Layout ───── */
#game-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#game-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 1rem;
  background: #12121f;
  border-bottom: 1px solid #252540;
  flex-shrink: 0;
}

#turn-display {
  flex: 1;
  text-align: center;
}

.turn-player {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.turn-zombie {
  font-size: 1.15rem;
  font-weight: 700;
  color: #cc2222;
  animation: zombiePulse 0.7s ease-in-out infinite alternate;
}

@keyframes zombiePulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.moves-badge {
  display: inline-block;
  margin-left: 0.75rem;
  background: #1a3a5c;
  color: #4a9eff;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

#room-info {
  font-size: 0.85rem;
  color: #888;
  white-space: nowrap;
}

.exit-badge {
  background: #ffe042;
  color: #000;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.7rem;
  margin-left: 0.25rem;
}

.zombie-count {
  color: #cc4444;
  margin-left: 0.5rem;
}

#game-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ───── Canvas Area ───── */
#canvas-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a14;
  overflow: hidden;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  cursor: crosshair;
}

/* ───── Sidebar ───── */
#sidebar {
  width: 280px;
  min-width: 240px;
  background: #12121f;
  border-left: 1px solid #252540;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel {
  border-bottom: 1px solid #252540;
  padding: 0.75rem;
}

.panel h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  margin-bottom: 0.5rem;
}

/* ───── Current Player Panel ───── */
.player-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.player-stat {
  font-size: 0.8rem;
  color: #999;
}

.player-stat strong {
  color: #c8c8d8;
}

/* ───── Health Bars ───── */
.health-bar-container {
  width: 100%;
  height: 16px;
  background: #1a1a2e;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.health-bar-container.small {
  height: 8px;
  margin-top: 0.2rem;
}

.health-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.hp-high { background: #4ae04a; }
.hp-mid { background: #ffe042; }
.hp-low { background: #cc3333; }

.health-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ───── Action Buttons ───── */
#action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#action-buttons .btn {
  width: 100%;
}

/* ───── Players List ───── */
.player-list-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  flex-wrap: wrap;
}

.player-list-item.player-dead {
  opacity: 0.4;
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-list-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.player-list-item .health-bar-container {
  flex: 1;
  min-width: 60px;
}

.status-dead {
  font-size: 0.65rem;
  font-weight: 700;
  color: #cc3333;
  text-transform: uppercase;
}

.status-escaped {
  font-size: 0.65rem;
  font-weight: 700;
  color: #4ae04a;
  text-transform: uppercase;
}

/* ───── Inventory ───── */
.empty-inv {
  font-size: 0.8rem;
  color: #555;
  font-style: italic;
}

.inv-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: #1a1a2e;
  border: 1px solid #333348;
  border-radius: 4px;
  margin-bottom: 0.3rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.inv-item:hover {
  border-color: #4a9eff;
}

.inv-item.inv-equipped {
  border-color: #4ae04a;
  background: #1a2e1a;
}

.inv-name {
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
}

.inv-stats {
  font-size: 0.7rem;
  color: #888;
}

.inv-badge {
  background: #4ae04a;
  color: #000;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}

.inv-slot {
  background: #333;
  color: #aaa;
  font-size: 0.65rem;
  font-weight: 700;
  width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ───── Hotkey Reference ───── */
.hotkeys-ref {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid #2a2a3e;
  font-size: 0.7rem;
  color: #666;
  line-height: 1.8;
}

.hotkeys-ref span {
  display: inline-block;
  background: #1a1a2e;
  color: #999;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  border: 1px solid #333;
  font-family: monospace;
  font-size: 0.65rem;
  margin-right: 0.15rem;
  margin-left: 0.3rem;
}

.hotkeys-ref span:first-child {
  margin-left: 0;
}

/* ───── Attack Button ───── */
.btn-warning {
  background: #5a4a1a;
  border-color: #8a7a3a;
  color: #ffe042;
}

.btn-warning:hover {
  background: #6a5a2a;
  border-color: #aa9a4a;
}

/* ───── Game Log ───── */
#game-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
}

.log-entry {
  padding: 0.15rem 0;
  color: #888;
  border-bottom: 1px solid #1a1a2e;
}

.log-entry.log-new {
  color: #c8c8d8;
}

/* ───── Dice Display ───── */
#dice-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6rem;
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 20px rgba(74, 158, 255, 0.8),
    0 0 50px rgba(74, 158, 255, 0.4);
  pointer-events: none;
  z-index: 20;
}

#dice-display.hidden {
  display: none;
}

#dice-display.dice-animate {
  animation: diceIn 0.3s ease-out;
}

#dice-display.dice-fade {
  animation: diceFade 0.6s ease-in forwards;
}

@keyframes diceIn {
  from {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes diceFade {
  from { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -70%) scale(1.2); }
}

/* ───── Zombie Tooltip ───── */
#zombie-tooltip {
  position: absolute;
  background: #1a1a2e;
  border: 1px solid #cc4444;
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  pointer-events: none;
  z-index: 30;
  min-width: 140px;
}

#zombie-tooltip.hidden {
  display: none;
}

.zt-title {
  font-weight: 700;
  color: #cc4444;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.zt-stat {
  font-size: 0.75rem;
  color: #aaa;
}

.zt-range {
  margin-top: 4px;
  font-weight: bold;
  font-size: 0.8rem;
}

.zt-range.in-range {
  color: #4ae04a;
}

.zt-range.out-of-range {
  color: #ff4444;
}

/* ───── Room Map Overlay ───── */
#room-map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 20, 0.95);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#room-map-overlay.hidden {
  display: none;
}

#room-map-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

#room-map-header h2 {
  color: #c8c8d8;
  font-size: 1.3rem;
  font-weight: 700;
}

#map-canvas {
  border: 1px solid #333;
  border-radius: 4px;
  max-width: 100%;
  max-height: 70vh;
}

.btn-small {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ───── Escape Overlay ───── */
.escape-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 40, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.escape-overlay.visible {
  opacity: 1;
}

.escape-content {
  text-align: center;
}

.escape-title {
  font-size: 5rem;
  font-weight: 900;
  color: #4ae04a;
  text-shadow:
    0 0 20px rgba(74, 224, 74, 0.6),
    0 0 60px rgba(74, 224, 74, 0.3),
    0 4px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.15em;
  animation: escapePulse 1s ease-in-out infinite alternate;
}

.escape-subtitle {
  font-size: 1.5rem;
  color: #c8e8c8;
  margin-top: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

@keyframes escapePulse {
  from {
    transform: scale(1);
    text-shadow:
      0 0 20px rgba(74, 224, 74, 0.6),
      0 0 60px rgba(74, 224, 74, 0.3);
  }
  to {
    transform: scale(1.05);
    text-shadow:
      0 0 30px rgba(74, 224, 74, 0.8),
      0 0 80px rgba(74, 224, 74, 0.5);
  }
}

/* ───── Damage Popup ───── */
.damage-popup {
  position: absolute;
  color: #ff4444;
  font-size: 1.5rem;
  font-weight: 900;
  pointer-events: none;
  z-index: 25;
  animation: damageFloat 1s ease-out forwards;
  text-shadow: 0 0 6px rgba(255, 50, 50, 0.6);
}

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

/* ───── Toast Notifications ───── */
#toast-container {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 40;
  pointer-events: none;
  max-width: 300px;
}

.toast {
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  transform: translateX(120%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: auto;
}

.toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.toast-exit {
  transform: translateX(120%);
  opacity: 0;
}

.toast-info {
  background: #1a3a5c;
  border: 1px solid #4a9eff;
  color: #8cbfff;
}

.toast-success {
  background: #1a3a1a;
  border: 1px solid #4ae04a;
  color: #8cff8c;
}

.toast-danger {
  background: #3a1a1a;
  border: 1px solid #cc4444;
  color: #ff8c8c;
}

.toast-warning {
  background: #3a3a1a;
  border: 1px solid #ffe042;
  color: #ffe88c;
}

/* ───── End Screen ───── */
#end-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
  gap: 1.5rem;
}

.end-win .game-title {
  color: #4ae04a;
  text-shadow:
    0 0 10px rgba(74, 224, 74, 0.6),
    0 0 30px rgba(74, 224, 74, 0.3),
    2px 2px 0 #001a00;
}

.end-lose .game-title {
  color: #cc2222;
}

.end-subtitle {
  font-size: 1.15rem;
  color: #999;
}

.end-stats {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 1rem 0;
}

.end-player {
  font-size: 1rem;
  color: #aaa;
}

/* ───── Scrollbar ───── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #0d0d1a;
}

::-webkit-scrollbar-thumb {
  background: #333348;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #444;
}

/* ───── Responsive ───── */
@media (max-width: 900px) {
  #game-body {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    min-width: unset;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid #252540;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .panel {
    flex: 1;
    min-width: 200px;
  }

  #game-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .game-title {
    font-size: 2.2rem;
  }
}

@media (max-width: 600px) {
  .game-title {
    font-size: 1.8rem;
  }

  #dice-display {
    font-size: 4rem;
  }

  #sidebar {
    flex-direction: column;
    max-height: 50vh;
  }

  .panel {
    min-width: unset;
  }
}
