:root {
  --bg: #0b0f15;
  --phone: #141a24;
  --head: #1a212d;
  --line: rgba(255, 255, 255, 0.07);
  --ink: #e6eaf0;
  --ink-dim: #8791a2;
  --ink-faint: #525c6d;
  --in: #222b38;
  --out: #2e5a4f;
  --out-ink: #eaf5f1;
  --accent: #5fd0a8;
  --orange: #ff8a3d;
  --orange-soft: rgba(255, 138, 61, 0.14);
  --red: #ff5a4e;
  --paper: #efe9d8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 70% -10%, rgba(255, 138, 61, 0.22), transparent 55%),
    radial-gradient(ellipse at 20% 110%, rgba(95, 208, 168, 0.1), transparent 60%),
    var(--bg);
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- phone frame ---------- */
.phone {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 430px;
  background: var(--phone);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (min-width: 600px) and (min-height: 700px) {
  .phone {
    height: min(880px, calc(100dvh - 48px));
    border-radius: 38px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 10px #05070a, 0 0 0 11px rgba(255, 255, 255, 0.06), 0 40px 100px rgba(0, 0, 0, 0.6);
  }
}

.statusbar {
  flex: none;
  height: 30px;
  padding: max(6px, env(safe-area-inset-top)) 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  background: var(--head);
  font-variant-numeric: tabular-nums;
}
.sb-right { display: flex; align-items: center; gap: 8px; }
.signal { display: flex; align-items: flex-end; gap: 2px; height: 11px; }
.signal i { display: block; width: 3px; background: var(--ink); border-radius: 1px; }
.signal i:nth-child(1) { height: 4px; }
.signal i:nth-child(2) { height: 6px; }
.signal i:nth-child(3) { height: 8px; }
.signal i:nth-child(4) { height: 11px; }
.sb-battery { width: 22px; height: 11px; border: 1.5px solid var(--ink); border-radius: 3px; padding: 1px; position: relative; }
.sb-battery::after { content: ''; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: var(--ink); border-radius: 1px; }
.sb-battery i { display: block; height: 100%; width: 86%; background: var(--ink); border-radius: 1px; }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 9px;
  border-bottom: 1px solid var(--line);
  background: var(--head);
}
.head-btn {
  border: 0; background: none; padding: 7px; border-radius: 50%; cursor: pointer; color: var(--accent);
  display: flex; position: relative;
}
.head-btn:active { background: rgba(255, 255, 255, 0.06); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #ff8a3d, #2e7a64);
}
.head-info { flex: 1; min-width: 0; }
.head-name { font-weight: 600; font-size: 16px; }
.head-status { font-size: 12.5px; color: var(--ink-dim); height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-status.online, .head-status.typing { color: var(--accent); }
.head-status.calling { color: var(--orange); }
.head-status.typing::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.map-btn { color: var(--orange); }
.map-btn.bump, .batt.bump { animation: bump 0.6s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.25) rotate(-6deg); } 60% { transform: scale(0.95); } 100% { transform: none; } }

/* Dan's battery */
.batt {
  flex: none;
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px 4px 6px;
  border-radius: 12px;
  background: rgba(95, 208, 168, 0.1);
  color: var(--accent);
  font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: background 0.3s, color 0.3s, opacity 0.3s;
}
.batt-body { width: 20px; height: 10px; border: 1.5px solid currentColor; border-radius: 3px; padding: 1px; position: relative; }
.batt-body::after { content: ''; position: absolute; right: -4px; top: 2px; width: 2px; height: 3px; background: currentColor; border-radius: 1px; }
.batt-fill { display: block; height: 100%; background: currentColor; border-radius: 1px; transition: width 0.5s; }
.batt.low { background: rgba(255, 90, 78, 0.14); color: var(--red); }
.batt.low .batt-fill { animation: lowblink 1.2s infinite; }
@keyframes lowblink { 50% { opacity: 0.25; } }
.batt.off { opacity: 0.45; }

