/* Practice 911 — styled to look like an iPhone running iOS. */

:root {
  --green: #34c759;
  --green-pressed: #7ddc92;
  --red: #ff3b30;
  --blue: #0a84ff;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --key: min(78px, 20.5vw, 9.6dvh);
  --key-gap-x: calc(var(--key) * 0.36);
  --key-gap-y: calc(var(--key) * 0.2);
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body { position: fixed; inset: 0; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

svg { display: block; width: 100%; height: 100%; }

#app { position: fixed; inset: 0; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  animation: fade-in 0.28s ease both;
}
.screen.zoom-in { animation: zoom-in 0.32s cubic-bezier(.2,.8,.2,1) both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.3); transform-origin: 20% 95%; } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%, 55% { transform: translateX(-14px); }
  35%, 75% { transform: translateX(14px); }
}
@keyframes nudge { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } to { transform: scale(1); } }

/* ---------- wallpaper ---------- */

.wallpaper {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 60% at 90% 100%, rgba(255, 176, 110, 0.65), transparent 60%),
    radial-gradient(90% 50% at 5% 25%, rgba(70, 130, 255, 0.5), transparent 60%),
    linear-gradient(180deg, #1c2a6b 0%, #5b389e 52%, #ec7378 100%);
}
.wallpaper.blurred { filter: blur(28px) brightness(0.72); transform: scale(1.15); }

/* ---------- practice label ---------- */

.practice-label {
  position: fixed;
  z-index: 20;
  top: calc(var(--safe-top) + 4px);
  left: 14px;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255, 59, 48, 0.88);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  pointer-events: none;
}
.practice-label.top-safe { top: calc(var(--safe-top) + 4px); }

/* ---------- lock screen ---------- */

