* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #120c10; color: #fbe7c6;
  font: 700 15px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 2px 2px 0 #2a1610; }
#hud > div, #map { position: absolute; }
.tl { left: 14px; top: 12px; } .tr { right: 14px; top: 12px; text-align: right; }
/* Dark plates behind the HUD groups so they read over bright sand. */
.tl, .tr, .tc, .bl, .obj { background: rgba(30, 16, 12, .55); padding: 6px 10px; box-shadow: inset 0 0 0 2px rgba(251, 231, 198, .22), 3px 3px 0 rgba(0, 0, 0, .3); }
.tc { left: 50%; top: 12px; transform: translateX(-50%); font-size: 26px; display: flex; gap: 8px; align-items: center; }
.tc svg { width: 26px; height: 26px; }
.tc.low { color: #ff5a3c; }
.obj { left: 50%; top: 60px; padding: 3px 10px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; font-size: 15px; color: #ffd060; }
.obj.home { color: #5aff8a; } .obj svg { width: 18px; height: 18px; fill: currentColor; stroke: #2a1610; stroke-width: 1.5; }
.bl { left: 14px; bottom: 12px; }
#speed { font-size: 44px; } .unit { font-size: 13px; margin-left: 6px; opacity: .8; }
.stat { display: flex; gap: 8px; align-items: center; font-size: 22px; } .tr .stat { justify-content: flex-end; }
.sub { font-size: 13px; opacity: .85; margin-top: 4px; }
.meter { display: flex; gap: 6px; align-items: center; margin-top: 6px; } .tr .meter { justify-content: flex-end; }
.bar { position: relative; width: 120px; height: 10px; background: #2a1610; border: 2px solid #fbe7c6; }
.bar::after { content: ''; position: absolute; inset: 0; }
.nitro .bar::after { background: repeating-linear-gradient(90deg, transparent 0 10px, #2a1610 10px 12px); }  /* 10 cells */
.heat .bar::after { background: repeating-linear-gradient(90deg, transparent 0 38px, #2a1610 38px 40px); }   /* one cell per heat level */
.nitro.full svg { color: #5ad1ff; animation: blink .6s steps(2) infinite; }
.bar i { display: block; height: 100%; width: 0; background: #ffb347; }
.heat .bar i { background: #ff5a3c; } .nitro .bar i { background: #5ad1ff; }
#map { right: 18px; bottom: 16px; border: 3px solid #fbe7c6; image-rendering: pixelated; background: #2a1610; }
#bust { left: 50%; top: 32%; transform: translateX(-50%); text-align: center; color: #ff5a3c; font-size: 22px; animation: blink .5s steps(2) infinite; }
#bust .bar { width: 200px; margin-top: 6px; border-color: #ff5a3c; } #bust .bar i { background: #ff5a3c; }
#toast { left: 50%; top: 20%; transform: translateX(-50%); font-size: 22px; white-space: nowrap; transition: opacity .3s; opacity: 0;
  padding: 6px 16px; background: rgba(30, 16, 12, .7); box-shadow: inset 0 0 0 2px #ffb347, 4px 4px 0 rgba(0, 0, 0, .35); color: #ffd060; }
#toast.bad { color: #ff6a4a; box-shadow: inset 0 0 0 2px #ff5a3c, 4px 4px 0 rgba(0, 0, 0, .35); }
#toast.good { color: #7aff9a; box-shadow: inset 0 0 0 2px #5aff8a, 4px 4px 0 rgba(0, 0, 0, .35); }
#toast.pop { animation: pop .28s steps(4); }
@keyframes pop { 0% { transform: translateX(-50%) scale(.6); } 60% { transform: translateX(-50%) scale(1.12); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes blink { 50% { opacity: .45; } }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: linear-gradient(#120c10cc, #3a1a14cc); text-align: center; padding: 24px; }
h1 { font-size: 84px; margin: 0; letter-spacing: .12em; color: #ffb347; text-shadow: 6px 6px 0 #7a2e1c; }
h1 b { color: #fbe7c6; margin-left: .3em; }
h2 { font-size: 40px; margin: 0 0 6px; color: #ffb347; text-shadow: 4px 4px 0 #7a2e1c; }
.tag { margin: 0 0 18px; opacity: .9; }
#missions { display: grid; grid-template-columns: repeat(5, 150px); gap: 10px; }
button { font: inherit; color: #2a1610; background: #ffb347; border: 0; padding: 12px 18px; cursor: pointer;
  box-shadow: 4px 4px 0 #7a2e1c; letter-spacing: inherit; }
button:hover, button:focus-visible, body.pad button:focus { background: #fbe7c6; outline: none; }
button:disabled { background: #5a3a30; color: #a07c6c; cursor: default; box-shadow: none; }
#missions button { display: flex; flex-direction: column; gap: 4px; padding: 12px 8px; min-height: 92px; justify-content: center; }
#mappick { display: flex; align-items: stretch; gap: 10px; margin: 0 0 14px; }
#mappick button { padding: 0 10px; display: flex; align-items: center; }
#mappick svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: square; }
#mapinfo { width: 520px; min-height: 70px; padding: 8px 14px; background: rgba(30, 16, 12, .6); box-shadow: inset 0 0 0 2px rgba(251, 231, 198, .22);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; text-align: left; align-content: center; }
#mapname { font-size: 22px; color: #ffb347; } #mapcount { font-size: 11px; opacity: .7; align-self: center; }
#mapblurb { grid-column: 1 / -1; font-size: 12px; opacity: .85; }
#loading { background: #120c10; z-index: 5; }
#missions small { font-size: 11px; opacity: .8; text-transform: capitalize; }
#btext, #etext { max-width: 560px; margin: 0 0 6px; }
#title { background: radial-gradient(ellipse at 50% 50%, #120c10b8 0 30%, #120c1050 70%, #120c1020 100%); }
.brow { display: flex; gap: 22px; align-items: center; text-align: left; max-width: 820px; margin: 6px 0 12px; }
.btextbox #btext { max-width: 440px; }
#bmap { width: 220px; height: 220px; image-rendering: pixelated; border: 3px solid #fbe7c6; box-shadow: 4px 4px 0 #7a2e1c; display: block; }
.legend { font-size: 10px; margin-top: 8px; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.legend .k { width: 8px; height: 8px; display: inline-block; margin-left: 4px; }
.k.home { background: #5aff8a; } .k.crate { background: #ffd060; } .k.law { background: #ffffff; } .k.rival { background: #c070ff; }
.stats { display: grid; grid-template-columns: repeat(4, 130px); gap: 8px; margin: 4px 0 12px; }
.stats div { background: rgba(30, 16, 12, .6); box-shadow: inset 0 0 0 2px rgba(251, 231, 198, .22); padding: 8px 6px; }
.stats b { display: block; font-size: 22px; color: #ffb347; } .stats small { font-size: 11px; opacity: .8; }
.newbest { color: #7aff9a; animation: blink .6s steps(2) 6; }
.facts { color: #ffb347; }
.bank { color: #ffb347; margin: 14px 0 0; }
.keys { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; max-width: 760px; font-size: 13px; margin-top: 12px; }
kbd { font: inherit; border: 2px solid #fbe7c6; padding: 0 5px; margin-right: 3px; }
.hint { font-size: 12px; opacity: .7; }
#pause button, #ebuttons button { min-width: 220px; margin: 4px; }

/* Controller: show pad hints instead of keyboard ones while a pad is connected. */
.padonly { display: none !important; }
body.haspad .padonly { display: revert !important; }
body.haspad .keys.padonly { display: flex !important; }
body.haspad .kbonly { display: none !important; }
body.pad { cursor: none; }
