:root {
  --bg: #1a1c2c;
  --panel: #262b44;
  --panel2: #3a4466;
  --text: #f4f4f4;
  --dim: #8b93af;
  --accent: #ffcd75;
  --accent2: #a7f070;
  --danger: #ef7d57;
  --bavaria: #73bed3;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'VT323', monospace;
  font-size: 20px;
  line-height: 1.35;
}

header {
  padding: 10px 14px 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  background: linear-gradient(#12141f, var(--bg));
}

h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 1px;
}

#statusline { color: var(--bavaria); font-size: 19px; }

#map {
  height: 46vh;
  min-height: 280px;
  border-top: 3px solid var(--panel2);
  border-bottom: 3px solid var(--panel2);
  background: #10121c;
}

#btn-center {
  position: absolute;
  bottom: 16px;
  right: 12px;
  z-index: 1000;
  width: 48px;
  height: 48px;
  font-size: 24px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* Pixel-Michi Marker */
.michi-icon {
  text-align: center;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.6));
}
.michi-icon .bike { width: 54px; height: 71px; }
.michi-icon .bike.flip { transform: scaleX(-1); }
/* Gedankenblase: rund, schwebt über dem Kopf, verdeckt nichts */
.michi-icon .bubble {
  position: absolute;
  top: -34px; left: -22px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
  font-family: 'VT323', monospace;
}
.michi-icon .bubble::after {
  content: '';
  position: absolute;
  bottom: -9px; right: 2px;
  width: 8px; height: 8px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.michi-icon .bubble::before {
  content: '';
  position: absolute;
  bottom: -17px; right: 12px;
  width: 5px; height: 5px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 50%;
}

#hud { padding: 10px 14px; background: var(--panel); }

.hud-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

.stat { min-width: 110px; }
.stat-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--dim);
  margin-bottom: 4px;
}
.stat-value { font-size: 22px; color: var(--accent); }
.stat-value.big { font-size: 24px; }

.bilanz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.bilanz-grid .bz-num {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  color: var(--accent);
  margin-right: 8px;
}
.bilanz-grid .bz-label { color: var(--dim); }
.bz-hype {
  grid-column: 1 / -1;
  color: var(--accent2);
  font-size: 22px;
}

/* Brezn-Kalender */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 14px;
}
.cal-head {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--dim);
  text-align: center;
  padding-bottom: 2px;
}
.cal-day {
  background: #12141f;
  border: 1px solid var(--panel2);
  border-radius: 4px;
  min-height: 34px;
  padding: 2px 4px;
  font-size: 15px;
  color: var(--dim);
}
.cal-day .cal-date { display: block; line-height: 1; }
.cal-day .cal-n {
  display: block;
  text-align: center;
  font-size: 18px;
  line-height: 1.2;
}
.cal-day.has {
  background: var(--accent);
  border-color: #b8862f;
  color: #1a1c2c;
}
.cal-day.today { border: 2px solid var(--accent2); }

.letter-tile {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: #1a1c2c;
  background: var(--accent);
  border-bottom: 3px solid #b8862f;
  border-radius: 4px;
  padding: 8px 10px;
  margin: 0 6px 6px 0;
}

.energybar {
  width: 150px; height: 14px;
  background: #12141f;
  border: 2px solid var(--panel2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 2px;
}
#energyfill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--accent), var(--accent2));
  width: 0%;
  transition: width .5s;
}

.buttons { margin-bottom: 0; }

.breze-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 12px 14px;
  background: var(--accent);
  color: #1a1c2c;
  border: 0;
  border-bottom: 4px solid #b8862f;
  border-radius: 6px;
  cursor: pointer;
}
.breze-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.breze-btn.rare {
  background: var(--accent2);
  border-bottom-color: #4f8f33;
}

#panel {
  display: grid;
  gap: 12px;
  padding: 12px 14px 30px;
  max-width: 900px;
}

.box {
  background: var(--panel);
  border: 2px solid var(--panel2);
  border-radius: 8px;
  padding: 12px 14px;
}
.box h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--bavaria);
  margin-bottom: 10px;
}

