* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #14121a;
  --card: #1f1c29;
  --line: #322d42;
  --txt: #ece9f5;
  --muted: #9b94b3;
  --accent: #7c3aed;
  --danger: #e11d48;
  --ok: #16a34a;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--txt);
  overflow-x: hidden;
}

/* ---------- Spielbildschirm ---------- */
#game {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  transition: background-color .5s ease;
  background: var(--accent);
}
#game .top { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; }
.level-cluster { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#stage-badge {
  background: rgba(0,0,0,.28); color: #fff; font-weight: 800;
  border-radius: 14px; padding: 8px 16px; font-size: 22px; backdrop-filter: blur(4px);
  display: grid; place-items: center; min-width: 44px; line-height: 1;
}
.level-cluster #raise {
  flex: 0 0 auto; max-width: none; padding: 8px 16px; font-size: 14px; font-weight: 700;
  height: 40px; border: none; border-radius: 14px;
  background: rgba(0,0,0,.28); color: #fff; backdrop-filter: blur(4px); cursor: pointer;
}
.level-cluster #raise:active { transform: scale(.96); }
.level-cluster .vote-circles { flex: 1 1 100%; }
#gear {
  flex: 0 0 auto;
  background: rgba(0,0,0,.28); border: none; color: #fff; cursor: pointer;
  width: 46px; height: 46px; min-width: 46px; border-radius: 50%; font-size: 22px; display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
#task {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  color: #fff; padding: 24px; font-size: clamp(26px, 6vw, 46px); font-weight: 700;
  line-height: 1.3; text-shadow: 0 2px 18px rgba(0,0,0,.35);
}
/* Modul: Überschrift und Bild */
#task .card-vis { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-height: 100%; }
#task .card-vis .card-img { width: 100%; display: flex; justify-content: center; }
#task .card-vis .card-img img { max-width: 100%; max-height: 50vh; object-fit: contain; border-radius: 16px; background: #fff; }
#task .card-vis .card-title { font-size: clamp(30px, 9vw, 64px); font-weight: 900; letter-spacing: .02em; line-height: 1.1; }

/* Modul: Text und Bild (50/50) */
#task .card-split { display: flex; gap: 20px; align-items: center; width: 100%; }
#task .card-split .card-text { flex: 1 1 50%; text-align: left; font-size: clamp(18px, 3.4vw, 30px); font-weight: 600; line-height: 1.35; }
#task .card-split .card-img { flex: 1 1 50%; display: flex; justify-content: center; }
#task .card-split .card-img img { max-width: 100%; max-height: 55vh; object-fit: contain; border-radius: 16px; background: #fff; }
@media (max-width: 520px) {
  #task .card-split { flex-direction: column; gap: 14px; }
  #task .card-split .card-text { text-align: center; }
}

#bottom { padding: 0 20px calc(20px + env(safe-area-inset-bottom)); }
#player-name {
  text-align: center; color: #fff; font-size: 22px; font-weight: 600; margin-bottom: 14px;
  text-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.action-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 12px; }
.action-row .ghost {
  flex: 1; max-width: 200px; padding: 12px; border-radius: 14px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.22); color: #fff;
  font-size: 15px; font-weight: 700; backdrop-filter: blur(4px);
}
.action-row .ghost:active { transform: scale(.97); }
#penalty-info { display: block; text-align: center; color: #fff; font-weight: 600; opacity: .9; font-size: 12px; margin-bottom: 10px; }
.action-row { align-items: center; }
.vote-circles { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 0 0 auto; }
.vote { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; border: 2px solid rgba(255,255,255,.85); background: rgba(0,0,0,.18);
  transition: transform .15s ease; }
