* { box-sizing: border-box; }

/* Lokal gebündelte Emoji-Schrift (Noto Color Emoji, OFL 1.1, subgesetzt &
   intern als "GameEmoji" – siehe assets/fonts/OFL.txt). Macht die Glyphen
   auf jedem Gerät identisch, ohne CDN/Geräte-Emoji-Abhängigkeit. */
@font-face {
  font-family: "GameEmoji";
  src: url("assets/fonts/emoji.woff2") format("woff2");
  font-display: block;
}

html, body {
  margin: 0;
  height: 100%;
  background: #0a0a0f;
  color: #e8e8e8;
  font-family: "GameEmoji", "Segoe UI", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
}

:root { --sidebar-w: 168px; }

/* Seitenleiste links + Spielfeld rechts nebeneinander, oben ausgerichtet.
   Die Status-Anzeige liegt damit neben dem Feld statt darüber. */
#game-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  box-shadow: 0 0 40px #000;
}

/* Linke Status-Spalte: feste, gut lesbare Breite. */
#sidebar {
  flex: 0 0 var(--sidebar-w);
  background: #0d0d16;
  border-right: 1px solid #23233a;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 13px;
}

/* Spielfeld rechts: skaliert in den verbleibenden Platz, hält 832:640. */
#game-stage {
  position: relative;
  flex: 0 0 auto;
  width: min(832px, calc(100vw - var(--sidebar-w)), calc(100vh * 832 / 640));
  aspect-ratio: 832 / 640;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #05050a;
  image-rendering: pixelated;
  touch-action: none; /* Browser-Gesten (Scroll/Zoom) auf dem Canvas unterbinden */
}

/* HP/Mana/XP-Balken in der Seitenleiste. */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 12px; line-height: 1; }
.bar { width: 100%; height: 14px; background: #222; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; transition: width 0.12s linear; }
.bar-fill.hp { background: #c0392b; }
.bar-fill.mp { background: #3d6bff; }
.bar-fill.xp { background: #f1c40f; }

.hud-line { font-size: 13px; }
#hud-depth { margin-top: 4px; }
#hud-gold { color: #ffd966; }
#hud-level { color: #9fe6c0; }
#hud-equip { margin-top: 6px; font-size: 12px; line-height: 1.5; opacity: 0.85; }

/* Inventar-Button (Rucksack) unter dem Charakter-Level. */
#touch-inv-btn {
  margin-top: 4px;
  padding: 9px 8px;
  font-size: 15px;
  background: #1a1a2e;
  border: 2px solid #33334d;
  border-radius: 8px;
  color: #e8e8e8;
  cursor: pointer;
  touch-action: manipulation;
}
#touch-inv-btn:hover { border-color: #ffcc44; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 16, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px;
}

.overlay.hidden { display: none; }

h1 { margin: 0; font-size: 42px; }
h2 { margin: 0 0 8px; }
.subtitle { margin: 0; opacity: 0.8; font-size: 20px; }
.hint { opacity: 0.6; font-size: 13px; margin-top: 8px; }

.class-grid { display: flex; gap: 16px; }

.class-card {
  width: 160px;
  padding: 18px 12px;
  background: #1a1a2e;
  border: 2px solid #33334d;
  border-radius: 10px;
  color: #e8e8e8;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.class-card:hover { transform: translateY(-4px); border-color: #ffcc44; background: #232340; }
.class-card .glyph { font-size: 40px; }
.class-card small { opacity: 0.7; }

.big-btn {
  padding: 12px 28px;
  font-size: 18px;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.big-btn:hover { background: #e04434; }

#inv-list { list-style: none; padding: 0; width: min(360px, 80vw); max-height: 320px; overflow-y: auto; }
#inv-list li {
  padding: 8px 12px;
  margin: 4px 0;
  background: #1a1a2e;
  border: 1px solid #33334d;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
#inv-list li:hover { border-color: #ffcc44; }
#inv-equipped { margin-bottom: 8px; opacity: 0.85; }
.rarity-common { color: #cccccc; }
.rarity-uncommon { color: #4caf50; }
.rarity-rare { color: #3d9bff; }
.rarity-epic { color: #b65cff; }

/* Schmale Bildschirme (Handy): schmalere Seitenleiste, Klassenauswahl
   untereinander, kleinere Titel. */
@media (max-width: 520px) {
  :root { --sidebar-w: 128px; }
  #sidebar { padding: 8px 7px; gap: 7px; font-size: 12px; }
  #touch-inv-btn { font-size: 13px; padding: 8px 6px; }
  h1 { font-size: 30px; }
  .subtitle { font-size: 16px; }
  .class-grid { flex-direction: column; align-items: center; }
  .class-card { width: min(200px, 70vw); padding: 12px; }
}
