/* City Walk HUD, phone and bubbles. Everything here sits below z-index 1000,
   under the platform chrome, and nothing paints a full-viewport background. */
:root {
  --cw-font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cw-ink: #1a1424;
  --cw-panel: rgba(18, 14, 28, 0.58);
  --cw-pink: #ff5fa2;
  --cw-red: #ff3d5e;
  --cw-green: #4fe39a;
  --ph-h: min(64vh, 560px, 130vw);
  --ph-w: calc(var(--ph-h) * 0.49);
  --sb: env(safe-area-inset-bottom, 0px);
}

#touchpad { position: fixed; inset: 0; z-index: 5; touch-action: none; display: none; }
body.cw-touch-live #touchpad { display: block; }

.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--cw-font); color: #fff; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
.hud[hidden] { display: none; }
.hud kbd, .phone kbd { font-family: var(--cw-font); font-size: 0.78em; font-weight: 800; display: inline-block; min-width: 1.5em; padding: 0.05em 0.4em; border-radius: 0.4em; background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.3); border-bottom-width: 2px; line-height: 1.3; text-align: center; }

/* Anxiety meter */
.hud-anx { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: calc(16px + var(--sb)); display: flex; align-items: center; gap: 12px; width: min(320px, 42vw); padding: 10px 14px 11px 12px; border-radius: 18px; background: var(--cw-panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); transition: opacity 0.4s; }
.anx-heart { width: 34px; flex: none; fill: var(--cw-red); filter: drop-shadow(0 0 6px rgba(255, 61, 94, 0.55)); transform-origin: 50% 55%; }
.anx-heart.beat { animation: cw-beat 0.32s ease-out; }
@keyframes cw-beat { 0% { transform: scale(1); } 18% { transform: scale(1.26); } 40% { transform: scale(1.04); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
.anx-body { flex: 1; min-width: 0; }
.anx-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.anx-label { font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.anx-bpm { font-size: 12px; font-weight: 700; opacity: 0.85; }
.anx-bpm b { font-size: 17px; font-variant-numeric: tabular-nums; opacity: 1; }
.anx-track { position: relative; height: 12px; border-radius: 7px; overflow: hidden; background: linear-gradient(90deg, #3fd68a 0%, #b9e04a 32%, #ffd23f 52%, #ff8a3d 74%, #ff2e4d 100%); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); }
.anx-cover { position: absolute; right: 0; top: 0; bottom: 0; background: rgba(12, 9, 18, 0.86); }
.anx-delta { position: absolute; top: 0; bottom: 0; z-index: 2; background: #fff; }
.anx-delta.down { background: var(--cw-green); }
.anx-tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255, 255, 255, 0.4); z-index: 3; }
.hud-anx.high { animation: cw-jitter 0.18s infinite; box-shadow: 0 0 0 2px rgba(255, 61, 94, 0.7), 0 0 30px rgba(255, 46, 77, 0.45); }
@keyframes cw-jitter { 0% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px); } 50% { transform: translate(-1px, 1px); } 75% { transform: translate(1px, 1px); } }

/* Distance and pace */
.hud-dist { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(14px + var(--sb)); text-align: right; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45); transition: opacity 0.4s; }
.hud-dist b { font-size: 46px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.hud-dist span { font-size: 20px; font-weight: 800; margin-left: 3px; opacity: 0.85; }
.hud-pace { display: flex; justify-content: flex-end; align-items: flex-end; gap: 3px; height: 14px; margin-top: 2px; }
.hud-pace i { width: 6px; border-radius: 2px; background: rgba(255, 255, 255, 0.25); }
.hud-pace i:nth-child(1) { height: 30%; } .hud-pace i:nth-child(2) { height: 45%; } .hud-pace i:nth-child(3) { height: 60%; } .hud-pace i:nth-child(4) { height: 80%; } .hud-pace i:nth-child(5) { height: 100%; }
.hud-pace i.on { background: #fff; }

/* Phone button, controls line, toast */
.hud-mid { position: absolute; left: 50%; bottom: calc(16px + var(--sb)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 9px; transition: opacity 0.25s; }
.hud.phone-up .hud-mid { opacity: 0; }
.hud-phone { pointer-events: auto; display: flex; align-items: center; gap: 9px; padding: 9px 14px 9px 12px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.28); background: var(--cw-panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; font: 800 15px var(--cw-font); cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); }
.hud-phone:hover { background: rgba(255, 95, 162, 0.35); }
.hud-phone.dead { opacity: 0.65; }
.hp-ico { font-size: 18px; line-height: 1; }
.hp-bat { position: relative; width: 22px; height: 11px; border: 1.5px solid rgba(255, 255, 255, 0.8); border-radius: 3px; padding: 1px; box-sizing: border-box; }
.hp-bat::after { content: ""; position: absolute; right: -4px; top: 2.5px; width: 2px; height: 4px; border-radius: 0 1px 1px 0; background: rgba(255, 255, 255, 0.8); }
.hp-bat i, .ph-bat i { display: block; height: 100%; border-radius: 1px; background: var(--cw-green); }
.hp-bat i.low, .ph-bat i.low { background: var(--cw-red); }
.hud-help { font-size: 13px; font-weight: 700; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); opacity: 0.9; white-space: nowrap; }
.hud-toast { font-size: 14px; font-weight: 900; padding: 6px 14px; border-radius: 999px; background: var(--cw-red); opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
.hud-toast.on { opacity: 1; transform: none; }

/* Speech bubbles and floating numbers */
.hud-bubbles, .hud-floats { position: absolute; inset: 0; overflow: hidden; }
.bubble { position: absolute; left: 0; top: 0; max-width: 230px; width: max-content; padding: 7px 12px 8px; border-radius: 15px; background: #fff; color: var(--cw-ink); font-size: 15px; font-weight: 800; line-height: 1.15; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28); will-change: transform; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: inherit; border-top-color: #fff; }
.bubble.loud { font-size: 17px; font-weight: 900; background: #ffe14d; border: 2px solid var(--cw-ink); padding: 6px 12px 7px; }
.bubble.loud::after { border-top-color: var(--cw-ink); bottom: -9px; }
.bubble.me { background: rgba(26, 20, 36, 0.88); color: #fff; font-style: italic; }
.bubble.me::after { border-top-color: rgba(26, 20, 36, 0.88); }
.bubble.behind { border: 2px dashed #fff; }
.bubble.behind::before { content: "behind you"; display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.6; font-style: normal; }
.float { position: absolute; transform: translate(-50%, -50%); font-size: 24px; font-weight: 900; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 0 12px rgba(0, 0, 0, 0.3); animation: cw-rise 1.1s ease-out forwards; }
.float.bad { color: #ff5470; }
.float.good { color: #5dffa8; }
@keyframes cw-rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -260%) scale(1); } }

/* Panic */
.hud-panic { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; opacity: 0; transition: opacity 0.8s; pointer-events: none; }
.hud-panic.on { opacity: 1; }
.hud-panic b { font-size: clamp(42px, 9vw, 112px); font-weight: 900; letter-spacing: 0.02em; color: #ff3d5e; text-shadow: 0 0 40px rgba(255, 30, 60, 0.6), 0 4px 0 rgba(0, 0, 0, 0.5); }
.hud-panic.on b { animation: cw-panic 0.09s infinite; }
.hud-panic span { font-size: 20px; font-weight: 700; opacity: 0.8; letter-spacing: 0.3em; text-transform: uppercase; }
@keyframes cw-panic { 0% { transform: translate(2px, 0) rotate(-0.5deg); } 50% { transform: translate(-2px, 1px) rotate(0.5deg); } 100% { transform: translate(1px, -2px); } }
.hud.panicking .hud-anx, .hud.panicking .hud-dist, .hud.panicking .hud-mid { opacity: 0; }

/* The phone */
.phone { position: fixed; left: 50%; bottom: calc(10px + var(--sb)); z-index: 20; height: var(--ph-h); width: var(--ph-w); transform-origin: 50% 100%; will-change: transform; font-family: var(--cw-font); visibility: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.ph-down { position: absolute; left: 50%; top: -38px; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; border: 0; background: rgba(18, 14, 28, 0.7); color: #fff; font: 800 13px var(--cw-font); cursor: pointer; white-space: nowrap; }
.ph-body { height: 100%; box-sizing: border-box; padding: calc(var(--ph-h) * 0.016); border-radius: calc(var(--ph-h) * 0.085); background: #17141d; box-shadow: 0 0 0 calc(var(--ph-h) * 0.009) #ff8fc3, 0 0 0 calc(var(--ph-h) * 0.012) #e2589a, 0 30px 70px rgba(0, 0, 0, 0.55); }
.ph-screen { position: relative; height: 100%; overflow: hidden; border-radius: calc(var(--ph-h) * 0.07); background: #f3f1f7; color: var(--cw-ink); }
.ph-status { position: absolute; left: 0; right: 0; top: 0; height: 6.5%; display: flex; align-items: center; justify-content: space-between; padding: 0 9%; font-size: calc(var(--ph-h) * 0.024); font-weight: 800; z-index: 3; }
.ph-island { position: absolute; left: 50%; top: 22%; width: 30%; height: 58%; transform: translateX(-50%); border-radius: 999px; background: #000; }
.ph-bat { position: relative; width: calc(var(--ph-h) * 0.042); height: calc(var(--ph-h) * 0.02); border: 1.5px solid rgba(0, 0, 0, 0.75); border-radius: 3px; padding: 1px; box-sizing: border-box; }
.ph-app { position: absolute; left: 0; right: 0; top: 6.5%; bottom: 0; display: flex; flex-direction: column; padding: 2% 5% 5%; }
.ph-head { display: flex; justify-content: space-between; align-items: center; height: 7%; }
.ph-head b { font-size: calc(var(--ph-h) * 0.04); font-weight: 900; letter-spacing: -0.03em; background: linear-gradient(90deg, #ff5fa2, #7a5cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ph-combo { font-size: calc(var(--ph-h) * 0.03); font-weight: 900; color: #ff7a1a; }
.ph-combo.hot { animation: cw-beat 0.5s infinite; }
.ph-deck { position: relative; flex: 1; margin-top: 2%; }
.card { position: absolute; inset: 0; display: flex; flex-direction: column; border-radius: calc(var(--ph-h) * 0.034); background: #fff; box-shadow: 0 6px 18px rgba(40, 20, 60, 0.16); transition: transform 0.36s cubic-bezier(.2, .8, .3, 1), opacity 0.36s; }
.card.in { transform: translateY(8%) scale(0.94); opacity: 0; }
.card.out { pointer-events: none; transition-timing-function: cubic-bezier(.5, 0, .9, .5); }
.card.out.left { transform: translateX(-125%) rotate(-16deg); opacity: 0.2; }
.card.out.right { transform: translateX(125%) rotate(16deg); opacity: 0.2; }
.card.out.down { transform: translateY(30%) scale(0.88); opacity: 0; }
.card-top { display: flex; justify-content: space-between; padding: 4.5% 6% 3%; font-size: calc(var(--ph-h) * 0.022); color: #6b6378; }
.card-top b { color: var(--cw-ink); }
.card-pic { flex: 1; margin: 0 4%; border-radius: calc(var(--ph-h) * 0.024); background: linear-gradient(140deg, var(--c1), var(--c2)); display: grid; place-items: center; overflow: hidden; }
.card-pic span { font-size: calc(var(--ph-h) * 0.12); line-height: 1; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.2)); }
.card-text { padding: 5% 6% 6%; font-size: calc(var(--ph-h) * 0.031); font-weight: 800; line-height: 1.2; min-height: 2.4em; }
.card-stamp { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.4); font-size: calc(var(--ph-h) * 0.16); font-weight: 900; opacity: 0; transition: transform 0.2s, opacity 0.2s; text-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
.card.out .card-stamp { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.card.ok .card-stamp { color: var(--cw-green); }
.card.bad .card-stamp { color: var(--cw-red); }
.card.meh .card-stamp { color: #aaa; }
.ph-timer { height: calc(var(--ph-h) * 0.009); margin: 4% 2% 3%; border-radius: 99px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.ph-timer i { display: block; height: 100%; background: #7a5cff; transform-origin: 0 50%; }
.ph-timer i.low { background: var(--cw-red); }
.ph-btns { display: flex; justify-content: space-around; }
.ph-btns button { position: relative; width: 26%; aspect-ratio: 1; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 4px 14px rgba(40, 20, 60, 0.18); font: 900 calc(var(--ph-h) * 0.05) var(--cw-font); cursor: pointer; display: grid; place-items: center; padding: 0; }
.ph-no { color: #7b7290; }
.ph-yes { color: var(--cw-pink); }
.ph-btns button:active { transform: scale(0.92); }
.ph-btns kbd { position: absolute; bottom: -16%; left: 50%; transform: translateX(-50%); font-size: calc(var(--ph-h) * 0.018); color: #8d859c; background: #ebe8f1; border-color: #d9d4e2; }
@media (hover: none) { .ph-btns kbd, .hud-phone kbd { display: none; } }
.ph-gain { position: absolute; left: 50%; top: 32%; transform: translate(-50%, 0); font-size: calc(var(--ph-h) * 0.07); font-weight: 900; opacity: 0; pointer-events: none; z-index: 4; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.ph-gain.good { color: #18c773; }
.ph-gain.bad { color: var(--cw-red); }
.ph-gain.pop { animation: cw-gain 0.8s ease-out forwards; }
@keyframes cw-gain { 0% { opacity: 0; transform: translate(-50%, 20%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -10%) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -120%) scale(1); } }
.ph-dead { position: absolute; inset: 0; z-index: 5; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: #050407; color: #fff; }
.ph-dead span { font-size: calc(var(--ph-h) * 0.09); }
.ph-dead b { font-size: calc(var(--ph-h) * 0.04); color: var(--cw-red); }
.ph-dead small { font-size: calc(var(--ph-h) * 0.022); opacity: 0.6; }
.ph-screen.dead .ph-dead { display: flex; }
.ph-cracks { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; fill: none; stroke: rgba(255, 255, 255, 0.95); stroke-width: 0.7; stroke-linejoin: bevel; filter: drop-shadow(0 0 0.6px rgba(0, 0, 0, 0.9)); }
.ph-cracks g { display: none; }
.crack1 .c1, .crack2 .c2, .crack3 .c3 { display: inline; }

/* Local preview only: stands in for the platform's title and result screens. */
.dev { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; font-family: var(--cw-font); color: #fff; pointer-events: none; }
.dev[hidden] { display: none; }
.dev-card { pointer-events: auto; width: min(420px, calc(100vw - 32px)); padding: 26px 26px 22px; border-radius: 24px; background: rgba(18, 14, 28, 0.74); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); text-align: center; }
.dev-card h1 { margin: 0; font-size: 44px; font-weight: 900; letter-spacing: -0.02em; }
.dev-card h1 em { font-style: normal; color: var(--cw-pink); }
.dev-card p { margin: 8px 0 0; opacity: 0.85; line-height: 1.4; }
.dev-card .dev-score { font-size: 64px; font-weight: 900; margin: 6px 0 2px; }
.dev-card dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 16px 0 0; text-align: left; font-size: 14px; }
.dev-card dt { opacity: 0.7; } .dev-card dd { margin: 0; font-weight: 800; text-align: right; }
.dev-card button { margin-top: 20px; padding: 13px 34px; border: 0; border-radius: 999px; background: var(--cw-pink); color: #fff; font: 900 18px var(--cw-font); cursor: pointer; box-shadow: 0 8px 24px rgba(255, 95, 162, 0.4); }
.dev-card button:hover { filter: brightness(1.08); }
.dev-card small { display: block; margin-top: 14px; font-size: 11px; opacity: 0.5; letter-spacing: 0.08em; text-transform: uppercase; }

/* Upright phones: the raised phone fills the bottom of the screen, so the
   meter and the distance live at the top, either side of the platform's
   in-round Home / Restart pair (top centre). */
@media (max-width: 600px) {
  .hud-anx { top: calc(10px + env(safe-area-inset-top, 0px)); bottom: auto; width: calc(50vw - 64px); gap: 8px; padding: 8px 10px 9px 9px; border-radius: 14px; }
  .anx-heart { width: 24px; }
  .anx-label { display: none; } .anx-row { justify-content: flex-start; margin-bottom: 5px; } .anx-bpm b { font-size: 14px; }
  .hud-dist { top: calc(6px + env(safe-area-inset-top, 0px)); bottom: auto; }
  .hud-dist b { font-size: 32px; } .hud-dist span { font-size: 15px; }
  .hud-help { display: none; }
  .bubble { font-size: 13px; max-width: 170px; }
  .bubble.loud { font-size: 14px; }
}
