:root {
  --bg: #f3f2ee;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #1d1d1b;
  --muted: #6f6d67;
  --line: #dcdad3;
  --accent: #2f4f86;
  --accent-ink: #fff;
  --danger: #b4232f;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

button, select, input, textarea { font: inherit; color: inherit; }
button, select {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 11px; cursor: pointer; font-size: 14px; line-height: 1.2;
}
button:hover:not(:disabled) { border-color: #b9b6ad; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.bar {
  position: fixed; top: 12px; left: 12px; right: 12px;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  pointer-events: none;
}
.bar > *, .bar-left > *, .bar-right > * { pointer-events: auto; }
.bar-left, .bar-right { display: flex; gap: 10px; align-items: center; min-width: 0; pointer-events: none; }
.bar-right { justify-content: flex-end; }
.group {
  display: flex; gap: 6px; align-items: center; background: var(--panel); padding: 5px;
  border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
#btn-save { white-space: nowrap; }
button.icon { padding: 6px 9px; display: inline-flex; align-items: center; gap: 5px; }
button.icon svg { display: block; }
.status { font-size: 12px; color: var(--muted); padding: 0 4px; white-space: nowrap; }
.status.dirty { color: #a8590c; font-weight: 600; }
.status.dirty::before { content: "● "; }
.seg button { border-color: transparent; background: transparent; }
.seg button.active { background: var(--ink); color: #fff; }
.short { display: none; }
body:not([data-mode="iso"]) .iso-only { display: none; }

.menu { position: relative; }
.menu summary {
  list-style: none; border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer;
  font-size: 14px; white-space: nowrap; user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: var(--muted); font-size: 11px; }
.menu summary:hover, .menu[open] summary { background: #fff; border-color: var(--line); }
#variant-name { font-weight: 650; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.menu-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 5; display: flex; flex-direction: column; gap: 2px;
  background: #fff; padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow); min-width: 240px;
}
.menu-right .menu-pop { left: auto; right: 0; min-width: 210px; }
.menu-pop button { text-align: left; border-color: transparent; white-space: nowrap; }
.menu-pop button:hover:not(:disabled) { background: var(--bg); border-color: transparent; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; width: auto; }
.menu-pop label { font-size: 14px; display: flex; gap: 8px; align-items: center; padding: 6px 10px; white-space: nowrap; cursor: pointer; }
.menu-pop select { margin: 2px 6px 4px; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 10px 2px; }
.menu-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.menu-list button.current { font-weight: 650; }
.menu-list button.current::before { content: "✓ "; }
.menu-list button:not(.current) { padding-left: 25px; }

.walk-hint {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.78); color: #fff; padding: 12px 18px; border-radius: var(--radius);
  font-size: 14px; display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center;
  pointer-events: none;
}
.walk-hint .touch { display: none; }
@media (pointer: coarse) { .walk-hint .desk { display: none; } .walk-hint .touch { display: inline; } }

.info {
  position: fixed; left: 12px; bottom: 12px; background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 36px 12px 14px; max-width: min(360px, calc(100vw - 24px));
}
.info #info-title { font-weight: 700; }
.info #info-id { font-size: 12px; color: var(--muted); margin: 3px 0 6px; font-family: ui-monospace, Menlo, monospace; }
.info small { color: var(--muted); }
.info button.close { position: absolute; top: 6px; right: 6px; border: 0; background: none; font-size: 18px; padding: 2px 8px; }
.info-tools { display: flex; gap: 6px; margin: 2px 0 8px; }
.info-tools button { padding: 4px 9px; font-size: 13px; }
body.dragging, body.dragging #scene { cursor: grabbing !important; }
#scene.rotmode { cursor: alias; }
body.mobile .info-tools, body.mobile .info small { display: none; }

.chat {
  position: fixed; top: 70px; right: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px));
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; transform: translateX(calc(100% + 24px)); transition: transform 0.2s ease;
}
body.chat-open .chat { transform: none; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-head button { border: 0; background: none; font-size: 20px; padding: 0 6px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 11px; border-radius: 10px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.msg.pending { color: var(--muted); font-style: italic; }
.msg.error { align-self: flex-start; background: #fdecee; color: var(--danger); }
.msg small { display: block; margin-top: 4px; font-size: 12px; color: #2f7a3a; font-weight: 600; }
.chat form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 14px; }
.chat form.busy button { opacity: 0.5; pointer-events: none; }

dialog { border: 0; border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.25); }
dialog h3 { margin: 0 0 6px; }
dialog p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
dialog input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.pdf-formats { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.pdf-formats label { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; }
.pdf-formats label:has(:checked) { border-color: var(--accent); background: #eef2f9; }
.pdf-formats input { width: auto; margin: 0; }
.pdf-formats small { font-weight: 400; color: var(--muted); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 0; padding: 0; }

.toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -12px); opacity: 0; transition: 0.2s;
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 14px; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--bg); transition: opacity 0.3s; }
body.ready .loading { opacity: 0; pointer-events: none; }

@media (max-width: 900px) {
  .status:not(.dirty) { display: none; }
}
@media (max-width: 760px) {
  .bar { top: 8px; left: 8px; right: 8px; gap: 6px; grid-template-columns: 1fr auto; }
  .seg { grid-row: 2; grid-column: 1 / -1; justify-self: center; }
  .long { display: none; }
  .short { display: inline; }
  .status { display: none; }
  #variant-name { max-width: 38vw; }
  .chat { top: auto; height: 55vh; right: 8px; left: 8px; width: auto; bottom: 8px; transform: translateY(calc(100% + 16px)); }
}

/* ---------- cyOOM ---------- */
@font-face { font-family: "Ginto"; src: url(../fonts/ABCGinto-Bold.woff2) format("woff2"); font-weight: 700; }
.seg button.hell:not(.active) { color: #b4232f; font-weight: 650; }
body.game .bar { opacity: 0.35; transition: opacity .2s; }
body.game .bar:hover { opacity: 1; }
body.game #scene { image-rendering: pixelated; }
#hud { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
#game-overlay {
  position: fixed; inset: 0; display: grid; place-items: center; cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(60, 8, 4, 0.55), rgba(10, 2, 0, 0.88));
}
#game-overlay .card { max-width: min(560px, calc(100vw - 32px)); color: #f3e6d6; text-align: center; padding: 24px; }
#game-overlay h1 {
  font: 700 clamp(44px, 9vw, 92px)/0.95 Ginto, Inter, system-ui, sans-serif; margin: 0 0 6px; letter-spacing: 0.02em;
  color: #ff4a1c; text-shadow: 0 4px 0 #6a0d05, 0 0 30px rgba(255, 80, 20, 0.45);
}
#game-overlay .small h1 { font-size: clamp(36px, 7vw, 64px); }
#game-overlay h2 { font: 700 14px/1 Ginto, Inter, sans-serif; letter-spacing: 0.3em; text-transform: uppercase; color: #e8c020; margin: 0 0 22px; }
#game-overlay p { font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
#game-overlay .keys { font-size: 13px; color: #c8b8a4; }
#game-overlay .keys b { color: #fff; font-weight: 650; }
#game-overlay .go {
  margin-top: 10px; background: #b4232f; border: 0; color: #fff; font-weight: 700; padding: 12px 22px; border-radius: 6px;
  font-size: 16px; letter-spacing: 0.04em; box-shadow: 0 4px 0 #5a0d12; animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { #game-overlay .go { animation: none; } }
