:root {
  color-scheme: dark;
  background: #020a22;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020a22;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overscroll-behavior: none;
  touch-action: manipulation;
}

.phone {
  position: relative;
  width: min(100vw, 56.33dvh);
  height: min(100dvh, 177.52vw);
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background: #063779;
  box-shadow: 0 0 60px rgba(0, 0, 0, .65);
}

.scene {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.version-label {
  position: absolute;
  z-index: 20;
  right: max(7px, env(safe-area-inset-right));
  bottom: max(5px, env(safe-area-inset-bottom));
  padding: 2px 5px;
  border-radius: 5px;
  color: rgba(255, 255, 255, .82);
  background: rgba(2, 10, 34, .52);
  font: 600 10px/1.2 system-ui, sans-serif;
  letter-spacing: .02em;
  pointer-events: none;
}

.call-button {
  position: absolute;
  z-index: 2;
  left: 11.2%;
  top: 82.2%;
  width: 77.6%;
  height: 12.2%;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.call-button::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: inherit;
  background: rgba(255,255,255,0);
  box-shadow: 0 0 0 0 rgba(255,255,255,0);
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}

.call-button:active::after,
.call-button.is-calling::after {
  background: rgba(255,255,255,.12);
  box-shadow: 0 0 28px 8px rgba(255, 224, 135, .55);
  transform: scale(.97);
}

.call-button:focus-visible {
  outline: 4px solid #fff3a6;
  outline-offset: -8px;
}

.call-button.is-speaking::after {
  animation: merry-glow 1.2s ease-in-out infinite alternate;
}

.menu-button {
  position: absolute;
  z-index: 5;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  width: 38px;
  height: 34px;
  padding: 0 0 8px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 18px;
  color: rgba(255,255,255,.72);
  background: rgba(2,10,34,.32);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  font: 700 18px/1 system-ui, sans-serif;
  letter-spacing: 1px;
  cursor: pointer;
  backdrop-filter: blur(5px);
  -webkit-tap-highlight-color: transparent;
}

.menu-button:focus-visible,
.close-button:focus-visible {
  outline: 3px solid #fff3a6;
  outline-offset: 2px;
}

.menu-button[aria-expanded="true"] {
  color: #2a1700;
  border-color: #fff0a7;
  background: #ffd76d;
  box-shadow: 0 0 0 3px rgba(2,10,34,.35), 0 4px 16px rgba(0,0,0,.4);
}

.menu {
  position: absolute;
  z-index: 6;
  top: calc(max(10px, env(safe-area-inset-top)) + 40px);
  right: 10px;
  padding: 7px;
  border: 2px solid #ffd76d;
  border-radius: 14px;
  background: rgba(4,19,55,.98);
  box-shadow: 0 10px 32px rgba(0,0,0,.55), 0 0 0 999px rgba(0,8,30,.16);
  backdrop-filter: blur(10px);
}

.menu button {
  min-width: 154px;
  padding: 13px 16px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: transparent;
  font: 750 16px/1.2 system-ui, sans-serif;
  text-align: left;
}

.menu button span { margin-right: 8px; }

.menu button:hover,
.menu button:focus-visible { background: rgba(255,255,255,.12); }

.configure-screen {
  position: absolute;
  z-index: 10;
  inset: 0;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(39,111,195,.62), transparent 42%),
    linear-gradient(180deg, rgba(2,19,62,.97), rgba(4,9,29,.99));
}

.child-picker {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(1,8,28,.76);
  backdrop-filter: blur(5px);
}

.picker-card {
  width: 100%;
  max-height: calc(100% - 24px);
  padding: 24px 20px 18px;
  overflow-y: auto;
  border: 2px solid #ffd76d;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(160deg, #123f82, #061331 72%);
  box-shadow: 0 18px 45px rgba(0,0,0,.6);
}

.picker-card h1 {
  margin: 0 0 20px;
  font: 800 clamp(27px, 7vw, 36px)/1.08 Georgia, serif;
}

