:root {
  --ios-blue: #0A84FF;
  --bubble-them: #E9E9EB;
  --bg-chat: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: #050507;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Inter", sans-serif;
  overflow: hidden;
}

#root { height: 100%; }

.app-root {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #14131a 0%, #050507 60%),
    #050507;
  padding: 8px;
}

/* ---------- device frame ---------- */
.device {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: min(92vh, 900px);
  border-radius: 42px;
  background: #000;
  box-shadow: 0 0 0 10px #111, 0 30px 80px rgba(0,0,0,0.8), 0 0 60px rgba(120,0,0,0.15);
  overflow: hidden;
  transition: box-shadow 0.4s;
}

.vignette {
  pointer-events: none;
  position: absolute; inset: 0; z-index: 40;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.75) 100%);
  transition: opacity 0.6s;
}

/* ---------- glitch fx ---------- */
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  15% { transform: translate(-4px, 2px); }
  30% { transform: translate(5px, -3px); }
  45% { transform: translate(-5px, 3px); }
  60% { transform: translate(4px, 2px); }
  75% { transform: translate(-3px, -2px); }
}
.fx-shake { animation: shake 0.5s; }

@keyframes flick {
  0%,100% { filter: none; }
  20% { filter: hue-rotate(30deg) contrast(1.4); transform: translateX(2px); }
  40% { filter: invert(0.08) saturate(1.6); transform: translateX(-3px); }
  60% { filter: brightness(1.4); }
  80% { filter: hue-rotate(-20deg); transform: translateX(2px); }
}
.fx-flicker { animation: flick 0.6s; }

