/* ============================================================
   Dungeon Crawler – Styles
   Wände: CSS-Verläufe (kein Emoji)
   Monster/Gegenstände/Spieler: Emojis
   ============================================================ */

:root {
  --bg-dark: #0d0b14;
  --bg-panel: #16131f;
  --bg-panel-2: #1d1929;
  --border: #2e2842;
  --text: #e8e2f5;
  --text-dim: #9a90b8;
  --accent: #c9a227;
  --accent-2: #7c5cff;
  --hp-green: #4caf50;
  --hp-mid: #ffb300;
  --hp-low: #e53935;
  --cell: 44px;
}

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

html,
body {
  height: 100%;
  background: var(--bg-dark);
  color: var(--text);
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ============ Buttons ============ */
.btn {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn:hover {
  background: #2a2440;
  border-color: var(--accent-2);
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(135deg, #7c5cff, #5a3fd4);
  border: none;
  font-size: 18px;
  padding: 14px 34px;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(124, 92, 255, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #8f70ff, #6a4fe0);
  box-shadow: 0 6px 24px rgba(124, 92, 255, 0.5);
}
.btn-small {
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 5px;
}

/* ============ Start / End screens ============ */
.start-box {
  text-align: center;
  max-width: 560px;
  padding: 40px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
}
.game-title {
  font-size: 42px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffd76a, #c9a227);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 16px;
}
.start-rules {
  text-align: left;
  background: var(--bg-panel-2);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 28px;
  line-height: 1.9;
  font-size: 14px;
}
.gameover-stats {
  background: var(--bg-panel-2);
  border-radius: 10px;
  padding: 14px 20px;
  margin-bottom: 24px;
  line-height: 1.9;
  font-size: 15px;
}

/* ============ Game layout ============ */
.game-layout {
  display: flex;
  gap: 16px;
  padding: 16px;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  overflow: hidden;
}

.dungeon-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.dungeon-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  font-size: 18px;
}
.hud-floor {
  font-weight: 700;
  color: var(--accent);
}
.hud-turn {
  color: var(--text-dim);
  font-size: 14px;
}

/* ============ Dungeon grid ============ */
/* Zellen-Größe passt sich dynamisch an den verfügbaren Platz an,
   damit Dungeon + Seitenpanel bei jeder Fenstergröße nebeneinander passen.
   Wichtig: Die Breite wird über min(100vw, 1200px) gedeckelt, weil
   .game-layout max-width: 1200px hat — sonst würde der Dungeon auf
   breiten Fenstern größer als der Container und überdeckt das Panel.
   Rechnung: Container − 32px Padding − 300px Panel − 16px Gap − 70px
   (Grid-Gaps/Paddding/Rahmen) = Platz für 24 Zellen. */
.dungeon {
  --cell: min(
    44px,
    calc((min(100vw, 1200px) - 418px) / 24),
    calc((100vh - 260px) / 16)
  );
  display: grid;
  grid-template-columns: repeat(24, var(--cell));
  grid-template-rows: repeat(16, var(--cell));
  gap: 2px;
  padding: 10px;
  background: #080610;
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.8),
    0 6px 30px rgba(0, 0, 0, 0.5);
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.6);
  line-height: 1;
  user-select: none;
  position: relative;
}

/* --- Wände: CSS-Verläufe (kein Emoji!) --- */
.cell-wall {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 40%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.5) 0%, transparent 45%),
    linear-gradient(180deg, #4a4258 0%, #35304a 55%, #241f38 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.12),
    inset 0 -3px 5px rgba(0, 0, 0, 0.55),
    0 2px 4px rgba(0, 0, 0, 0.4);
}
/* leichte Variation für organischeren Look */
.cell-wall.v1 {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 40%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.45) 0%, transparent 45%),
    linear-gradient(180deg, #514863 0%, #3a3452 55%, #272240 100%);
}
.cell-wall.v2 {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 40%),
    linear-gradient(315deg, rgba(0, 0, 0, 0.55) 0%, transparent 45%),
    linear-gradient(180deg, #443c55 0%, #302b45 55%, #201c33 100%);
}

