/* ─── Edward's Last Stand ─── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg0: #07070c;
  --bg1: #16162a;
  --card: #171725;
  --card-edge: #2b2b3d;
  --text: #f2eef4;
  --muted: #a9a3b8;
  --accent: #ff4f7d;
  --accent-soft: #ff8fb0;
  --gold: #ffd166;
  --bubble-bg: #fdfbf7;
  --bubble-text: #2b2735;
}

html, body { height: 100%; }
html { touch-action: manipulation; }

.bubble, .card, .btn, .chibi, .toast {
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: radial-gradient(140% 60% at 50% -12%, #171728 0%, #000 52%) #000;
  color: var(--text);
  font-family: "Quicksand", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* twinkly background */
.stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 12% 22%, rgba(255,255,255,.55), transparent 100%),
    radial-gradient(1.2px 1.2px at 78% 14%, rgba(255,255,255,.4), transparent 100%),
    radial-gradient(1.8px 1.8px at 64% 34%, rgba(255,209,102,.5), transparent 100%),
    radial-gradient(1.2px 1.2px at 30% 54%, rgba(255,255,255,.35), transparent 100%),
    radial-gradient(1.5px 1.5px at 88% 48%, rgba(255,143,176,.45), transparent 100%),
    radial-gradient(1.2px 1.2px at 8% 76%, rgba(255,255,255,.3), transparent 100%),
    radial-gradient(1.6px 1.6px at 46% 86%, rgba(255,255,255,.4), transparent 100%),
    radial-gradient(1.3px 1.3px at 70% 70%, rgba(255,209,102,.35), transparent 100%);
  animation: twinkle 4.5s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

#app {
  position: relative; z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: 28px 20px 44px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
}

/* ── speech bubble ── */
.bubble-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; }
.bubble {
  background: var(--bubble-bg);
  color: var(--bubble-text);
  border-radius: 20px;
  padding: 16px 18px;
  max-width: 360px;
  width: 100%;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.55;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  min-height: 56px;
}
.bubble b { color: #d33f63; }
.bubble-tail {
  width: 0; height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 14px solid var(--bubble-bg);
  margin-top: -1px;
}
.caret {
  display: inline-block;
  width: 3px; height: 1.05em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 2px;
  animation: blink .8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── chibi ── */
.chibi { position: relative; z-index: 2; }
.pop-in { animation: pop .75s cubic-bezier(.2, 1.5, .35, 1) both; }
@keyframes pop {
  0% { transform: scale(0) translateY(30px); opacity: 0; }
  70% { transform: scale(1.06) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.chibi-inner { animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

.chibi.tappable { cursor: pointer; }
.chibi.tappable .face-wrap { animation: wiggle 1.8s ease-in-out infinite; transform-origin: 50% 88%; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(2.5deg); }
  70% { transform: rotate(-2.5deg); }
}
.tap-hint {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
}

.face-wrap {
  width: 220px; height: 252px;
  position: relative;
  margin: 0 auto;
}
.face {
  position: absolute; bottom: 0; left: 50%;
  transform: translateX(-50%);
  height: 100%; width: auto;
  transition: opacity .14s ease, height .4s ease;
  user-select: none; -webkit-user-drag: none;
}
.face-swap { opacity: 0; }

/* compact chibi when a card needs the room */
.face-wrap { transition: width .4s ease, height .4s ease; }
#app.compact .face-wrap { width: 175px; height: 190px; }

/* ── panel & cards ── */
.panel { width: 100%; max-width: 360px; }
.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 18px;
  margin-top: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.card-title {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.waiting-msg { color: var(--muted); font-size: 15px; line-height: 1.55; }
.waiting-msg b { color: var(--accent-soft); }

.dots { display: flex; gap: 7px; justify-content: center; margin-top: 14px; }
.dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-soft);
  animation: dotpulse 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: .18s; }
.dots span:nth-child(3) { animation-delay: .36s; }
@keyframes dotpulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }

.auto-note {
  text-align: center;
  font-size: 12.5px;
  color: #6f6a80;
  margin-top: 12px;
}

.car-desc {
  font-size: 19px; font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  text-transform: capitalize;
}
.plate {
  background: #f4f2ec;
  color: #23232e;
  border: 3px solid #23232e;
  border-radius: 10px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: .14em;
  text-align: center;
  text-transform: uppercase;
  padding: 10px 14px;
  position: relative;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), 0 6px 18px rgba(0,0,0,.4);
}
.plate .screw {
  position: absolute; top: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: #b9b6ad; box-shadow: inset 0 1px 1px rgba(0,0,0,.5);
}
.plate .screw:first-child { left: 8px; }
.plate .screw:last-child { right: 8px; }

.outside-banner {
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  border-radius: 12px;
  padding: 12px 10px;
  margin-bottom: 13px;
  animation: softpulse 2.4s ease-in-out infinite;
}
@keyframes softpulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 79, 125, .0); }
  50% { box-shadow: 0 0 22px rgba(255, 79, 125, .45); }
}
.eta {
  text-align: center;
  color: var(--gold);
  font-size: 15px;
  font-weight: 600;
  margin-top: 12px;
}
.eta b { font-size: 17.5px; }