#game-touch { position: fixed; right: 14px; bottom: calc(15vh + 10px); display: flex; flex-direction: column; gap: 10px; }
#game-touch button { width: 76px; height: 54px; border-radius: 12px; border: 2px solid #5a0d12; background: rgba(180, 35, 47, 0.75); color: #fff; font-weight: 700; font-size: 13px; }
#game-touch button[data-a="fire"] { height: 76px; border-radius: 50%; }
body.game #scene { filter: contrast(1.12) saturate(1.2) brightness(0.9); }
.bar { z-index: 10; }
#game-overlay { z-index: 5; }
#game-overlay .leave { margin-top: 10px; background: transparent; border: 1px solid #8a6a5a; color: #f3e6d6; padding: 11px 18px; border-radius: 6px; font-size: 15px; }
#game-overlay .leave:hover { border-color: #f3e6d6; }

/* ---------- Arbeitssimulator ---------- */
.seg button.worksim:not(.active) { color: #2f6f3e; font-weight: 650; }
body.work .bar { opacity: 0.4; transition: opacity .2s; }
body.work .bar:hover { opacity: 1; }
#work-hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; color: var(--ink); }
#work-hud > div { position: absolute; }
.w-clock { left: 14px; bottom: 14px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 14px; display: flex; flex-direction: column; }
.w-clock b { font: 700 26px/1 Ginto, Inter, sans-serif; font-variant-numeric: tabular-nums; }
.w-clock span { font-size: 12px; color: var(--muted); margin-top: 3px; }
.w-goal { left: 50%; top: 66px; transform: translateX(-50%); background: #1d1d1b; color: #fff; border-radius: 999px; padding: 7px 16px 7px 10px; font-size: 14px; display: flex; gap: 10px; align-items: center; white-space: nowrap; box-shadow: var(--shadow); }
.w-arrow { display: inline-block; color: #3ec46d; font-size: 18px; transition: transform .1s linear; }
.w-log { right: 14px; top: 66px; width: min(290px, 42vw); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px; }
.w-log-h { font-weight: 700; display: flex; justify-content: space-between; margin-bottom: 6px; }
.w-score { color: #2f6f3e; }
.w-log ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.w-log li b { display: block; font-weight: 650; }
.w-log li span { color: var(--muted); }
.w-log li.muted { color: var(--muted); }
.w-log li.done { color: #2f6f3e; }
.w-log li.failed { color: var(--danger); text-decoration: line-through; }
.w-carry:not(:empty) { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); color: #a8590c; font-weight: 600; }
.w-cross { left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,0.9); box-shadow: 0 0 0 1px rgba(0,0,0,0.35); }
.w-prompt { left: 50%; top: calc(50% + 26px); transform: translateX(-50%); background: rgba(29,29,27,0.82); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.w-prompt b { display: inline-block; background: #fff; color: #1d1d1b; border-radius: 4px; padding: 0 6px; margin-right: 6px; }
.w-dialog { left: 50%; bottom: 22px; transform: translateX(-50%); width: min(640px, calc(100vw - 200px)); background: #fff; border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,0.25); padding: 14px 18px; border-left: 5px solid #e2552c; }
.w-who { font: 700 13px/1 Ginto, Inter, sans-serif; color: #e2552c; letter-spacing: .02em; }
.w-say { margin: 6px 0 6px; font-size: 16px; line-height: 1.45; }
.w-dialog small { color: var(--muted); }
.w-toast { left: 50%; top: 110px; transform: translateX(-50%); background: #2f6f3e; color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); }
#work-overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; cursor: pointer; background: rgba(243, 242, 238, 0.82); backdrop-filter: blur(4px); }
#work-overlay .card { max-width: min(540px, calc(100vw - 32px)); background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 28px; text-align: center; }
#work-overlay h1 { font: 700 clamp(30px, 6vw, 48px)/1 Ginto, Inter, sans-serif; margin: 0 0 6px; color: #1d1d1b; }
#work-overlay h2 { font-size: 13px; letter-spacing: .2em; text-transform: uppercase; color: #e2552c; margin: 0 0 18px; }
#work-overlay p { font-size: 15px; line-height: 1.5; margin: 0 0 12px; }
#work-overlay .keys { font-size: 13px; color: var(--muted); }
#work-overlay .keys b { color: var(--ink); }
#work-overlay b.y { background: #ffd21a; padding: 0 5px; border-radius: 3px; }
#work-overlay .go { background: #e2552c; border: 0; color: #fff; font-weight: 700; padding: 11px 20px; border-radius: 8px; font-size: 15px; margin-top: 6px; }
#work-overlay .leave { margin-top: 6px; padding: 10px 16px; border-radius: 8px; font-size: 15px; }
#work-touch { position: fixed; right: 16px; bottom: calc(15vh + 10px); z-index: 4; }
#work-touch button { width: 76px; height: 76px; border-radius: 50%; background: rgba(226, 85, 44, 0.85); color: #fff; font: 700 26px/1 Ginto, Inter, sans-serif; border: 0; }
@media (max-width: 700px) { .w-log { top: auto; bottom: 14px; right: 14px; width: 48vw; } .w-dialog { width: calc(100vw - 24px); bottom: 90px; } }
