/* Night Loop - title, HUD, minimap, end panel and touch controls over the canvas (frame.css sets the page and the back link) */
html, body { touch-action: none; }
body { background: #0c0718; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
body > canvas { position: fixed; inset: 0; width: 100%; height: 100%; }

/* ---- attract mode title */
.nl-title { position: fixed; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; padding: 11vh 20px calc(8vh + env(safe-area-inset-bottom)); box-sizing: border-box; text-align: center; pointer-events: none; transition: opacity 0.4s; background: linear-gradient(rgb(8 4 20 / 0.55), rgb(8 4 20 / 0) 38%, rgb(8 4 20 / 0) 68%, rgb(8 4 20 / 0.5)); }
.nl-title.nl-hide { opacity: 0; }
.nl-title-name { margin: 0; font-size: clamp(46px, 10vw, 120px); line-height: 1; font-weight: 800; letter-spacing: -0.035em; color: #fff; text-shadow: 0 0 18px rgb(255 43 214 / 0.85), 0 0 46px rgb(255 43 214 / 0.55), 0 0 2px #ffd3f5, 0 4px 30px rgb(0 0 0 / 0.5); }
.nl-title-sub { margin: 14px 0 auto; font-size: 13px; line-height: 20px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: #8ff3ff; text-shadow: 0 0 12px rgb(34 230 255 / 0.7), 0 1px 6px rgb(0 0 0 / 0.8); }
.nl-title-go { margin: 0; padding: 10px 22px; border-radius: 9999px; background: rgb(12 6 26 / 0.62); border: 1px solid rgb(255 255 255 / 0.22); font-size: clamp(14px, 2.2vw, 18px); line-height: 24px; font-weight: 600; color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: nl-breathe 2.4s ease-in-out infinite; }
@keyframes nl-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.62; } }

/* ---- HUD */
.nl-hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 0.4s; font-variant-numeric: tabular-nums; text-shadow: 0 1px 8px rgb(0 0 0 / 0.75); }
.nl-hud.nl-show { opacity: 1; }

