/* ============================================================
   Das Drachental – C64-Style Theme
   ============================================================ */

:root {
  --c64-bg:       #3535c8;   /* C64 Blau */
  --c64-fg:       #7070f0;   /* Hellblau */
  --c64-text:     #d4d4ff;
  --c64-bright:   #ffffff;
  --c64-yellow:   #e8e800;
  --c64-red:      #ff4040;
  --c64-green:    #40e840;
  --c64-border:   #9090e8;
  --c64-dark:     #1a1a7a;
  --c64-panel:    #22228a;
  --font:         'Courier New', Courier, monospace;
}

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

body {
  background: #0a0a2e;
  color: var(--c64-text);
  font-family: var(--font);
  font-size: 15px;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--c64-dark);
  border-bottom: 2px solid var(--c64-border);
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.title-main {
  font-size: 18px;
  font-weight: bold;
  color: var(--c64-yellow);
  letter-spacing: 3px;
  text-shadow: 0 0 8px var(--c64-yellow);
}

.title-sub {
  font-size: 10px;
  color: var(--c64-fg);
  letter-spacing: 1px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-controls button {
  background: var(--c64-panel);
  color: var(--c64-yellow);
  border: 1px solid var(--c64-border);
  padding: 4px 10px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.header-controls button:hover {
  background: var(--c64-fg);
  color: #000;
}

#score-display {
  color: var(--c64-green);
  font-size: 14px;
  font-weight: bold;
  min-width: 42px;
  text-align: right;
}

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; }

main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Output-Panel (links) ── */
#output-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--c64-border);
  min-width: 0;
}

#output-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  background: var(--c64-bg);
}

#output-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  color: var(--c64-text);
}

/* Eingabezeile mit Blinkursor */
#input-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--c64-dark);
  border-top: 2px solid var(--c64-border);
}

#prompt {
  color: var(--c64-yellow);
  font-weight: bold;
  white-space: nowrap;
}

#cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--c64-bright);
  font-family: var(--font);
  font-size: 15px;
  caret-color: var(--c64-yellow);
  text-transform: uppercase;
}
#cmd-input::placeholder { color: var(--c64-fg); text-transform: none; }

#btn-send {
  background: var(--c64-panel);
  color: var(--c64-yellow);
  border: 1px solid var(--c64-border);
  padding: 3px 10px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}
#btn-send:hover { background: var(--c64-fg); color: #000; }

/* Schnellbefehle */
#quick-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--c64-dark);
  border-top: 1px solid var(--c64-border);
}

.dir-btn, .qb {
  background: var(--c64-panel);
  color: var(--c64-text);
  border: 1px solid var(--c64-border);
  padding: 3px 9px;
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
}
.dir-btn { color: var(--c64-yellow); font-weight: bold; }
.dir-btn:hover, .qb:hover { background: var(--c64-fg); color: #000; }
.sep { color: var(--c64-border); }

/* ── Seiten-Panel (rechts) ── */
#side-panel {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--c64-dark);
  overflow-y: auto;
}

#room-name-box {
  padding: 7px 10px;
  border-bottom: 1px solid var(--c64-border);
  background: var(--c64-panel);
}

#room-name {
  color: var(--c64-yellow);
  font-weight: bold;
  font-size: 13px;
  letter-spacing: 1px;
  text-shadow: 0 0 6px var(--c64-yellow);
}

/* C64-Bildschirm-Simulation */
#c64-screen {
  padding: 10px;
  background: #111;
  border-bottom: 1px solid var(--c64-border);
  text-align: center;
  position: relative;
}

#room-canvas {
  display: block;
  margin: 0 auto;
  width: 320px;
  height: 200px;
  image-rendering: pixelated;
  border: 3px solid #555;
}

#room-ai-img {
  display: block;
  margin: 0 auto;
  width: 320px;
  height: 200px;
  object-fit: cover;
  border: 3px solid var(--c64-border);
  border-radius: 2px;
}

#pic-label {
  margin-top: 4px;
  font-size: 10px;
  color: #555;
}

/* Inventar-Box */
#inventory-box {
  padding: 8px 10px;
  border-bottom: 1px solid var(--c64-border);
}

.box-title {
  color: var(--c64-yellow);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 5px;
  border-bottom: 1px solid var(--c64-fg);
  padding-bottom: 2px;
}

#inv-list {
  list-style: none;
  font-size: 12px;
  line-height: 1.6;
  color: var(--c64-text);
}
#inv-list li.empty { color: var(--c64-fg); font-style: italic; }
#inv-list li::before { content: "▸ "; color: var(--c64-yellow); }
#inv-list li.empty::before { content: ""; }

/* Ausgänge-Kompass */
#exits-box {
  padding: 8px 10px;
}

