/* HARI NG KALSAWA — HUD & screens */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --yellow: #ffe14d; --red: #ff5040; --green: #38d95e; --ink: #101418;
}
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d1226;
  font-family: 'Arial Black', 'Arial Narrow Bold', Arial, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none;
  -webkit-tap-highlight-color: transparent; }
#app, #app canvas { position: fixed; inset: 0; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; z-index: 5; }
#hud.visible { opacity: 1; }

#hud-top { position: absolute; top: calc(6px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; padding: 0 12px; }
#hud-top label { font-size: 10px; color: #ffffffaa; letter-spacing: 2px; display: block; }
#hud-fare { font-size: clamp(20px, 4.5vw, 34px); color: var(--yellow);
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; }
#hud-pax-wrap { font-size: 12px; color: #fff; opacity: .85; margin-top: 2px; }
#hud-time { font-size: clamp(40px, 9vw, 72px); color: #fff; line-height: 1;
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000; font-style: italic; min-width: 120px; text-align: center; }
#hud-time.panic { color: var(--red); animation: panicpulse .5s infinite alternate; }
@keyframes panicpulse { from { transform: scale(1); } to { transform: scale(1.14); } }
#hud-speed-wrap { text-align: right; }
#hud-speed { font-size: clamp(22px, 4.5vw, 36px); color: #7fd8ff; text-shadow: 2px 2px 0 #000; }

/* destination arrow + readout */
#hud-dest { position: absolute; top: calc(74px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; opacity: 0; transition: opacity .25s; }
#hud-dest.visible { opacity: 1; }
#hud-arrow { transition: transform .12s linear; filter: drop-shadow(2px 2px 0 #000); }
#hud-dest-text { text-align: left; }
#hud-dist { font-size: clamp(20px, 4vw, 32px); text-shadow: 2px 2px 0 #000; }
#hud-destname { font-size: clamp(12px, 2.4vw, 18px); color: #fff; text-shadow: 1px 1px 0 #000; max-width: 40vw; }
#hud-tip { width: clamp(120px, 26vw, 220px); height: 10px; background: #00000088;
  border: 2px solid #ffffffcc; border-radius: 6px; margin-top: 4px; opacity: 0; transition: opacity .2s; }
#hud-tip.visible { opacity: 1; }
#hud-tip-fill { height: 100%; width: 100%; background: var(--yellow); border-radius: 4px; transition: width .2s linear; }
#hud-tip-val { font-size: 11px; color: #ffffffcc; margin-top: 2px; text-shadow: 1px 1px 0 #000; }

#hud-combo { position: absolute; top: 30%; right: 6%; font-size: clamp(18px, 4vw, 30px);
  color: #ff9d2e; text-shadow: 2px 2px 0 #000; opacity: 0; transform: rotate(6deg); }
#hud-combo.visible { opacity: 1; }
#hud-combo.bump { animation: bump .3s; }
@keyframes bump { 0% { transform: scale(1.6) rotate(6deg); } 100% { transform: scale(1) rotate(6deg); } }

#hud-street { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); left: 12px;
  font-size: clamp(11px, 2vw, 14px); color: #ffffffb0; letter-spacing: 1px; text-shadow: 1px 1px 0 #000; }

/* trick announcements */
#announce { position: absolute; top: 38%; left: 0; right: 0; display: flex; flex-direction: column;
  align-items: center; gap: 4px; }
