/* ============ CRAZY CAB — arcade UI ============ */
@font-face{font-family:'Bungee';src:url('../fonts/bungee-400.woff2') format('woff2');font-weight:400;font-display:swap}
@font-face{font-family:'Rubik';src:url('../fonts/rubik-500.woff2') format('woff2');font-weight:500;font-display:swap}
@font-face{font-family:'Rubik';src:url('../fonts/rubik-700.woff2') format('woff2');font-weight:700;font-display:swap}

:root{
  --yellow:#ffcf1a; --yellow2:#ffb300; --green:#37e05c; --green2:#14b53f;
  --red:#ff3b30; --orange:#ff8a00; --ink:#141414; --sky:#5ec8ff;
  --outline: 2px 0 0 #111,-2px 0 0 #111,0 2px 0 #111,0 -2px 0 #111,2px 2px 0 #111,-2px -2px 0 #111,2px -2px 0 #111,-2px 2px 0 #111,0 5px 0 rgba(0,0,0,.45);
}
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{width:100%;height:100%;overflow:hidden;background:#0b1e33}
body{font-family:'Rubik',system-ui,sans-serif;color:#fff;-webkit-user-select:none;user-select:none;touch-action:none}
#app{position:fixed;inset:0}
#gl{position:absolute;inset:0;width:100%;height:100%;display:block}
.hidden{display:none!important}
kbd{display:inline-block;background:#111;color:var(--yellow);border:2px solid #000;border-bottom-width:4px;border-radius:6px;padding:1px 7px;margin:0 2px;font-family:'Bungee';font-size:.85em;box-shadow:0 2px 0 rgba(0,0,0,.4)}

/* ---------- HUD ---------- */
#hud{position:absolute;inset:0;pointer-events:none;z-index:5;font-family:'Bungee'}
#hud-top{position:absolute;top:max(10px,env(safe-area-inset-top));left:12px;right:12px;display:flex;justify-content:space-between;align-items:flex-start;gap:10px}
#hud-bottom{position:absolute;bottom:max(12px,env(safe-area-inset-bottom));left:12px;right:12px;display:flex;justify-content:space-between;align-items:flex-end}
.hud-chip{background:rgba(10,10,10,.38);border:3px solid #111;border-radius:14px;padding:6px 14px;box-shadow:0 4px 0 rgba(0,0,0,.35);backdrop-filter:blur(2px)}
.hud-label{font-size:11px;letter-spacing:.14em;color:var(--yellow);text-shadow:1px 1px 0 #000}
.hud-label.tiny{font-size:9px;margin-bottom:2px}
.hud-big{font-size:clamp(30px,4.6vw,52px);line-height:1;color:#fff;text-shadow:var(--outline)}
.hud-mid{font-size:clamp(15px,2vw,24px);line-height:1.05;color:#fff;text-shadow:var(--outline)}
.hud-tips{font-size:13px;color:var(--green);text-shadow:1px 1px 0 #000}
#hud-time{min-width:96px;text-align:center}
#time-value.warn{color:#ffb02e} #time-value.crit{color:#ff4b4b;animation:pulse .5s infinite}
#hud-money{text-align:right}
#money-value{color:var(--green)}
#hud-dest{position:absolute;left:50%;transform:translateX(-50%);top:max(10px,env(safe-area-inset-top));min-width:min(46vw,340px);text-align:center;background:rgba(20,120,40,.55);border-color:#0a3d16}
#dest-name{color:#d7ffe0}
#fare-bar{height:8px;border:2px solid #000;border-radius:5px;background:#321;margin-top:5px;overflow:hidden}
#fare-bar-fill{height:100%;width:100%;background:linear-gradient(90deg,#37e05c,#c9ff3e);transition:width .18s linear}
#fare-bar-fill.low{background:linear-gradient(90deg,#ff3b30,#ff8a00)}
#hud-speed{text-align:center;min-width:104px}
#speed-value{font-size:clamp(34px,5vw,60px);color:var(--yellow)}
#hud-fare{text-align:left}
#gear-value{font-size:clamp(20px,2.6vw,34px);color:#fff}
#gear-value.rev{color:#ff6b5e}
#boost-wrap{margin-top:4px}
#boost-bar{width:110px;height:9px;border:2px solid #000;border-radius:5px;background:#203040;overflow:hidden}
#boost-fill{height:100%;width:100%;background:linear-gradient(90deg,#ff8a00,#ffe45e)}
#vignette{position:absolute;inset:0;pointer-events:none;box-shadow:inset 0 0 140px rgba(0,0,20,.28)}

/* combo toast + announcements */
#combo-toast{position:absolute;top:23%;left:50%;transform:translateX(-50%) rotate(-4deg);font-family:'Bungee';font-size:clamp(22px,3.4vw,42px);color:var(--orange);text-shadow:var(--outline);white-space:nowrap;animation:pop .28s ease-out}
#combo-x{color:#ffe45e;font-size:.7em;margin-left:8px}
#announce{position:absolute;top:34%;left:50%;transform:translateX(-50%);text-align:center;font-family:'Bungee';pointer-events:none}
#announce-main{font-size:clamp(30px,5.4vw,64px);color:var(--green);text-shadow:var(--outline);animation:pop .3s cubic-bezier(.2,2,.4,1)}
#announce-main.bad{color:var(--red)} #announce-main.gold{color:var(--yellow)}
#announce-sub{font-size:clamp(15px,2.2vw,26px);color:#fff;text-shadow:var(--outline);margin-top:6px}
#center-hint{position:absolute;bottom:13%;left:50%;transform:translateX(-50%);font-family:'Bungee';font-size:clamp(15px,2vw,22px);color:#fff;text-shadow:var(--outline);background:rgba(0,0,0,.35);padding:8px 18px;border-radius:12px;border:2px solid #111;white-space:nowrap}
@keyframes pop{0%{transform:translateX(-50%) scale(.3) rotate(-4deg);opacity:0}100%{transform:translateX(-50%) scale(1) rotate(-4deg);opacity:1}}
#announce #announce-main{transform:none} #announce.pop #announce-main{animation:popc .3s cubic-bezier(.2,2,.4,1)}
@keyframes popc{0%{transform:scale(.3);opacity:0}100%{transform:scale(1);opacity:1}}
@keyframes pulse{50%{opacity:.35}}
@keyframes blink{50%{opacity:0}}
.blink{animation:blink 1.05s steps(2) infinite}

/* ---------- corner buttons ---------- */
#corner-btns{position:absolute;top:max(10px,env(safe-area-inset-top));right:12px;z-index:30;display:flex;flex-direction:column;gap:8px}
#hud:not(.hidden)~#corner-btns{top:calc(max(10px,env(safe-area-inset-top)) + 108px)}
.cbtn{pointer-events:auto;width:46px;height:46px;border-radius:12px;border:3px solid #111;background:rgba(20,20,20,.55);color:#fff;font-size:20px;cursor:pointer;box-shadow:0 3px 0 rgba(0,0,0,.4)}
.cbtn:active{transform:translateY(2px);box-shadow:none}
.cbtn.muted{color:#888}

/* ---------- touch controls ---------- */
#touch{position:absolute;inset:auto 0 0 0;z-index:20;display:flex;justify-content:space-between;padding:0 14px calc(12px + env(safe-area-inset-bottom));pointer-events:none}
#touch-left,#touch-right{display:flex;gap:12px;align-items:flex-end;pointer-events:auto}
#touch-right{flex-direction:row}
.tbtn{pointer-events:auto;width:76px;height:76px;border-radius:20px;border:4px solid #111;background:rgba(255,207,26,.85);color:#111;font-family:'Bungee';font-size:30px;box-shadow:0 5px 0 rgba(0,0,0,.45);cursor:pointer;touch-action:none}
.tbtn.gas{background:rgba(55,224,92,.9)}
.tbtn.small{width:64px;height:56px;font-size:13px;background:rgba(255,138,0,.9)}
.tbtn:active,.tbtn.on{transform:translateY(4px);box-shadow:none;filter:brightness(1.15)}

/* ---------- screens ---------- */
.screen{position:absolute;inset:0;z-index:40;display:flex;flex-direction:column;align-items:center;justify-content:center;background:radial-gradient(ellipse at 50% 38%,rgba(8,20,40,.24),rgba(4,10,24,.78) 75%)}
#screen-title{justify-content:space-between;background:linear-gradient(180deg,rgba(0,30,70,.25),rgba(0,10,30,.15) 40%,rgba(0,10,30,.55))}
.checker-top,.checker-bot{width:100%;height:26px;background:repeating-conic-gradient(#111 0 25%,var(--yellow) 0 50%) 0 0/52px 52px;opacity:.95;border-bottom:4px solid #111}
.checker-bot{transform:scaleY(-1);border-bottom:none;border-top:4px solid #111}
.title-wrap{display:flex;flex-direction:column;align-items:center;gap:14px;padding:10px}
#logo{text-align:center;transform:rotate(-3deg);filter:drop-shadow(0 10px 0 rgba(0,0,0,.35))}
.logo-crazy{font-family:'Bungee';font-size:clamp(44px,9.5vw,108px);line-height:.9;color:var(--yellow);text-shadow:var(--outline);letter-spacing:.02em}
.logo-cab{font-family:'Bungee';font-size:clamp(64px,14vw,160px);line-height:.86;color:#fff;text-shadow:var(--outline),0 10px 0 var(--yellow2);margin-top:2px}
.logo-sub{font-family:'Bungee';font-size:clamp(14px,2.4vw,26px);color:var(--sky);text-shadow:var(--outline);letter-spacing:.5em;margin-top:10px}
#title-blink{font-family:'Bungee';font-size:clamp(15px,2.4vw,26px);color:#fff;text-shadow:var(--outline)}
#title-hiscore{font-family:'Bungee';color:var(--green);font-size:clamp(14px,2vw,20px);text-shadow:var(--outline)}
#title-controls{display:flex;flex-wrap:wrap;justify-content:center;gap:7px 16px;max-width:640px;font-family:'Rubik';font-weight:700;font-size:clamp(11px,1.5vw,15px);color:#fff;text-shadow:1px 1px 0 #000;background:rgba(0,0,0,.32);padding:10px 18px;border-radius:14px;border:2px solid rgba(0,0,0,.5)}
.ctl{white-space:nowrap}
#title-hint{font-family:'Rubik';font-weight:500;font-size:clamp(11px,1.6vw,15px);color:#ffe9a8;text-shadow:1px 1px 0 #000;text-align:center;max-width:600px}

.panel{background:linear-gradient(180deg,#1c2b45,#0e1a30);border:5px solid #111;border-radius:22px;box-shadow:0 12px 0 rgba(0,0,0,.45),inset 0 2px 0 rgba(255,255,255,.12);padding:26px 34px;text-align:center;max-width:min(92vw,520px)}
.panel-title{font-family:'Bungee';font-size:clamp(30px,5vw,52px);color:var(--yellow);text-shadow:var(--outline)}
.panel-row{margin:10px 0 4px;font-weight:500;color:#cfe0ff;font-size:15px}
.panel-btns{display:flex;flex-direction:column;gap:10px;margin-top:18px;align-items:center}
.mbtn{pointer-events:auto;font-family:'Bungee';font-size:clamp(16px,2.4vw,22px);color:#111;background:linear-gradient(180deg,var(--yellow),var(--yellow2));border:4px solid #111;border-radius:14px;padding:10px 30px;min-width:260px;cursor:pointer;box-shadow:0 5px 0 rgba(0,0,0,.5)}
.mbtn:hover{filter:brightness(1.08)}
.mbtn:active{transform:translateY(3px);box-shadow:0 2px 0 rgba(0,0,0,.5)}
.mbtn.dim{background:linear-gradient(180deg,#7f8ba0,#5d6880);color:#fff}
.mini{font-size:.6em;opacity:.75}
.results .panel-title{color:var(--red)}
#grade-badge{font-family:'Bungee';font-size:clamp(20px,3vw,32px);color:#fff;margin:8px auto;background:linear-gradient(135deg,#3a4a6b,#1a2438);border:4px solid #111;border-radius:14px;display:inline-block;padding:6px 22px;box-shadow:0 4px 0 rgba(0,0,0,.4)}
#grade-letter{color:var(--yellow);font-size:1.5em}
.result-rows{margin:14px 0 4px;display:flex;flex-direction:column;gap:6px;min-width:min(78vw,340px)}
.rrow{display:flex;justify-content:space-between;font-family:'Rubik';font-weight:700;font-size:clamp(14px,2vw,18px);color:#dfe8ff}
.rrow b{color:var(--green);font-family:'Bungee';font-weight:400}
.rrow.total{border-top:3px solid #33415e;padding-top:8px;font-size:clamp(17px,2.4vw,22px)}
.rrow.total b{color:var(--yellow)}

#rotate-hint{display:none;position:absolute;top:8px;left:50%;transform:translateX(-50%);z-index:50;background:#111a;border:2px solid #000;color:#ffd94d;font-family:'Bungee';font-size:12px;padding:6px 14px;border-radius:10px}
@media (orientation:portrait) and (pointer:coarse){#rotate-hint{display:block}}

/* ---------- small screens ---------- */
@media (max-width:700px){
  .hud-chip{padding:4px 9px;border-radius:10px}
  #hud-dest{min-width:44vw;padding:4px 8px}
  #hud-top{left:8px;right:8px}
  #hud-bottom{bottom:calc(96px + env(safe-area-inset-bottom))}
  #boost-bar{width:74px}
  #corner-btns .cbtn{width:40px;height:40px;font-size:16px}
  #hud:not(.hidden)~#corner-btns{top:calc(max(8px,env(safe-area-inset-top)) + 84px)}
  #center-hint{bottom:27%;font-size:13px;max-width:92vw;white-space:normal;text-align:center}
  .panel{padding:18px 16px}
}
@media (max-width:520px){
  #touch{padding:0 8px calc(10px + env(safe-area-inset-bottom));gap:6px}
  #touch-left,#touch-right{gap:8px}
  .tbtn{width:56px;height:56px;font-size:21px;border-radius:14px;border-width:3px}
  .tbtn.small{width:48px;height:44px;font-size:10px;border-radius:12px}
}
@media (max-height:520px) and (orientation:landscape){
  #hud-bottom{bottom:calc(78px + env(safe-area-inset-bottom))}
  #touch{padding-bottom:8px}
  .tbtn{width:58px;height:58px;font-size:22px}
  .tbtn.small{width:48px;height:42px;font-size:10px}
  .hud-chip{padding:3px 9px}
  .hud-big{font-size:30px}
  .hud-mid{font-size:15px}
  #hud-dest{min-width:150px}
  #corner-btns .cbtn{width:38px;height:38px;font-size:15px}
  #hud:not(.hidden)~#corner-btns{top:calc(max(8px,env(safe-area-inset-top)) + 62px)}
}
