:root {
  --bg: #0b120d;
  --panel: rgba(12, 20, 15, 0.88);
  --panel-border: rgba(150, 220, 160, 0.18);
  --text: #eaf3ec;
  --muted: #93a89a;
  --accent: #7bdc4a;
  --gold: #ffcf3a;
  --volt: #6ad8ff;
  --bad: #ff5a5a;
  --warn: #ffb02e;
  --radius: 10px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#stage { position: fixed; inset: 0; }
#stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }

button {
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; font-weight: 600; transition: background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.3); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, #5cc23a, #8be35a); color: #0b1a08; border-color: transparent; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.on { background: rgba(123, 220, 74, 0.2); border-color: var(--accent); color: var(--accent); }
.muted { color: var(--muted); }

/* ── Bildschirme ── */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; overflow-y: auto; background: radial-gradient(ellipse at center, rgba(8, 14, 10, 0.3), rgba(8, 14, 10, 0.85)); }
.screen.overlay { background: rgba(5, 9, 6, 0.65); backdrop-filter: blur(3px); }
.panel { width: min(560px, 100%); max-height: 100%; overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.panel.wide { width: min(980px, 100%); }
.main-panel { text-align: center; }
h1, h2, h3 { margin: 0 0 10px; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-top: 16px; }
.logo { font-size: clamp(2.2rem, 8vw, 3.4rem); font-weight: 800; letter-spacing: 0.04em; line-height: 1; }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 4px; }
.menu { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.help .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.help p { line-height: 1.5; margin: 0 0 6px; font-size: 0.95rem; }
@media (max-width: 720px) { .help .cols { grid-template-columns: 1fr; } }

.el-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 8px; }
.el-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 12px; text-align: center; }
.el-card .big { font-size: 1.8rem; }
.el-card small { color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.el-card.on { border-color: var(--el, var(--accent)); background: color-mix(in srgb, var(--el, var(--accent)) 18%, transparent); }

/* ── HUD ── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px 10px; }
.top .grow { flex: 1; }
.stat { display: flex; align-items: baseline; gap: 6px; font-family: var(--mono); font-size: 1.05rem; padding: 0 6px; }
.stat .ic { color: var(--bad); }
.stat .ic.gold { color: var(--gold); }
.stat .ic.volt { color: var(--volt); }
.stat .ic.way { color: var(--accent); }
.stat small { color: var(--muted); font-size: 0.75rem; }
.stat small.low { color: var(--bad); font-weight: 700; }
.stat.wave { font-family: var(--font); }
.next-info { font-size: 0.85rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.next-info b { color: var(--text); }
.tag { display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.tag.weak { background: rgba(123, 220, 74, 0.2); color: #a8f07a; }
.tag.res { background: rgba(255, 90, 90, 0.18); color: #ff9b9b; }
.tag.sp { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.speed { display: flex; gap: 2px; }
.speed button { padding: 6px 9px; font-family: var(--mono); font-size: 0.85rem; }
button.boss { border-color: rgba(255, 90, 90, 0.5); color: #ffb0b0; }
button.boss.live { background: rgba(255, 90, 90, 0.25); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { background: rgba(255, 90, 90, 0.45); } }

.bottom { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; gap: 8px; align-items: flex-end; pointer-events: none; }
.bottom > * { pointer-events: auto; }
.builders { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px; }
.builder { display: flex; align-items: center; gap: 8px; padding: 6px 10px; text-align: left; min-width: 150px; }
.builder .k { font-family: var(--mono); color: var(--muted); font-size: 0.75rem; }
.builder small { color: var(--muted); font-weight: 500; }
.builder.on { border-color: var(--el); background: color-mix(in srgb, var(--el) 20%, transparent); }
.buildbar { display: flex; flex-wrap: wrap; gap: 4px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 6px; max-width: 760px; }
.bbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 9px; min-width: 92px; position: relative; }
.bbtn .n { font-size: 0.85rem; }
.bbtn .c { font-family: var(--mono); font-size: 0.75rem; color: var(--gold); }
.bbtn .c i { color: var(--volt); font-style: normal; margin-left: 6px; }
.bbtn .k { position: absolute; top: 3px; right: 6px; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); }
.bbtn .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.bbtn.on { border-color: var(--accent); background: rgba(123, 220, 74, 0.18); }
.bbtn.combo { border-style: dashed; }

.info { position: absolute; right: 8px; top: 64px; width: 260px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px; font-size: 0.9rem; }
.info h4 { margin: 0 0 4px; font-size: 1.05rem; }
.info .row { display: flex; justify-content: space-between; color: var(--muted); padding: 1px 0; }
.info .row b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.info p { margin: 6px 0; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.info .acts { display: flex; gap: 6px; margin-top: 8px; }
.info .acts button { flex: 1; padding: 7px 8px; font-size: 0.85rem; }

.toasts { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 7px 14px; font-weight: 600; animation: toast 3.2s forwards; }
.toast.good { border-color: var(--accent); color: #c6f5a8; }
.toast.bad { border-color: var(--bad); color: #ffb3b3; }
.toast.warn { border-color: var(--warn); color: #ffd99a; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.tip { position: fixed; pointer-events: none !important; background: rgba(0, 0, 0, 0.75); border-radius: 6px; padding: 3px 8px; font-size: 0.8rem; white-space: nowrap; transform: translate(14px, 14px); }
.tip.bad { color: #ffb3b3; }

.floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.floater { position: absolute; font-family: var(--mono); font-weight: 800; font-size: 0.8rem; color: var(--gold); text-shadow: 0 1px 2px #000; transform: translate(-50%, -50%); animation: float 0.9s forwards; }
@keyframes float { to { transform: translate(-50%, -160%); opacity: 0; } }

@media (max-width: 900px) {
  .builder { min-width: 0; }
  .builder small { display: none; }
  .bbtn { min-width: 74px; }
  .info { top: auto; bottom: 120px; width: 220px; }
  .next-info { display: none; }
}

.info p.alert { color: #ff8080; font-weight: 700; }
.tip.warn { color: #ffd080; }

/* Kleinere Bildschirme: HUD verkleinern */
@media (max-width: 1200px), (max-height: 700px) { #hud { font-size: 14px; } .top button, .bbtn { padding: 5px 8px; } .stat { font-size: 0.95rem; } }
@media (max-width: 700px) { #hud { font-size: 12px; } .bottom { flex-direction: column; align-items: stretch; } .builders { flex-direction: row; } .info { width: auto; left: 8px; } }

.submit { display: flex; gap: 8px; margin-top: 12px; }
.submit input, #layout-text { flex: 1; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 9px 12px; }
#layout-text { width: 100%; font-family: var(--mono); font-size: 0.75rem; resize: vertical; margin: 8px 0; word-break: break-all; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.board { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.board th, .board td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.board th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.board td.num { font-family: var(--mono); }
.board tr.me td { background: rgba(123, 220, 74, 0.12); }
.slot { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.slot span { flex: 1; color: var(--muted); font-size: 0.85rem; }
.slot button { padding: 5px 10px; font-size: 0.85rem; }
.boss-card .row { display: flex; justify-content: space-between; color: var(--muted); padding: 2px 0; }
.boss-card .row b { color: var(--text); font-family: var(--mono); }
.boss-card .mech { background: rgba(255, 90, 90, 0.1); border: 1px solid rgba(255, 90, 90, 0.3); border-radius: 10px; padding: 10px; margin: 10px 0; line-height: 1.45; }
.targets { display: flex; gap: 4px; margin-top: 6px; }
.targets button { flex: 1; padding: 5px 4px; font-size: 0.8rem; }

.boss-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 10px; }
.boss-list .boss-card { border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.boss-list .boss-card.easy { border-color: rgba(123, 220, 74, 0.5); }
.boss-list .boss-card.hard { border-color: rgba(255, 90, 90, 0.45); }
.boss-card header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.boss-card header h3 { margin: 0; color: var(--text); font-size: 1.05rem; text-transform: none; letter-spacing: 0; }
.boss-card .mech { font-size: 0.85rem; margin: 6px 0; }
.boss-card button { margin-top: auto; }
.diff, .rec { font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.diff.easy { background: rgba(123, 220, 74, 0.2); color: #a8f07a; }
.diff.medium { background: rgba(255, 176, 46, 0.2); color: #ffd080; }
.diff.hard { background: rgba(255, 90, 90, 0.2); color: #ff9b9b; }
.rec { background: var(--accent); color: #0b1a08; }
.why { margin: 6px 0 10px; padding-left: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.why li.plus { color: #a8f07a; }
.why li.minus { color: #ff9b9b; }

/* Tutorial */
.coach { position: absolute; left: 8px; top: 64px; width: 310px; max-height: calc(100vh - 200px); overflow: auto; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px; font-size: 0.9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }
.coach small { color: var(--muted); font-family: var(--mono); }
.coach h3 { margin: 2px 0 6px; color: var(--accent); }
.coach p { margin: 0 0 8px; line-height: 1.4; }
.coach .goal { font-weight: 600; color: #ffd080; }
.coach .goal.ok { color: var(--accent); }
.coach .row-btns { display: flex; gap: 8px; justify-content: flex-end; }
.tut-hl { outline: 3px solid #ffd080 !important; outline-offset: 2px; box-shadow: 0 0 16px 4px rgba(255, 208, 128, 0.55) !important; animation: tut-pulse 1.2s ease-in-out infinite; }
@keyframes tut-pulse { 50% { outline-color: rgba(255, 208, 128, 0.25); box-shadow: 0 0 6px 1px rgba(255, 208, 128, 0.2); } }
#btn-tut.new::after { content: 'Neu hier?'; margin-left: 8px; font-size: 0.75em; padding: 1px 6px; border-radius: 6px; background: #ffd080; color: #1a1408; }
@media (max-width: 700px) { .coach { top: 132px; width: auto; right: 8px; max-height: 32vh; } }
@media (max-height: 500px) { .coach { width: 250px; max-height: calc(100vh - 150px); font-size: 0.8rem; } }

/* Handy: Bau bestätigen, größere Ziele, keine Tastenkürzel */
.confirm { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); display: flex; gap: 8px; }
.confirm button { padding: 10px 18px; font-size: 1rem; white-space: nowrap; }
.coach h3 { cursor: pointer; }
.coach h3::after { content: ' –'; color: var(--muted); }
.coach.min h3::after { content: ' +'; }
.coach.min p:not(.goal) { display: none; }
@media (hover: none) {
  .bbtn .k, #hud .k { display: none; }
  button { -webkit-tap-highlight-color: transparent; }
  body { user-select: none; -webkit-user-select: none; }
}
@media (max-width: 700px) {
  .confirm { bottom: 170px; }
  .coach { font-size: 0.82rem; padding: 8px 10px; }
  .coach h3 { font-size: 0.95rem; }
}
@media (max-height: 500px) { .confirm { left: auto; right: 8px; transform: none; bottom: 76px; flex-direction: column; } }