.ann { font-size: clamp(22px, 5.5vw, 44px); font-style: italic;
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000; animation: annin .22s ease-out; text-align: center; }
.ann small { display: block; font-size: .45em; color: #fff; font-style: normal; }
.ann.out { opacity: 0; transform: translateY(-18px) scale(.9); transition: all .35s; }
@keyframes annin { 0% { transform: scale(2.2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

#flash { position: absolute; top: 22%; left: 0; right: 0; text-align: center;
  font-size: clamp(24px, 6vw, 48px); opacity: 0; text-shadow: 3px 3px 0 #000, -1px -1px 0 #000; }
#flash.visible { animation: flashpop 1.6s ease-out; }
@keyframes flashpop { 0% { opacity: 0; transform: scale(.4); } 12% { opacity: 1; transform: scale(1.15); }
  25% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(1.02) translateY(-10px); } }

/* passenger bark bubble */
#bark { position: absolute; bottom: 26%; left: 50%; transform: translateX(-50%);
  background: #fff; color: #101418; border: 3px solid #101418; border-radius: 14px;
  padding: 8px 14px; max-width: min(78vw, 420px); font-family: Arial, sans-serif; font-weight: bold;
  font-size: clamp(13px, 2.6vw, 17px); opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: 4px 4px 0 #00000055; }
#bark.visible { opacity: 1; transform: translateX(-50%) translateY(-6px); }
#bark.urgent { background: #ffdf3d; animation: barkshake .3s infinite; }
#bark.driver { background: #cde8ff; }
#bark.driver #bark-name { color: #0b5bd3; }
#bark::after { content: ''; position: absolute; bottom: -14px; left: 50%; margin-left: -8px;
  border: 8px solid transparent; border-top-color: #101418; }
#bark-name { display: block; font-size: .72em; color: #b3001b; text-transform: uppercase; letter-spacing: 1px; }
@keyframes barkshake { 0%,100% { transform: translateX(-50%) rotate(-1deg); } 50% { transform: translateX(-50%) rotate(1.4deg); } }

/* touch controls */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
#touch-left { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 12px;
  display: flex; gap: 12px; pointer-events: auto; }
#touch-right { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); right: 12px;
  display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.tbtn { width: 68px; height: 68px; border-radius: 50%; background: #ffffff22; border: 3px solid #ffffff88;
  color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center;
  text-shadow: 1px 1px 0 #000; backdrop-filter: blur(2px); }
.tbtn.big { width: 88px; height: 88px; background: #38d95e33; border-color: #38d95ecc; font-size: 18px; }
.tbtn.small { width: 54px; height: 54px; font-size: 12px; }
.tbtn.held { background: #ffe14d66; border-color: var(--yellow); transform: scale(.94); }
@media (max-width: 640px) {
  .tbtn { width: 56px; height: 56px; font-size: 18px; }
  .tbtn.big { width: 76px; height: 76px; font-size: 15px; }
  .tbtn.small { width: 46px; height: 46px; font-size: 10px; }
  #touch-right, #touch-left { gap: 7px; }
  #btn-brake { font-size: 13px; }
}
#btn-pause { position: absolute; top: calc(60px + env(safe-area-inset-top)); right: 12px; width: 40px; height: 40px;
  border-radius: 8px; background: #00000066; border: 2px solid #ffffff66; color: #fff;
  display: none; align-items: center; justify-content: center; font-size: 14px; pointer-events: auto; }
body.touch #btn-pause { display: flex; }

/* ============ SCREENS ============ */
.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 10; background: radial-gradient(ellipse at center, #14204c88 0%, #0a0e1ecc 78%);
  padding: 16px; }
.screen.visible { display: flex; }
.panel { background: #101828ee; border: 4px solid var(--yellow); border-radius: 18px;
  padding: clamp(16px, 4vw, 36px); max-width: 560px; width: 100%; text-align: center;
  box-shadow: 0 18px 60px #00000088; max-height: 92vh; overflow-y: auto; }
.logo-kicker { color: #7fd8ff; font-size: clamp(10px, 2vw, 13px); letter-spacing: 4px; }
.logo { font-size: clamp(44px, 11vw, 84px); line-height: .95; font-style: italic;
  background: linear-gradient(180deg, #ffe14d 20%, #ff8c1a 60%, #ff5040);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(3px 3px 0 #000); }
.logo-sub { color: #fff; font-size: clamp(14px, 3vw, 20px); margin-top: 6px; letter-spacing: 3px; }
.tagline { color: #d6dbe4; font-family: Arial, sans-serif; font-size: clamp(12px, 2.4vw, 15px);
  margin: 14px auto; max-width: 46ch; line-height: 1.45; }
#title-best { color: var(--green); font-size: clamp(14px, 3vw, 19px); margin: 8px 0; text-shadow: 1px 1px 0 #000; }
.controls-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.controls-grid div { background: #ffffff10; border: 1px solid #ffffff28; border-radius: 8px; padding: 8px 4px; }
.controls-grid b { display: block; color: var(--yellow); font-size: clamp(11px, 2.4vw, 14px); }
.controls-grid span { color: #aab4c4; font-family: Arial, sans-serif; font-size: clamp(10px, 2vw, 12px); }
body.touch .controls-grid { grid-template-columns: repeat(2, 1fr); }
.bigbtn { display: block; width: 100%; margin-top: 12px; padding: 16px; font-family: inherit;
  font-size: clamp(17px, 3.6vw, 24px); font-style: italic; color: #101418;
  background: linear-gradient(180deg, #ffe14d, #ff9d2e); border: none; border-radius: 12px;
  cursor: pointer; box-shadow: 0 5px 0 #a35b00, 0 8px 18px #00000066; }
.bigbtn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a35b00; }
.midbtn { display: block; width: 100%; margin-top: 10px; padding: 12px; font-family: inherit;
  font-size: clamp(13px, 2.8vw, 17px); color: #fff; background: #ffffff1a;
  border: 2px solid #ffffff55; border-radius: 10px; cursor: pointer; }
.hint { color: #8b96a8; font-family: Arial, sans-serif; font-size: 11px; margin-top: 12px; }
h2 { color: var(--yellow); font-size: clamp(26px, 6vw, 40px); font-style: italic; text-shadow: 2px 2px 0 #000; }

#screen-countdown { background: transparent; pointer-events: none; }
#cd-num { font-size: clamp(110px, 30vw, 260px); color: var(--yellow); font-style: italic;
  text-shadow: 6px 6px 0 #000, -3px -3px 0 #000; }
#cd-num.pop { animation: cdpop .9s ease-out; }
@keyframes cdpop { 0% { transform: scale(2.4); opacity: 0; } 20% { transform: scale(1); opacity: 1; }
  85% { opacity: 1; } 100% { opacity: 0; transform: scale(.92); } }

#res-rank { font-size: clamp(80px, 20vw, 150px); line-height: 1; font-style: italic;
  text-shadow: 5px 5px 0 #000; }
#res-title { color: #fff; font-size: clamp(15px, 3.4vw, 22px); margin-top: 4px; }
#res-note { color: #9fb0c8; font-family: Arial, sans-serif; font-size: clamp(12px, 2.4vw, 14px); margin: 6px 0 14px; }
.rrow { display: flex; justify-content: space-between; padding: 6px 10px; color: #d6dbe4;
  font-family: Arial, sans-serif; font-size: clamp(13px, 2.8vw, 16px); border-bottom: 1px dashed #ffffff22; }
.rrow b { color: var(--yellow); font-family: inherit; }
.rrow.total { font-size: clamp(16px, 3.6vw, 22px); border-bottom: none; padding-top: 10px; }
.rrow.total b { color: var(--green); }
#res-best { margin-top: 10px; color: #9fb0c8; font-size: clamp(12px, 2.6vw, 15px); }
#res-best.newbest { color: var(--green); animation: bump .5s 3; }

@media (max-width: 640px) {
  #bark { bottom: 34%; }
  #hud-dest { top: calc(64px + env(safe-area-inset-top)); }
  #hud-combo { top: 24%; }
  #announce { top: 30%; }
  #flash { top: 17%; }
}
