/* Race overlay: quiet panels, readable numbers, and a clear driving view. */
:root { --hud-edge: max(12px, env(safe-area-inset-left)); --hud-top: max(12px, env(safe-area-inset-top)); --hud-panel: #142333df; --hud-line: #ffffff29; }
.hud { font-family: 'Arial Rounded MT Bold', system-ui, sans-serif; font-weight: 750; letter-spacing: .02em; text-shadow: 0 1px 2px #0006; font-variant-numeric: tabular-nums; }
.hud.gold { background: none; color: #fff3bb; -webkit-text-fill-color: currentColor; -webkit-text-stroke: 0; filter: none; font-style: normal; }
#pos, #lap, #coins, #cc { background: var(--hud-panel); border: 1px solid var(--hud-line); border-radius: 12px; box-sizing: border-box; }
#pos { left: var(--hud-edge); top: var(--hud-top); width: 88px; height: 76px; padding: 21px 10px 5px; font-size: 44px; line-height: 1; }
#pos::before { content: 'POSITION'; position: absolute; left: 11px; top: 8px; font-size: 9px; letter-spacing: .12em; color: #c7d4df; }
#pos small { top: 2px; margin-left: 2px; font-size: 16px; }
#item-wrap { top: var(--hud-top); left: calc(var(--hud-edge) + 100px); width: 114px; align-items: flex-start; gap: 5px; }
#item { width: 66px; height: 66px; box-sizing: border-box; border: 2px solid #f8df8b; outline: none; border-radius: 14px; background: var(--hud-panel); box-shadow: 0 3px 9px #0003; }
#item:empty::after { content: 'ITEM'; font-size: 10px; color: #b9c9d8; letter-spacing: .1em; }
#item b { right: 3px; bottom: 0; font-size: 15px; }
#item-reserve { left: 73px; top: 0; width: 40px; height: 40px; box-sizing: border-box; border: 1px solid #ffffff60; border-radius: 10px; background: var(--hud-panel); }
#item-reserve:empty { visibility: hidden; }
#item-reserve .icon { transform: scale(.57); }
#item-reserve b { font-size: 11px; }
#item-name { font-size: 10px; line-height: 15px; min-height: 15px; white-space: nowrap; color: #fff3bb; }
#lap { right: var(--hud-edge); top: var(--hud-top); width: 114px; padding: 8px 12px; font-size: 30px; line-height: 1.1; text-align: right; }
#lap small { display: block; font-size: 10px; letter-spacing: .12em; color: #c7d4df; margin-bottom: 3px; }
#lap br { display: none; }
#lap.finished { font-size: 22px; width: 140px; }
#laptime, body.time-trial #laptime { top: calc(var(--hud-top) + 68px); right: var(--hud-edge); font-size: 12px; line-height: 20px; text-align: right; white-space: pre-line; }
#targets { top: calc(var(--hud-top) + 112px); right: var(--hud-edge); font-size: 10px; }
#targets[hidden] { display: none; }
#coins { left: var(--hud-edge); bottom: max(12px, env(safe-area-inset-bottom)); top: auto; padding: 7px 10px; font-size: 17px; display: flex; align-items: center; gap: 7px; line-height: 20px; }
#coins .coin-icon { width: 15px; height: 19px; border-width: 2px; box-shadow: none; margin: 0; }
#cc { transform: none; left: calc(var(--hud-edge) + 85px); top: auto; bottom: max(12px, env(safe-area-inset-bottom)); padding: 9px 10px; font-size: 10px; line-height: 16px; color: #c7d4df; }
#minimap { right: var(--hud-edge); bottom: 12px; width: 138px; height: 138px; opacity: .9; }
#toast { top: 27%; left: 15%; right: 15%; font-size: clamp(17px, 3vw, 28px); line-height: 1.2; }
#countdown { font-size: clamp(76px, 19vh, 140px); text-shadow: 0 4px 16px #142333; }
#countdown.gold { color: #fff3bb; }
#warn, body.touchui #warn { left: 50%; top: 112px; margin: 0 0 0 -18px; width: 36px; height: 36px; }
#warn .ring { inset: 4px; border-width: 2px; font-size: 19px; line-height: 24px; box-shadow: none; }
#warn .arrow::before { top: -9px; border-width: 6px; border-bottom-width: 9px; margin-left: -6px; filter: none; }
#warn .kind { top: 42px; padding: 4px 8px; font-size: 10px; letter-spacing: .03em; }
/* Fixed-size targets avoid tiny buttons on short landscape screens. */
body.touchui #coins { top: calc(var(--hud-top) + 94px); bottom: auto; }
body.touchui #cc { top: calc(var(--hud-top) + 134px); bottom: auto; left: var(--hud-edge); }
body.touchui #minimap { left: auto; right: var(--hud-edge); top: calc(var(--hud-top) + 140px); bottom: auto; transform: none; width: 76px; height: 76px; background: none; }
#touch .stick { left: var(--hud-edge); bottom: 25px; width: 106px; border: 2px solid #ffffff50; background: #14233366; box-shadow: none; }
#touch .stick .knob { border: 2px solid #ffffff85; background: #e2edf4aa; box-shadow: none; }
#touch .stick span { bottom: -19px; font: 700 9px system-ui; letter-spacing: .12em; }
#touch .tbtn { width: 52px; height: 52px; border: 1px solid #ffffff66; background: #142333b8; border-radius: 16px; box-shadow: none; font: 800 10px system-ui; text-shadow: none; }
#touch .tbtn.down { background: #f8df8b; color: #142333; box-shadow: none; transform: scale(.96); filter: none; }
#touch #t-gas { right: 12px; bottom: 16px; width: 62px; height: 62px; background: #39724bc9; }
#touch #t-drift { right: 82px; bottom: 16px; width: 62px; height: 62px; color: #ffe29b; }
#touch #t-item { right: 82px; bottom: 86px; color: #e2c6ff; }
#touch #t-brake { right: 12px; bottom: 86px; }
#touch #t-rear { right: 152px; bottom: 86px; }
#touch #t-charge { right: 152px; bottom: 16px; }
#touch #t-pause { left: 50%; bottom: 16px; width: 44px; height: 44px; transform: translateX(-50%); font-size: 16px; }
@media (max-height: 540px), (max-width: 740px) {
 :root { --hud-top: max(8px, env(safe-area-inset-top)); --hud-edge: max(8px, env(safe-area-inset-left)); }
 #pos { width: 64px; height: 58px; font-size: 32px; padding: 19px 8px 4px; border-radius: 10px; }
 #pos::before { left: 8px; top: 7px; font-size: 7px; }
 #pos small { font-size: 12px; }
 #item-wrap { left: calc(var(--hud-edge) + 72px); width: 94px; gap: 3px; }
 #item { width: 52px; height: 52px; border-radius: 11px; }
 #item .icon { transform: scale(.78); }
 #item-reserve { left: 58px; width: 34px; height: 34px; }
 #item-reserve .icon { transform: scale(.47); }
 #item-name { font-size: 9px; line-height: 13px; }
 #lap { width: 96px; font-size: 25px; padding: 7px 9px; border-radius: 10px; }
 #lap small { font-size: 9px; }
 #laptime, body.time-trial #laptime { top: calc(var(--hud-top) + 59px); font-size: 11px; line-height: 16px; }
 #targets { top: calc(var(--hud-top) + 96px); font-size: 9px; }
 #minimap { width: 96px; height: 96px; }
 #warn, body.touchui #warn { top: 90px; }
 body.touchui #coins { top: calc(var(--hud-top) + 82px); padding: 4px 8px; font-size: 14px; }
 body.touchui #cc { top: calc(var(--hud-top) + 116px); padding: 4px 8px; font-size: 9px; }
 body.touchui #minimap { top: calc(var(--hud-top) + 110px); width: 64px; height: 64px; }
}
@media (orientation: portrait) and (max-width: 540px) {
 #touch .stick { bottom: 90px; width: 90px; }
 #touch #t-pause { left: 30px; bottom: 16px; }
 #warn, body.touchui #warn { top: 190px; }
 #toast { top: 34%; }
}
@media (prefers-reduced-motion: reduce) { #pos.pass { animation: none; } }

/* Combat confirmations stay independent of lap/boost messages and clear the road. */
#combat-feedback { left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(230px, 52vw); padding: 7px 11px; border: 1px solid #ffe17a80; border-radius: 10px; background: var(--hud-panel); color: #ffe17a; font-size: 11px; line-height: 16px; text-align: center; }
#combat-feedback[hidden] { display: none; }
#combat-feedback[data-kind="block"] { color: #a0e8ff; border-color: #a0e8ff80; }
#combat-feedback[data-kind="damage"] { color: #ffb5a0; border-color: #ffb5a080; }
body.touchui #combat-feedback { bottom: 160px; }
@media (orientation: portrait) and (max-width: 540px) { body.touchui #combat-feedback { bottom: 235px; } }

/* Authored item art stays sharp at both slot sizes, without the fallback glyph transforms. */
#item .item-illustration, #item-reserve .item-illustration {
  display: block; width: 92%; height: 92%; object-fit: contain;
  image-rendering: auto; pointer-events: none; user-select: none;
  filter: drop-shadow(0 2px 1px #0005);
}
#item b, #item-reserve b { z-index: 1; text-shadow: 0 1px 2px #000, 1px 0 2px #000, -1px 0 2px #000; }

/* Blue uses the authored green-shell silhouette with a distinct cool palette. */
#item .item-art-blue, #item-reserve .item-art-blue { filter: hue-rotate(110deg) drop-shadow(0 2px 1px #0005); }

/* Desktop viewing distance needs a larger overlay than a handheld screen.
   Keep coarse-pointer/short layouts unchanged, including Retroid controller play. */
@media (min-width: 1000px) and (min-height: 600px) and (pointer: fine) {
 :root { --hud-u: clamp(1.25px, .1vw, 2px); --hud-edge: max(18px, min(2vw, 32px), env(safe-area-inset-left)); --hud-top: max(18px, min(2vw, 32px), env(safe-area-inset-top)); }
 #pos { width: calc(88 * var(--hud-u)); height: calc(80 * var(--hud-u)); padding: calc(23 * var(--hud-u)) calc(10 * var(--hud-u)) calc(5 * var(--hud-u)); font-size: calc(44 * var(--hud-u)); border-radius: calc(12 * var(--hud-u)); }
 #pos::before { left: calc(11 * var(--hud-u)); top: calc(8 * var(--hud-u)); font-size: calc(9 * var(--hud-u)); }
 #pos small { font-size: calc(16 * var(--hud-u)); }
 #item-wrap { left: calc(var(--hud-edge) + 100 * var(--hud-u)); width: calc(150 * var(--hud-u)); gap: calc(6 * var(--hud-u)); }
 #item { width: calc(80 * var(--hud-u)); height: calc(80 * var(--hud-u)); border-width: calc(2 * var(--hud-u)); border-radius: calc(15 * var(--hud-u)); }
 #item:empty::after { font-size: calc(11 * var(--hud-u)); }
 #item b { right: calc(4 * var(--hud-u)); font-size: calc(18 * var(--hud-u)); }
 #item-reserve { left: calc(89 * var(--hud-u)); width: calc(48 * var(--hud-u)); height: calc(48 * var(--hud-u)); border-radius: calc(11 * var(--hud-u)); }
 #item-reserve b { font-size: calc(13 * var(--hud-u)); }
 #item-name { font-size: calc(11 * var(--hud-u)); line-height: calc(17 * var(--hud-u)); min-height: calc(17 * var(--hud-u)); }
 #lap { width: calc(114 * var(--hud-u)); padding: calc(8 * var(--hud-u)) calc(12 * var(--hud-u)); font-size: calc(36 * var(--hud-u)); border-radius: calc(12 * var(--hud-u)); }
 #lap small { font-size: calc(10 * var(--hud-u)); margin-bottom: calc(3 * var(--hud-u)); }
 #lap.finished { font-size: calc(22 * var(--hud-u)); width: calc(140 * var(--hud-u)); }
 #laptime, body.time-trial #laptime { top: calc(var(--hud-top) + 76 * var(--hud-u)); font-size: calc(12 * var(--hud-u)); line-height: calc(20 * var(--hud-u)); }
 #targets { top: calc(var(--hud-top) + 122 * var(--hud-u)); font-size: calc(10 * var(--hud-u)); }
 #coins { bottom: var(--hud-top); padding: calc(7 * var(--hud-u)) calc(10 * var(--hud-u)); gap: calc(7 * var(--hud-u)); font-size: calc(17 * var(--hud-u)); line-height: calc(20 * var(--hud-u)); }
 #coins .coin-icon { width: calc(15 * var(--hud-u)); height: calc(19 * var(--hud-u)); }
 #cc { left: calc(var(--hud-edge) + 85 * var(--hud-u)); bottom: var(--hud-top); padding: calc(9 * var(--hud-u)) calc(10 * var(--hud-u)); font-size: calc(10 * var(--hud-u)); line-height: calc(16 * var(--hud-u)); }
 #minimap { bottom: var(--hud-top); width: calc(138 * var(--hud-u)); height: calc(138 * var(--hud-u)); }
 #warn { top: calc(var(--hud-top) + 100 * var(--hud-u)); width: calc(36 * var(--hud-u)); height: calc(36 * var(--hud-u)); margin-left: calc(-18 * var(--hud-u)); }
 #warn .ring { inset: calc(4 * var(--hud-u)); font-size: calc(19 * var(--hud-u)); line-height: calc(24 * var(--hud-u)); }
 #warn .arrow::before { top: calc(-9 * var(--hud-u)); border-width: calc(6 * var(--hud-u)); border-bottom-width: calc(9 * var(--hud-u)); margin-left: calc(-6 * var(--hud-u)); }
 #toast { font-size: calc(22 * var(--hud-u)); }
 #warn .kind { top: calc(42 * var(--hud-u)); padding: calc(4 * var(--hud-u)) calc(8 * var(--hud-u)); font-size: calc(11 * var(--hud-u)); }
 #combat-feedback { bottom: var(--hud-top); max-width: calc(230 * var(--hud-u)); padding: calc(7 * var(--hud-u)) calc(11 * var(--hud-u)); font-size: calc(12 * var(--hud-u)); line-height: calc(17 * var(--hud-u)); }
}
