* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #07081a; color: #fff;
  font-family: "Fredoka", "Segoe UI", Arial, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#game canvas { display: block; position: fixed; inset: 0; width: 100%; height: 100%; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; font-size: 48px; background: #07081a; z-index: 50; }

/* speed effects */
#speedlines { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,.0) 0deg 3deg, rgba(180,230,255,.22) 3deg 3.6deg);
  -webkit-mask: radial-gradient(circle at 50% 55%, transparent 28%, #000 70%); mask: radial-gradient(circle at 50% 55%, transparent 28%, #000 70%); }
#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; direction: ltr; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: stretch; }
.box { background: rgba(8,10,28,.62); border: 1px solid rgba(0,229,255,.35); border-radius: 12px; padding: 4px 14px; text-align: center; min-width: 76px;
  backdrop-filter: blur(4px); box-shadow: 0 0 14px rgba(0,229,255,.15); }
.box small { display: block; font-size: 11px; opacity: .75; letter-spacing: .5px; }
.box b { font-size: 24px; font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(0,229,255,.7); }
#hLapTime { font-size: 11px; opacity: .8; }
#sirenBtn { font-size: 20px; }
#sirenBtn.off { filter: grayscale(1); opacity: .55; }
#sirenBtn.hidden { display: none; }
.icon-btn { pointer-events: auto; background: rgba(8,10,28,.62); border: 1px solid rgba(255,43,214,.5); color: #fff; border-radius: 12px; width: 44px; font-weight: 900; }
#minimap { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; width: 150px; height: 150px; opacity: .92; }
#speedo-wrap { position: absolute; right: 12px; bottom: 10px; width: 200px; }
#speedo { width: 200px; height: 200px; display: block; }
#nitro { position: relative; height: 16px; margin: -18px 18px 0; border-radius: 9px; background: rgba(8,10,28,.75); border: 1px solid rgba(77,184,255,.6); overflow: hidden; }
#nitroFill { position: absolute; inset: 0 auto 0 0; width: 50%; background: linear-gradient(90deg, #1f6bff, #4db8ff, #b5f0ff); box-shadow: 0 0 12px #4db8ff; }
#nitro span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 15px; font-weight: 700; letter-spacing: 1px; }
#msg { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-size: 84px; font-weight: 900; font-style: italic;
  color: #fff; text-shadow: 0 0 18px #ff2bd6, 0 0 40px #ff2bd6; opacity: 0; transition: opacity .2s, transform .2s; }
#msg.show { opacity: 1; }
#msg.warn { color: #ffeb3b; text-shadow: 0 0 18px #ff1744, 0 0 40px #ff1744; }
#drift { position: absolute; top: 46%; left: 0; right: 0; text-align: center; font-size: 30px; font-weight: 900; font-style: italic;
  color: #b5f0ff; text-shadow: 0 0 14px #00e5ff; opacity: 0; transition: opacity .3s; }

/* touch */
#touch { position: fixed; inset: auto 0 0 0; height: 0; direction: ltr; }
#touch button { position: relative; pointer-events: auto; border: 2px solid rgba(255,255,255,.35); background: rgba(10,14,40,.45); color: #fff;
  border-radius: 50%; font-weight: 900; backdrop-filter: blur(3px); touch-action: none; }
#touch button.on { background: rgba(0,229,255,.45); border-color: #00e5ff; }
#touch .tl { position: fixed; left: max(14px, env(safe-area-inset-left)); bottom: 22px; display: flex; gap: 16px; }
#touch .tl button { width: 86px; height: 86px; font-size: 34px; }
#touch .tr { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: 210px; display: grid; grid-template-columns: 70px 86px; gap: 10px; align-items: end; }
#touch .tr .gas { width: 86px; height: 110px; border-radius: 22px; font-size: 30px; background: rgba(0,200,83,.4); }
#touch .tr .brake { width: 70px; height: 70px; font-size: 24px; background: rgba(255,23,68,.35); }
#touch .tr .nitro { width: 70px; height: 56px; border-radius: 16px; font-size: 15px; background: rgba(31,107,255,.45); }
#touch .tr .drift { width: 86px; height: 56px; border-radius: 16px; font-size: 14px; background: rgba(255,43,214,.35); }
body.touch #speedo-wrap { right: auto; left: 50%; transform: translateX(-50%) scale(.72); transform-origin: bottom center; bottom: 0; }
body.touch #minimap { width: 110px; height: 110px; }
body.touch .hud-top { transform: translateX(-50%) scale(.85); transform-origin: top center; }

/* screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 100%, rgba(255,43,214,.18), transparent 60%), linear-gradient(180deg, rgba(5,6,20,.35), rgba(5,6,20,.75)); }
#menu { align-items: flex-end; background: linear-gradient(180deg, transparent 0%, rgba(5,6,20,.55) 45%, rgba(5,6,20,.9) 100%); }
.panel { width: min(760px, 100%); text-align: center; padding: 18px 20px; border-radius: 22px; background: rgba(8,10,30,.72);
  border: 1px solid rgba(0,229,255,.3); box-shadow: 0 0 40px rgba(0,229,255,.12), inset 0 0 30px rgba(255,43,214,.06); backdrop-filter: blur(8px); margin: auto 0 0; }
.panel.small { width: min(440px, 100%); margin: auto; }
h1 { margin: 0; font-size: clamp(38px, 7vw, 66px); font-style: italic; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(90deg, #00e5ff, #fff 45%, #ff2bd6); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(0,229,255,.5)); }
h2 { margin: 4px 0 14px; font-size: 34px; font-style: italic; text-shadow: 0 0 14px #00e5ff; }
h3 { margin: 12px 0 6px; font-size: 15px; opacity: .85; font-weight: 600; }
.sub { margin: 2px 0 6px; opacity: .8; }
/* the logo carries the Hebrew name; the h1 text stays for screen readers and shows (smaller) in English */
.logo { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto 4px; border-radius: 16px;
  -webkit-mask-image: radial-gradient(ellipse 72% 78% at 50% 50%, #000 62%, transparent 100%);
  mask-image: radial-gradient(ellipse 72% 78% at 50% 50%, #000 62%, transparent 100%); }
html[lang="he"] h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html[lang="en"] h1 { font-size: clamp(26px, 4.5vw, 38px); }
#cars { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.car-card { flex: 1 1 128px; max-width: 160px; cursor: pointer; padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,.04); border: 2px solid rgba(255,255,255,.12); color: #fff; text-align: start; }
.car-card.sel { border-color: var(--c); box-shadow: 0 0 18px var(--c); background: rgba(255,255,255,.08); }
.car-card .nm { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.car-card .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.stat { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 4px; }
.stat span { width: 70px; opacity: .8; }
.stat i { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; display: block; }
.stat i::after { content: ""; display: block; height: 100%; width: var(--v); background: var(--c); }
.row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.seg { display: inline-flex; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,.2); }
.seg button { background: transparent; color: #fff; border: 0; padding: 7px 14px; }
.seg button.sel { background: linear-gradient(135deg, #00b8d4, #c51fa8); font-weight: 700; }
.big { margin: 16px auto 4px; display: block; padding: 13px 40px; font-size: 24px; font-weight: 900; font-style: italic; color: #fff; border: 0; border-radius: 16px;
  background: linear-gradient(135deg, #00b8d4, #c51fa8); box-shadow: 0 0 24px rgba(255,43,214,.5); transition: transform .1s; }
.big:hover { transform: scale(1.04); }
.mid { display: block; margin: 8px auto; width: 200px; padding: 9px; font-size: 17px; color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 12px; background: rgba(255,255,255,.06); }
.controls { font-size: 12.5px; opacity: .75; margin: 8px 0 2px; }
.copy { font-size: 11px; opacity: .5; margin: 4px 0 0; }
.top-btns { position: fixed; top: 12px; inset-inline-end: 12px; display: flex; gap: 8px; z-index: 5; }
.pill { padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,.3); background: rgba(8,10,30,.6); color: #fff; }
#rPlace { font-size: 52px; font-weight: 900; font-style: italic; text-shadow: 0 0 20px #ffb000; }
#rTable { margin: 10px auto; border-collapse: collapse; min-width: 260px; }
#rTable td { padding: 4px 10px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: start; font-variant-numeric: tabular-nums; }
#rTable tr.me td { color: #00e5ff; font-weight: 800; }
#rRecord { color: #ffd54f; font-weight: 700; }

@media (max-height: 560px) {
  .panel { padding: 10px 14px; }
  h1 { font-size: 34px; }
  .logo { max-width: 300px; }
  .sub, .controls { display: none; }
  .car-card { padding: 6px 10px; }
  .big { margin-top: 10px; padding: 9px 30px; font-size: 20px; }
  #msg { font-size: 56px; }
}

/* display font: Exo 2 for Latin letters and digits, Karantina for Hebrew; Fredoka for the rest of the UI */
h1, h2, .big, #msg, #drift, #rPlace { font-family: "Exo 2", "Karantina", "Fredoka", sans-serif; }
.box b, .car-card .nm, .points, .price { font-family: "Exo 2", "Fredoka", sans-serif; }
/* Karantina is narrow: give the Hebrew headings more size */
html[lang="he"] .big { font-size: 31px; letter-spacing: 1px; }
html[lang="he"] h2 { font-size: 42px; }
html[lang="he"] #rPlace { font-size: 62px; }
html[lang="he"] #drift { font-size: 38px; }
html[lang="he"] #msg { font-size: 100px; }
h1 { letter-spacing: 2px; }
#msg { font-style: normal; letter-spacing: 3px; }
.box small, .seg button, .pill, .mid { font-family: "Fredoka", sans-serif; }

/* garage */
.points { display: inline-block; margin: 2px 0 4px; padding: 4px 16px; border-radius: 20px; font-size: 17px; font-weight: 800;
  color: #ffd54f; background: rgba(255,193,7,.1); border: 1px solid rgba(255,213,79,.5); text-shadow: 0 0 10px rgba(255,193,7,.6); }
.car-card .nm { font-size: 16px; }
.car-card .stat span { width: 58px; font-size: 11px; }
.car-card.locked { filter: saturate(.55); opacity: .82; }
.car-card .price { margin-top: 6px; font-size: 13px; color: #ffd54f; font-weight: 800; }
.car-card .price.own { color: #69f0ae; }
.car-card .buy { margin-top: 6px; width: 100%; padding: 5px; border: 0; border-radius: 10px; color: #1a1300; font-weight: 900;
  background: linear-gradient(135deg, #ffe082, #ffb300); box-shadow: 0 0 12px rgba(255,179,0,.6); font-family: "Fredoka", sans-serif; }
#rBuy { color: #ffd54f; font-weight: 800; }

/* police modes */
.mode-seg button, .map-seg button { padding: 9px 16px; font-size: 15px; }
.mode-desc { min-height: 2.6em; max-width: 520px; margin: 8px auto 4px; }
#meter { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 70px); left: 50%; transform: translateX(-50%); width: min(360px, 70vw);
  text-align: center; opacity: 0; transition: opacity .25s; pointer-events: none; }
#meter.show { opacity: 1; }
#meter span { display: block; font-size: 15px; font-weight: 800; margin-bottom: 4px; text-shadow: 0 0 8px #000; }
#meter .bar { height: 12px; border-radius: 7px; background: rgba(8,10,28,.75); border: 1px solid rgba(255,255,255,.35); overflow: hidden; }
#meter i { display: block; height: 100%; width: 0; }
#meter.esc i { background: linear-gradient(90deg, #ff9100, #ff1744); box-shadow: 0 0 12px #ff1744; }
#meter.esc span { color: #ff5252; }
#meter.cop i { background: linear-gradient(90deg, #00e5ff, #2979ff); box-shadow: 0 0 12px #2979ff; }
#meter.cop span { color: #82b1ff; }
#meter.stop i { background: linear-gradient(90deg, #ffd54f, #ff9100); box-shadow: 0 0 12px #ffb300; }
#meter.stop span { color: #ffe082; }
/* the mission's current goal, under the top boxes */
#goal { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 112px); left: 50%; transform: translateX(-50%);
  max-width: min(560px, 88vw); padding: 7px 16px; border-radius: 14px; background: rgba(8,10,28,.72); border: 1px solid rgba(255,213,79,.55);
  color: #fff3c4; font: 700 18px "Fredoka", "Karantina", sans-serif; text-align: center; opacity: 0; transition: opacity .3s; pointer-events: none;
  unicode-bidi: plaintext; text-shadow: 0 0 8px #000; }
#goal.show { opacity: 1; }
#goal.pop { animation: goalPop .6s ease-out; }
@keyframes goalPop { 0% { transform: translateX(-50%) scale(1.25); } 100% { transform: translateX(-50%) scale(1); } }
html[lang="he"] #goal { font-size: 21px; }
body.touch #goal { top: calc(max(10px, env(safe-area-inset-top)) + 96px); font-size: 15px; }
.box b.late { color: #ff8a65; text-shadow: 0 0 10px #ff3d00; }
.mode-seg, .map-seg { flex-wrap: wrap; justify-content: center; }
/* game modes in two rows: the races and missions, then the emergency services */
.mode-rows { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pasuk { margin: -4px 0 8px; font-size: 13px; opacity: .8; font-style: italic; }
body.touch #meter { top: calc(max(10px, env(safe-area-inset-top)) + 58px); }
@media (max-height: 560px) {
  html[lang="he"] .big { font-size: 25px; }
  html[lang="he"] #msg { font-size: 68px; }
}

/* the HUD is laid out left-to-right, but its words follow their own language (so "!" ends up at the end of a Hebrew sentence) */
#msg, #drift, #toast, #meterLbl, .box small, #hudPts, #nitro span { unicode-bidi: plaintext; }
html[dir="rtl"] #msg, html[dir="rtl"] #drift, html[dir="rtl"] #toast, html[dir="rtl"] #meterLbl, html[dir="rtl"] .box small { direction: rtl; }

/* live points in the race */
#hudPts { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 160px); left: 12px; display: flex; align-items: baseline; gap: 6px;
  padding: 4px 12px; border-radius: 16px; background: rgba(8,10,28,.62); border: 1px solid rgba(255,213,79,.5); box-shadow: 0 0 12px rgba(255,193,7,.25);
  font-family: "Exo 2", "Fredoka", sans-serif; direction: ltr; }
#hudPts b { font-size: 20px; color: #ffd54f; font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(255,193,7,.7); }
#hudPts i { font-style: normal; font-size: 13px; color: #b9f6ca; font-weight: 700; }
body.touch #hudPts { top: calc(max(10px, env(safe-area-inset-top)) + 118px); transform: scale(.85); transform-origin: top left; }

/* pickup pop-up text */
#toast { position: absolute; top: 58%; left: 0; right: 0; text-align: center; font-size: 30px; font-weight: 900;
  font-family: "Exo 2", "Karantina", "Fredoka", sans-serif; opacity: 0; pointer-events: none; }
#toast.show { opacity: 1; transition: opacity .4s .6s; }
#toast.pop { animation: toastPop .9s ease-out forwards; }
#toast.nitro { color: #b5f0ff; text-shadow: 0 0 14px #1f6bff, 0 0 30px #4db8ff; }
#toast.star { color: #ffe082; text-shadow: 0 0 14px #ff9100, 0 0 30px #ffb300; }
#toast.warn { color: #ffeb3b; text-shadow: 0 0 14px #ff1744; }
html[lang="he"] #toast { font-size: 36px; }
@keyframes toastPop { 0% { transform: scale(.6) translateY(10px); opacity: 0; } 15% { transform: scale(1.12); opacity: 1; } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: translateY(-26px); opacity: 0; } }

/* garage: 360° button + viewer */
.car-card { position: relative; }
.view360 { position: absolute; top: 6px; inset-inline-end: 6px; padding: 2px 7px; border-radius: 9px; font-size: 11px; font-weight: 800;
  color: #b5f0ff; background: rgba(0,229,255,.12); border: 1px solid rgba(0,229,255,.45); font-family: "Exo 2", sans-serif; }
.view360:hover { background: rgba(0,229,255,.3); }
#viewer { z-index: 20; background: rgba(4,5,16,.78); backdrop-filter: blur(4px); }
.viewer-panel { position: relative; width: min(620px, 100%); }
.vclose { position: absolute; top: 10px; inset-inline-end: 12px; width: 38px; height: 38px; border-radius: 50%; color: #fff; font-size: 18px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.3); }
.v-stage { position: relative; }
#vCanvas { display: block; width: 100%; height: min(320px, 42vh); border-radius: 16px; touch-action: none; cursor: grab;
  background: radial-gradient(ellipse at 50% 75%, rgba(0,229,255,.16), transparent 60%), radial-gradient(ellipse at 50% 20%, rgba(255,43,214,.12), transparent 60%); }
#vCanvas:active { cursor: grabbing; }
.v-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 58px; border-radius: 14px; font-size: 34px; line-height: 1; color: #fff;
  background: rgba(8,10,30,.6); border: 1px solid rgba(0,229,255,.4); }
.v-arrow.left { left: 6px; } .v-arrow.right { right: 6px; }
.v-hint { margin: 6px 0; font-size: 13px; opacity: .7; }
#vStats { max-width: 300px; margin: 0 auto; }
#vStats .stat span { width: 70px; }
.v-btn { margin-top: 12px; }
.buy-big { background: linear-gradient(135deg, #ffe082, #ffb300) !important; color: #1a1300 !important; box-shadow: 0 0 22px rgba(255,179,0,.6) !important; }
.v-locked { margin-top: 12px; font-size: 22px; font-weight: 800; color: #ffd54f; font-family: "Exo 2", "Fredoka", sans-serif; }
.v-locked small { display: block; font-size: 13px; font-weight: 500; color: #fff; opacity: .75; font-family: "Fredoka", sans-serif; }

/* garage: car picture above the name (click it for the 360° showroom) */
.car-card .thumb { display: block; width: calc(100% + 12px); margin: 14px -6px 2px; aspect-ratio: 32 / 19; object-fit: contain; cursor: zoom-in;
  border-radius: 12px; background: radial-gradient(ellipse at 50% 80%, color-mix(in srgb, var(--c) 28%, transparent), transparent 65%);
  transition: transform .2s; user-select: none; }
.car-card .thumb:hover { transform: scale(1.06); }

/* the Yedidim symbol (its four colored corners) before the mode's name */
.mode-seg button[data-v="yedidim"]::before {
  content: ""; display: inline-block; width: 1.15em; height: 1.15em; margin-inline-end: .35em; vertical-align: -0.2em;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='%23f9b350' transform=''%3E%3Cpath d='M0 43V11Q0 0 11 0H43V20H24.4Q20 20 20 24.4V43Z'/%3E%3Ccircle cx='31.9' cy='31.9' r='9.5'/%3E%3C/g%3E%3Cg fill='%23c25c9e' transform='translate%28100 0%29 scale%28-1 1%29'%3E%3Cpath d='M0 43V11Q0 0 11 0H43V20H24.4Q20 20 20 24.4V43Z'/%3E%3Ccircle cx='31.9' cy='31.9' r='9.5'/%3E%3C/g%3E%3Cg fill='%23b9d15f' transform='translate%280 100%29 scale%281 -1%29'%3E%3Cpath d='M0 43V11Q0 0 11 0H43V20H24.4Q20 20 20 24.4V43Z'/%3E%3Ccircle cx='31.9' cy='31.9' r='9.5'/%3E%3C/g%3E%3Cg fill='%232798d5' transform='translate%28100 100%29 scale%28-1 -1%29'%3E%3Cpath d='M0 43V11Q0 0 11 0H43V20H24.4Q20 20 20 24.4V43Z'/%3E%3Ccircle cx='31.9' cy='31.9' r='9.5'/%3E%3C/g%3E%3C/svg%3E") center / 82% no-repeat; border-radius: 4px;
}

/* the Ichud Hatzalah logo (six outlined arms) before the mode's name */
.mode-seg button[data-v="hatzolah"]::before {
  content: ""; display: inline-block; width: 1.15em; height: 1.15em; margin-inline-end: .35em; vertical-align: -0.2em;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-106 -106 212 212'%3E%3Cg fill='none' stroke='%23f37a20' stroke-width='12'%3E%3Cpath transform='rotate%280%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3Cpath transform='rotate%2860%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3Cpath transform='rotate%28120%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3Cpath transform='rotate%28180%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3Cpath transform='rotate%28240%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3Cpath transform='rotate%28300%29' d='M-28-90.8A95 95 0 0 1 28-90.8L28-47L0-28L-28-47Z'/%3E%3C/g%3E%3C/svg%3E") center / 86% no-repeat; border-radius: 4px;
}