.vote.on { background: rgba(255,255,255,.95); transform: scale(1.08); }
.vote.pen { font-weight: 800; color: #fff; }
.vote.pen.done { opacity: .4; }
.vote.pen.on { background: rgba(255,255,255,.95); color: #111; transform: scale(1.08); }
#next {
  width: 100%; padding: 18px; border: none; border-radius: 18px; cursor: pointer;
  background: rgba(255,255,255,.95); color: #111; font-size: 20px; font-weight: 800;
}
#next:active { transform: scale(.98); }
.hint { text-align: center; color: rgba(255,255,255,.85); margin-top: 14px; font-size: 14px; }

/* ---------- Admin / Einstellungen ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin-bottom: 4px; }
h2 { font-size: 17px; margin: 28px 0 12px; color: var(--txt); }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
a.back { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 15px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=number], input[type=password] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #161320; color: var(--txt); font-size: 16px;
}
input[type=color] { width: 56px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #161320; }
.row { display: flex; gap: 12px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 12px 16px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 15px; font-weight: 700; background: var(--accent); color: #fff;
}
.btn.secondary { background: #2a2638; color: var(--txt); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn:active { transform: scale(.98); }

/* Admin-Menü / Tabs */
.admin-menu { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 8px 0; }
.admin-menu .menu-btn {
  flex: 1 1 auto; min-width: 84px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: #161320; color: var(--muted); font-size: 14px; font-weight: 700;
}
.admin-menu .menu-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.admin-menu .menu-btn:active { transform: scale(.97); }
.admin-section { display: none; }
.admin-section.active { display: block; }

.stage-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.stage-grid button {
  padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #161320;
  color: var(--txt); cursor: pointer; text-align: left; font-size: 14px;
}
.stage-grid button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.stage-grid button:disabled { opacity: .4; cursor: not-allowed; }
.stage-grid button small { display: block; opacity: .7; font-size: 11px; margin-top: 3px; }

.consent { display: grid; gap: 8px; margin-top: 8px; }
.consent label { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--txt); font-size: 15px;
  padding: 10px 12px; background: #161320; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.consent input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Geschlechts-Umschalter m/d/w */
.gender-toggle { display: flex; gap: 8px; margin-top: 8px; }
.gender-toggle .g-opt {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #161320; color: var(--txt); cursor: pointer; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px; line-height: 1;
}
.gender-toggle .g-opt .g-ico { font-size: 17px; line-height: 1; display: inline-block; }

/* Ausklappbare „Erweiterte Einstellungen" */
details.advanced { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: #161320; }
details.advanced > summary {
  list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 700; color: var(--txt);
  display: flex; align-items: center; justify-content: space-between; user-select: none;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::after { content: '⌄'; transition: transform .2s; opacity: .7; }
details.advanced[open] > summary::after { transform: rotate(180deg); }
details.advanced .advanced-body { padding: 0 14px 14px; }
details.advanced .advanced-body label:first-child { margin-top: 0; }
.gender-toggle .g-opt.on[data-g="m"] { background: #2563eb; border-color: #2563eb; color: #fff; }
.gender-toggle .g-opt.on[data-g="d"] { background: #6b7280; border-color: #6b7280; color: #fff; }
.gender-toggle .g-opt.on[data-g="w"] { background: #ec4899; border-color: #ec4899; color: #fff; }
.gender-toggle .g-opt:active { transform: scale(.97); }
.consent label.locked { opacity: .7; }

/* Spielerliste mit Swipe */
.player-list { display: grid; gap: 10px; margin-top: 8px; }
.swipe { position: relative; overflow: hidden; border-radius: 12px; }
.swipe .del {
  position: absolute; inset: 0; background: var(--danger); display: flex; align-items: center;
  justify-content: flex-end; padding-right: 22px; color: #fff; font-weight: 700;
}
.swipe .front {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: transform .18s ease; touch-action: pan-y;
}
.dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; }
.swipe .front .nm { font-weight: 600; flex: 1; }
.swipe .front .chev { color: var(--muted); }

.dropzone {
  border: 2px dashed var(--line); border-radius: 16px; padding: 28px 16px; text-align: center;
  color: var(--muted); background: #161320; cursor: pointer; transition: .15s;
}
.dropzone.drag { border-color: var(--accent); color: var(--txt); background: #1c1830; }
.dropzone strong { color: var(--txt); }
.import-status { margin-top: 10px; font-size: 14px; }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center;
  justify-content: center; padding: 20px; z-index: 50;
}
.modal-back.show { display: flex; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal h3 { margin-bottom: 10px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2a2638; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 100;
  border: 1px solid var(--line); opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.muted-block { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Spielcode-Gate */
.code-gate { text-align: center; }
.code-gate .logo { width: 140px; height: 140px; margin: 0 auto 14px; display: block; object-fit: contain; }
.code-gate h3 { margin-bottom: 6px; }
.code-gate input { text-align: center; letter-spacing: 1px; font-weight: 700; text-transform: lowercase; margin-top: 6px; }
.code-gate .actions { justify-content: center; }
.code-gate .buy-link { display: inline-block; margin-top: 14px; color: var(--accent); font-weight: 700; text-decoration: none; }
.code-gate .buy-link:active { opacity: .8; }

/* ---------- Shop ---------- */
.shop-hero { text-align: center; margin: 18px 0 22px; }
.shop-hero .logo { width: 120px; height: 120px; object-fit: contain; margin-bottom: 12px; }
.shop-hero h1 { margin-bottom: 4px; }
.product { display: flex; gap: 16px; align-items: center; }
.product-media img { width: 120px; height: 120px; border-radius: 14px; object-fit: contain; }
.product-info { flex: 1; }
.feat { list-style: none; margin: 8px 0; display: grid; gap: 4px; color: var(--muted); font-size: 14px; }
.price { font-size: 26px; font-weight: 800; color: var(--txt); }
.qty { display: inline-flex; align-items: center; gap: 12px; background: #161320; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; }
.qty span { min-width: 18px; text-align: center; font-weight: 700; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cl-name { font-weight: 600; }
.cl-sum { font-weight: 700; min-width: 72px; text-align: right; }
.cart-total { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; font-size: 18px; }
@media (max-width: 520px) {
  .product { flex-direction: column; align-items: stretch; }
  .product-media { text-align: center; }
}

/* Aufgaben-Tabelle */
.task-table { margin-top: 12px; }
.task-head, .task-row {
  display: grid; grid-template-columns: 110px 1fr 2fr 76px; gap: 10px; align-items: start;
  padding: 10px 8px; border-bottom: 1px solid var(--line);
}
.task-head { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.task-row { font-size: 14px; }
.t-module { font-weight: 700; }
.t-cats { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #2a2638; border: 1px solid var(--line); border-radius: 8px; padding: 2px 6px; font-size: 11px; white-space: nowrap; }
.t-text { color: var(--txt); }
.t-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn { background: #2a2638; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 15px; padding: 6px 8px; }
.icon-btn:active { transform: scale(.95); }

.code-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.code-name { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .02em; }
.code-note { grid-column: 1 / -1; width: 100%; box-sizing: border-box; background: #1e1b29; border: 1px solid var(--line); border-radius: 8px; color: var(--txt); font-size: 13px; padding: 7px 9px; }
.code-note::placeholder { color: var(--muted); }
.code-note:focus { outline: none; border-color: var(--accent); }
.code-note.saved { border-color: #22c55e; }
@media (max-width: 560px) {
  .task-head { display: none; }
  .task-row { grid-template-columns: 1fr 64px; grid-template-areas: 'module actions' 'cats actions' 'text text'; }
  .t-module { grid-area: module; } .t-cats { grid-area: cats; } .t-text { grid-area: text; } .t-actions { grid-area: actions; }
}