.nl-laps { position: absolute; left: calc(14px + env(safe-area-inset-left)); top: calc(58px + env(safe-area-inset-top)); }
.nl-lapno { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: 0.14em; color: #8ff3ff; }
.nl-laptime { margin-top: 2px; font-size: 32px; line-height: 36px; font-weight: 700; letter-spacing: -0.01em; }
.nl-delta { min-height: 20px; font-size: 15px; line-height: 20px; font-weight: 700; color: #ff7a8c; }
.nl-delta.nl-ahead { color: #6dffb0; }
.nl-laplist { margin-top: 4px; font-size: 12px; line-height: 16px; font-weight: 600; color: rgb(255 255 255 / 0.72); white-space: pre; }
.nl-bestlap { margin-top: 2px; font-size: 12px; line-height: 16px; font-weight: 600; color: #ffc65c; }

.nl-scorebox { position: absolute; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; }
.nl-label { font-size: 11px; line-height: 14px; font-weight: 700; letter-spacing: 0.18em; color: #ff8ae6; }
.nl-score { font-size: 26px; line-height: 30px; font-weight: 800; }

.nl-map { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(56px + env(safe-area-inset-top)); width: 168px; height: 168px; border-radius: 16px; background: rgb(10 6 24 / 0.55); border: 1px solid rgb(255 255 255 / 0.12); }

.nl-drift { position: absolute; left: 50%; top: 22%; transform: translate(-50%, 6px) scale(0.92); text-align: center; opacity: 0; transition: opacity 0.2s, transform 0.2s; }
.nl-drift.nl-show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.nl-drift-pts { font-size: 40px; line-height: 44px; font-weight: 800; color: #fff; text-shadow: 0 0 16px rgb(255 43 214 / 0.9), 0 2px 10px rgb(0 0 0 / 0.6); }
.nl-drift-mult { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: 0.16em; color: #ff8ae6; }

.nl-toast { position: absolute; left: 50%; top: 34%; transform: translate(-50%, 8px); padding: 4px 16px; border-radius: 9999px; background: rgb(12 6 26 / 0.6); font-size: 17px; line-height: 26px; font-weight: 700; color: #8ff3ff; white-space: nowrap; opacity: 0; transition: opacity 0.25s, transform 0.25s; }
.nl-toast.nl-show { opacity: 1; transform: translate(-50%, 0); }
.nl-toast.nl-bad { color: #ff8b8b; }
.nl-toast.nl-good { color: #ffd36e; }

.nl-wrong { position: absolute; left: 50%; top: 44%; transform: translateX(-50%); padding: 6px 18px; border-radius: 9999px; background: rgb(150 10 40 / 0.7); font-size: 16px; line-height: 24px; font-weight: 800; letter-spacing: 0.14em; opacity: 0; transition: opacity 0.3s; }
.nl-wrong.nl-show { opacity: 1; }

.nl-count { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 96px; line-height: 1; font-weight: 800; color: #fff; text-shadow: 0 0 24px rgb(34 230 255 / 0.9), 0 4px 20px rgb(0 0 0 / 0.6); opacity: 0; }
.nl-count.nl-pop { animation: nl-count 0.95s ease-out forwards; }
.nl-count.nl-go { color: #ffe9fb; text-shadow: 0 0 26px rgb(255 43 214 / 0.95), 0 4px 20px rgb(0 0 0 / 0.6); }
@keyframes nl-count { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }

.nl-dash { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nl-speedrow { display: flex; align-items: baseline; gap: 6px; }
.nl-speed { min-width: 64px; text-align: right; font-size: 34px; line-height: 38px; font-weight: 800; }
.nl-unit { font-size: 12px; line-height: 16px; font-weight: 600; color: rgb(255 255 255 / 0.65); }
.nl-gear { margin-left: 6px; width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgb(255 255 255 / 0.3); font-size: 15px; line-height: 26px; font-weight: 800; text-align: center; align-self: center; text-shadow: none; background: rgb(10 6 24 / 0.5); }
.nl-boost { display: flex; align-items: center; gap: 10px; font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: 0.14em; color: rgb(255 255 255 / 0.55); transition: color 0.2s; }
.nl-boost-bar { position: relative; width: 180px; height: 8px; border-radius: 4px; background: rgb(10 6 24 / 0.6); border: 1px solid rgb(255 255 255 / 0.14); overflow: hidden; }
.nl-boost-fill { position: absolute; inset: 0; background: linear-gradient(90deg, #22e6ff, #ff2bd6); transform-origin: 0 50%; transform: scaleX(0); }
.nl-boost.nl-ready { color: #8ff3ff; }
.nl-boost.nl-firing { color: #fff; }
.nl-boost.nl-firing .nl-boost-fill { background: linear-gradient(90deg, #fff, #ffb020); }

.nl-hint { position: fixed; z-index: 11; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; max-width: min(640px, 92vw); padding: 8px 16px; border-radius: 14px; background: rgb(10 6 24 / 0.6); border: 1px solid rgb(255 255 255 / 0.12); font-size: 13px; line-height: 20px; color: rgb(255 255 255 / 0.82); pointer-events: none; opacity: 0; transition: opacity 0.8s; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.nl-hint.nl-show { opacity: 1; }
.nl-hint-item { white-space: nowrap; }
.nl-hint b { color: #8ff3ff; font-weight: 700; }

/* ---- end of race panel */
.nl-over { position: fixed; inset: 0; z-index: 14; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgb(8 4 20 / 0.42); opacity: 0; visibility: hidden; transition: opacity 0.4s, visibility 0.4s; }
.nl-over.nl-show { opacity: 1; visibility: visible; }
.nl-card { width: min(320px, 84vw); padding: 26px 28px 24px; border-radius: 20px; background: rgb(14 8 30 / 0.82); border: 1px solid rgb(255 255 255 / 0.14); box-shadow: 0 0 40px rgb(255 43 214 / 0.22); text-align: center; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transform: translateY(12px); transition: transform 0.4s; font-variant-numeric: tabular-nums; }
.nl-over.nl-show .nl-card { transform: none; }
.nl-card p { margin: 0; }
.nl-over-head { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: #ff8ae6; }
.nl-over-total { margin-top: 6px !important; font-size: 48px; line-height: 54px; font-weight: 800; letter-spacing: -0.02em; }
.nl-over-rows, .nl-over-stats { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.nl-over-stats { padding-top: 12px; border-top: 1px solid rgb(255 255 255 / 0.12); }
.nl-row { display: flex; justify-content: space-between; font-size: 14px; line-height: 20px; color: rgb(255 255 255 / 0.72); }
.nl-row-best { color: #ffc65c; font-weight: 700; }
.nl-row-stat b { color: #fff; font-weight: 700; }
.nl-over-record { margin-top: 12px !important; font-size: 13px; line-height: 18px; color: rgb(255 255 255 / 0.6); }
.nl-over-record.nl-new { color: #6dffb0; font-weight: 600; }
.nl-btn { margin-top: 18px; height: 48px; padding: 0 32px; border: 0; border-radius: 9999px; background: #ff2bd6; color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; box-shadow: 0 0 24px rgb(255 43 214 / 0.5); transition: transform 0.15s, background 0.15s; }
.nl-btn:hover { background: #ff55e0; transform: translateY(-1px); }
.nl-btn:active { transform: scale(0.97); }
.nl-btn:focus-visible, .nl-mute:focus-visible, .nl-reset:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nl-over-key { margin-top: 8px !important; min-height: 16px; font-size: 12px; line-height: 16px; color: rgb(255 255 255 / 0.45); }

/* ---- mute */
.nl-mute { position: fixed; z-index: 50; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid rgb(255 255 255 / 0.16); background: rgb(15 15 15 / 0.6); color: #fff; cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.nl-mute:hover { background: rgb(15 15 15 / 0.85); }
.nl-mute svg { display: block; width: 20px; height: 20px; margin: auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nl-mute .nl-off { display: none; }
.nl-mute.nl-muted .nl-off { display: inline; }
.nl-mute.nl-muted .nl-on { display: none; }

/* ---- touch controls: a wheel on the left, pedals and handbrake on the right */
.nl-touch { position: fixed; inset: 0; z-index: 11; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.3s; }
.nl-touch.nl-show { opacity: 1; visibility: visible; }
.nl-wheelzone { position: absolute; left: 0; bottom: 0; width: 44vw; height: 62vh; pointer-events: auto; touch-action: none; }
.nl-wheel { position: absolute; left: calc(24px + env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 136px; height: 136px; border-radius: 50%; border: 12px solid rgb(255 255 255 / 0.28); box-sizing: border-box; background: rgb(10 6 24 / 0.25); box-shadow: 0 0 18px rgb(34 230 255 / 0.35), inset 0 0 12px rgb(34 230 255 / 0.3); }
.nl-wheel-hub { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: rgb(255 255 255 / 0.35); }
.nl-wheel-spoke { position: absolute; left: 50%; top: 50%; width: 44px; height: 8px; margin-top: -4px; border-radius: 4px; background: rgb(255 255 255 / 0.3); }
.nl-spoke-l { margin-left: -56px; }
.nl-spoke-r { margin-left: 12px; }
.nl-spoke-b { width: 8px; height: 40px; margin: 12px 0 0 -4px; }
.nl-wheel-mark { position: absolute; left: 50%; top: -12px; width: 8px; height: 12px; margin-left: -4px; border-radius: 3px; background: #ff2bd6; }
.nl-pedals { position: absolute; right: calc(18px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 76px 84px; grid-template-rows: 64px 120px; gap: 12px; }
.nl-pad { display: flex; align-items: center; justify-content: center; border-radius: 16px; border: 1px solid rgb(255 255 255 / 0.28); background: rgb(10 6 24 / 0.4); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: 0.1em; color: rgb(255 255 255 / 0.85); pointer-events: auto; touch-action: none; transition: background 0.08s, transform 0.08s; }
.nl-pad.nl-down { transform: scale(0.95); background: rgb(255 255 255 / 0.3); }
.nl-pad-hand { border-color: rgb(255 176 32 / 0.7); color: #ffc65c; }
.nl-pad-boost { border-color: rgb(34 230 255 / 0.7); color: #8ff3ff; border-radius: 9999px; }
.nl-pad-brake { border-color: rgb(255 90 110 / 0.6); }
.nl-pad-gas { border-color: rgb(109 255 176 / 0.6); }
.nl-pad-hand.nl-down { background: rgb(255 176 32 / 0.4); }
.nl-pad-boost.nl-down { background: rgb(34 230 255 / 0.4); }
.nl-reset { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(56px + env(safe-area-inset-right)); width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid rgb(255 255 255 / 0.16); background: rgb(15 15 15 / 0.6); color: #fff; font: inherit; font-size: 18px; line-height: 34px; cursor: pointer; pointer-events: auto; }

/* small screens: a smaller map, and the dash sits above the touch controls */
@media (max-width: 720px), (max-height: 480px) {
  .nl-map { width: 112px; height: 112px; border-radius: 12px; }
  .nl-laptime { font-size: 24px; line-height: 28px; }
  .nl-laplist { display: none; }
  .nl-score { font-size: 20px; line-height: 24px; }
  .nl-drift-pts { font-size: 30px; line-height: 34px; }
  .nl-count { font-size: 72px; }
}
@media (max-height: 480px) {
  .nl-scorebox { top: calc(8px + env(safe-area-inset-top)); }
  .nl-wheel { width: 116px; height: 116px; border-width: 10px; }
  .nl-pedals { grid-template-columns: 68px 76px; grid-template-rows: 54px 96px; gap: 10px; }
}
.nl-touchmode .nl-dash { bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (max-width: 720px) {
  .nl-touchmode .nl-dash { bottom: calc(240px + env(safe-area-inset-bottom)); }
  .nl-touchmode .nl-hint { bottom: calc(320px + env(safe-area-inset-bottom)); }
}