#fragments li { margin-left: 20px; margin-bottom: 6px; color: var(--accent); }
#fragments li.leer {
  list-style: none;
  margin-left: 0;
  color: var(--dim);
  font-style: italic;
}

#diary { max-height: 320px; overflow-y: auto; }
.diary-entry { margin-bottom: 10px; }
.diary-entry .time { color: var(--dim); font-size: 16px; }
.diary-entry.kind-letter { color: var(--accent); white-space: pre-wrap; }
.diary-entry.kind-breze { color: var(--accent2); }
.diary-entry.kind-event { color: var(--bavaria); }
.diary-entry.kind-fragment { color: var(--accent); }
.diary-entry.kind-flavor { color: var(--text); }
.diary-entry.kind-system { color: var(--dim); }

/* Arcade-Popups: groß und mittig über dem Bildschirm */
.dmg-pop {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, 0);
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(24px, 7vw, 64px);
  max-width: 94vw;
  text-align: center;
  pointer-events: none;
  z-index: 3000;
  white-space: nowrap;
  text-shadow: 3px 3px 0 #12141f, -3px 3px 0 #12141f, 3px -3px 0 #12141f, -3px -3px 0 #12141f, 0 0 24px rgba(0,0,0,.6);
  animation: dmgfloat 1.8s ease-out forwards;
}
.dmg-neg { color: #ff5252; }
.dmg-pos { color: var(--accent2); }
.dmg-pause { color: var(--danger); }
.dmg-hint { color: var(--accent); }
@keyframes dmgfloat {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.4); }
  12% { opacity: 1; transform: translate(-50%, -12px) scale(1.3); }
  25% { transform: translate(-50%, -20px) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -120px) scale(0.85); }
}

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 18, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}
#overlay-card {
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 0 40px rgba(255, 205, 117, .25);
}
#ov-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 14px;
}
#ov-text { white-space: pre-wrap; margin-bottom: 16px; }

#ov-choices button {
  display: block;
  width: 100%;
  text-align: left;
  font-family: 'VT323', monospace;
  font-size: 20px;
  margin-bottom: 8px;
  padding: 10px 12px;
  background: var(--panel2);
  color: var(--text);
  border: 2px solid var(--bavaria);
  border-radius: 6px;
  cursor: pointer;
}
#ov-choices button:hover { background: var(--bavaria); color: #12141f; }

#ov-letters { margin-bottom: 10px; }
#ov-letters:empty { display: none; }

#ov-gate input {
  width: 100%;
  font-family: 'VT323', monospace;
  font-size: 22px;
  padding: 8px 10px;
  background: #12141f;
  color: var(--text);
  border: 2px solid var(--bavaria);
  border-radius: 6px;
  margin-bottom: 8px;
}
#ov-gate button {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 10px 14px;
  background: var(--bavaria);
  border: 0;
  border-bottom: 4px solid #3a7a8c;
  border-radius: 6px;
  cursor: pointer;
}
#gate-feedback { margin-top: 10px; color: var(--danger); }

.hidden { display: none !important; }

/* Zuschauer-Modus: nichts anfassbar */
.watch .breze-btn { display: none; }
.watch #ov-choices,
.watch #ov-gate { display: none !important; }
#ov-watchnote { color: var(--bavaria); margin-top: 6px; }

@media (min-width: 760px) {
  #panel { grid-template-columns: 1fr 1fr; }
  #map { height: 52vh; }
}

/* Breiter Desktop: Reisetagebuch als feste Vollhöhen-Spalte rechts,
   Karte und Rest rücken davon ab */
@media (min-width: 1100px) {
  #map,
  #hud,
  #panel {
    margin-right: 424px;
  }
  #map { height: 40vh; border-right: 3px solid var(--panel2); }
  #panel {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    padding-bottom: 12px;
    max-width: none;
  }
  #diary-box {
    position: fixed;
    top: 64px;
    right: 10px;
    bottom: 10px;
    width: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 500;
  }
  #diary {
    max-height: none;
    flex: 1 1 auto;
    overflow-y: auto;
  }
}

/* Sehr breite Monitore: die drei Boxen nebeneinander — alles auf einen Blick */
@media (min-width: 1500px) {
  #panel { grid-template-columns: 1fr 1fr 1fr; }
}