#exits-compass {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
}

.compass-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.compass-center {
  color: var(--c64-fg);
  font-size: 14px;
}

.exit-indicator {
  display: inline-block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border: 1px solid var(--c64-border);
  font-size: 13px;
  font-weight: bold;
  color: #333;
  background: #111;
  border-radius: 3px;
  transition: all 0.2s;
  cursor: default;
}

.exit-indicator.active {
  color: var(--c64-yellow);
  background: var(--c64-panel);
  border-color: var(--c64-yellow);
  box-shadow: 0 0 6px var(--c64-yellow);
  cursor: pointer;
}

/* ── Scrollbar ── */
#output-scroll::-webkit-scrollbar { width: 6px; }
#output-scroll::-webkit-scrollbar-track { background: var(--c64-dark); }
#output-scroll::-webkit-scrollbar-thumb { background: var(--c64-border); border-radius: 3px; }

/* ── Ausgabe-Formatierung ── */
.out-line           { display: block; }
.out-separator      { color: var(--c64-fg); }
.out-room           { color: var(--c64-yellow); font-weight: bold; }
.out-error          { color: var(--c64-red); }
.out-success        { color: var(--c64-green); }
.out-system         { color: var(--c64-fg); font-style: italic; }
.out-input          { color: var(--c64-bright); }
.out-death          { color: var(--c64-red); font-weight: bold; }
.out-victory        { color: var(--c64-yellow); font-weight: bold; text-align: center; }

/* ── Mobile-Inventar-Leiste (Desktop: versteckt) ── */
#mobile-inv-bar { display: none; }

/* ── Responsive ── */
@media (max-width: 700px) {

  /* Viewport-Höhe mobil-sicher (Browser-Chrome berücksichtigt) */
  body { height: 100dvh; overflow: hidden; }
  #app { height: 100dvh; }

  /* ── Header: zweizeilig ── */
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    padding: 5px 10px;
  }
  .title-main { font-size: 14px; letter-spacing: 1px; }
  .title-sub  { font-size: 8px; }
  .header-controls { width: 100%; justify-content: space-between; gap: 4px; }
  .header-controls button { flex: 1; padding: 6px 4px; font-size: 11px; }

  /* ── Hauptlayout: Spalten untereinander ── */
  main { flex-direction: column; overflow: hidden; }

  /* ── Seiten-Panel: nur Canvas, ganz oben ── */
  #side-panel {
    order: -1;               /* Canvas vor dem Story-Panel */
    width: 100%;
    flex-direction: column;
    flex-shrink: 0;
    height: auto;
    overflow: visible;
    background: #111;
  }
  #room-name-box { display: none; }
  #inventory-box { display: none; }
  #exits-box     { display: none; }

  /* Canvas: halbe Höhe, Bild vertikal mittig beschnitten */
  #c64-screen {
    display: flex;
    align-items: center;      /* vertikale Zentrierung → oben/unten beschnitten */
    padding: 0;
    background: #111;
    border-bottom: none;
    width: 100%;
    aspect-ratio: 320 / 100;  /* halbe Originalhöhe (200/2 = 100) */
    overflow: hidden;
  }
  #room-canvas {
    display: block;
    width: 100%;
    aspect-ratio: 320 / 200;  /* volle Höhe → überragt Container, wird beschnitten */
    flex-shrink: 0;
    border: none;
    height: auto;
  }
  #room-ai-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border: none;
    border-radius: 0;
  }
  #pic-label { display: none; }

  /* ── Output-Panel: Story + Inventar-Leiste + Eingabe ── */
  #output-panel {
    order: 0;
    flex: 1;
    min-height: 0;
    border-right: none;
  }

  /* Story: nimmt allen verfügbaren Platz ── */
  #output-scroll { flex: 1; min-height: 0; }

  /* Schnellbuttons: auf Mobile ausgeblendet */
  #quick-buttons { display: none; }

  /* ── Mobile Inventar-Leiste ── */
  #mobile-inv-bar {
    display: block;
    flex-shrink: 0;          /* nie schrumpfen – Story gibt Platz ab */
    padding: 5px 10px;
    background: var(--c64-dark);
    border-top: 1px solid var(--c64-border);
    color: var(--c64-yellow);
    font-size: 12px;
    font-weight: bold;
    white-space: normal;     /* Umbruch erlaubt */
    word-break: break-word;  /* sehr lange Wörter umbrechen */
    overflow: visible;       /* Höhe passt sich dem Inhalt an */
  }

  /* ── Eingabezeile: immer am unteren Rand, kein Scrollen ── */
  #input-row {
    flex-shrink: 0;
    padding: 8px 10px;
  }
  /* 16px verhindert automatischen Zoom auf iOS */
  #cmd-input { font-size: 16px; }
}
