* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0d1017;
  color: #e6e9ef;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }
.dim { color: #8b95a7; }

button, input { font: inherit; color: inherit; }
input {
  width: 100%;
  padding: 10px 12px;
  background: #151a24;
  border: 1px solid #2a3242;
  border-radius: 8px;
  outline: none;
}
input:focus { border-color: #e10600; }
button, a.btn {
  display: block;
  padding: 10px 16px;
  background: #1c2331;
  border: 1px solid #2a3242;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: inherit;
}
button:hover, a.btn:hover { background: #252e40; }
.primary { background: #e10600 !important; border-color: #e10600 !important; color: #fff !important; font-weight: 800; }
.primary:hover { background: #ff2a22 !important; }
.wide { width: 100%; }
.big { padding: 14px; font-size: 18px; }
.field { display: block; margin: 14px 0; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: #8b95a7; }
.field small { display: block; margin-top: 6px; color: #8b95a7; }
.label { font-size: 12px; letter-spacing: 1px; opacity: .75; }

a.hub.corner {
  position: fixed; top: 14px; right: 16px; z-index: 5;
  padding: 9px 16px; border-radius: 10px; font-weight: 700; text-decoration: none; color: #e6e9ef;
  background: #1c2331; border: 1px solid #2a3242;
}
a.hub.corner:hover { background: #252e40; border-color: #e10600; }
a.btn.hub { margin-top: 8px; }

/* aviso de atualização ao vivo, por cima de tudo */
#updating {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 100;
  padding: 16px 26px; border-radius: 12px; font-size: 18px; font-weight: 700; text-align: center;
  background: #0d1017f2; border: 1px solid #ffd166; color: #ffd166; box-shadow: 0 10px 40px #000a;
}

/* ---------- lobby ---------- */

#lobby { max-width: 520px; margin: 0 auto; padding: 48px 20px; }
#lobby h1 { margin: 0; font-size: 44px; font-style: italic; letter-spacing: 1px; }
#lobby h1 span { color: #e10600; }
#lobby h2 { margin: 28px 0 10px; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: #8b95a7; }
.sub { margin: 6px 0 24px; color: #8b95a7; }
.msg { padding: 10px 12px; margin-bottom: 8px; background: #3a1a20; border: 1px solid #7a2c38; border-radius: 8px; }
.keys { margin-top: 32px; font-size: 13px; color: #626c7e; }
.login { padding: 16px; margin: 8px 0 16px; background: #151a24; border: 1px solid #e10600; border-radius: 10px; }
.login p { margin: 0 0 12px; }
#on-track { margin: 10px 0 0; font-size: 13px; text-align: center; }

#ranking { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; counter-reset: pos; }
#ranking li { display: flex; gap: 12px; padding: 8px 12px; background: #151a24; border: 1px solid #2a3242; border-radius: 8px; counter-increment: pos; }
#ranking li::before { content: counter(pos) "º"; color: #ffd166; font-weight: 700; min-width: 26px; }
#ranking li.empty { color: #626c7e; justify-content: center; }
#ranking li.empty::before { content: none; }
#ranking .name { flex: 1; font-weight: 600; }
#ranking .time { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- pista ---------- */

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; text-shadow: 0 1px 3px #000c; font-variant-numeric: tabular-nums; }

#top-left { position: absolute; left: 16px; top: 14px; }
#lap-box { padding: 10px 14px; background: #0009; border-radius: 10px; min-width: 190px; }
#lap-box .row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; }
#lap-cur { font-size: 26px; }
#lap-flag { margin-top: 6px; padding: 2px 8px; border-radius: 6px; background: #e10600; color: #fff; font-size: 12px; font-weight: 800; text-align: center; text-shadow: none; }

#board { position: absolute; right: 16px; top: 14px; display: grid; gap: 3px; font-size: 13px; min-width: 190px; }
#board div { display: flex; gap: 10px; padding: 3px 9px; background: #0009; border-radius: 6px; }
#board .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
#board .me { color: #ffd166; font-weight: 700; }

#feed { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: grid; gap: 4px; justify-items: center; font-size: 14px; }
#feed div { padding: 4px 12px; background: #000a; border-radius: 6px; }
#feed .pb { color: #6ee7a0; font-weight: 700; }
#feed .record { color: #d58cff; font-weight: 800; }
#feed .bad { color: #ff8a8a; }

#center {
  position: absolute; left: 50%; top: 28%; transform: translateX(-50%);
  padding: 12px 22px; background: #000a; border-radius: 10px; font-size: 20px; font-weight: 700; text-align: center; white-space: pre-line;
}

#minimap { position: absolute; left: 16px; bottom: 16px; width: 160px; height: 200px; opacity: .92; }

#dash { position: absolute; right: 20px; bottom: 16px; width: 280px; }
#rpm { height: 12px; border-radius: 99px; background: #0009; overflow: hidden; }
#rpm-bar { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2ecc71 0 60%, #ffd166 60% 85%, #e10600 85%); background-size: 280px 100%; }
#dash-row { display: flex; justify-content: flex-end; align-items: baseline; gap: 16px; margin-top: 6px; }
#gear { font-size: 46px; font-weight: 900; color: #ffd166; min-width: 34px; text-align: center; }
#speed { font-size: 58px; font-weight: 900; margin-right: 6px; }

#menu { position: absolute; inset: 0; display: grid; place-items: center; background: #0008; pointer-events: auto; text-shadow: none; }
#menu .panel { width: min(400px, 90vw); max-height: 90dvh; overflow-y: auto; padding: 26px; background: #0d1017; border: 1px solid #2a3242; border-top: 3px solid #e10600; border-radius: 12px; display: grid; gap: 10px; box-shadow: 0 24px 80px #0009; }
#menu h2 { margin: 0 0 8px; font-size: 20px; }
#open-menu { position: absolute; right: 20px; bottom: 150px; pointer-events: auto; background: #0d1017dd; font-weight: 700; }
#open-menu span { margin-left: 12px; color: #8b95a7; font-size: 12px; }
.menu-eyebrow { margin: 0; font-size: 11px; letter-spacing: 1.8px; color: #ff554f; font-weight: 800; }
.menu-note { margin: -6px 0 4px; color: #8b95a7; font-size: 13px; line-height: 1.5; }
.audio-settings { padding: 16px; margin-bottom: 6px; background: #151a24; border: 1px solid #2a3242; border-radius: 10px; }
.volume-heading { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; }
#volume-value { color: #ff554f; font-variant-numeric: tabular-nums; }
#engine-volume { padding: 0; margin: 16px 0; height: 24px; accent-color: #e10600; cursor: pointer; }
#mute-engine { width: 100%; font-size: 13px; }
button:focus-visible, a.btn:focus-visible, #engine-volume:focus-visible { outline: 2px solid #ffd166; outline-offset: 4px; }
