/* Pannen, Meldungen, Erfolge sowie Apps: Snake, Drucker-Cam, Ausbau, Entwicklermenü, Personal, KI (Ladereihenfolge siehe index.html) */

/* ---------- Pannen, Meldungen, Erfolge ---------- */

.hud-warning {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(181, 57, 43, 0.85);
  font-size: 0.75rem;
  font-weight: 600;
  animation: pulse-warning 1.4s ease-in-out infinite;
}
.hud-warning.hidden { display: none; }
@keyframes pulse-warning { 50% { background: rgba(181, 57, 43, 0.55); } }

/* Meldungen rechts oben */
#feed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100% - 32px));
  pointer-events: none;
}
.feed-item {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--accent);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: feed-in 0.35s cubic-bezier(0.2, 0.9, 0.2, 1);
  transition: opacity 0.5s, transform 0.5s;
}
.feed-item.good { border-left-color: var(--good); }
.feed-item.bad { border-left-color: var(--bad); }
.feed-item.leaving { opacity: 0; transform: translateX(30px); }
@keyframes feed-in { from { opacity: 0; transform: translateX(40px); } }

/* Erfolg freigeschaltet */
#achievement {
  position: fixed;
  left: 50%;
  bottom: 90px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px 12px 14px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(60, 45, 10, 0.92), rgba(30, 24, 8, 0.92));
  border: 1px solid var(--gold);
  box-shadow: 0 10px 40px rgba(255, 207, 74, 0.25);
  transform: translate(-50%, 30px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s, visibility 0.4s;
}
#achievement.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.achievement-icon { font-size: 2rem; line-height: 1; }
.achievement-small { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--gold); }
.achievement-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.achievement-text { font-size: 0.8rem; opacity: 0.75; }

/* Erfolge-App */
.card.achievement.locked { opacity: 0.45; }
.card.achievement.unlocked { border-color: rgba(255, 207, 74, 0.5); }