.feed {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background:
    radial-gradient(circle at 85% 0%, rgba(255, 138, 61, 0.07), transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(95, 208, 168, 0.05), transparent 45%),
    var(--phone);
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.day {
  align-self: center;
  margin: 8px 0 10px;
  font-size: 12px;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 10px;
  border-radius: 10px;
}

.msg {
  max-width: 82%;
  padding: 7px 10px 6px;
  border-radius: 16px;
  line-height: 1.38;
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: pop 0.22s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg.in { align-self: flex-start; background: var(--in); border-bottom-left-radius: 5px; }
.msg.out { align-self: flex-end; background: var(--out); color: var(--out-ink); border-bottom-right-radius: 5px; }
.msg.gap { margin-top: 7px; }
.msg.pin { font-weight: 600; }
.meta {
  float: right;
  margin: 6px 0 -3px 10px;
  font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.msg.out .meta { color: rgba(234, 245, 241, 0.5); }
.ticks { margin-left: 3px; letter-spacing: -3px; }
.ticks.read { color: #8ff0cc; }
.msg.photo { padding: 3px; }
.msg.photo img { display: block; width: 250px; max-width: 100%; border-radius: 13px; cursor: zoom-in; }
.msg.photo.captioned { padding-bottom: 6px; }
.msg.photo .cap { padding: 6px 7px 0; }
.msg.photo:not(.captioned) .meta {
  position: absolute; right: 9px; bottom: 7px; margin: 0; float: none;
  background: rgba(0, 0, 0, 0.45); color: #eee; padding: 1px 6px; border-radius: 8px;
}

/* system lines */
.sys {
  align-self: center;
  margin: 10px 0;
  font-size: 12.5px;
  color: var(--ink-dim);
  text-align: center;
  max-width: 85%;
}
.map-line {
  color: var(--orange);
  background: var(--orange-soft);
  border: 1px dashed rgba(255, 138, 61, 0.5);
  padding: 4px 12px;
  border-radius: 12px;
  cursor: pointer;
  animation: pop 0.3s ease-out;
}
.map-pin, .call-ico { margin-right: 6px; }
.call-mark { color: var(--orange); font-weight: 500; margin: 12px 0 4px; }
.call-mark.end { color: var(--ink-faint); margin: 4px 0 12px; }

/* the call transcript */
.cl {
  max-width: 86%;
  padding: 6px 11px;
  font-size: 14px;
  line-height: 1.4;
  border-radius: 12px;
  animation: pop 0.22s ease-out;
}
.cl.op { align-self: flex-start; background: rgba(255, 138, 61, 0.08); border-left: 3px solid var(--orange); border-radius: 4px 12px 12px 4px; }
.cl.me { align-self: flex-end; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--ink-dim); font-style: italic; }
.cl-who { font-size: 11px; font-weight: 600; color: var(--orange); margin-bottom: 2px; font-style: normal; }

.typing-bubble {
  align-self: flex-start; background: var(--in); padding: 11px 14px; border-radius: 16px; border-bottom-left-radius: 5px;
  display: flex; gap: 4px; margin-top: 7px;
}
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* replies */
.replies { flex: none; padding: 0 10px; max-height: 0; overflow: hidden; transition: max-height 0.3s ease; background: var(--phone); }
.replies.open { max-height: 420px; padding-bottom: 8px; overflow-y: auto; }
.timer { height: 3px; background: rgba(255, 255, 255, 0.07); border-radius: 2px; margin: 6px 4px 8px; overflow: hidden; visibility: hidden; }
.timer.on { visibility: visible; }
.timer-fill { height: 100%; width: 100%; background: var(--red); transform-origin: left; }
.reply-list { display: flex; flex-direction: column; gap: 6px; }
.reply {
  display: flex; align-items: center; gap: 10px;
  text-align: left;
  border: 1px solid rgba(95, 208, 168, 0.3);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  padding: 10px 13px;
  border-radius: 14px;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.15s, border-color 0.15s;
  animation: pop 0.25s ease-out both;
}
.reply:hover { background: rgba(95, 208, 168, 0.08); border-color: rgba(95, 208, 168, 0.6); }
.reply:active { transform: scale(0.985); }
.reply-text { flex: 1; }
.reply-cost {
  flex: none;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--red);
  background: rgba(255, 90, 78, 0.12);
  padding: 2px 7px;
  border-radius: 8px;
}
.reply.special { border-color: rgba(255, 138, 61, 0.6); background: rgba(255, 138, 61, 0.06); }
.reply.special .reply-text::before { content: '🔍 '; }
.reply.place { border: 1px solid var(--orange); background: var(--orange-soft); font-weight: 600; justify-content: center; text-align: center; }

.composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--head);
}
.composer-input {
  flex: 1;
  padding: 9px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-faint);
  font-size: 14.5px;
  user-select: none;
}
.composer-send { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--ink-faint); }

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(3, 5, 8, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.overlay.open { display: flex; animation: fadein 0.25s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  padding: 22px 18px max(22px, env(safe-area-inset-bottom));
  background: var(--head);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; gap: 9px;
  animation: slideup 0.3s ease-out;
}
@keyframes slideup { from { transform: translateY(30px); } to { transform: none; } }
.sheet-title { font-weight: 600; font-size: 17px; text-align: center; margin-bottom: 6px; }

/* the map */
.map-sheet { max-height: 96%; padding-top: 16px; padding-left: 10px; padding-right: 10px; }
.map-sheet.picking .sheet-title { color: var(--orange); }
.map-wrap { position: relative; align-self: center; width: 100%; max-width: 400px; aspect-ratio: 4 / 5; max-height: calc(100dvh - 210px); }
.map-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 10px; background: var(--paper); }
.map-spots { position: absolute; inset: 0; }
.spot {
  position: absolute;
  width: 38px; height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  border: 2px solid var(--orange);
  background: rgba(255, 138, 61, 0.18);
  cursor: pointer;
  animation: pulse 1.6s ease-out infinite;
}
.spot:hover { background: rgba(255, 138, 61, 0.45); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 138, 61, 0.6); } 100% { box-shadow: 0 0 0 12px rgba(255, 138, 61, 0); } }

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none;
  padding: 13px 16px; border-radius: 14px; border: 1px solid transparent; cursor: pointer;
  background: var(--out); color: #fff; font-weight: 600; font-size: 15px;
}
.btn:active { transform: scale(0.985); }
.btn.ghost { background: rgba(255, 255, 255, 0.04); color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn.warn { background: var(--red); color: #fff; }

.ending { align-items: center; padding: 16px; background: rgba(3, 5, 8, 0.75); }
.ending .sheet { border-radius: 20px; border: 1px solid var(--line); max-height: 100%; overflow-y: auto; }
.end-label { text-align: center; font-size: 11.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--orange); }
.end-title { text-align: center; font-weight: 800; font-size: 26px; margin: 2px 0 6px; letter-spacing: -0.01em; }
.end-text { color: #c3cad6; line-height: 1.55; font-size: 14.5px; white-space: pre-wrap; margin-bottom: 6px; }
.end-found { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }
.end-list { list-style: none; padding: 0; margin: 0 0 8px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.end-list li { color: var(--ink-faint); }
.end-list li.got { color: var(--ink); }
.end-list li.got::before { content: '● '; color: var(--orange); }
.end-list li:not(.got)::before { content: '○ '; }

.viewer {
  position: absolute; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(2, 3, 5, 0.95); cursor: zoom-out;
}
.viewer.open { display: flex; animation: fadein 0.2s; }
.viewer img { max-width: 100%; max-height: 100%; }

/* ---------- menu ---------- */
.menu {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 138, 61, 0.35), transparent 50%),
    linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.5)),
    #121925;
}
.menu::before {
  /* a mountain skyline */
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 34%;
  background: #0b1018;
  clip-path: polygon(0 40%, 12% 22%, 22% 34%, 34% 8%, 44% 28%, 52% 18%, 63% 36%, 74% 12%, 86% 30%, 100% 20%, 100% 100%, 0 100%);
  opacity: 0.85;
}
.menu.closed { display: none; }
.menu-inner { position: relative; width: 100%; max-width: 330px; text-align: center; }
.logo-batt {
  width: 58px; height: 28px; margin: 0 auto 14px;
  border: 3px solid var(--ink); border-radius: 7px; padding: 3px; position: relative;
}
.logo-batt::after { content: ''; position: absolute; right: -8px; top: 7px; width: 4px; height: 9px; background: var(--ink); border-radius: 2px; }
.logo-batt i { display: block; height: 100%; width: 14%; background: var(--red); border-radius: 2px; animation: lowblink 1.4s infinite; }
.logo { font-weight: 800; font-size: 46px; letter-spacing: -0.03em; color: var(--ink); }
.logo em { font-style: normal; color: var(--orange); }
.menu-sub { white-space: pre-line; color: #aab3c2; margin: 10px 0 30px; font-size: 14px; line-height: 1.55; }
.menu-btns { display: flex; flex-direction: column; gap: 9px; }
.lang-switch { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.lang-switch button {
  flex: 1; padding: 9px; border-radius: 10px; border: 0; background: none; color: var(--ink-dim); cursor: pointer; font-weight: 500;
}
.lang-switch button.on { background: rgba(255, 255, 255, 0.1); color: var(--ink); }
.menu-found { margin-top: 22px; font-size: 12px; color: var(--ink-dim); letter-spacing: 0.08em; text-transform: uppercase; min-height: 15px; }
.menu-hint { white-space: pre-line; margin-top: 10px; font-size: 12px; color: var(--ink-dim); line-height: 1.5; }
