* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #7fb0de; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none;
}
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .btn, #prompt { pointer-events: auto; }

.btn {
  position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(18, 22, 30, 0.45);
  color: #fff; font: 800 13px/1 system-ui, sans-serif; letter-spacing: 0.06em; touch-action: none; padding: 0; outline: none;
  transition: transform 0.06s, background 0.06s;
}
.btn.pressed { background: rgba(255, 255, 255, 0.38); transform: scale(0.93); }
#btn-jump { width: 92px; height: 92px; right: calc(24px + env(safe-area-inset-right, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); font-size: 15px; }
#btn-action { width: 74px; height: 74px; right: calc(132px + env(safe-area-inset-right, 0px)); bottom: calc(36px + env(safe-area-inset-bottom, 0px)); background: rgba(255, 160, 30, 0.75); border-color: #fff; }
#btn-car { width: 60px; height: 60px; right: calc(40px + env(safe-area-inset-right, 0px)); bottom: calc(132px + env(safe-area-inset-bottom, 0px)); background: rgba(155, 89, 255, 0.6); font-size: 12px; }
#btn-horn { width: 58px; height: 58px; right: calc(40px + env(safe-area-inset-right, 0px)); bottom: calc(132px + env(safe-area-inset-bottom, 0px)); font-size: 10px; }

#topbar { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); display: flex; align-items: center; gap: 8px; }
#topbar .btn { position: static; width: 42px; height: 42px; }
#cash {
  padding: 7px 14px; border-radius: 20px; background: rgba(0, 0, 0, 0.55);
  font: 800 18px/1 system-ui, sans-serif; color: #7dff9a; font-variant-numeric: tabular-nums;
}
#cash.pop { animation: pop 0.6s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); color: #fff; } 100% { transform: scale(1); } }

#minimap {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: calc(10px + env(safe-area-inset-left, 0px));
  width: 124px; height: 124px; border-radius: 50%; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

#mission {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  width: min(46vw, 420px); padding: 8px 14px 10px; border-radius: 14px;
  background: rgba(15, 20, 32, 0.82); border-left: 6px solid #2ecc71; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.m-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
#m-title { font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; }
#m-timer { font: 800 20px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
#m-timer.low { color: #ff6b6b; }
#m-text { font-size: 16px; font-weight: 800; margin-top: 2px; }
#m-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
#m-sub.warn { color: #ffcf4d; opacity: 1; font-weight: 700; }
#m-bar { margin-top: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); overflow: hidden; }
#m-bar i { display: block; height: 100%; width: 0; background: #ff4d4d; }

#countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 900 clamp(70px, 18vw, 150px)/1 system-ui, sans-serif; color: #ffd21f; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}

#toast {
  position: absolute; top: calc(96px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  max-width: 60vw; padding: 8px 16px; border-radius: 20px; background: rgba(0, 0, 0, 0.6);
  font-size: 14px; font-weight: 600; text-align: center; opacity: 0; transition: opacity 0.4s;
}
#toast.show { opacity: 1; }

#speedo {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  text-align: center; font: 800 34px/1 system-ui, sans-serif; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55); font-variant-numeric: tabular-nums;
}
#speedo small { display: block; font-size: 11px; letter-spacing: 0.14em; opacity: 0.85; }

#prompt {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(380px, 44vw); padding: 12px 14px; border-radius: 16px;
  background: #fff; color: #14213d; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
#p-cat { display: inline-block; padding: 2px 8px; border-radius: 8px; color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
#prompt h3 { margin: 6px 0 2px; font-size: 18px; }
#prompt p { margin: 0; font-size: 12.5px; line-height: 1.4; color: #42506e; }
#p-meta { margin-top: 6px; font-size: 12px; font-weight: 700; color: #1d3f8f; }
#p-req { margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: #fff3cd; color: #7a5800; font-size: 12px; font-weight: 600; }
#prompt .row { display: flex; gap: 8px; margin-top: 10px; }
#prompt button { flex: 1; font: 800 14px/1 system-ui, sans-serif; padding: 11px; border-radius: 10px; border: 2px solid #1d3f8f; background: #fff; color: #1d3f8f; }
#prompt button.primary { background: #1d3f8f; color: #fff; }
#prompt button:disabled { opacity: 0.4; }

#joy-base { position: absolute; left: 0; top: 0; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.55); background: rgba(18, 22, 30, 0.25); }
#joy-base.idle { opacity: 0.45; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.8); }