/* ── room reveal ── */
.room-card { text-align: center; padding: 26px 18px; border-color: rgba(255, 209, 102, .45); }
.room-label {
  font-size: 12.5px; letter-spacing: .22em; font-weight: 700;
  color: var(--muted); margin-bottom: 8px;
}
.room-num {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-size: 46px; font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(255, 209, 102, .45);
  line-height: 1.1;
  animation: glowpulse 2.2s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { text-shadow: 0 0 18px rgba(255,209,102,.35); }
  50% { text-shadow: 0 0 34px rgba(255,209,102,.65); }
}
.room-sub { margin-top: 10px; color: var(--accent-soft); font-size: 16px; font-weight: 600; font-style: italic; }

/* ── buttons ── */
.actions { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 11px; margin-top: 16px; }
.btn {
  font-family: "Quicksand", sans-serif;
  font-size: 16.5px; font-weight: 700;
  border: none; border-radius: 999px;
  padding: 16px 20px;
  width: 100%;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
  line-height: 1.35;
}
.btn:active { transform: scale(.965); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 100%);
  color: #fff;
  box-shadow: 0 10px 26px rgba(255, 79, 125, .38);
}
.btn-ghost {
  background: transparent;
  color: #d8d2e6;
  border: 1.5px solid #3c3c52;
}
.btn.busy { opacity: .55; pointer-events: none; }

.reveal { animation: rise .5s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ── confirm popup ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 2, 6, .74);
  display: flex; align-items: center; justify-content: center;
  padding: 26px;
  z-index: 150;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 20px;
  padding: 24px 20px 18px;
  max-width: 320px; width: 100%;
  display: flex; flex-direction: column; gap: 11px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  animation: rise .28s cubic-bezier(.2, .8, .3, 1) both;
}
.modal-msg {
  text-align: center;
  font-weight: 700;
  font-size: 17.5px;
  margin-bottom: 8px;
}

/* ── toast ── */
.toast {
  position: fixed;
  left: 50%; bottom: 110px;
  width: max-content;
  transform: translateX(-50%) translateY(20px);
  background: #2a1b26;
  border: 1px solid #573345;
  color: #ffd9e4;
  font-size: 14.5px; font-weight: 600;
  padding: 12px 18px;
  border-radius: 14px;
  max-width: min(360px, calc(100vw - 32px));
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-height: 700px) {
  .face-wrap { width: 190px; height: 212px; }
  .bubble { font-size: 15.5px; padding: 13px 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .chibi-inner, .stars, .room-num, .dots span, .pop-in, .reveal, .outside-banner, .chibi.tappable .face-wrap { animation: none; }
}
