* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --night: #0b1f3a; --card: #112a4e; --line: #28487a; --soft: #a9bdde; --pale: #cfe0ff;
  --red: #e23d3d; --green: #35c759; --gold: #ffd54a;
}
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--night); color: #fff;
  overflow: hidden;
}

/* gentle snowfall everywhere */
.snow {
  position: fixed; inset: -100px 0 0 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 90px 120px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 160px 60px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 230px 160px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 300px 90px, #fff 50%, transparent 51%);
  background-size: 320px 200px;
  animation: snow 14s linear infinite;
}
@keyframes snow { to { transform: translateY(200px); } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

.screen {
  display: none;
  width: 100vw; height: 100dvh;
  position: fixed; inset: 0; z-index: 1;
  align-items: center; justify-content: center;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.screen.active { display: flex; animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---- Registration form ---- */
.card {
  background: var(--card); border-radius: 20px; padding: 26px 22px;
  width: min(440px, 92vw); max-height: 92dvh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.card.center { text-align: center; }
h1 { margin: 0 0 6px; font-size: 1.4rem; }
.sub { color: var(--soft); margin: 0 0 18px; font-size: .95rem; line-height: 1.4; }
label { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--pale); }
.opt { color: #7d93bb; font-size: .8rem; }
.row { display: flex; gap: 12px; }
.row .grow { flex: 1; }
.row .age { width: 90px; }
label.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: .82rem; color: var(--soft); }
label.checkbox input { margin-top: 3px; accent-color: var(--red); }
input[type=text], input[type=number], select {
  width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--night); color: #fff; font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--red); }
button { border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; cursor: pointer; color: #fff; }
#santa-form button[type=submit], #againBtn {
  width: 100%; padding: 15px; background: var(--red); margin-top: 6px; font-size: 1.05rem;
}
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--pale); padding: 10px 14px; }
button.ghost.wide { width: 100%; margin-top: 10px; }
.voice-row { display: flex; gap: 8px; align-items: flex-end; }
.voice-row select { flex: 1; }
.hint-small { display: block; color: #7d93bb; font-size: .75rem; margin-top: 6px; line-height: 1.35; }
.settings { margin: 4px 0 16px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.settings summary { cursor: pointer; color: var(--pale); font-size: .9rem; }
.settings[open] summary { margin-bottom: 12px; }
.note { font-size: .75rem; color: #7d93bb; margin-top: 12px; text-align: center; line-height: 1.4; }
.note.mode { color: var(--gold); opacity: .8; }
.error { color: #ff9a9a; font-size: .85rem; text-align: center; }

/* ---- Countdown ---- */
.countdown-wrap { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hint, .hint2 { color: var(--soft); margin: 10px 0; }
.countdown-num { font-size: 5.5rem; font-weight: 700; color: var(--gold); text-shadow: 0 0 24px rgba(255,213,74,.6); }

/* ---- Call backgrounds ---- */
.call-bg { position: absolute; inset: 0; background: radial-gradient(circle at 50% 30%, #1d3b66, #050d1c 75%); z-index: -1; }
.incall-bg { background: radial-gradient(circle at 50% 28%, #6b1f1f 0%, #2a1020 35%, #050d1c 80%); }

/* ---- Incoming call ---- */
.incoming-wrap { text-align: center; width: 100%; }
.incoming-label { text-transform: uppercase; letter-spacing: 2px; color: var(--soft); font-size: .8rem; margin-bottom: 18px; }
.avatar {
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff6e6, #f3d9b1 60%, #c9a777);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px; position: relative;
  box-shadow: 0 0 0 6px rgba(255,255,255,.08);
}
.avatar span { font-size: 5rem; line-height: 1; }
.avatar.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53,199,89,.55); }
  70% { box-shadow: 0 0 0 34px rgba(53,199,89,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,199,89,0); }
}
.caller-name { margin: 0; font-size: 1.6rem; }
.caller-sub { color: var(--soft); margin: 4px 0 44px; }
.call-actions { display: flex; justify-content: center; gap: 80px; }
.call-btn {
  width: 72px; height: 72px; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 1.6rem;
}
.call-btn small { font-size: .62rem; font-weight: 400; }
.call-btn.decline { background: var(--red); }
.call-btn.accept { background: var(--green); }
.call-btn.big { width: 76px; height: 76px; font-size: 1.8rem; }
.wiggle { animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 0%,60%,100% { transform: rotate(0); } 10%,30%,50% { transform: rotate(-12deg); } 20%,40% { transform: rotate(12deg); } }

/* ---- In call ---- */
.incall-wrap {
  width: min(480px, 94vw); height: 100%; display: flex; flex-direction: column;
  align-items: center; padding: 22px 12px 18px; gap: 4px;
}
.call-head { text-align: center; }
.call-timer { color: var(--soft); margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.stage { position: relative; margin: 18px 0 6px; }
.avatar.big { width: 170px; height: 170px; margin: 0; transition: transform .25s ease; }
.avatar.big span { font-size: 6rem; }
.avatar.big.speaking { animation: talk .9s ease-in-out infinite; box-shadow: 0 0 0 8px rgba(255,213,74,.25), 0 0 60px rgba(255,213,74,.35); }
@keyframes talk { 0%,100% { transform: scale(1) rotate(0); } 25% { transform: scale(1.03) rotate(-2deg); } 75% { transform: scale(1.02) rotate(2deg); } }
.avatar.big.listening { box-shadow: 0 0 0 8px rgba(53,199,89,.35), 0 0 50px rgba(53,199,89,.35); animation: listen 1.6s ease-in-out infinite; }
@keyframes listen { 50% { box-shadow: 0 0 0 16px rgba(53,199,89,.15), 0 0 70px rgba(53,199,89,.25); } }
.avatar.big.thinking span { animation: think 1.2s ease-in-out infinite; }
@keyframes think { 50% { transform: translateY(-4px) rotate(-6deg); } }

.wave { display: flex; gap: 5px; justify-content: center; height: 26px; align-items: center; margin-top: 12px; opacity: 0; transition: opacity .2s; }
.wave.on { opacity: 1; }
.wave i { width: 5px; height: 8px; border-radius: 3px; background: var(--gold); animation: bar .9s ease-in-out infinite; }
.wave.kid i { background: var(--green); }
.wave i:nth-child(2) { animation-delay: .15s; } .wave i:nth-child(3) { animation-delay: .3s; }
.wave i:nth-child(4) { animation-delay: .45s; } .wave i:nth-child(5) { animation-delay: .6s; }
@keyframes bar { 50% { height: 24px; } }

.status-line { color: var(--gold); font-size: .9rem; min-height: 1.3em; margin: 4px 0 2px; text-align: center; }
.caption { min-height: 2.6em; margin: 0 0 8px; text-align: center; font-size: 1.05rem; line-height: 1.35; color: #fff; padding: 0 8px; }
.caption.kid { color: #b9f5c8; font-style: italic; }

.transcript {
  flex: 1; width: 100%; overflow-y: auto; text-align: left;
  background: rgba(255,255,255,.05); border-radius: 14px; padding: 10px;
  font-size: .86rem; display: flex; flex-direction: column; gap: 6px; min-height: 0;
}
.transcript[hidden] { display: none; }
.transcript .line { max-width: 86%; padding: 7px 11px; border-radius: 12px; line-height: 1.35; }
.transcript .santa { background: #4a1f24; align-self: flex-start; }
.transcript .kid { background: #1f4a2e; align-self: flex-end; }
.spacer { flex: 1; }

.fallback-input { display: flex; gap: 8px; width: 100%; margin-top: 10px; }
.fallback-input input { flex: 1; margin: 0; }
.fallback-input button { padding: 10px 16px; background: var(--green); }

.call-controls { display: flex; align-items: center; justify-content: center; gap: 34px; margin-top: 14px; }
.ctl {
  width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.14);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 1.3rem; gap: 1px;
}
.ctl small { font-size: .58rem; font-weight: 400; }
.ctl.active { background: var(--green); }
.ctl:disabled { opacity: .35; }

/* ---- Ended ---- */
.recap { text-align: left; margin: 10px 0 16px; }
.recap summary { cursor: pointer; color: var(--soft); font-size: .88rem; margin-bottom: 8px; }
.recap-list { max-height: 40dvh; flex: none; }

@media (max-width: 380px) {
  .call-actions { gap: 56px; }
  .avatar { width: 124px; height: 124px; }
  .avatar span { font-size: 4rem; }
  .avatar.big { width: 140px; height: 140px; }
  .avatar.big span { font-size: 5rem; }
}
@media (max-height: 640px) {
  .stage { margin: 8px 0 2px; }
  .avatar.big { width: 120px; height: 120px; }
  .avatar.big span { font-size: 4.2rem; }
}

/* =========================================================
   Phone-style call screens (incoming + in call)
   ========================================================= */
.screen.phone {
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 56px) 24px calc(env(safe-area-inset-bottom) + 44px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Roboto, sans-serif;
  color: #fff;
}
.phone-bg {
  position: absolute; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(120% 70% at 20% 10%, rgba(196, 52, 52, .55), transparent 60%),
    radial-gradient(110% 70% at 85% 90%, rgba(40, 110, 70, .45), transparent 60%),
    linear-gradient(180deg, #2a1b26 0%, #141a2a 55%, #0b0f18 100%);
}
.phone-bg::after {   /* soft frosted-glass haze like a phone's contact poster */
  content: ""; position: absolute; inset: 0;
  backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  background: rgba(0, 0, 0, .18);
}
.phone-top { text-align: center; }
.phone-label { margin: 0 0 6px; font-size: .95rem; color: rgba(255,255,255,.65); letter-spacing: .2px; }
.phone-name { margin: 0; font-size: 2.35rem; font-weight: 400; letter-spacing: -.5px; }
.phone-sub { margin: 6px 0 0; font-size: 1.05rem; color: rgba(255,255,255,.65); font-variant-numeric: tabular-nums; }

.phone-photo {
  width: 168px; height: 168px; border-radius: 50%; padding: 0; margin: 0 auto;
  background: radial-gradient(circle at 50% 40%, #fff6e6, #f3d9b1 60%, #c9a777);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; transition: box-shadow .3s ease, transform .3s ease;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 12px 40px rgba(0,0,0,.45);
}
.phone-photo span { font-size: 6.2rem; line-height: 1; pointer-events: none; }
.phone-photo.ring { animation: ringpulse 1.6s ease-out infinite; }
@keyframes ringpulse {
  0% { box-shadow: 0 0 0 0 rgba(255,255,255,.35), 0 12px 40px rgba(0,0,0,.45); }
  100% { box-shadow: 0 0 0 36px rgba(255,255,255,0), 0 12px 40px rgba(0,0,0,.45); }
}
/* no words — Santa's photo shows what's happening */
.phone-photo.speaking { animation: santatalk 1s ease-in-out infinite; }
@keyframes santatalk {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 6px rgba(255,213,74,.18), 0 0 50px rgba(255,213,74,.25); }
  50% { transform: scale(1.035); box-shadow: 0 0 0 12px rgba(255,213,74,.12), 0 0 70px rgba(255,213,74,.35); }
}
.phone-photo.listening { box-shadow: 0 0 0 6px rgba(52,199,89,.28), 0 0 50px rgba(52,199,89,.25); }
.phone-photo.thinking span { animation: think 1.2s ease-in-out infinite; }
.phone-photo:disabled { opacity: 1; cursor: default; }

/* round phone buttons */
.btn-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.btn-col small { font-size: .82rem; color: #fff; font-weight: 400; }
.round {
  width: 76px; height: 76px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; border: none; cursor: pointer; transition: background .15s, color .15s, transform .1s;
}
.round:active { transform: scale(.94); }
.round svg { width: 32px; height: 32px; }
.round.red { background: #ff3b30; }
.round.green { background: #34c759; }
.round svg.hang { transform: rotate(135deg); }
.round.glass {
  background: rgba(255,255,255,.17);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.round.glass.on { background: #fff; color: #1c1c1e; }
.round.glass:disabled { opacity: .45; cursor: default; }
.round .slash { display: none; }
.round.on .slash { display: inline; }

.incoming-actions { display: flex; justify-content: space-between; width: min(320px, 100%); margin: 0 auto; }
.incoming-actions .round { width: 78px; height: 78px; }
.shake { animation: phoneshake 1.4s ease-in-out infinite; }
@keyframes phoneshake { 0%, 55%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-10deg); } 20%, 40% { transform: rotate(10deg); } }

.incall-grid {
  display: grid; grid-template-columns: repeat(3, 76px); justify-content: space-between;
  row-gap: 22px; width: min(320px, 100%); margin: 0 auto;
}

/* keypad → a small typing bar (also appears if the microphone can't be used) */
.type-sheet {
  display: flex; gap: 8px; width: min(340px, 100%); margin: 0 auto 18px;
  background: rgba(255,255,255,.14); border-radius: 26px; padding: 6px 6px 6px 16px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.type-sheet[hidden] { display: none; }
.type-sheet input {
  flex: 1; margin: 0; border: none; outline: none; background: transparent;
  color: #fff; font-size: 1rem; padding: 8px 0;
}
.type-sheet input::placeholder { color: rgba(255,255,255,.55); }
.type-sheet input:focus { outline: none; }
.type-sheet button { width: 40px; height: 40px; border-radius: 50%; background: #34c759; display: flex; align-items: center; justify-content: center; padding: 0; }
.type-sheet button svg { width: 20px; height: 20px; }

@media (max-height: 700px) {
  .screen.phone { padding-top: calc(env(safe-area-inset-top) + 30px); padding-bottom: calc(env(safe-area-inset-bottom) + 26px); }
  .phone-photo { width: 128px; height: 128px; }
  .phone-photo span { font-size: 4.6rem; }
  .round { width: 66px; height: 66px; }
  .incall-grid { grid-template-columns: repeat(3, 66px); row-gap: 16px; }
}
