:root {
  --bg-deep: #0b1d16;
  --bg-mid: #122b21;
  --card-bg: rgba(20, 45, 35, 0.82);
  --card-border: rgba(212, 175, 55, 0.28);
  --gold: #f3c65f;
  --gold-bright: #ffe08a;
  --crimson: #c92a2a;
  --crimson-hover: #e03131;
  --pine-light: #2b6e52;
  --text-main: #f8f9fa;
  --text-muted: #b7cec3;
  --danger: #ff6b6b;
  --success: #51cf66;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #1b4332 0%, #0b1d16 65%, #07120e 100%);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

#snow-canvas,
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#confetti-canvas {
  z-index: 999;
}

.app-wrapper {
  position: relative;
  z-index: 2;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  margin-bottom: 28px;
}

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

.brand-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 2px 8px rgba(243, 198, 95, 0.4));
}

.brand h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--gold-bright);
  letter-spacing: 0.3px;
}

.brand p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.user-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-admin {
  background: var(--gold);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
}

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

.btn-primary {
  background: linear-gradient(135deg, #d93838 0%, #a61e1e 100%);
  border-color: rgba(255, 200, 150, 0.3);
  color: #fff;
  box-shadow: 0 4px 15px rgba(201, 42, 42, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #e84545 0%, #b82525 100%);
  box-shadow: 0 6px 20px rgba(201, 42, 42, 0.55);
}

.btn-gold {
  background: linear-gradient(135deg, #f3c65f 0%, #d49b27 100%);
  color: #162119;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(243, 198, 95, 0.3);
}

.btn-gold:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffe08a 0%, #e0a832 100%);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.35);
  color: #ff9999;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.28);
}

/* Cards & Layout */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 20px;
}

/* Login Box */
.login-container {
  max-width: 440px;
  margin: 48px auto;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input,
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 22, 16, 0.75);
  color: var(--text-main);
  font-size: 0.96rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

.input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(243, 198, 95, 0.15);
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 11px 20px;
  border-radius: var(--radius-md);
  background: rgba(20, 45, 35, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(243, 198, 95, 0.22), rgba(201, 42, 42, 0.25));
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Interactive Gift Lot Box */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

.wichtel-stage {
  margin-top: 18px;
  padding: 26px 20px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at center, rgba(243, 198, 95, 0.14) 0%, rgba(9, 24, 18, 0.78) 100%);
  border: 1px dashed rgba(243, 198, 95, 0.45);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.gift-box-interactive {
  font-size: 4.8rem;
  display: inline-block;
  cursor: pointer;
  user-select: none;
  margin: 12px 0;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.5));
  transition: transform 0.25s ease;
}

.gift-box-interactive:hover {
  transform: scale(1.08) rotate(-3deg);
}

.gift-shaking {
  animation: giftShake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) infinite;
}

@keyframes giftShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1.1); }
  15% { transform: translate(-8px, -6px) rotate(-10deg) scale(1.15); }
  30% { transform: translate(8px, -4px) rotate(10deg) scale(1.15); }
  45% { transform: translate(-8px, 4px) rotate(-8deg) scale(1.18); }
  60% { transform: translate(8px, 2px) rotate(8deg) scale(1.18); }
  75% { transform: translate(-5px, -3px) rotate(-5deg) scale(1.14); }
}

.revealed-card {
  animation: popReveal 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes popReveal {
  0% {
    opacity: 0;
    transform: scale(0.75) translateY(15px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.partner-name-banner {
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold-bright);
  margin: 10px 0 6px;
  text-shadow: 0 2px 14px rgba(243, 198, 95, 0.45);
}

.wishlist-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  text-align: left;
  font-size: 0.9rem;
}

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-main);
}

.chip.active-group {
  background: rgba(81, 207, 102, 0.2);
  border-color: #51cf66;
  color: #b2f2bb;
}

/* Admin Tables & Rules */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  vertical-align: middle;
}

th {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(243, 198, 95, 0.35);
  color: var(--gold-bright);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.86rem;
}

/* Rules Matrix */
.rule-row {
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.rule-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.rule-pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rule-pill:hover {
  transform: translateY(-1px);
}

.rule-pill.rule-exclude {
  background: rgba(224, 49, 49, 0.28);
  border-color: #ff6b6b;
  color: #ffc9c9;
}

.rule-pill.rule-allow {
  background: rgba(243, 198, 95, 0.28);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.alert-error {
  background: rgba(201, 42, 42, 0.25);
  border: 1px solid #ff6b6b;
  color: #ffd8d8;
}

.alert-success {
  background: rgba(43, 138, 62, 0.28);
  border: 1px solid #51cf66;
  color: #d3f9d8;
}

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

@media (max-width: 720px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .top-header {
    padding: 14px 16px;
  }
}