/* screens */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 12px max(14px, env(safe-area-inset-left, 0px));
  background: rgba(10, 16, 32, 0.6); overflow-y: auto; touch-action: pan-y;
}
.dialog {
  width: min(360px, 100%); margin: auto; padding: 18px; border-radius: 18px;
  background: #fff; color: #14213d; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.dialog.wide { width: min(620px, 100%); }
.dialog h1 { margin: 0; font-size: clamp(28px, 5vw, 40px); letter-spacing: 0.02em; }
.dialog h2 { margin: 0; font-size: 20px; }
.dialog h3 { margin: 4px 0 0; font-size: 14px; }
.dialog p { margin: 0; font-size: 14px; line-height: 1.45; color: #2a3550; }
.dialog button { font: 700 15px/1 system-ui, sans-serif; padding: 12px 16px; border-radius: 12px; border: 2px solid #1d3f8f; background: #fff; color: #1d3f8f; }
.dialog button.primary { background: #1d3f8f; color: #fff; }
.dialog button.big { font-size: 20px; padding: 15px; letter-spacing: 0.1em; }
.dialog button:disabled { opacity: 0.4; }
.dialog .row { display: flex; gap: 10px; }
.dialog .row button { flex: 1; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; font-weight: 600; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.help { font-size: 12px !important; color: #5a6680 !important; }
.help.keys { display: none; }
@media (hover: hover) and (pointer: fine) { .help.keys { display: block; } .help.touch { display: none; } }

#r-badge { align-self: flex-start; font: 900 22px/1 system-ui, sans-serif; padding: 8px 14px; border-radius: 10px; background: #19a34a; color: #fff; }
#r-badge.fail { background: #d4111a; }
#r-badge.gold { background: #d9a400; } #r-badge.silver { background: #8a96a8; } #r-badge.bronze { background: #b06a2c; }
#r-reason { color: #42506e; }
#r-cash { font: 900 28px/1 system-ui, sans-serif; color: #19a34a; }
#r-cash:empty, #r-reason:empty { display: none; }
#r-stats { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }

.g-head { display: flex; justify-content: space-between; align-items: baseline; }
#g-cash { font: 800 20px/1 system-ui, sans-serif; color: #19a34a; }
#g-cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 8px; }
.gcar { padding: 10px 12px; border-radius: 12px; border: 2px solid #e3e7ef; }
.gcar.sel { border-color: #1d3f8f; background: #f1f5ff; }
.gtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gtop button { padding: 7px 10px; font-size: 13px; }
.gdesc { font-size: 12px; color: #5a6680; margin: 4px 0 6px; }
.gstat { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 6px; font-size: 11px; color: #5a6680; margin-top: 3px; }
.gstat i { display: block; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #2ecc71, #1d3f8f); }
.tag { font-size: 11px; font-weight: 800; color: #1d3f8f; letter-spacing: 0.06em; }
#g-paint { display: flex; flex-wrap: wrap; gap: 8px; }
#g-paint .sw { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 3px solid #e3e7ef; }
#g-paint .sw.on { border-color: #14213d; box-shadow: 0 0 0 2px #fff inset; }

/* copyright footer + licences screen */
.legal { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-top: 8px; border-top: 1px solid #e3e7ef; font-size: 12px; color: #5a6680; }
.dialog .legal button { padding: 0; border: none; background: none; color: #1d3f8f; font: 700 12px/1.4 system-ui, sans-serif; text-decoration: underline; }
.legal-doc { gap: 4px; user-select: text; -webkit-user-select: text; }
.legal-doc h3 { margin: 10px 0 2px; font-size: 14px; color: #1d3f8f; }
.legal-doc p, .legal-doc li { margin: 4px 0; font-size: 13px; line-height: 1.5; color: #2a3550; }
.legal-doc ul { margin: 4px 0; padding-left: 20px; }
.legal-doc summary { font-size: 13px; font-weight: 700; color: #1d3f8f; cursor: pointer; margin-top: 4px; }
.legal-doc pre { margin: 6px 0 0; padding: 10px; border-radius: 8px; background: #f1f3f8; color: #2a3550; font-size: 10.5px; line-height: 1.45; white-space: pre-wrap; }
.legal-doc .row { margin-top: 10px; }

#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: #14213d; font: 700 18px/1.4 system-ui, sans-serif; text-align: center; padding: 24px; }
}
@media (max-height: 420px) {
  #btn-jump { width: 82px; height: 82px; }
  #prompt { width: min(360px, 50vw); padding: 10px 12px; }
  #prompt p { font-size: 12px; }
}
