/* Palabunutan — Apple-style, centered, phone first */

:root {
  --bg: #f5f5f7;
  --tile: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #86868b;
  --line: #d2d2d7;
  --blue: #0071e3;
  --blue-press: #0062c4;
  --red: #c8102e;
  --gold: #e0a020;
  --green: #1f8a4c;
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 100%/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  transition: background-color 500ms ease;
}
body.dark { background: #000; }
button, select, input { font: inherit; color: inherit; }

/* ---------- screens: everything centered ---------- */
#app { max-width: 440px; margin: 0 auto; }
.screen {
  display: none; flex-direction: column; align-items: center; text-align: center;
  min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--safe-t) + 28px) 24px calc(var(--safe-b) + 24px);
}
.screen.active { display: flex; }
.screen.enter { animation: enter 480ms var(--spring) both; }
.screen.enter.from-left { animation-name: enter-left; }
@keyframes enter      { from { opacity: 0; transform: translateX(24px); } }
@keyframes enter-left { from { opacity: 0; transform: translateX(-24px); } }

.content { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.actions { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 20px; }

/* ---------- type (Apple scale) ---------- */
.display { margin: 4px 0 0; font-size: clamp(3rem, 14vw, 3.5rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.headline { margin: 0; font-size: 2.25rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.eyebrow { margin: 0; font-size: 1.06rem; font-weight: 600; color: var(--red); letter-spacing: -0.01em; }
.eyebrow.light { color: #f5f5f7; opacity: .8; font-weight: 500; font-size: 1.2rem; margin-bottom: 18px; }
.lead { margin: 0; font-size: 1.2rem; line-height: 1.38; color: var(--ink); letter-spacing: -0.012em; max-width: 20em; }
.lead.muted, .muted { color: var(--ink-3); }
.star { width: 56px; height: 56px; margin-bottom: 6px; filter: drop-shadow(0 6px 16px rgba(224, 160, 32, .35)); }

/* ---------- buttons ---------- */
.pill {
  min-width: 230px; min-height: 50px; padding: 0 28px; border-radius: 980px; border: 0; cursor: pointer;
  font-size: 1.06rem; font-weight: 500; letter-spacing: -0.01em;
  transition: transform 120ms ease-out, background-color 160ms ease, opacity 160ms ease;
  touch-action: manipulation;
}
.pill:active { transform: scale(0.97); }
.pill:disabled { opacity: .35; cursor: default; transform: none; }
.pill.primary { background: var(--blue); color: #fff; }
.pill.primary:active { background: var(--blue-press); }
.pill.light { background: #f5f5f7; color: #1d1d1f; }
.link { background: none; border: 0; padding: 10px 16px; color: var(--blue); font-size: 1.02rem; cursor: pointer; border-radius: 980px; touch-action: manipulation; }
.link:active { background: rgba(0, 113, 227, .08); }

.dots { display: flex; gap: 8px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: width 300ms var(--spring); }
.dots i.on { width: 22px; border-radius: 4px; background: var(--ink); }

/* ---------- how ---------- */
.steps { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; width: 100%; }
.steps li { background: var(--tile); border-radius: 18px; padding: 18px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.steps p { margin: 0; font-size: 1.04rem; line-height: 1.42; color: var(--ink); }
.steps b { font-weight: 600; }
.num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: .95rem; background: var(--ink); color: #fff; }

/* ---------- rules ---------- */
.rules { list-style: none; margin: 14px 0 6px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rules li { font-size: 1.1rem; line-height: 1.4; letter-spacing: -0.01em; }
.tile { background: var(--tile); border-radius: 18px; width: 100%; }
.details { padding: 6px 20px; }
.details > div { display: flex; flex-direction: column; align-items: center; padding: 12px 0; }
.details > div + div { border-top: 1px solid #e8e8ed; }
.details .label { font-size: .8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.details .value { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
.details small { font-weight: 400; color: var(--ink-3); font-size: .9rem; }

/* ---------- avatars ---------- */
.avatar {
  width: 76px; height: 76px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 1.5rem; color: #fff; background: var(--av, #888);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 104px; height: 104px; font-size: 2rem; margin-bottom: 6px; box-shadow: 0 8px 24px -8px rgba(0,0,0,.25); }
.avatar.xxl { width: 156px; height: 156px; font-size: 3rem; box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--gold); }

/* ---------- people ---------- */
.people { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 0; margin-top: 18px; width: 100%; }
.people > .person { width: 33.333%; }
.person { background: none; border: 0; padding: 6px 2px; border-radius: 18px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: transform 120ms ease-out; touch-action: manipulation; }
.person:active { transform: scale(0.93); }
.person .pic { position: relative; }
.person .avatar { box-shadow: 0 6px 16px -8px rgba(0,0,0,.35); }
.person .name { font-size: .98rem; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
.person .badge { position: absolute; right: -1px; bottom: -1px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; border: 2.5px solid var(--bg); }
.person.drawn .avatar { opacity: .4; filter: grayscale(1); }
.person.drawn .name { color: var(--ink-3); }
.person.drawn .badge { background: var(--green); color: #fff; }
.person.locked .badge { background: var(--ink); color: #fff; }
.legend { margin: 14px 0 0; color: var(--ink-3); font-size: .92rem; }
.tick { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--green); color: #fff; font-size: .68rem; font-weight: 700; margin-right: 4px; vertical-align: -3px; }

/* ---------- pin ---------- */
.pickers { display: flex; gap: 12px; width: 100%; max-width: 300px; margin-top: 14px; }
.picker { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.picker span { font-size: .8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.picker select {
  appearance: none; -webkit-appearance: none; width: 100%; height: 64px; border-radius: 16px; padding: 0 12px;
  font-size: 1.75rem; font-weight: 600; text-align: center; text-align-last: center;
  background: var(--tile); border: 1.5px solid var(--line); color: var(--ink); cursor: pointer;
}
.picker select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.15); }
.hint { margin: 6px 0 0; color: var(--ink-2); font-size: .98rem; }
.hint b { color: var(--ink); }
.error { min-height: 1.4em; margin: 2px 0 0; color: #e30000; font-size: .98rem; }
.shake { animation: shake 380ms ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- deck ---------- */
.deck { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 10px; width: 100%; margin-top: 18px; }
.deck > .card { width: calc((100% - 30px) / 4); }
.deck.few { grid-template-columns: repeat(2, minmax(0, 140px)); justify-content: center; }
.deck.one { grid-template-columns: minmax(0, 170px); justify-content: center; }
.card {
  aspect-ratio: 3 / 4; border-radius: 16px; border: 0; padding: 0; cursor: pointer; position: relative; overflow: hidden;
  transition: transform 380ms var(--spring), opacity 300ms ease, filter 300ms ease; touch-action: manipulation;
}
.card:active { transform: scale(0.95); }
.card, .card-art {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 215, 106, .22) 0 20%, transparent 21%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 2px, transparent 2px 12px),
    linear-gradient(160deg, #d3203a 0%, #8e0f22 100%);
  box-shadow: inset 0 0 0 1.5px rgba(255, 215, 106, .8), inset 0 0 0 6px #8e0f22, inset 0 0 0 7px rgba(255, 215, 106, .35), 0 10px 22px -10px rgba(142, 15, 34, .55);
}
.card::after, .card-art::after { content: "🎁"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; }
.deck.choosing .card { pointer-events: none; }
.deck.choosing .card:not(.chosen) { opacity: .15; transform: scale(.92); }
.card.chosen { transform: scale(1.08); animation: wiggle 900ms ease-in-out 120ms; z-index: 1; }
@keyframes wiggle { 0%,100% { rotate: 0deg; } 20% { rotate: -3deg; } 40% { rotate: 3deg; } 60% { rotate: -2deg; } 80% { rotate: 2deg; } }

/* ---------- reveal (Apple black tile) ---------- */
.screen.dark { color: #f5f5f7; }
.flip { position: relative; width: min(74vw, 290px); aspect-ratio: 3 / 4; transform-style: preserve-3d; transition: transform 900ms var(--spring); }
.flip.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: 28px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.back-face .card-art { position: absolute; inset: 0; }
.back-face .card-art::after { font-size: 3.4rem; }
.front-face { transform: rotateY(180deg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 20px; background: #1d1d1f; }
.reveal-name { margin: 8px 0 0; font-size: 2.25rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; color: #f5f5f7; }
.reveal-gift { margin: 0; color: #a1a1a6; font-size: 1rem; }
.after { margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0; transform: translateY(10px); transition: opacity 500ms ease 150ms, transform 600ms var(--spring) 150ms; }
.after.show { opacity: 1; transform: none; }
.note { margin: 0; font-size: 1.02rem; color: #f5f5f7; max-width: 20em; }
.note.strong b { color: #ffd76a; font-weight: 600; }
.note.dim { color: #86868b; font-size: .95rem; }

.big-ico { font-size: 3.2rem; margin-bottom: 4px; }

/* ---------- smaller phones ---------- */
@media (max-height: 700px) {
  .screen { padding-top: calc(var(--safe-t) + 16px); padding-bottom: calc(var(--safe-b) + 16px); }
  .headline { font-size: 2rem; }
  .steps li { padding: 14px 18px; }
  .details > div { padding: 9px 0; }
  .avatar { width: 66px; height: 66px; }
  .people { gap: 10px 0; margin-top: 10px; }
  .flip { width: min(60vw, 230px); }
  .avatar.xxl { width: 120px; height: 120px; }
}

/* ---------- accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  .screen.enter, .screen.enter.from-left { animation: fade 200ms ease both; }
  @keyframes fade { from { opacity: 0; } }
  .flip, .flip.flipped { transition: none; transform: none; }
  .flip.flipped .back-face { opacity: 0; }
  .flip.flipped .front-face { transform: none; }
  .card.chosen { animation: none; transform: none; }
}

/* ---------- organizer page ---------- */
.admin-wrap { max-width: 520px; margin: 0 auto; padding: calc(var(--safe-t) + 28px) 18px calc(var(--safe-b) + 40px); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.admin-wrap .tile { padding: 16px 18px; }
.admin-wrap h3 { margin: 0 0 10px; font-size: 1.15rem; letter-spacing: -0.01em; }

/* ---------- Santa (intro screens only) ---------- */
.santa-track { width: 100%; height: 92px; position: relative; overflow: hidden; display: flex; justify-content: center; }
.santa-walker { position: absolute; bottom: 0; left: 50%; margin-left: -36px; animation: pace 9s ease-in-out infinite; will-change: transform; }
.santa-hop { animation: hop 520ms ease-in-out infinite alternate; }
.santa { display: block; overflow: visible; }
.santa .leg { transform-box: fill-box; transform-origin: 50% 0; animation: step 520ms ease-in-out infinite alternate; }
.santa .leg-b { animation-direction: alternate-reverse; }
.santa .arm { transform-box: fill-box; transform-origin: 0 0; animation: swing 520ms ease-in-out infinite alternate; }
.santa .arm-b { animation-direction: alternate-reverse; }
@keyframes pace {
  0%   { transform: translateX(-120px) scaleX(1); }
  46%  { transform: translateX(120px)  scaleX(1); }
  50%  { transform: translateX(120px)  scaleX(-1); }
  96%  { transform: translateX(-120px) scaleX(-1); }
  100% { transform: translateX(-120px) scaleX(1); }
}
@keyframes hop   { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@keyframes step  { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
@keyframes swing { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }
@media (max-width: 340px) { @keyframes pace { 0%,100% { transform: translateX(-90px) scaleX(1); } 46% { transform: translateX(90px) scaleX(1); } 50% { transform: translateX(90px) scaleX(-1); } 96% { transform: translateX(-90px) scaleX(-1); } } }
@media (max-height: 700px) { .santa-track { height: 76px; } .santa { width: 60px; height: 72px; } .santa-walker { margin-left: -30px; } }
@media (prefers-reduced-motion: reduce) { .santa-walker, .santa-hop, .santa .leg, .santa .arm { animation: none; } }

/* ---------- 4-digit PIN boxes ---------- */
.code { position: relative; display: flex; gap: 12px; margin-top: 16px; cursor: text; }
.code .box {
  width: 58px; height: 68px; border-radius: 16px; background: var(--tile); border: 1.5px solid var(--line);
  display: grid; place-items: center; transition: border-color 160ms ease, box-shadow 160ms ease, transform 200ms var(--spring);
}
.code .box.filled::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); }
.code .box.next { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,227,.15); }
.code .box.filled { transform: scale(1.03); }
.code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.01; border: 0; background: transparent;
  color: transparent; caret-color: transparent; font-size: 16px; text-align: center; -webkit-appearance: none;
}
.code.busy { opacity: .5; pointer-events: none; }

/* compact centered steps (4 steps) */
.steps { gap: 10px; margin-top: 14px; }
.steps li { display: block; padding: 14px 18px; }
.steps li .num { display: inline-grid; width: 24px; height: 24px; font-size: .8rem; margin: 0 6px 0 0; vertical-align: 1px; }
.steps li p { display: inline; }
@media (max-height: 700px) { .steps li { padding: 11px 14px; } .steps p { font-size: .98rem; } .santa-track { height: 70px; } }
