:root {
  --bg: #0b111b;
  --card: #121a27;
  --card2: #172133;
  --line: #233047;
  --text: #e6edf5;
  --muted: #8a97ab;
  --accent: #ff5a1f;
  --accent2: #2dd4bf;
  --gold: #ffd166;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1a2740 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: var(--safe-b);
}
button, select, input { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 18px 10px;
  max-width: 1500px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; letter-spacing: .2px; }
.brand b { color: var(--accent); font-weight: 800; }
.logo { width: 30px; height: 30px; color: var(--accent); animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.preset { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.preset select { min-width: 150px; }

.layout {
  max-width: 1500px; margin: 0 auto; padding: 0 18px 18px;
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  grid-template-areas: "stage controls" "results controls" "table controls";
  align-items: start;
}
.stage { grid-area: stage; }
.results { grid-area: results; }
.controls { grid-area: controls; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.table { grid-area: table; }

.card {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.stage { padding: 0; overflow: hidden; }
.canvas-wrap { position: relative; aspect-ratio: 16 / 9; }
#scene { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.stage-bar { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }

.shifter {
  position: absolute; bottom: 12px; display: flex; align-items: center; gap: 6px;
  background: rgba(10,15,24,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px;
}
.shifter span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 0 2px; }
.shifter-left { left: 12px; }
.shifter-right { right: 12px; }
.shifter button {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card2); font-size: 22px; font-weight: 700; line-height: 1;
}
.shifter button:active { background: var(--accent); }

.seg { display: inline-flex; background: #0d141f; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 11px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; min-height: 34px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.seg.wide { display: flex; width: 100%; margin-bottom: 14px; }
.seg.wide button { flex: 1; }

h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 18px 0 10px; font-weight: 700; }
h2:first-child { margin-top: 2px; }

.field { display: block; margin: 0 0 12px; }
.field > span { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field output { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: #0d141f url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a97ab' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 34px 10px 12px; min-height: 44px;
}
select:focus, .seg button:focus-visible, .chips button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type=range] { width: 100%; appearance: none; -webkit-appearance: none; background: transparent; height: 32px; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), #24314a var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: #24314a; }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); margin-top: -9px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: #0d141f; border-radius: 8px; padding: 8px 9px; min-width: 52px; min-height: 38px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.chips button.on { border-color: var(--gold); color: var(--gold); background: rgba(255,209,102,.08); font-weight: 700; }
.warn { background: rgba(255,209,102,.1); border: 1px solid rgba(255,209,102,.35); color: var(--gold); padding: 8px 10px; border-radius: 10px; font-size: 13px; margin: -4px 0 12px; }

.big { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: #0d141f; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat strong { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat em { font-style: normal; color: var(--muted); margin-left: 4px; font-size: 13px; }
.stat.hero strong { color: var(--accent); font-size: 38px; }
.stat.hero:nth-child(2) strong { color: var(--accent2); }
.small { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; margin-top: 14px; }
.small small { display: block; color: var(--muted); font-size: 12px; }
.small b { font-variant-numeric: tabular-nums; font-size: 16px; }

.split { margin-top: 14px; }
.split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #0d141f; }
.split-bar i { display: block; transition: width .3s; }
#bAir, .c-air { background: #60a5fa; }
#bRoll, .c-roll { background: #a78bfa; }
#bClimb, .c-climb { background: var(--accent); }
.split-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.split-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.split-legend b { color: var(--text); font-weight: 600; }

.table-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-head h2 { margin: 0; }
.scroll { overflow-x: auto; margin: 12px -4px 0; padding: 0 4px; -webkit-overflow-scrolling: touch; }
#grid { border-collapse: separate; border-spacing: 3px; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
#grid th { color: var(--muted); font-weight: 600; padding: 4px; font-size: 12px; }
#grid th.ring { text-align: right; padding-right: 8px; color: var(--text); }
#grid td {
  text-align: center; padding: 8px 4px; border-radius: 7px; cursor: pointer; min-width: 44px;
  background: hsl(var(--h, 210) 60% calc(14% + var(--l, 0) * 22%));
  transition: transform .12s;
}
#grid td:hover { transform: scale(1.06); }
#grid td.cross { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.35) 0 4px, transparent 4px 8px); color: #c3cbd6; }
#grid td.sel { outline: 2px solid var(--gold); color: var(--gold); font-weight: 800; }
#grid tr.steps td { background: transparent; color: var(--muted); font-size: 12px; cursor: default; padding: 2px; }
#grid tr.steps td:hover { transform: none; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.ladder { position: relative; height: 92px; margin: 4px 6px 0; }
.ladder .axis { position: absolute; left: 0; right: 0; bottom: 22px; height: 1px; background: var(--line); }
.ladder .tick { white-space: nowrap; position: absolute; bottom: 0; transform: translateX(-50%); font-size: 12px; color: var(--muted); }
.ladder .dot {
  position: absolute; width: 16px; height: 16px; border-radius: 50%; transform: translate(-50%, 50%);
  border: 2px solid #0b111b; cursor: pointer; padding: 0;
}
.ladder .dot.sel { box-shadow: 0 0 0 3px var(--gold); z-index: 2; }

.foot { max-width: 1500px; margin: 0 auto; padding: 4px 18px 24px; color: var(--muted); font-size: 12px; }

/* Tablet */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr); }
  .big { grid-template-columns: repeat(2, 1fr); }
  .small { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "results" "controls" "table"; padding: 0 10px 12px; gap: 12px; }
  .controls { position: static; max-height: none; overflow: visible; }
  .top { padding-left: 12px; padding-right: 12px; }
  .brand { font-size: 18px; }
  .preset > span { display: none; }
  .preset select { min-width: 0; max-width: 46vw; }
}
/* Smartphone hochkant: Animation bleibt oben sichtbar */
@media (max-width: 860px) and (orientation: portrait) and (min-height: 600px) {
  .stage { position: sticky; top: 0; z-index: 5; border-radius: 0 0 var(--radius) var(--radius); margin: 0 -10px; border-top: 0; }
  .canvas-wrap { aspect-ratio: auto; height: 31vh; }
  .stage-bar { padding: 6px 8px; }
  .seg button { padding: 6px 9px; }
}
@media (max-width: 560px) {
  .small { grid-template-columns: repeat(2, 1fr); }
  .stat strong { font-size: 24px; }
  .stat.hero strong { font-size: 30px; }
  .card { padding: 12px; }
  .stage { padding: 0; }
  .shifter button { width: 40px; height: 40px; }
  .shifter span { display: none; }
}

