/* Kugelwerk – Werkstatt-Look: warmes Holz, gebürsteter Stahl, ruhiges Licht. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #131820; color: #e8e3da;
}
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Safe-Area-Ränder */
.safe { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
#hud { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center;
  justify-content: space-between; pointer-events: none; z-index: 5;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.hud-right { pointer-events: auto; }
.hud-chip {
  background: rgba(19, 24, 32, 0.82); border: 1px solid rgba(230, 200, 150, 0.25);
  padding: 6px 12px; border-radius: 10px; font-size: 15px; white-space: nowrap;
}
.hud-chip.dim { color: #b9ab94; font-size: 13px; }
.hud-time {
  font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: 0.5px;
  background: rgba(19, 24, 32, 0.82); border-radius: 10px; padding: 4px 14px;
  border: 1px solid rgba(230, 200, 150, 0.25);
}
.icon-btn {
  min-width: 46px; min-height: 46px; border-radius: 12px; font-size: 20px;
  background: rgba(28, 35, 46, 0.9); color: #e8e3da; border: 1px solid rgba(230, 200, 150, 0.25);
  cursor: pointer; touch-action: manipulation;
}
.icon-btn:focus-visible, .menu-btn:focus-visible, .level-card:focus-visible {
  outline: 3px solid #e6b96a; outline-offset: 2px;
}

/* Banner (Hinweise, Duell) */
.banner {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(28, 35, 46, 0.94); border: 1px solid rgba(230, 200, 150, 0.35);
  padding: 10px 18px; border-radius: 12px; font-size: 16px; z-index: 8;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; white-space: nowrap;
}
.banner.visible, .banner[hidden="false"] { opacity: 1; }
#duel-banner { opacity: 1; }
#note { z-index: 20; }

/* Screens */
.screen {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 10; background: radial-gradient(120% 120% at 50% 0%, rgba(24, 30, 40, 0.88), rgba(12, 15, 20, 0.96));
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.screen.visible { display: flex; }
.panel {
  background: linear-gradient(180deg, #232b36, #1a212b);
  border: 1px solid rgba(230, 200, 150, 0.22); border-radius: 18px;
  padding: 28px 26px; width: min(420px, 94vw); max-height: 92vh; overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}
.panel.wide { width: min(680px, 96vw); }
.title {
  font-size: 40px; letter-spacing: 1px; color: #e6b96a;
  font-weight: 800; margin-bottom: 4px; text-align: center;
}
.subtitle { text-align: center; color: #b9ab94; margin-bottom: 22px; }
h2 { color: #e6b96a; margin-bottom: 16px; text-align: center; font-size: 26px; }
.version { margin-top: 18px; text-align: center; color: #6d7688; font-size: 13px; }
.status { color: #b9ab94; font-size: 14px; margin: 6px 0; text-align: center; }

.menu-btn {
  display: block; width: 100%; margin: 10px 0; padding: 15px 18px;
  font-size: 17px; text-align: center; color: #e8e3da; cursor: pointer;
  background: #2c3542; border: 1px solid rgba(230, 200, 150, 0.28); border-radius: 13px;
  min-height: 50px; touch-action: manipulation;
  transition: background 0.15s, transform 0.05s;
}
.menu-btn:active { transform: scale(0.985); background: #35404f; }
.menu-btn.primary { background: #7a5a2e; border-color: #e6b96a; font-weight: 700; }
.menu-btn.primary:active { background: #8a6634; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.level-card {
  background: #2c3542; border: 1px solid rgba(230, 200, 150, 0.28); border-radius: 13px;
  padding: 12px; color: #e8e3da; cursor: pointer; min-height: 84px; text-align: left;
  display: flex; flex-direction: column; gap: 4px; touch-action: manipulation;
}
.level-card.locked { opacity: 0.45; cursor: default; }
.lv-num { color: #e6b96a; font-weight: 800; font-size: 20px; }
.lv-name { font-size: 15px; }
.lv-best { color: #b9ab94; font-size: 13px; }

.slider-label { display: block; margin: 14px 0; font-size: 15px; color: #b9ab94; }
.slider-label input, .slider-label select { width: 100%; margin-top: 8px; accent-color: #e6b96a; font-size: 16px; }
.slider-label select { background: #2c3542; color: #e8e3da; border: 1px solid rgba(230,200,150,.3); border-radius: 8px; padding: 10px; }

.import-preview { background: #20293a; border: 1px solid rgba(230, 200, 150, 0.3); border-radius: 12px; padding: 12px; margin: 10px 0; }
.import-preview p { font-size: 14px; color: #cfc6b6; margin-bottom: 8px; }

#results-body { text-align: center; font-size: 18px; margin: 10px 0 18px; }
#results-body p { margin: 6px 0; }

#fatal {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: #131820; padding: 24px; text-align: center; font-size: 18px; color: #e8e3da;
}

@media (prefers-reduced-motion: reduce) {
  .banner { transition: none; }
  .menu-btn { transition: none; }
}
@media (max-width: 560px) {
  .title { font-size: 32px; }
  .hud-time { font-size: 18px; }
  .hud-chip { font-size: 13px; }
}

[hidden] { display: none !important; }
.panel { max-height: 100%; overscroll-behavior: contain; }
.screen { min-height: 0; }
#play-hint {
  position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: 90vw;
  padding: 8px 12px; border-radius: 8px; background: #131820dd; text-align: center;
}
.banner { top: max(80px, calc(env(safe-area-inset-top) + 72px)); max-width: 92vw; white-space: normal; text-align: center; }
@media (max-width: 640px) {
  #hud { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; }
  .hud-left { grid-row: 1; grid-column: 1; min-width: 0; }
  .hud-center { grid-row: 1; grid-column: 2; justify-self: end; padding-right: max(12px, env(safe-area-inset-right)); }
  .hud-right { grid-column: 1 / -1; justify-self: end; }
  .hud-chip { overflow: hidden; text-overflow: ellipsis; }
  .hud-chip.dim { display: none; }
  .hud-time { font-size: 15px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .banner { top: max(105px, calc(env(safe-area-inset-top) + 100px)); }
}