.lock { justify-content: flex-start; touch-action: none; }
.lock .lock-content { display: flex; flex-direction: column; align-items: center; width: 100%; flex: 1; will-change: transform; }
.lock .lock-icon { width: 18px; height: 22px; margin-top: 14px; }
.lock .date { margin-top: 10px; font-size: 21px; font-weight: 600; text-shadow: 0 1px 8px rgba(0,0,0,.15); }
.lock .time {
  font-family: var(--font-rounded);
  font-size: min(108px, 27vw);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 12px rgba(0,0,0,.12);
}
.lock .spacer { flex: 1; }
.lock .corners { width: 100%; display: flex; justify-content: space-between; padding: 0 46px; }
.lock .corner {
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.lock .corner svg { width: 22px; height: 22px; }
.lock .hint { margin-top: 18px; font-size: 16px; font-weight: 500; opacity: .85; }
.lock .hint.nudge { animation: nudge .45s ease; }
.home-bar { width: 140px; height: 5px; border-radius: 3px; background: #fff; margin: 12px 0 8px; }

/* ---------- passcode ---------- */

.passcode .lock-icon { width: 18px; height: 22px; margin-top: 36px; }
.passcode .title { margin-top: 14px; font-size: 20px; }
.dots { display: flex; gap: 22px; margin-top: 22px; }
.dots.shake { animation: shake .45s linear; }
.dot { width: 13px; height: 13px; border-radius: 50%; border: 1.4px solid #fff; transition: background .08s; }
.dot.filled { background: #fff; }
.passcode .pad { margin-top: auto; margin-bottom: auto; }
.bottom-actions {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 40px 20px;
  font-size: 17px;
}
.bottom-actions button { padding: 10px 4px; min-width: 70px; }
.bottom-actions button:active { opacity: .5; }

/* ---------- keypads ---------- */

.pad { display: grid; grid-template-columns: repeat(3, var(--key)); column-gap: var(--key-gap-x); row-gap: var(--key-gap-y); }
.key {
  width: var(--key);
  height: var(--key);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--key-bg);
  color: var(--key-fg);
  transition: background .35s ease-out;
}
.key.pressed, .key:active { background: var(--key-bg-pressed); transition: none; }
.key .digit { font-size: calc(var(--key) * 0.46); font-weight: 400; line-height: 1; }
.key .letters { font-size: calc(var(--key) * 0.13); font-weight: 700; letter-spacing: 1.5px; margin-top: 1px; min-height: 1em; }
.key.star .digit { font-size: calc(var(--key) * 0.62); transform: translateY(16%); }
.key.pound .digit { font-size: calc(var(--key) * 0.44); }
.key.bare .letters { display: none; }

.pad.glass { --key-bg: rgba(255,255,255,.18); --key-bg-pressed: rgba(255,255,255,.55); --key-fg: #fff; }
.pad.dark { --key-bg: #333335; --key-bg-pressed: #737373; --key-fg: #fff; }
.pad .zero-slot { grid-column: 2; }

.call-row { display: grid; grid-template-columns: repeat(3, var(--key)); column-gap: var(--key-gap-x); margin-top: var(--key-gap-y); }
.call-btn {
  grid-column: 2;
  width: var(--key); height: var(--key); border-radius: 50%;
  background: var(--green);
  display: grid; place-items: center;
  transition: background .3s;
}
.call-btn.pressed, .call-btn:active { background: var(--green-pressed); transition: none; }
.call-btn svg { width: 42%; height: 42%; color: #fff; }
.del-btn { grid-column: 3; display: grid; place-items: center; color: #8e8e93; opacity: 0; pointer-events: none; transition: opacity .15s; }
.del-btn.show { opacity: 1; pointer-events: auto; }
.del-btn svg { width: 30px; height: 30px; }

.number {
  height: 64px;
  width: 100%;
  padding: 0 28px;
  text-align: center;
  font-size: 40px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  direction: rtl; /* keep the newest digits visible */
  line-height: 64px;
}
.number span { direction: ltr; unicode-bidi: bidi-override; }
.add-number { color: var(--blue); font-size: 17px; height: 22px; visibility: hidden; }
.add-number.show { visibility: visible; }

/* ---------- emergency dialer ---------- */

.emergency { background: #000; }
.emergency .label { margin-top: 44px; color: var(--red); font-size: 17px; font-weight: 600; }
.emergency .number { margin-top: auto; }
.emergency .dial-area { margin-bottom: auto; margin-top: 16px; display: flex; flex-direction: column; align-items: center; }

/* ---------- home screen ---------- */

.home { justify-content: flex-start; }
.home .grid { display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 24px; width: 100%; padding: 26px 18px 0; }
.app-icon { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.app-icon .tile {
  width: min(62px, 16vw); height: min(62px, 16vw);
  border-radius: 22.5%;
  display: grid; place-items: center;
  font-size: min(32px, 8.2vw);
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: transform .2s, filter .2s;
}
.app-icon:active .tile, .app-icon.pressed .tile { transform: scale(.92); filter: brightness(.75); }
.app-icon .name { font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,.3); }
.app-icon.wiggle .tile { animation: shake .35s; }
.tile.phone { background: linear-gradient(#66e766, #20b636); }
.tile.phone svg { width: 58%; height: 58%; color: #fff; }
.home .search {
  margin-top: auto; margin-bottom: 14px;
  display: flex; align-items: center; gap: 4px;
  padding: 7px 12px; border-radius: 99px;
  background: rgba(255,255,255,.22);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  font-size: 13px; font-weight: 600;
}
.home .search svg { width: 13px; height: 13px; }
.dock {
  width: calc(100% - 20px);
  margin-bottom: 6px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 16px 8px;
  border-radius: 34px;
  background: rgba(255,255,255,.22);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
}

/* ---------- Phone app ---------- */

.phone-app { background: #000; padding-bottom: 0; }
.phone-app .tab-body { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; }
.phone-app .keypad-tab .number { margin-top: auto; }
.phone-app .keypad-tab .dial-area { margin-bottom: auto; margin-top: 10px; display: flex; flex-direction: column; align-items: center; }
.phone-app .pad { --key-bg: #333335; --key-bg-pressed: #737373; --key-fg: #fff; }
.tabbar {
  width: 100%;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 7px 0 calc(var(--safe-bottom) + 2px);
  background: rgba(22,22,22,.94);
  border-top: .5px solid rgba(255,255,255,.15);
  --tabbar-bg: #161616;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; color: #8e8e93; font-size: 10px; font-weight: 500; }
.tab svg { width: 26px; height: 26px; }
.tab .cut { fill: var(--tabbar-bg); }
.tab .hand { stroke: var(--tabbar-bg); }
.tab.active { color: var(--blue); }
.empty-tab { flex: 1; width: 100%; padding: 12px 20px; }
.empty-tab h1 { font-size: 34px; font-weight: 700; }
.empty-tab .empty { margin-top: 30vh; text-align: center; color: #8e8e93; font-size: 22px; font-weight: 600; }

/* ---------- in-call ---------- */

.call { background: #1c1c1e; }
.call .wallpaper { filter: blur(40px) brightness(.45); transform: scale(1.2); }
.call .who { margin-top: 56px; font-size: 32px; font-weight: 400; }
.call .status { margin-top: 4px; font-size: 18px; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }
.captions { flex: 1; width: 100%; padding: 18px 24px 8px; display: flex; flex-direction: column; justify-content: center; gap: 14px; min-height: 0; }
.caption {
  font-family: var(--font-rounded);
  font-size: clamp(20px, 5.6vw, 26px);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}
.caption.operator { color: #fff; }
.caption.child { color: #9fd3ff; font-weight: 500; font-size: clamp(18px, 4.8vw, 22px); min-height: 1.3em; }
.caption.hidden { visibility: hidden; }
.listening { display: flex; justify-content: center; align-items: center; gap: 8px; color: #9fd3ff; font-size: 15px; opacity: 0; transition: opacity .2s; }
.listening.on { opacity: 1; }
.listening svg { width: 20px; height: 20px; animation: pulse 1.2s infinite; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; padding: 0 18px; }
.choices:empty { display: none; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px; border-radius: 18px;
  background: rgba(255,255,255,.16);
  font-family: var(--font-rounded);
  font-size: clamp(16px, 4.4vw, 19px); font-weight: 600; text-align: left;
  min-height: 64px;
}
.choice:active { background: rgba(255,255,255,.35); }
.choice .emoji { font-size: 30px; line-height: 1; }
.choice.wide { grid-column: span 2; justify-content: center; }
.call-grid { display: grid; grid-template-columns: repeat(3, var(--key)); column-gap: var(--key-gap-x); row-gap: 18px; margin: 14px 0 10px; }
.call-grid.compact { row-gap: 10px; }
.call-grid .cg { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; }
.call-grid .cg .circle { width: var(--key); height: var(--key); border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); }
.call-grid.compact .cg .circle { width: calc(var(--key) * .72); height: calc(var(--key) * .72); }
.call-grid .cg svg { width: 44%; height: 44%; }
.end-btn { width: var(--key); height: var(--key); border-radius: 50%; background: var(--red); display: grid; place-items: center; margin-bottom: 18px; }
.end-btn svg { width: 44%; height: 44%; transform: rotate(135deg); color: #fff; }
.end-btn.pulse { animation: pulse 1s infinite; box-shadow: 0 0 0 6px rgba(255,59,48,.35); }
.hang-up-hint { font-family: var(--font-rounded); font-size: 17px; font-weight: 600; color: #ffd0cc; margin-bottom: 8px; min-height: 1.3em; }

/* ---------- result ---------- */

.result { background: #000; padding-left: 24px; padding-right: 24px; overflow-y: auto; }
.result .big {
  flex: none;
  margin-top: 6vh;
  width: min(150px, 38vw); height: min(150px, 38vw);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: min(96px, 24vw); font-weight: 800; color: #fff;
  animation: pop .5s cubic-bezier(.2,.9,.3,1.2) both;
}
.result .big.good { background: var(--green); }
.result .big.bad { background: var(--red); }
.result .big.try { background: #ff9f0a; }
.result h1 { flex: none; margin-top: 22px; font-family: var(--font-rounded); font-size: 34px; font-weight: 800; text-align: center; }
.result .message { margin-top: 10px; font-family: var(--font-rounded); font-size: 21px; font-weight: 500; color: #c7c7cc; text-align: center; line-height: 1.3; }
.checklist { margin-top: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 8px; }
.check-row { flex: none; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; background: #1c1c1e; font-family: var(--font-rounded); font-size: 18px; font-weight: 600; }
.check-row .mark { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; flex: none; }
.check-row .mark.good { background: var(--green); }
.check-row .mark.partial { background: #ff9f0a; }
.check-row .mark.missed { background: #48484a; }
.check-row .tip { display: block; font-size: 14px; font-weight: 500; color: #aeaeb2; margin-top: 2px; }
.result .again {
  flex: none;
  margin-top: auto;
  width: 100%; max-width: 380px;
  padding: 18px; border-radius: 16px;
  background: var(--green); color: #fff;
  font-family: var(--font-rounded); font-size: 22px; font-weight: 800;
}
.result .again.blue { background: var(--blue); }
.result .again:active { filter: brightness(.85); }
.result .footnote { margin-top: 12px; font-size: 13px; color: #8e8e93; text-align: center; }
.result .grownups { margin: 6px 0 14px; font-size: 13px; color: var(--blue); padding: 6px; }

/* ---------- real-emergency check ---------- */

.real-help { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; gap: 18px; }
.real-help h1 { font-family: var(--font-rounded); font-size: 28px; font-weight: 800; }
.real-help p { font-family: var(--font-rounded); font-size: 21px; color: #e5e5ea; line-height: 1.35; }
.real-help .emoji { font-size: 64px; }
.real-help button { margin-top: 10px; padding: 16px 28px; border-radius: 16px; background: #3a3a3c; font-size: 19px; font-weight: 700; }

/* ---------- grown-up sheets (iOS Settings look) ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; animation: fade-in .2s both; }
.sheet {
  width: 100%; max-height: calc(100% - var(--safe-top) - 12px);
  margin: 0 auto; max-width: 640px;
  background: #1c1c1e; color: #fff;
  border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
  animation: slide-up .3s cubic-bezier(.2,.8,.2,1) both;
  -webkit-user-select: text; user-select: text;
}
@keyframes slide-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 16px; border-bottom: .5px solid #38383a; }
.sheet-head h2 { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-head .left { justify-self: start; color: var(--blue); font-size: 17px; }
.sheet-head .right { justify-self: end; color: var(--blue); font-size: 17px; font-weight: 600; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(var(--safe-bottom) + 24px); -webkit-overflow-scrolling: touch; background: #000; }
.group-title { margin: 22px 16px 6px; font-size: 13px; color: #8e8e93; text-transform: uppercase; }
.group { background: #1c1c1e; border-radius: 10px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 16px; font-size: 17px; }
.row + .row { border-top: .5px solid #38383a; }
.row .value { color: #8e8e93; }
.row input[type=text], .row input[type=tel], .row input[type=number], .row select {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: #fff; font: inherit; text-align: right;
  -webkit-user-select: text; user-select: text;
}
.row select { -webkit-appearance: none; appearance: none; color: #8e8e93; text-align: right; text-align-last: right; max-width: 62%; text-overflow: ellipsis; }
.row.stack { flex-direction: column; align-items: stretch; }
.row.stack input { text-align: left; }
.group-foot { margin: 6px 16px 0; font-size: 13px; color: #8e8e93; line-height: 1.35; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #39393d; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.btn-row { color: var(--blue); width: 100%; text-align: left; }
.btn-row.danger { color: var(--red); }
.error { color: var(--red); font-size: 14px; margin: 6px 16px 0; min-height: 1em; }

.gate { padding: 30px 20px 40px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; background: #000; }
.gate .emoji { font-size: 44px; }
.gate h3 { font-size: 22px; }
.gate .q { font-size: 20px; color: #e5e5ea; }
.gate input { width: 160px; padding: 12px; border-radius: 10px; border: 0; background: #1c1c1e; color: #fff; font-size: 24px; text-align: center; -webkit-user-select: text; user-select: text; }
.gate .primary, .welcome .primary { padding: 14px 30px; border-radius: 12px; background: var(--blue); color: #fff; font-size: 17px; font-weight: 600; }
.gate .primary:disabled { opacity: .4; }

.welcome { padding: 28px 22px calc(var(--safe-bottom) + 30px); background: #000; overflow-y: auto; }
.welcome h1 { font-size: 34px; font-weight: 800; }
.welcome .lead { margin-top: 8px; font-size: 19px; color: #aeaeb2; line-height: 1.35; }
.welcome .point { display: flex; gap: 14px; margin-top: 20px; }
.welcome .point .emoji { font-size: 28px; width: 36px; flex: none; text-align: center; }
.welcome .point b { display: block; font-size: 17px; }
.welcome .point span { font-size: 15px; color: #aeaeb2; line-height: 1.35; }
.welcome .actions { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; }
.welcome .secondary { color: var(--blue); font-size: 17px; padding: 8px; }
.install-steps { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; color: #e5e5ea; }
.install-steps .share { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: var(--blue); }