/* --- Boden --- */
.cell-floor {
  background:
    radial-gradient(ellipse at 30% 25%, rgba(255, 255, 255, 0.03) 0%, transparent 60%),
    linear-gradient(180deg, #191527 0%, #131020 100%);
  border-radius: 3px;
}
.cell-floor.v1 {
  background:
    radial-gradient(ellipse at 70% 30%, rgba(255, 255, 255, 0.035) 0%, transparent 60%),
    linear-gradient(180deg, #1b1729 0%, #141122 100%);
}
.cell-floor.v2 {
  background:
    radial-gradient(ellipse at 40% 70%, rgba(255, 255, 255, 0.025) 0%, transparent 60%),
    linear-gradient(180deg, #171325 0%, #110e1d 100%);
}

/* --- Nebel (unentdeckt) --- */
.cell-fog {
  background: #050409;
  border-radius: 3px;
}

/* --- Entdeckt, aber nicht sichtbar (gedächtnis) --- */
.cell-memory {
  background: linear-gradient(180deg, #100d1a 0%, #0c0a15 100%);
  border-radius: 3px;
  opacity: 0.55;
}

/* --- Spieler --- */
.cell-player {
  font-size: calc(var(--cell) * 0.68);
  filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.9));
  animation: playerPulse 2s ease-in-out infinite;
}
@keyframes playerPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(124, 92, 255, 0.7));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(124, 92, 255, 1));
  }
}

/* --- Monster --- */
.cell-monster {
  font-size: calc(var(--cell) * 0.64);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}
.cell-boss {
  font-size: calc(var(--cell) * 0.78);
  filter: drop-shadow(0 0 12px rgba(229, 57, 53, 0.9));
  animation: bossPulse 1.5s ease-in-out infinite;
}
@keyframes bossPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(229, 57, 53, 0.7));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(229, 57, 53, 1));
    transform: scale(1.08);
  }
}

/* --- Treppen --- */
.cell-stairs {
  font-size: calc(var(--cell) * 0.64);
  filter: drop-shadow(0 0 10px rgba(201, 162, 39, 0.8));
  animation: stairsGlow 2.5s ease-in-out infinite;
}
@keyframes stairsGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.6));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(201, 162, 39, 1));
  }
}

/* --- Gegenstände --- */
.cell-item {
  font-size: calc(var(--cell) * 0.55);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7));
}

/* --- Schadens-Animation --- */
.cell-hit {
  animation: hitFlash 0.3s ease;
}
@keyframes hitFlash {
  0% {
    background: rgba(229, 57, 53, 0.6);
  }
  100% {
    background: transparent;
  }
}

/* ============ Message log (unter dem Dungeon) ============ */
.message-log {
  width: 100%;
  margin-top: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  height: 92px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}
.message-log p {
  margin: 0;
}
.msg-dim {
  color: var(--text-dim);
}
.msg-good {
  color: #81c784;
}
.msg-bad {
  color: #e57373;
}
.msg-gold {
  color: #ffd76a;
}
.msg-info {
  color: #9fa8da;
}

/* ============ Side panel ============ */
.side-panel {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.panel-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.panel-box h2 {
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* HP bar */
.hp-bar-wrap {
  margin-bottom: 12px;
}
.hp-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text-dim);
}
.hp-bar {
  height: 16px;
  background: #0c0a15;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--hp-green), #66bb6a);
  border-radius: 8px;
  transition:
    width 0.3s ease,
    background 0.3s ease;
}
.hp-bar-fill.mid {
  background: linear-gradient(90deg, var(--hp-mid), #ffca28);
}
.hp-bar-fill.low {
  background: linear-gradient(90deg, var(--hp-low), #ef5350);
}

/* Stats grid */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  background: var(--bg-panel-2);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.stat-icon {
  font-size: 16px;
}
.stat-name {
  color: var(--text-dim);
  flex: 1;
}
.stat-value {
  font-weight: 700;
  font-size: 15px;
}

/* Inventory */
.inventory-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inventory-list li {
  background: var(--bg-panel-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.inventory-list li:hover {
  background: #2a2440;
}
.inventory-list li .inv-icon {
  font-size: 18px;
}
.inventory-list li .inv-name {
  flex: 1;
}
.inventory-list li .inv-desc {
  color: var(--text-dim);
  font-size: 11px;
}
.inventory-list li.equipped {
  border: 1px solid var(--accent-2);
}
.inventory-empty {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* Side log */
.side-log {
  max-height: 180px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}
.side-log p {
  margin: 0 0 2px 0;
}

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
}
.modal-box h2 {
  color: var(--accent);
  margin-bottom: 8px;
}
.modal-hint {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 14px;
}
.inventory-list-modal li {
  cursor: pointer;
}
.modal-box .btn {
  margin-top: 16px;
  width: 100%;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-panel);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3d3560;
}

/* Responsive: kleiner Screen */
@media (max-width: 1000px) {
  .dungeon {
    /* Spalten-Layout: verfügbare Breite = 100vw − 32px Padding;
       Grid selbst braucht 24×Zelle + 70px (Gaps/Padding/Rahmen). */
    --cell: min(32px, calc((100vw - 110px) / 24), calc((100vh - 320px) / 16));
  }
  .dungeon-panel {
    overflow: visible;
  }
  .game-layout {
    flex-direction: column;
    overflow-y: auto;
  }
  .side-panel {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .side-panel .panel-box {
    flex: 1;
    min-width: 260px;
  }
}
