:root {
  --hintergrund: #141d2b;
  --karte: #1e2a3c;
  --rahmen: #33415a;
  --text: #e6ebf2;
  --text-leise: #d1d8e2;
  --akzent: #5aa9ff;
  --border-radius: 5px;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--rahmen) transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--hintergrund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.app {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
}

.buehne {
  flex: 1 1 0;
  min-width: 0;
}

.bild {
  position: relative;
  width: min(100%, calc((100vh - 40px) * var(--verhaeltnis, 1.194)));
}

#simulation {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

@media (max-width: 900px) {
  .app { flex-direction: column; align-items: stretch; padding: 12px; }
  .panel, .buehne { flex: none; }
}

.panel {
  flex: 0 0 320px;
  min-height: min-content;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px;
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

@media (min-width: 901px) {
  .panel {
    max-height: calc(100vh - 40px);
  }
}

.panel h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.steuerung {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--hintergrund);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
}

.aktionen {
  flex-direction: row;
  gap: 8px;
}

.aktion-knopf {
  flex: 1 1 auto;
  padding: 6px 10px;
  white-space: nowrap;
  background: var(--karte);
  color: var(--text);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.aktion-knopf:hover,
.aktion-knopf:focus-visible {
  border-color: var(--akzent);
  outline: none;
}

.aktion-knopf[aria-pressed="true"] {
  background: rgba(90, 169, 255, 0.15);
  border-color: var(--akzent);
}

.aktion-knopf:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--rahmen);
  background: var(--karte);
}

.icon-leiste {
  display: flex;
  gap: 10px;
}

.icon-button {
  flex: 1 1 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--hintergrund);
  color: var(--text-leise);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--text);
  border-color: var(--akzent);
  outline: none;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.modal-stapel {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, calc(100vw - 40px));
  pointer-events: none;
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  pointer-events: auto;
  padding: 12px 10px 16px 14px;
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.modal-schliessen {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-leise);
  border: 0;
  border-radius: var(--border-radius);
  cursor: pointer;
}

.modal-schliessen:hover {
  color: var(--text);
  background: var(--rahmen);
}

.modal-schliessen svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal-text {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rahmen) transparent;
  color: var(--text-leise);
  font-size: 13px;
  padding-right: 6px;
}

.modal-text p {
  margin: 0 0 8px;
}

.modal-text p:last-child,
.modal-text ul:last-child {
  margin-bottom: 0;
}

.modal-text ul {
  margin: 0;
  padding-left: 18px;
}

.modal-text li + li {
  margin-top: 6px;
}

.modal-text strong {
  color: var(--text);
}

.modal-fortschritt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--rahmen);
}

.modal-fortschritt span {
  display: block;
  height: 100%;
  background: var(--akzent);
  transform-origin: left center;
}
