:root {
  --gap: 16px;
  --card: #ffffff;
  --bg: #0f172a;
  --muted: #e2e8f0;
  --accent: #22c55e;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    "Noto Sans";
  background: var(--bg);
  color: #0b1020;
  line-height: 1.5;
}

a {
  color: inherit;
}

.container {
  width: min(100% - 32px, 1100px);
  margin: 0 auto;
  padding: clamp(16px, 4vw, 32px);
}

.layout-sm {
  max-width: 520px;
}

.layout-md {
  max-width: 760px;
}

.layout-lg {
  max-width: 980px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  padding: 20px;
}

.card + .card {
  margin-top: var(--space-lg);
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-sm) 0;
  line-height: 1.25;
}

p {
  margin: 0 0 var(--space-sm) 0;
}

label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 600;
}

.muted {
  color: #64748b;
}

.muted-small {
  color: #64748b;
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-light {
  color: #fff;
}

.text-xs {
  font-size: 12px;
}

.mt-0 {
  margin-top: 0;
}

.mt-xs {
  margin-top: var(--space-xs);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mt-2xl {
  margin-top: var(--space-2xl);
}

.mb-0 {
  margin-bottom: 0;
}

.grid {
  display: grid;
  gap: var(--gap);
}

.grid-2 {
  grid-template-columns: 1fr;
}

.stack,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.grow {
  flex: 1 1 220px;
}

.btn {
  background: #111827;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #0b1220;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.select,
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #fff;
}

.toggle {
  display: inline-flex;
  gap: var(--space-sm);
  align-items: center;
}

.check-grid {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.kvs {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  gap: var(--space-xs) var(--space-md);
}

.list {
  margin: var(--space-xs) 0 0 var(--space-md);
}

.preview-grid {
  display: grid;
  gap: var(--space-lg);
}

.errors-block h4 {
  margin: 0 0 var(--space-xs) 0;
}

.errors-block ul {
  margin: 0 0 var(--space-sm) var(--space-md);
}

.divider {
  height: 1px;
  background: #e2e8f0;
  margin: var(--space-sm) 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  background: #f1f5f9;
  border-radius: 999px;
  font-size: 12px;
}

.pill-muted {
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

.ok {
  color: #16a34a;
  font-weight: 600;
}

.bad {
  color: #dc2626;
  font-weight: 600;
}

.warn {
  color: #ca8a04;
  font-weight: 600;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 10px;
  border-bottom: 1px dashed #e5e7eb;
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-item.editing {
  background: #f8fafc;
  border-radius: 10px;
  padding: 10px;
}

.rank {
  width: 32px;
  text-align: right;
  font-weight: 700;
}

.pts {
  width: 90px;
  text-align: right;
}

.lb-top {
  background: rgba(34, 197, 94, 0.12);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.25) inset,
    0 6px 18px rgba(34, 197, 94, 0.15);
}

.leaderboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.footer {
  color: var(--muted);
  text-align: center;
  margin-top: var(--space-lg);
}

.requires-auth {
  display: none;
}

.requires-auth.auth-on {
  display: flex;
}

.admin-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: flex-start;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.tab {
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  background: #64748b;
  color: #fff;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.danger {
  background: #dc2626;
  color: #fff;
}

.hidden {
  display: none !important;
}

.pin-input {
  -webkit-text-security: disc;
  text-security: disc;
}

.large-code {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 6px;
}

details summary {
  cursor: pointer;
  padding: var(--space-sm) 0;
}

.choice-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-xs) 0;
}

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  background: #e2e8f0;
}

.choice {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin: 8px 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff; /* ensures a consistent base */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease;
}

.choice:active {
  background: #eff6ff; /* optional pressed state */
}

.choice:focus-visible {
  outline: 2px solid var(--siemens-teal);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .choice:hover {
    background: #f1f5f9;
  }
}

.choice.disabled {
  opacity: 0.6;
  cursor: default;
}

.choice-correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}

.choice-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.07);
}

.team-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 10px;
  margin: var(--space-sm) 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.team-collapsible > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: 6px 2px;
}

.team-collapsible > summary::-webkit-details-marker {
  display: none;
}

.team-summary::after {
  content: "▾";
  margin-left: 8px;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.team-collapsible[open] .team-summary::after {
  transform: rotate(180deg);
}

.team-title {
  font-weight: 600;
}

.team-body {
  padding: 6px 4px 2px 4px;
}

.team-member {
  padding: 3px 0;
}

.timer-wrap {
  margin-top: var(--space-sm);
}

.timer-bar {
  position: relative;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.timer-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: #22c55e;
  transition: width 0.1s linear;
}

.timer-badge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: -26px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s linear;
  white-space: nowrap;
}

.timer-badge--pin {
  right: 2px;
  transform: translateY(-50%);
}

.footer-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: stretch;
  margin-top: var(--space-lg);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
}

.chip--ok {
  background: rgba(34, 197, 94, 0.18);
}

.chip--bad {
  background: rgba(239, 68, 68, 0.18);
}

.big-score {
  font-size: 32px;
  font-weight: 800;
  margin: var(--space-sm) 0 var(--space-xs) 0;
}

.subtle {
  color: #64748b;
  font-size: 13px;
}

.icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  margin-right: 8px;
  flex: 0 0 22px;
}

.icon-ok {
  background: #22c55e;
}

.icon-bad {
  background: #ef4444;
}

.q-line {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.q-text {
  flex: 1 1 200px;
}

#msg {
  min-height: 18px;
  display: inline-block;
}

#emptyAll {
  display: none;
}

@media (min-width: 600px) {
  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

@media (min-width: 720px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .admin-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .header-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .card {
    padding: 16px;
  }

  .tabs {
    gap: var(--space-xs);
  }

  .leaderboard-item {
    flex-wrap: wrap;
  }

  .rank,
  .pts {
    width: auto;
  }
}
