* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #e63946;
  --primary-dark: #c1121f;
  --secondary: #457b9d;
  --accent: #f4a261;
  --bg: #f1faee;
  --card: #ffffff;
  --text: #1d3557;
  --muted: #6b7280;
  --border: #d1d5db;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '🎁';
  font-size: 6rem;
  position: absolute;
  top: -1rem;
  left: -1.5rem;
  opacity: .15;
}
header::after {
  content: '🎄';
  font-size: 6rem;
  position: absolute;
  bottom: -1rem;
  right: -1rem;
  opacity: .15;
}
header h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -0.5px; }
header p  { margin-top: .5rem; opacity: .9; font-size: 1.05rem; }

/* ── Layout ── */
main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Form elements ── */
label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
input, textarea, select {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: #fafafa;
  transition: border-color .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--secondary);
  background: #fff;
}
textarea { resize: vertical; min-height: 80px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 500px) { .field-row { grid-template-columns: 1fr; } }

/* ── Participants table ── */
.participants-table-wrap { overflow-x: auto; }

.participants-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.participants-table thead th {
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
  padding: .4rem .5rem .6rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.participants-table thead th.col-num { text-align: center; width: 32px; }
.participants-table thead th.col-remove { width: 36px; }

.participant-row td {
  padding: .3rem .4rem;
  vertical-align: middle;
}
.participant-row + .participant-row td { border-top: 1px solid var(--bg); }

.participant-row .col-num {
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  padding-right: .25rem;
}

.participant-row .p-cell input,
.participant-row .p-cell select {
  padding: .45rem .6rem;
  font-size: .88rem;
  border-radius: 7px;
}
.participant-row .p-cell input:focus,
.participant-row .p-cell select:focus { border-color: var(--secondary); background: #fff; }

.participant-row .p-cell.cell-error input,
.participant-row .p-cell.cell-error select { border-color: var(--primary); background: #fff8f8; }

.participant-row .col-remove { text-align: center; }
.remove-row-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  padding: .25rem .4rem;
  border-radius: 5px;
  transition: color .2s, background .2s;
  line-height: 1;
}
.remove-row-btn:hover { color: var(--primary); background: #fff0f1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, box-shadow .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(230,57,70,.35);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(230,57,70,.45); }
.btn-secondary {
  background: var(--secondary);
  color: white;
  box-shadow: 0 2px 8px rgba(69,123,157,.3);
}
.btn-secondary:hover { background: #355e78; }
.btn-danger { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-danger:hover { background: #fff0f1; }
.btn-big {
  width: 100%;
  padding: .9rem;
  font-size: 1.1rem;
  border-radius: 10px;
  letter-spacing: .2px;
}

/* ── Validation ── */
.error-msg {
  color: var(--primary);
  font-size: .82rem;
  margin-top: .3rem;
  display: none;
}
.field-error input, .field-error textarea { border-color: var(--primary); }
.field-error .error-msg { display: block; }

/* ── Alerts ── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: .6rem;
}
.alert.show     { display: flex; }
.alert-warning  { background: #fff7ed; border: 1.5px solid #fdba74; color: #9a3412; }
.alert-success  { background: #f0fdf4; border: 1.5px solid #86efac; color: #166534; }
.alert-error    { background: #fff0f1; border: 1.5px solid #fca5a5; color: #991b1b; }

/* ── Results overlay ── */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#overlay.show { display: flex; }

.modal {
  background: var(--card);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 1.5rem 1.75rem;
  text-align: center;
}
.modal-header h2 { font-size: 1.5rem; }
.modal-header p  { opacity: .9; margin-top: .35rem; font-size: .95rem; }

.modal-body { padding: 1.5rem 1.75rem; }
.modal-body > p {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.result-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
.result-list li {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--bg);
  border-radius: 10px;
}
.result-list li .arrow    { color: var(--primary); font-size: 1.1rem; }
.result-list li .giver    { font-weight: 700; }
.result-list li .receiver { color: var(--secondary); font-weight: 600; }

.modal-footer {
  padding: 1rem 1.75rem 1.5rem;
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ── Confetti canvas ── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

/* ── Step indicator ── */
.steps {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin-bottom: 1rem;
}
.step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  background: var(--border);
  color: var(--muted);
}
.step.active { background: var(--primary); color: white; }
.step-label  { font-size: .75rem; color: var(--muted); text-align: center; margin-top: .2rem; }
.step-item   { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  align-self: center;
  margin-bottom: 1.2rem;
  max-width: 60px;
}

/* ── Draw button area ── */
.draw-btn-wrap { text-align: center; }
.draw-btn-wrap .hint { font-size: .82rem; color: var(--muted); margin-top: .5rem; }

/* ── Exclusion text input ── */
.p-exclude-text { min-width: 140px; }

/* ── Modal success body ── */
.modal-body-success {
  text-align: center;
  padding: 2.25rem 1.75rem;
}
.success-icon  { font-size: 3.5rem; margin-bottom: .75rem; }
.success-title { color: var(--text); font-size: 1.2rem; margin-bottom: .6rem; }
.success-msg   { color: var(--muted); font-size: .95rem; line-height: 1.6; margin: 0; }