#play svg { width: 14px; height: 14px; display: block; fill: currentColor; }
.tip { margin: 12px 0 0; font-size: 13px; color: var(--gold); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tip button { border: 1px solid var(--gold); background: transparent; color: var(--gold); border-radius: 8px; padding: 6px 10px; cursor: pointer; min-height: 34px; }

.pick-row { display: flex; gap: 8px; }
.pick-row select { flex: 1 1 0; min-width: 0; width: 0; }
.edit-btn { border: 1px solid var(--line); background: #0d141f; border-radius: 10px; padding: 0 12px; min-height: 44px; cursor: pointer; color: var(--muted); font-size: 13px; white-space: nowrap; }
.edit-btn.on, .edit-btn.mod { border-color: var(--gold); color: var(--gold); }
.editor { margin-top: 8px; padding: 10px; border: 1px dashed rgba(255,209,102,.4); border-radius: 12px; background: rgba(255,209,102,.03); }
.editor-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.editor-head b { color: var(--gold); font-weight: 600; }
.editor-head button { border: 0; background: transparent; color: var(--accent2); cursor: pointer; font-size: 12px; padding: 4px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.steps-grid.rings { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.stepper { display: flex; flex-direction: column; align-items: stretch; background: #0d141f; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.stepper.changed { border-color: var(--gold); }
.stepper button { border: 0; background: #162033; cursor: pointer; height: 30px; font-size: 16px; line-height: 1; padding: 0; }
.stepper button:active { background: var(--accent); }
.stepper button:disabled { opacity: .3; cursor: default; }
.stepper b { text-align: center; padding: 4px 0; font-variant-numeric: tabular-nums; font-size: 15px; }
.stepper.changed b { color: var(--gold); }
.stepper small { text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 3px; }
.editor-note { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.warn { white-space: pre-line; }

/* SEO-Inhalte */
a.brand { color: inherit; text-decoration: none; }
.intro { max-width: 1500px; margin: 0 auto; padding: 0 18px 12px; }
.intro h1 { font-size: 22px; margin: 0; letter-spacing: -.2px; }
.intro p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.info { max-width: 1500px; margin: 8px auto 0; padding: 0 18px; display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info section { background: linear-gradient(180deg, var(--card2), var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.info section:nth-child(3), .info section:nth-child(4) { grid-column: 1 / -1; }
.info h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0 0 10px; }
.info p, .info dd, .info li { color: #c3cdda; line-height: 1.6; }
.info strong { color: var(--text); }
.formulas { margin: 0; }
.formulas dt { font-weight: 700; color: var(--gold); margin-top: 10px; }
.formulas dd { margin: 2px 0 0; }
.brands { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.brand-block h3 { margin: 0 0 4px; color: var(--accent); font-size: 16px; }
.brand-block h4 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.brand-block ul { margin: 0; padding-left: 18px; font-size: 13px; }
.brand-block li { line-height: 1.5; }
.info details { border-top: 1px solid var(--line); padding: 10px 0; }
.info details:first-of-type { border-top: 0; }
.info summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; min-height: 28px; align-items: center; }
.info summary::-webkit-details-marker { display: none; }
.info summary::after { content: "+"; color: var(--accent); font-size: 20px; font-weight: 400; }
.info details[open] summary::after { content: "−"; }
.info details p { margin: 8px 0 0; }
@media (max-width: 860px) {
  .intro { padding: 0 12px 10px; }
  .intro h1 { font-size: 18px; }
  .intro p { font-size: 13px; }
  .info { grid-template-columns: minmax(0, 1fr); padding: 0 10px; }
  .brands { grid-template-columns: minmax(0, 1fr); }
  .info section { padding: 14px; }
}

/* Teilen */
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.share-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #0d141f; border-radius: 10px; min-height: 44px; padding: 0 14px; cursor: pointer; color: var(--text); font-size: 14px; }
.share-btn svg { width: 18px; height: 18px; fill: var(--accent); }
.share-btn:hover { border-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); background: #e6edf5; color: #0b111b; font-weight: 600; padding: 10px 16px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 560px) {
  .share-btn span { display: none; }
  .share-btn { padding: 0 12px; }
  .top-actions { gap: 6px; }
}

/* ---- Usability-Überarbeitung ---- */
.stat small .s { display: none; }
.canvas-wrap { max-height: 60vh; width: 100%; }
.shifter button:disabled { opacity: .35; cursor: default; }
.sh-val { display: flex; flex-direction: column; align-items: center; min-width: 44px; line-height: 1.05; }
.sh-val b { font-size: 18px; font-variant-numeric: tabular-nums; color: var(--gold); }
.sh-val small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.shifter span.sh-val { padding: 0; text-transform: none; letter-spacing: 0; }
.sh-legend { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); font-size: 12px; color: rgba(230,237,245,.55); white-space: nowrap; pointer-events: none; }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 12px; list-style: none; display: none; }
.more summary::-webkit-details-marker { display: none; }
.link-btn { display: block; width: 100%; margin-top: 8px; background: transparent; border: 1px dashed var(--line); color: var(--muted); border-radius: 10px; min-height: 44px; cursor: pointer; font-size: 13px; }
.link-btn:hover { color: var(--text); border-color: var(--muted); }

/* Touch-Geräte: größere Ziele */
@media (pointer: coarse) {
  .seg button { min-height: 42px; padding: 8px 12px; }
  .chips button { min-height: 42px; }
  .stepper button { height: 36px; }
  .info summary { min-height: 44px; }
}

/* Laptop mit geringer Höhe: Animation flacher */
@media (min-width: 861px) and (max-height: 820px) {
  .canvas-wrap { aspect-ratio: 2 / 1; max-height: 52vh; }
  .intro p { display: none; }
}

/* Smartphone: kompakte Ergebniskacheln, Details einklappbar */
@media (max-width: 560px) {
  .intro p { display: none; }
  .big { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stat { padding: 7px 6px; text-align: center; border-radius: 10px; }
  .stat small { font-size: 11px; }
  .stat small .l { display: none; }
  .stat small .s { display: inline; }
  .stat strong, .stat.hero strong { font-size: 22px; display: block; letter-spacing: -.3px; }
  .stat em { display: block; margin: 0; font-size: 11px; }
  .more summary { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
  .more summary::after { content: "+"; color: var(--accent); font-size: 18px; }
  .more[open] summary::after { content: "−"; }
  .small { margin-top: 6px; }
  .sh-val small { display: none; }
  .sh-val { min-width: 34px; }
  .sh-legend { font-size: 11px; bottom: 4px; }
  .top { gap: 8px; }
  .brand { font-size: 17px; gap: 7px; }
  .logo { width: 26px; height: 26px; }
  .preset select { max-width: 40vw; }
}
@media (max-width: 380px) {
  .brand span { font-size: 15px; }
  .sh-legend { display: none; }
}

/* Smartphone quer: zweispaltig, Animation links, Einstellungen rechts scrollbar */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 600px) {
  .intro { display: none; }
  .top { padding-top: 6px; padding-bottom: 6px; }
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-areas: "stage controls" "results controls" "table table"; padding: 0 10px 12px; gap: 10px; }
  .stage { position: sticky; top: 6px; margin: 0; border-radius: var(--radius); border-top: 1px solid var(--line); z-index: 2; }
  .canvas-wrap { aspect-ratio: auto; height: 58vh; max-height: none; }
  .controls { position: sticky; top: 6px; max-height: calc(100vh - 12px); overflow: auto; }
  .stage-bar { padding: 6px 8px; }
  .big { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat strong, .stat.hero strong { font-size: 22px; }
}
@media (pointer: coarse) {
  .ladder { height: 104px; }
  .ladder .dot { width: 24px; height: 24px; }
}
@media (min-width: 561px) and (max-width: 860px) {
  .big { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat strong { font-size: 26px; }
  .stat.hero strong { font-size: 30px; }
}

/* Schalt-Anzeige: Zähnezahl immer sichtbar, Legende zweizeilig mittig */
.shifter span.sh-val { display: flex; }
.sh-legend { display: flex; flex-direction: column; align-items: center; gap: 1px; bottom: 14px; line-height: 1.2; }
.sh-legend span { display: block; }
@media (orientation: landscape) and (max-height: 520px) {
  .sh-val small { display: none; }
  .sh-val { min-width: 32px; }
  .shifter button { width: 38px; height: 38px; }
  .sh-legend { display: none; }
}
@media (max-width: 380px) { .sh-legend { display: none; } }
@media (max-width: 400px) {
  .stage-bar { flex-wrap: nowrap; gap: 6px; }
  .stage-bar .seg { flex-wrap: nowrap; }
  .stage-bar .seg button { padding: 6px 8px; font-size: 13px; }
}
.stage-bar .seg button { min-width: 40px; }
