:root {
  --bg: #7a1424;
  --bg-2: #5c0e1b;
  --paper: #fffaf2;
  --ink: #2b1a14;
  --muted: #6d5a50;
  --green: #1f6b3a;
  --green-dark: #154d29;
  --gold: #e8b64c;
  --line: #e7dccd;
  --danger: #a3242f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 50% 0%, var(--bg) 0%, var(--bg-2) 100%) fixed;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 20px;
  line-height: 1.45;
  padding: 24px 16px 48px;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
}

.header {
  text-align: center;
  color: var(--paper);
  margin-bottom: 20px;
}
.header .tree { font-size: 48px; line-height: 1; }
.header h1 {
  margin: 8px 0 0;
  font-size: 32px;
  letter-spacing: 0.5px;
}

.panel {
  background: var(--paper);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 26px;
  text-align: center;
}
.lead {
  margin: 0 0 22px;
  text-align: center;
  color: var(--muted);
}

.names {
  display: grid;
  gap: 12px;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  -webkit-tap-highlight-color: transparent;
}

.name-btn {
  width: 100%;
  padding: 18px 16px;
  font-size: 24px;
  font-weight: 600;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--line);
}
.name-btn:hover, .name-btn:focus-visible {
  border-color: var(--green);
  outline: none;
}

.big-btn {
  display: block;
  width: 100%;
  padding: 20px 16px;
  font-size: 24px;
  font-weight: 700;
  background: var(--green);
  color: #fff;
}
.big-btn:hover, .big-btn:focus-visible { background: var(--green-dark); outline: none; }
.big-btn:disabled { opacity: 0.6; cursor: default; }

.plain-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  font-size: 20px;
  background: transparent;
  color: var(--muted);
  border: 2px solid var(--line);
}

.who {
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  margin: 6px 0 24px;
  color: var(--green);
}

.error {
  background: #fdecee;
  color: var(--danger);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: center;
}

/* ---------- Kaart, mida tuleb all hoida ---------- */

.card-stage {
  perspective: 1200px;
  margin: 8px auto 18px;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 5 / 7;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.card {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
  cursor: pointer;
}
.card.revealed { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.card-front {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.07) 0 14px, transparent 14px 28px),
    var(--green);
  color: #fff;
  border: 6px solid var(--gold);
}
.card-front .gift { font-size: 84px; line-height: 1; }
.card-front .hint { margin-top: 18px; font-size: 22px; font-weight: 700; }

.card-back {
  background: #fff;
  border: 6px solid var(--gold);
  transform: rotateY(180deg);
}
.card-back { padding: 10px; }
.card-back .small { color: var(--muted); font-size: 20px; }
.card-back .receiver {
  /* font-size seatakse skriptis nii suureks, kui kaardile mahub */
  font-size: 96px;
  line-height: 1;
  font-weight: 800;
  color: var(--bg);
  margin: 16px 0;
  width: 100%;
  overflow: hidden;
}

.note {
  text-align: center;
  color: var(--muted);
  font-size: 18px;
  margin: 0;
}

.hidden { display: none !important; }

.footer {
  text-align: center;
  margin-top: 28px;
}
.admin-link {
  display: inline-block;
  padding: 8px 18px;
  font-size: 16px;
  color: rgba(255, 250, 242, 0.75);
  border: 1px solid rgba(255, 250, 242, 0.35);
  border-radius: 999px;
  text-decoration: none;
}
.admin-link:hover, .admin-link:focus-visible { color: var(--paper); border-color: var(--paper); }

/* ---------- Admin ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}
.stat .num { font-size: 36px; font-weight: 800; color: var(--green); line-height: 1.1; }
.stat .lbl { font-size: 16px; color: var(--muted); }

.section { margin-top: 26px; }
.section h3 { margin: 0 0 10px; font-size: 21px; }

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: none; }
.list .time { color: var(--muted); font-size: 16px; }
.list .empty { color: var(--muted); justify-content: center; }

.small-btn {
  padding: 8px 12px;
  font-size: 16px;
  background: #fff;
  border: 2px solid var(--line);
  color: var(--ink);
  white-space: nowrap;
}
.small-btn.danger { color: var(--danger); }

.linkbox {
  display: flex;
  gap: 8px;
}
.linkbox input { flex: 1; min-width: 0; font-size: 16px; }

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

.reveal-list li { font-size: 22px; font-weight: 600; justify-content: center; }

.exclude-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.exclude-row select { flex: 1; min-width: 120px; }
.exclude-row span { color: var(--muted); }
select {
  font: inherit;
  padding: 12px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 18px; }
.check input { width: 22px; height: 22px; }

.giver-tag {
  text-align: center;
  font-size: 22px;
  color: var(--muted);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  margin: 0 auto 14px;
  width: fit-content;
  max-width: 100%;
}
.giver-tag strong { color: var(--green); font-size: 26px; }