/* ---------- phone screen ---------- */
.phone {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg-chat);
  transition: background 0.8s;
}
.phone.dark { background: #0c0c10; }
.phone.verydark { background: #060608; }

/* ---------- status bar ---------- */
.statusbar {
  height: 50px;
  padding: 14px 26px 0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 600;
  color: #000;
}
.phone.dark .statusbar { color: #eee; }
.sb-time { letter-spacing: 0.5px; }
.sb-right { display: flex; align-items: center; gap: 7px; }
.sb-signal { display: flex; align-items: flex-end; gap: 2px; height: 11px; }
.sb-dot { width: 3px; background: currentColor; opacity: 0.25; border-radius: 1px; }
.sb-dot:nth-child(1){height:5px;} .sb-dot:nth-child(2){height:7px;}
.sb-dot:nth-child(3){height:9px;} .sb-dot:nth-child(4){height:11px;}
.sb-dot.on { opacity: 1; }
.sb-noservice { font-size: 12px; font-weight: 600; }
.sb-wifi { font-size: 13px; }
.sb-battery { display: flex; align-items: center; gap: 4px; }
.sb-batt-pct { font-size: 12px; }
.sb-batt-shell {
  width: 24px; height: 12px; border: 1px solid currentColor; border-radius: 3px;
  padding: 1px; position: relative; opacity: 0.7;
}
.sb-batt-fill { height: 100%; background: currentColor; border-radius: 1px; transition: width 0.8s; }
.sb-battery.low .sb-batt-fill { background: #ff3b30; }
.sb-battery.low .sb-batt-pct { color: #ff3b30; }
.sb-battery.low { animation: lowpulse 1.6s infinite; }
@keyframes lowpulse { 0%,100%{opacity:1;} 50%{opacity:0.55;} }

/* ---------- header ---------- */
.im-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 16px 10px;
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
  background: rgba(249,249,249,0.9);
  backdrop-filter: blur(10px);
}
.phone.dark .im-header { background: rgba(20,20,24,0.9); border-bottom-color: rgba(255,255,255,0.06); }
.im-back { color: var(--ios-blue); font-size: 30px; line-height: 1; width: 30px; }
.im-facetime { color: var(--ios-blue); font-size: 22px; width: 30px; text-align: right; }
.im-contact { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.im-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(160deg, #ff9d6e, #ff5e8a);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.im-avatar.glitchface {
  background: linear-gradient(160deg, #3a3a3a, #111);
  animation: faceglitch 0.4s infinite;
}
@keyframes faceglitch {
  0%,100%{filter:none;} 33%{filter:invert(1);} 66%{filter:hue-rotate(180deg);}
}
.im-name { font-size: 12px; font-weight: 600; color: #333; }
.phone.dark .im-name { color: #ccc; }
.im-chev { color: #999; }

/* ---------- thread ---------- */
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 14px;
  display: flex; flex-direction: column; gap: 3px;
  scroll-behavior: smooth;
}
.sys-divider {
  text-align: center; font-size: 11px; font-weight: 600;
  color: #8e8e93; margin: 12px 0 6px;
  letter-spacing: 0.3px;
}
.row { display: flex; margin-top: 2px; }
.row.me { justify-content: flex-end; }
.row.them { justify-content: flex-start; }

.bubble {
  max-width: 75%;
  padding: 9px 14px;
  border-radius: 19px;
  font-size: 16px; line-height: 1.32;
  word-wrap: break-word;
  animation: pop 0.22s ease-out;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.b-them {
  background: var(--bubble-them); color: #000;
  border-bottom-left-radius: 5px;
}
.phone.dark .b-them { background: #26262b; color: #f0f0f0; }
.b-me {
  background: linear-gradient(180deg, #0B93F6, #0A84FF);
  color: #fff; border-bottom-right-radius: 5px;
}
.receipt {
  text-align: right; font-size: 11px; color: #8e8e93;
  margin-top: 2px; padding-right: 4px; font-weight: 500;
}

/* typing */
.typing { display: flex; gap: 4px; padding: 12px 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9a9a9f; animation: bounce 1.2s infinite; }
.dot:nth-child(2){ animation-delay: 0.2s; }
.dot:nth-child(3){ animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0);opacity:0.5;} 30%{transform:translateY(-5px);opacity:1;} }

/* image bubble */
.img-bubble {
  max-width: 68%; border-radius: 18px; overflow: hidden;
  background: #111; animation: pop 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.img-bubble img { width: 100%; display: block; filter: brightness(0.9) contrast(1.1); }

/* ---------- choices / input ---------- */
.choice-wrap { padding: 4px 10px 8px; background: rgba(249,249,249,0.6); }
.phone.dark .choice-wrap { background: rgba(12,12,16,0.6); }
.choice-hint {
  text-align: center; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1px; color: #b0b0b5; margin: 2px 0 6px;
}
.choices { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.choice {
  border: none; cursor: pointer;
  background: #eef0f2; color: #111;
  padding: 12px 16px; border-radius: 20px;
  font-size: 15px; text-align: left; font-family: inherit;
  transition: transform 0.1s, background 0.2s;
  border: 1px solid rgba(0,0,0,0.05);
}
.phone.dark .choice { background: #1c1c22; color: #e8e8e8; border-color: rgba(255,255,255,0.05); }
.choice:active { transform: scale(0.97); }
.choice-danger {
  background: #ff3b30; color: #fff; font-weight: 700; text-align: center;
  animation: dangerpulse 1.1s infinite;
  box-shadow: 0 0 18px rgba(255,59,48,0.5);
}
@keyframes dangerpulse {
  0%,100% { transform: scale(1); box-shadow: 0 0 18px rgba(255,59,48,0.45); }
  50% { transform: scale(1.03); box-shadow: 0 0 30px rgba(255,59,48,0.8); }
}

.input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 14px;
}
.input-bar.solo { background: rgba(249,249,249,0.7); }
.phone.dark .input-bar.solo { background: rgba(10,10,14,0.7); }
.plus {
  width: 32px; height: 32px; border-radius: 50%;
  background: #e5e5ea; color: #7a7a7f;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.phone.dark .plus { background: #2a2a30; color: #999; }
.field {
  flex: 1; border: 1px solid #d1d1d6; border-radius: 18px;
  padding: 8px 14px; color: #b0b0b5; font-size: 15px;
}
.phone.dark .field { border-color: #333; color: #666; }
.field.muted { color: #c4c4c9; }
.mic { color: #8e8e93; font-size: 18px; width: 24px; text-align: center; }

/* ---------- call screen ---------- */
.call-screen {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #1a0505 0%, #050505 100%);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 70px 26px 44px;
}
.call-top { text-align: center; margin-bottom: 20px; }
.call-name { font-size: 32px; font-weight: 300; letter-spacing: 0.5px; }
.call-status { font-size: 16px; color: #b0b0b5; margin-top: 6px; }
.call-subs {
  flex: 1; margin-top: 20px; display: flex; flex-direction: column;
  gap: 12px; overflow-y: auto;
}
.call-sub {
  font-size: 14px; color: #ddd; line-height: 1.4;
  background: rgba(255,255,255,0.06); padding: 10px 14px; border-radius: 12px;
  animation: pop 0.3s;
}
.call-sub span { color: #ff8a80; }
.call-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 26px; margin: 24px auto; max-width: 260px;
}
.call-key { text-align: center; color: #fff; }
.call-key-ic {
  width: 62px; height: 62px; margin: 0 auto 6px;
  border-radius: 50%; background: rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.call-key-lb { font-size: 11px; color: #ccc; }
.call-end-wrap { text-align: center; }
.call-end {
  width: 66px; height: 66px; border-radius: 50%;
  background: #ff3b30; color: #fff; font-size: 28px; border: none;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255,59,48,0.5);
  transform: rotate(135deg);
}
.call-end:active { transform: rotate(135deg) scale(0.94); }

/* ---------- intro ---------- */
.intro {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 400px at 50% 20%, #1a0d14 0%, #060608 65%),
    #060608;
  padding: 30px;
}
.intro-inner { text-align: center; max-width: 340px; }
.intro-badge {
  display: inline-block; font-size: 11px; letter-spacing: 2px;
  color: #ff6b6b; border: 1px solid rgba(255,107,107,0.4);
  padding: 5px 12px; border-radius: 20px; margin-bottom: 22px;
}
.intro-title {
  font-size: 46px; font-weight: 700; color: #f5f5f5; margin: 0 0 14px;
  letter-spacing: -1px;
  text-shadow: 0 0 30px rgba(255,50,50,0.25);
  animation: introglow 3.5s infinite;
}
@keyframes introglow {
  0%,100%{text-shadow:0 0 30px rgba(255,50,50,0.2);}
  50%{text-shadow:0 0 40px rgba(255,50,50,0.5);}
}
.intro-sub { color: #bcbcc4; font-size: 16px; line-height: 1.5; margin: 0 0 22px; }
.intro-warn {
  color: #7a7a85; font-size: 12px; line-height: 1.55;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06);
  padding: 12px; border-radius: 12px; margin-bottom: 26px;
}
.intro-row { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.intro-btn {
  background: #ff3b30; color: #fff; border: none; cursor: pointer;
  padding: 15px 40px; border-radius: 30px; font-size: 17px; font-weight: 600;
  font-family: inherit;
  box-shadow: 0 6px 24px rgba(255,59,48,0.4);
  transition: transform 0.15s;
}
.intro-btn:active { transform: scale(0.96); }
.intro-mute {
  background: none; border: none; color: #888; cursor: pointer;
  font-size: 13px; font-family: inherit;
}

/* ---------- ending ---------- */
.ending {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 32px; overflow-y: auto;
}
.end-good { background: radial-gradient(600px 400px at 50% 30%, #0a1a14, #050505); }
.end-bad, .end-twist { background: radial-gradient(600px 400px at 50% 30%, #1a0505, #050505); }
.end-inner { text-align: center; max-width: 340px; }
.end-glitch {
  position: relative; font-size: 30px; font-weight: 800;
  color: #f2f2f2; letter-spacing: 1px; margin-bottom: 22px;
  line-height: 1.2;
}
.end-good .end-glitch { color: #7fe3a8; }
.end-glitch::before, .end-glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  opacity: 0.7;
}
.end-bad .end-glitch::before, .end-twist .end-glitch::before {
  color: #ff3b30; animation: gl1 2.5s infinite; clip-path: inset(0 0 55% 0);
}
.end-bad .end-glitch::after, .end-twist .end-glitch::after {
  color: #38bdf8; animation: gl2 2.5s infinite; clip-path: inset(55% 0 0 0);
}
@keyframes gl1 { 0%,90%,100%{transform:translate(0);} 92%{transform:translate(-3px,1px);} 96%{transform:translate(2px,-1px);} }
@keyframes gl2 { 0%,90%,100%{transform:translate(0);} 93%{transform:translate(3px,-1px);} 97%{transform:translate(-2px,1px);} }
.end-body { color: #cfcfd6; font-size: 15px; line-height: 1.6; margin-bottom: 26px; }
.end-count { color: #ff8a80; font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.end-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 26px; }
.end-tag {
  font-size: 11px; padding: 5px 12px; border-radius: 14px;
  background: rgba(255,255,255,0.05); color: #666; border: 1px solid rgba(255,255,255,0.06);
}
.end-tag.got { color: #7fe3a8; border-color: rgba(127,227,168,0.3); }
.end-btn {
  background: #f2f2f2; color: #111; border: none; cursor: pointer;
  padding: 14px 40px; border-radius: 30px; font-size: 16px; font-weight: 600;
  font-family: inherit; transition: transform 0.15s;
}
.end-btn:active { transform: scale(0.96); }

/* ---------- remix / footer ---------- */
.remix {
  display: block; margin-top: 22px; color: #55555f;
  font-size: 12px; text-decoration: none;
}
.remix.light { color: #55555f; }
.remix:hover { color: #999; }

.footer {
  margin-top: 10px; display: flex; align-items: center; gap: 16px;
}
.mute-toggle { cursor: pointer; font-size: 15px; opacity: 0.6; }
.mute-toggle:hover { opacity: 1; }
.footer-remix { color: #444; font-size: 11px; text-decoration: none; }
.footer-remix:hover { color: #888; }

/* mobile: fill screen */
@media (max-width: 480px) {
  .app-root { padding: 0; }
  .device { max-width: 100%; height: 100vh; border-radius: 0; box-shadow: none; }
  .footer { position: fixed; bottom: 6px; }
}