/* Druckermenü: Pannen und Risiko */
.status.failed { color: #fff; background: #b5392b; }
.risk { font-size: 0.8rem; padding: 6px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.risk.low { color: #7ee08a; }
.risk.mid { color: #f2c419; }
.risk.high { color: #ff8a7a; background: rgba(181, 57, 43, 0.18); }

/* Aufträge: Eilauftrag, Sonderwunsch, Sterne, Spruch */
.card.order.rush { border-color: rgba(242, 196, 25, 0.6); }
.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}
.tag.rush { background: #f2c419; color: #2a2100; }
.tag.special { background: #9b6bff; color: #fff; }
.tag.regular { background: #2f8f4a; color: #fff; }
.stars { color: var(--gold); letter-spacing: 1px; }
.order-note { margin: 0; font-size: 0.85rem; font-style: italic; opacity: 0.8; }

.accessory-icon { font-size: 1.8rem; }

/* Titelbildschirm: verwendete Grafikkarte, Warnung bei Software-Rendering */
.title-gpu { margin-top: 12px; font-size: 0.75rem; opacity: 0.55; }
.title-gpu.warn { opacity: 1; padding: 10px 12px; border-radius: 10px; background: rgba(181, 57, 43, 0.3); border: 1px solid var(--bad); line-height: 1.5; }

/* Snake */

.snake { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.snake-bar { display: flex; align-items: center; gap: 16px; font-variant-numeric: tabular-nums; }
.snake-bar button { padding: 4px 12px; }
.snake-modes { margin-left: auto; display: flex; }
.snake-modes button:first-child { border-radius: 6px 0 0 6px; }
.snake-modes button:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.snake-modes button.active { background: #00ae42; border-color: #00ae42; color: #fff; }
.snake-stage { position: relative; flex: 1; min-height: 160px; display: grid; place-items: center; }
.snake-stage canvas { border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.35); }
.snake-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  text-align: center;
  background: rgba(10, 14, 12, 0.55);
  border-radius: 8px;
}
.snake-overlay[hidden] { display: none; }
.snake-overlay b { font-family: var(--font-display); font-size: 2rem; letter-spacing: 0.04em; }
.snake-overlay small { opacity: 0.7; }
/* Steuerkreuz nur auf Touch-Geräten */
.snake-pad { display: none; }
@media (pointer: coarse) {
  .snake-pad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 50px); gap: 6px; justify-content: center; }
  .snake-pad button {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: #343944;
    color: #fff;
    font-size: 1.2rem;
    touch-action: manipulation;
  }
  .snake-pad button:active { background: #4a5160; }
  .snake-pad [data-snake-dir="up"] { grid-column: 2; }
  .snake-pad [data-snake-dir="left"] { grid-column: 1; grid-row: 2; }
  .snake-pad [data-snake-dir="down"] { grid-column: 2; grid-row: 2; }
  .snake-pad [data-snake-dir="right"] { grid-column: 3; grid-row: 2; }
}
/* Handy quer: Steuerkreuz neben statt unter das Spielfeld */
@media (pointer: coarse) and (max-height: 500px) {
  .snake { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; column-gap: 12px; }
  .snake-bar { grid-column: 1 / -1; }
  .snake-pad { align-self: center; }
}

/* Drucker-Cam */

.cam { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.cam-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-tab {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #cfd6e4;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
}
.cam-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cam-empty { opacity: 0.6; }
.cam-view {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.risk.info { color: #cfd6e4; }
.wear.ok { color: #7ee08a; }
.wear.warn { color: #f2c419; }
.wear.bad { color: #ff8a7a; font-weight: 600; }
/* Kleiner Knopf in einer Infozeile, z. B. „Leeren“ beim Mülleimer */
.secondary.small { margin-left: 6px; padding: 2px 8px; font-size: 11px; font-weight: 500; }

/* Ausbau-App */

.upgrade .steps { display: flex; gap: 6px; }
.upgrade .step { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.upgrade .step.owned { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.power-note { margin-top: 16px !important; }

/* Kellerkarte (#50): 6 × 6 Felder, gebaute hell, Lager blau, Daten-Bunker grün, nicht festgelegt gestrichelt */
.basement-map-card { margin-top: 14px; }
.basement-map {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px;
  width: min(100%, 300px); margin: 10px 0;
}
.bm-cell {
  position: relative; aspect-ratio: 1; border-radius: 5px; padding: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); color: inherit;
}
.bm-cell.built { background: rgba(255, 255, 255, 0.22); border-color: rgba(255, 255, 255, 0.35); }
button.bm-cell { cursor: var(--cursor-hand); font: inherit; font-size: 18px; }
button.bm-cell:hover { filter: brightness(1.25); }
.bm-cell.storage { background: rgba(90, 160, 255, 0.45); border-color: #7fb4ff; }
.bm-cell.bunker { background: rgba(80, 210, 130, 0.45); border-color: #7ee08a; }
.bm-cell.unset { border-style: dashed; color: #cfd6e4; }
.bm-cell.blocked { opacity: 0.75; }
.bm-cell.fixed { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
.bm-stairs { position: absolute; top: 1px; left: 3px; font-size: 10px; }
.bm-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: #cfd6e4; }
.bm-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.bm-swatch.storage { background: #7fb4ff; }
.bm-swatch.bunker { background: #7ee08a; }
.bm-swatch.unset { border: 1px dashed #cfd6e4; }

/* Entwicklermenü (geheim) */
#shop .taskbar-start { cursor: var(--cursor-hand); }
.dev-list { display: flex; flex-direction: column; gap: 10px; }
.dev-option { gap: 8px; }

/* Personal-App */
.staff .staff-avatar { font-size: 1.8rem; line-height: 1; }
.staff.hire { border-style: dashed; }

/* Server-Vermietung: Serverwahl je Anfrage, Auslastungsbalken (.progress aus dem Druckermenü) und laufende VMs */
.rental-requests { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.rental-servers { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.rental-server {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: #343944;
  color: inherit;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
}
.rental-server:not(:disabled):hover { border-color: #3aa0ff; }
.rental-server.selected { border-color: #3aa0ff; background: rgba(58, 160, 255, 0.18); box-shadow: inset 0 0 0 1px #3aa0ff; }
.rental-server:disabled { opacity: 0.45; }
.rental-server small { opacity: 0.65; }
.rental-server-free { grid-column: 1; opacity: 0.75; font-variant-numeric: tabular-nums; }
.rental-server-rent { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rental-server:not(:disabled) .rental-server-rent { color: #7ee08a; }
.rental-server:disabled .rental-server-rent { font-weight: 400; max-width: 180px; }
.rental-host .rack-status { align-self: flex-start; }
.rental-meter { display: grid; grid-template-columns: 48px 1fr 92px; align-items: center; gap: 8px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.rental-meter .progress { margin-top: 0; height: 8px; }
.rental-meter span:last-child { text-align: right; opacity: 0.8; }
/* Server-Karten nicht auf die Höhe der längsten in der Reihe strecken */
.rental-hosts { align-items: start; }
/* VM-Liste: höchstens etwa 4 Zeilen hoch, darüber scrollt nur die Liste (Kopf mit Balken und Fuß bleiben stehen).
   Schatten oben/unten zeigen, dass es dort weitergeht; die „local“-Verläufe decken sie am jeweiligen Ende ab. */
.rental-vms {
  flex: none;
  margin: 0;
  padding: 0 4px 0 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 202px; /* genau 4 Zeilen (je ca. 46 px) plus 3 Abstände */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a5160 transparent;
  background:
    linear-gradient(#2a2e36 30%, rgba(42, 46, 54, 0)) top / 100% 24px no-repeat local,
    linear-gradient(rgba(42, 46, 54, 0), #2a2e36 70%) bottom / 100% 24px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, 0.55), transparent) top / 100% 10px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, 0.55), transparent) bottom / 100% 10px no-repeat scroll;
}
.rental-vms > .rental-vm { flex: none; }
.rental-more { opacity: 0.75; }
.rental-vm {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 6px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.rental-vm span:first-child { flex: 1 0 100%; }
.rental-warn { flex-basis: 100%; color: #f2c419; }
.rental-warn.danger { color: #ff8a7a; font-weight: 600; }
.rental-host .empty { margin: 0; font-size: 0.85rem; }

/* KI-App: Kopf mit Stufe, Chat-Verlauf (scrollt allein), Vorschläge und Eingabe */
.ai-app { display: flex; flex-direction: column; gap: 10px; height: 100%; min-height: 0; }
.ai-head { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.ai-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #2a2e36;
  min-width: 0;
}
.ai-stat span { font-size: 0.75rem; opacity: 0.65; }
.ai-stat b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.ai-steps { display: flex; gap: 3px; margin-top: 4px; } /* 10 Kästchen (MAX_LEVEL), passen auch am Handy in eine Zeile */
.ai-step { flex: 1 1 0; min-width: 0; height: 8px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); }
.ai-step.on { background: linear-gradient(90deg, #23a455, #4be08a); }
.ai-step.on:nth-child(n + 6) { background: linear-gradient(90deg, #4be08a, #3aa0ff); } /* Stufe 6–10 */
.ai-offline { margin: 0; padding: 10px 12px; border-radius: 8px; background: rgba(181, 57, 43, 0.25); border: 1px solid var(--bad); font-weight: 600; }
.ai-offline[hidden] { display: none; }
.ai-chat {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #15171b;
  scrollbar-width: thin;
  scrollbar-color: #4a5160 transparent;
}
.ai-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.ai-msg[hidden] { display: none; }
.ai-msg.ai { align-self: flex-start; background: #2a3a30; border: 1px solid rgba(75, 224, 138, 0.25); border-bottom-left-radius: 4px; }
.ai-msg.user { align-self: flex-end; background: #3aa0ff; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.system { align-self: center; max-width: 100%; padding: 2px 10px; background: none; font-size: 0.78rem; opacity: 0.65; }
.ai-msg.thinking { font-style: italic; opacity: 0.8; }
.ai-dots { display: inline-flex; gap: 3px; margin-left: 6px; }
.ai-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: ai-dot 1s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-suggest .secondary { padding: 4px 10px; font-size: 0.8rem; }
.ai-suggest:empty { display: none; }
.ai-input { display: flex; gap: 8px; }
.ai-input input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: #15171b;
  color: inherit;
  font: inherit;
  outline: none;
}
.ai-input input:focus { border-color: #3aa0ff; }
.ai-input input:disabled { opacity: 0.5; }
#shop .ai-input input { cursor: text; }
@media (max-width: 560px) { .ai-head { grid-template-columns: 1fr 1fr; } .ai-level-box { grid-column: 1 / -1; } }
/* Handy: ab Stufe 6 gibt es bis zu 8 Vorschläge – eine Zeile zum Wischen statt vieler Zeilen über dem Chat (Klasse
   swipe aus ui/ai-app.js); Stufe 1–5 brechen wie bisher um */
@media (max-width: 560px) { .ai-suggest.swipe { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .ai-suggest.swipe .secondary { flex: none; } }
/* Server-Shop: Hinweis neben einer Serien-Überschrift (z. B. KI) */
.server-series .hint { margin-left: 8px; font-weight: 400; font-size: 0.85rem; opacity: 0.6; }
