:root {
  --bg: #151515;
  --card: #1f1f1f;
  --card2: #262626;
  --text: #f2f2f2;
  --muted: #b9b9b9;
  --muted2: #9a9a9a;
  --accent: #7c3aed;
  --danger: #ef4444;
  --ok: #22c55e;
  --border: #323232;
  --shadow: 0 12px 30px rgba(0,0,0,0.40);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --thumb-cols: 2;
  --thumb-h: 260px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.h-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.h-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}
.h-title .sub {
  font-size: 13px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }

@media (max-width: 900px) {
  .col-8, .col-6, .col-4 { grid-column: span 12; }
}

.row { display:flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: #1c1c1c;
  border-radius: 999px;
}

.timer-big {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 900;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #1c1c1c;
  border-radius: 14px;
  min-width: 118px;
  text-align: center;
}

.timer-big.red {
  color: var(--danger);
  border-color: rgba(239,68,68,0.6);
}


.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
}
.btn:hover { background: #2d2d2d; }
.btn.primary { background: #3b1a7a; border-color: #5b2aa7; }
.btn.primary:hover { background: #47208f; }
.btn.danger { background: #3a1a1a; border-color: #7a2a2a; }
.btn.danger:hover { background: #4a1f1f; }
.btn.ok { background: #183022; border-color: #1f6a3b; }
.btn.ok:hover { background: #1b3a2a; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.input {
  border: 1px solid var(--border);
  background: #1c1c1c;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
}

.small { font-size: 12px; color: var(--muted); }

.hr { height:1px; background: var(--border); margin: 12px 0; }

.list {
  display:flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display:flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #1c1c1c;
}

.badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.online { border-color: rgba(34,197,94,0.6); color: rgba(34,197,94,0.95); background: rgba(34,197,94,0.10); }
.badge.offline { border-color: rgba(255,255,255,0.18); }

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 92vw;
  display: none;
  z-index: 9999;
}

.canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #1c1c1c;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 560px;
  display: block;
  touch-action: none;
  background: white;
}

@media (max-width: 900px) {
  canvas { height: 440px; }
}

@media (max-width: 600px) {
  canvas { height: 360px; }
}

.tools {
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: #181818;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(var(--thumb-cols), minmax(0, 1fr));
  gap: 12px;
}

.card-img {
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #1c1c1c;
  cursor: pointer;
}
.card-img:hover { background: #232323; }
.card-img.selected { outline: 2px solid rgba(124,58,237,0.8); }
.card-img.correct { outline: 2px solid rgba(34,197,94,0.75); }
.card-img.odd { outline: 2px solid rgba(239,68,68,0.75); }

.card-img img {
  width: 100%;
  height: var(--thumb-h);
  object-fit: contain;
  background: white;
  border-radius: 12px;
  display: block;
}

.name {
  margin-top: 8px;
  font-weight: 700;
}
.voters {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.kbd {
  font-family: var(--mono);
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #1c1c1c;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding: 8px;
  text-align: left;
}
.table th { color: var(--muted); font-size: 12px; font-weight: 700; }

.footer-note { margin-top: 10px; color: var(--muted2); font-size: 12px; }

/* site footer */
.site-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted2);
  padding: 10px 16px 16px;
}

.hidden { display:none !important; }

/* --- Modal (Host "Datenbank") --- */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9998;
}

.modal.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
}

.modal-panel {
  position: relative;
  max-width: 1200px;
  margin: 40px auto;
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: var(--card);
}

.db-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #1c1c1c;
  overflow-x: auto;
}

.db-row .idx {
  width: 42px;
  flex: 0 0 42px;
  text-align: right;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.db-row .db-input {
  flex: 1 1 260px;
  min-width: 220px;
}

.db-row .db-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
