/* Linienwerk – UI für iPad (Touch, Quer- und Hochformat) */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0b1220;
  color: #e8eefc;
  font-family: -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#spiel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

/* ---------------- HUD ---------------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: linear-gradient(rgba(10, 14, 24, 0.92), rgba(10, 14, 24, 0.55) 82%, transparent);
  pointer-events: none;
}

#hud button,
#hud .swatch {
  pointer-events: auto;
}

.hud-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hud-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.brand {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 14px;
  color: #9fc1ff;
}

.stat { font-size: 13px; color: #b8c4d8; display: flex; align-items: center; gap: 6px; }
.stat b { color: #fff; font-size: 16px; }
.stat.small { font-size: 12px; }
.muted { color: #7f8ca3; font-size: 12px; }

.weekbar {
  width: 74px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.weekbar i {
  display: block;
  height: 100%;
  width: 0;
  background: #7ec8ff;
  border-radius: 3px;
  transition: width 0.3s linear;
}

#hud button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.10);
  color: #e8eefc;
  font-size: 14px;
  font-weight: 600;
  touch-action: manipulation;
  cursor: pointer;
}
#hud button.active {
  background: #2e6df1;
  border-color: #9fc1ff;
  color: #fff;
}

/* Linien-Farbleiste */
.swatches { display: flex; gap: 8px; align-items: center; }
.swatch {
  width: 46px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.30);
  background:
    conic-gradient(rgba(255, 255, 255, 0.55) calc(var(--hold, 0) * 360deg), transparent 0),
    var(--c, #888);
  color: #101826;
  font-weight: 800;
  font-size: 12px;
  touch-action: manipulation;
  cursor: pointer;
}
.swatch.pressing { border-color: #fff; }
.swatch.slot {
  background: rgba(255, 255, 255, 0.08);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.35);
  color: #b8c4d8;
  pointer-events: none;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(16, 22, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 30;
  max-width: 92vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Overlays ---------------- */

.overlay, .modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 18, 0.72);
  padding: 20px;
}
.overlay.show, .modal.show { display: flex; }

.panel {
  background: #131b2c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 22px 24px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel.small { max-width: 420px; text-align: center; }

.panel h1 { font-size: 30px; margin-bottom: 6px; letter-spacing: 0.04em; }
.panel h2 { font-size: 22px; margin-bottom: 10px; }
.panel .lead { color: #b8c4d8; margin-bottom: 14px; }
.panel ul { margin: 0 0 16px 18px; color: #cdd7e8; font-size: 14px; line-height: 1.55; }

.rulegrid {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 14px;
  color: #cdd7e8;
}

.glyph {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
}
.glyph.circle { border-radius: 50%; background: #ffd166; }
.glyph.tri {
  background: #63d68b;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.glyph.sq { background: #7eb2ff; border-radius: 3px; }

button.big {
  min-height: 52px;
  padding: 14px 34px;
  border-radius: 14px;
  border: none;
  background: #2e6df1;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

/* Belohnungs-Fenster */
.opts { display: flex; gap: 14px; margin-top: 16px; }
.opt {
  flex: 1;
  min-height: 130px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: #e8eefc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.opt:active { background: #2e6df1; }
.opt-icon { font-size: 30px; }
.opt-title { font-weight: 700; }
.opt-sub { font-size: 12px; color: #9fb0c8; }

/* Hochformat: Leiste kompakter */
@media (orientation: portrait) {
  #hud { flex-wrap: wrap; gap: 8px; }
  .hud-right .stat.small { display: none; }
  .stat.small { display: none; }
}

/* Seed-Eingabe */
.seedrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.seedrow label { font-size: 14px; color: #b8c4d8; }
.seedrow input {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  width: 180px;
}
.seedrow button {
  min-width: 48px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

/* Statistik am Ende */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.statcell {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  color: #9fb0c8;
}
.statcell b { color: #fff; font-size: 16px; }

/* Bestenliste */
.board { margin: 8px 0 18px 22px; }
.board li { font-size: 13px; color: #cdd7e8; padding: 5px 0; }
.board li b { color: #ffd166; font-size: 15px; }

.panel h3 { font-size: 16px; margin-top: 10px; }

.btnrow { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
button.ghost {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #cdd7e8;
  font-size: 14px;
  cursor: pointer;
}

/* ---- Einstellungen ---- */
.setting {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}
.setting label { font-size: 14px; color: #b8c4d8; }
.setting input[type="range"] { width: 100%; accent-color: #3da9ff; }
.setting .toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; color: #e8eefc; }
.setting .toggle input { width: 22px; height: 22px; accent-color: #3da9ff; }
.seg { display: flex; gap: 8px; }
.seg button {
  min-width: 64px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: #cdd7e8;
  font-size: 15px;
  cursor: pointer;
}
.seg button.active { background: #3da9ff; color: #08111f; border-color: #3da9ff; font-weight: 700; }

/* ---- Tutorial-Blase ---- */
.tutorial-bubble {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(560px, 92vw);
  background: rgba(16, 24, 38, 0.95);
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 16px;
  padding: 14px 18px;
  display: none;
  z-index: 30;
}
.tutorial-bubble.show { display: block; }
.tutorial-bubble p { margin: 0 0 10px; font-size: 15px; color: #f4e9c8; }
.tutorial-btns { display: flex; gap: 10px; justify-content: flex-end; }
.tutorial-btns button {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #cdd7e8;
  font-size: 14px;
  cursor: pointer;
}
.tutorial-btns button.primary { background: #ffd166; color: #17202f; border-color: #ffd166; font-weight: 700; }

/* Farb-Muster auf Linien-Farbfeldern im Farbenblind-Modus */
.swatch.cb {
  background-image: repeating-linear-gradient(
    135deg,
    var(--c) 0 6px,
    rgba(0, 0, 0, 0.55) 6px 9px
  );
}
