:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #16171b;
    --surface: #1f2127;
    --border: #2e3038;
    --text: #f2f3f5;
    --text-muted: #9aa0ab;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --success: #4ade80;
  }
}

:root[data-theme='dark'] {
  --bg: #16171b;
  --surface: #1f2127;
  --border: #2e3038;
  --text: #f2f3f5;
  --text-muted: #9aa0ab;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --success: #4ade80;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

header.topbar h1 {
  font-size: 18px;
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 800px) {
  .grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input[type='text'],
input[type='password'],
input[type='number'],
select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-row > div {
  flex: 1;
  min-width: 160px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--primary-hover);
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--bg);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-size: 13px;
}

button.danger:hover {
  background: var(--danger);
  color: white;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

ul.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

ul.list li:last-child {
  border-bottom: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0;
}

.success {
  color: var(--success);
  font-size: 13px;
  margin: 8px 0;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 0;
}

.checkbox-list input[type='checkbox'] {
  width: auto;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.group-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.group-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.group-card ol {
  margin: 0;
  padding-left: 20px;
}

nav.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

nav.tabs button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

nav.tabs button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

a.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
}

a.link:hover {
  text-decoration: underline;
}

/* ---------- Sorteador: header con marca ---------- */

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 16px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon-wrap svg {
  width: 26px;
  height: 26px;
  color: white;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

.text-gradient {
  background: linear-gradient(90deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.btn-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-pill svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Sorteador: configuración ---------- */

.config-grid {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.field {
  flex: 1;
  min-width: 200px;
}

.field-stepper {
  flex: 0 0 auto;
  min-width: 0;
}

.field label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field label svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stepper {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  width: fit-content;
}

.stepper-btn {
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 0;
  width: 38px;
  font-size: 18px;
  font-weight: 700;
  padding: 0;
}

.stepper-btn:hover {
  background: var(--border);
}

.stepper input {
  border: none;
  background: transparent;
  width: 56px;
  text-align: center;
  border-radius: 0;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper input:focus {
  outline: none;
}

.btn-gradient {
  background: linear-gradient(90deg, var(--primary), #a855f7);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding: 11px 22px;
}

.btn-gradient:hover {
  filter: brightness(1.08);
  background: linear-gradient(90deg, var(--primary), #a855f7);
}

.btn-gradient svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-with-icon svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- Sorteador: resultado ---------- */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.results-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-title .emoji {
  font-size: 26px;
  line-height: 1;
}

.results-title h2 {
  margin: 0;
  font-size: 18px;
}

.results-title p {
  margin: 2px 0 0;
}

.results-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.group-card-v2 {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.group-card-v2::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
}

.group-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.group-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.group-icon svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.group-card-header h3 {
  margin: 0;
  font-size: 16px;
  flex: 1;
}

.pill-accent {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: transparent;
  color: var(--accent);
  font-weight: 600;
}

.group-members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-members li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.member-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

@media print {
  .hero-header,
  .config-card,
  .results-actions,
  .btn-pill {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .group-card-v2 {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