.setup-prompt-card p {
  margin: 0 0 22px;
  color: rgba(255, 255, 255, .92);
  font: 650 17px/1.45 system-ui, sans-serif;
}

.setup-prompt-card .child-choice { width: 100%; }

.child-choices { display: grid; gap: 11px; }

.child-choice {
  min-height: 54px;
  padding: 12px 16px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#ff2b2b, #c90000);
  box-shadow: 0 5px 14px rgba(0,0,0,.3);
  font: 800 18px/1.15 system-ui, sans-serif;
}

.cancel-picker {
  width: 100%;
  min-height: 44px;
  margin-top: 13px;
  border: 0;
  color: rgba(255,255,255,.78);
  background: transparent;
  font: 700 14px/1 system-ui, sans-serif;
}

.configure-card {
  width: 100%;
  min-height: 100%;
  padding: 16px 4px 8px;
  color: #fff;
}

.configure-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #ffd76d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.configure-card h1 {
  margin: 0;
  font: 800 clamp(25px, 7vw, 34px)/1.05 Georgia, serif;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.optional-note {
  margin: 8px 0 0;
  color: rgba(255,255,255,.72);
  font-size: 13px;
}

.close-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  color: #fff;
  background: rgba(255,255,255,.08);
  font: 300 28px/1 system-ui, sans-serif;
}

.configure-card form { display: grid; gap: 17px; }

.children-list { display: grid; gap: 18px; }

.children-list:empty::before {
  content: "No children configured.";
  display: block;
  padding: 22px 14px;
  border: 1px dashed rgba(255,255,255,.35);
  border-radius: 14px;
  color: rgba(255,255,255,.72);
  font-size: 14px;
  text-align: center;
}

.child-card {
  display: grid;
  gap: 15px;
  min-width: 0;
  margin: 0;
  padding: 15px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 16px;
  background: rgba(255,255,255,.075);
}

.child-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.child-card h2 {
  margin: 0;
  color: #ffd76d;
  font: 800 19px/1.1 Georgia, serif;
}

.remove-child-button {
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  color: rgba(255,255,255,.82);
  background: rgba(0,0,0,.18);
  font: 700 12px/1 system-ui, sans-serif;
}

.configure-card label {
  display: grid;
  gap: 7px;
  font-size: 14px;
  font-weight: 750;
}

.configure-card input,
.configure-card select {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 12px;
  color: #151515;
  background: rgba(255,255,255,.97);
  font: 600 16px/1.2 system-ui, sans-serif;
  outline: none;
}

.configure-card input:focus,
.configure-card select:focus {
  border-color: #ffd76d;
  box-shadow: 0 0 0 3px rgba(255,215,109,.28);
}

.save-button {
  min-height: 54px;
  margin-top: 8px;
  border: 2px solid #ffd76d;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(#ff2b2b, #c90000);
  box-shadow: 0 6px 18px rgba(0,0,0,.32);
  font: 800 19px/1 system-ui, sans-serif;
}

.add-child-button {
  min-height: 48px;
  border: 1px dashed rgba(255,255,255,.55);
  border-radius: 13px;
  color: #fff;
  background: rgba(255,255,255,.07);
  font: 750 15px/1 system-ui, sans-serif;
}

.add-child-button span {
  margin-right: 5px;
  color: #ffd76d;
  font-size: 20px;
  vertical-align: -1px;
}

.save-note {
  min-height: 20px;
  margin: 0;
  color: #dfffe0;
  font-size: 13px;
  text-align: center;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes merry-glow {
  from { background: rgba(255,255,255,.04); box-shadow: 0 0 10px 2px rgba(255,225,140,.25); }
  to { background: rgba(255,255,255,.15); box-shadow: 0 0 32px 10px rgba(255,225,140,.65); }
}

@media (prefers-reduced-motion: reduce) {
  .call-button::after { transition: none; }
  .call-button.is-speaking::after { animation: none; background: rgba(255,255,255,.1); }
}
