:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f7fbff;
  background: #071321;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  margin: 0;
  padding: clamp(14px, 3vw, 38px) 14px calc(var(--app-banner-height, 210px) + 30px + env(safe-area-inset-bottom));
  background: #071321;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(3, 12, 29, .72) 0%, rgba(5, 14, 29, .47) 42%, rgba(3, 10, 23, .91) 100%),
    url("/guest/laptime-background.jpg") center center / cover no-repeat;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #ffd459;
  outline-offset: 3px;
}

.page-shell { width: min(1120px, 100%); margin: 0 auto; }
.page-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 3.5vw, 40px);
  border: 1px solid rgba(201, 227, 255, .25);
  border-radius: 24px;
  background: linear-gradient(115deg, rgba(4, 17, 41, .91), rgba(5, 25, 54, .68) 62%, rgba(8, 38, 75, .43));
  box-shadow: 0 22px 70px rgba(0, 5, 17, .35);
  backdrop-filter: blur(10px);
}
.page-hero::after {
  position: absolute;
  top: -28px;
  right: -28px;
  width: 182px;
  height: 182px;
  content: "";
  opacity: .11;
  transform: rotate(-15deg);
  background: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0) 0 0 / 30px 30px;
  pointer-events: none;
}
.brand-row { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 900; }
.brand-mark {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 5px;
  background: conic-gradient(#fff 25%, #12345d 0 50%, #fff 0 75%, #12345d 0) 0 0 / 12px 12px;
  box-shadow: 0 0 18px rgba(78, 189, 255, .4);
}
.brand-name { font-size: clamp(23px, 2.3vw, 31px); line-height: 1; letter-spacing: -.035em; text-shadow: 0 3px 18px rgba(78, 189, 255, .32); }
h1 { margin: clamp(24px, 3vw, 35px) 0 0; font-size: clamp(42px, 7vw, 78px); font-weight: 900; letter-spacing: -.055em; line-height: 1; text-wrap: balance; }
.intro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 28px 0 0; padding: 0; list-style: none; counter-reset: guest-step; }
.intro li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid rgba(186, 222, 255, .17);
  border-radius: 13px;
  background: rgba(5, 17, 39, .5);
  color: #ecf5ff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}
.intro li::before {
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #72d7ff;
  color: #06213b;
  content: counter(guest-step, decimal-leading-zero);
  counter-increment: guest-step;
  font-size: 12px;
  font-weight: 900;
}
.step-optional { display: inline-block; margin-left: 5px; padding: 3px 7px; border: 1px solid rgba(124, 220, 255, .55); border-radius: 99px; color: #99e4ff; font-size: 11px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }

.entry-layout { margin-top: 18px; }
.app-promo, #guestRaceForm {
  border: 1px solid rgba(191, 222, 255, .24);
  border-radius: 22px;
  background: rgba(5, 17, 39, .88);
  box-shadow: 0 18px 45px rgba(0, 6, 20, .31);
  backdrop-filter: blur(14px);
}
.app-promo {
  position: fixed;
  z-index: 20;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(800px, calc(100% - 24px));
  max-height: min(46vh, 330px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 8% 0%, rgba(14, 171, 255, .4), transparent 53%), linear-gradient(145deg, rgba(5, 50, 103, .96), rgba(4, 24, 59, .92));
}
.app-promo::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 170px;
  height: 170px;
  content: "";
  opacity: .11;
  transform: none;
  background: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0) 0 0 / 34px 34px;
  pointer-events: none;
}
.promo-kicker { margin: 0 0 10px; color: #a7e8ff; font-size: 14px; font-weight: 800; letter-spacing: .03em; }
.app-promo-main { position: relative; z-index: 1; display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 16px; }
.app-promo-logo { display: block; width: 76px; height: 76px; padding: 3px; border-radius: 16px; background: #fff; box-shadow: 0 9px 28px rgba(0, 9, 29, .38); object-fit: contain; }
.app-promo h2 { margin: 0 0 5px; font-size: clamp(22px, 3vw, 30px); line-height: 1.08; letter-spacing: -.04em; text-wrap: balance; }
.app-promo p:not(.promo-kicker) { margin: 0; color: #d7e9ff; font-size: 15px; line-height: 1.5; }
.get-app-button, .scan-button {
  width: 100%;
  min-height: 48px;
  padding: 11px 17px;
  border: 0;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 800;
  transition: transform .18s ease, filter .18s ease;
}
.get-app-button:hover:not(:disabled), .scan-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.app-promo-actions { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) 48px; margin-top: 14px; }
.get-app-button { border-radius: 11px 0 0 11px; background: #ffd459; color: #15253d; }
.promo-toggle-button { display: grid; place-items: center; min-height: 48px; border: 0; border-left: 1px solid rgba(72, 60, 24, .26); border-radius: 0 11px 11px 0; background: #e9be4e; color: #15253d; }
.promo-toggle-button:hover { background: #ffe083; }
.promo-toggle-button span { width: 11px; height: 11px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.app-promo.is-collapsed .promo-toggle-button span { transform: translateY(2px) rotate(225deg); }
.app-promo.is-collapsed { overflow: hidden; padding: 8px; }
.app-promo.is-collapsed .app-promo-copy, .app-promo.is-collapsed .app-store-choices { display: none !important; }
.app-promo.is-collapsed .app-promo-actions { margin-top: 0; }
.app-store-choices { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 13px; }
.store-badge { display: block; flex: 0 1 auto; min-width: 0; line-height: 0; text-decoration: none; }
.store-badge-apple { width: 209px; }
.store-badge-google { width: 236px; }
.store-badge img { display: block; width: 100%; height: auto; }
.store-badge:hover { filter: brightness(1.1); }
.app-store-status { display: block; margin-top: 8px; color: #ffd0d0; font-size: 13px; }
.app-store-status:empty { display: none; }

#guestRaceForm { width: min(760px, 100%); margin: 0 auto; padding: 24px; backdrop-filter: none; }
.guest-racers { display: grid; gap: 13px; }
.racer-card { padding: 18px; border: 1px solid rgba(194, 224, 255, .17); border-radius: 16px; background: linear-gradient(150deg, rgba(22, 47, 82, .69), rgba(8, 25, 52, .79)); }
.racer-card.entered { border-color: rgba(104, 236, 184, .58); background: linear-gradient(150deg, rgba(12, 68, 68, .53), rgba(8, 34, 51, .8)); }
.racer-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.racer-card-header h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.entry-badge { padding: 5px 9px; border: 1px solid rgba(139, 246, 195, .55); border-radius: 99px; background: rgba(25, 114, 81, .42); color: #c8ffe7; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.remove-racer { width: auto; padding: 7px 10px; border: 1px solid rgba(255, 150, 150, .48); border-radius: 8px; background: rgba(127, 29, 29, .35); color: #ffd3d3; font-size: 13px; font-weight: 700; }
.remove-racer:hover { background: rgba(150, 39, 39, .65); }
.racer-fields { display: grid; grid-template-columns: minmax(0, 1fr) 126px; gap: 15px; align-items: start; }
.text-fields { display: grid; gap: 11px; }
label { display: grid; gap: 6px; color: #e2efff; font-size: 13px; font-weight: 700; }
input, select { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid #a7bfd6; border-radius: 9px; background: #f8fbff; color: #10243c; font-size: 16px; }
input:disabled, select:disabled { border-color: #8fa9bd; background: #d9e6ef; color: #263e50; opacity: .92; }
input.invalid, select.invalid { border-color: #ff8e8e; outline: 2px solid rgba(255, 142, 142, .28); }
.field-error { min-height: 16px; color: #ffb4b4; font-size: 12px; font-weight: 400; }
.avatar-picker { display: grid; gap: 7px; }
.avatar-picker img { width: 76px; height: 76px; margin: 0 auto; border-radius: 11px; background: rgba(1, 9, 23, .7); object-fit: contain; }
.scan-button { margin-top: 15px; background: linear-gradient(130deg, #22b9f4, #0877d2); color: #fff; }
.scan-button, .add-racer-button { font-family: "Segoe UI", Arial, sans-serif; font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.entry-confirmation { display: grid; gap: 4px; margin-top: 15px; padding: 13px 14px; border: 1px solid rgba(125, 239, 189, .45); border-radius: 11px; background: rgba(11, 91, 70, .42); color: #d7f8e9; font-size: 13px; }
.entry-confirmation strong { color: #f1fff9; font-size: 17px; }
.entry-confirmation b { color: #fff; letter-spacing: .04em; }
.racer-status { min-height: 20px; margin: 9px 0 0; color: #a4f1d1; font-size: 13px; }
.racer-status.error, .page-status.error { color: #ffb4b4; }
.page-status { min-height: 20px; margin: 13px 0 0; color: #d5e6f9; font-size: 14px; }
.add-racer-row { margin-top: 14px; }
.add-racer-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 55px; border: 1px dashed rgba(134, 207, 255, .65); border-radius: 12px; background: rgba(13, 57, 98, .55); color: #e8f6ff; font-size: 16px; font-weight: 800; }
.add-racer-button:hover:not(:disabled) { background: rgba(20, 89, 143, .7); }
.add-racer-button span { position: relative; display: block; flex: 0 0 29px; width: 29px; height: 29px; border-radius: 8px; background: #72d7ff; }
.add-racer-button span::before, .add-racer-button span::after { position: absolute; top: 50%; left: 50%; width: 13px; height: 2px; border-radius: 2px; background: #06213b; content: ""; transform: translate(-50%, -50%); }
.add-racer-button span::after { transform: translate(-50%, -50%) rotate(90deg); }
.scanner { position: fixed; z-index: 30; inset: 0; display: grid; align-content: center; gap: 12px; padding: 18px; background: rgba(2, 8, 20, .98); }
.scanner-view { position: relative; width: min(620px, 100%); margin: 0 auto; }
video { display: block; width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 10px; }
.scan-guide { position: absolute; top: 50%; left: 50%; width: min(58vw, 310px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 2px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(2, 6, 23, .28); pointer-events: none; }
.scan-guide::before, .scan-guide::after { position: absolute; inset: -2px; border: 5px solid #22d3ee; border-radius: 14px; content: ""; clip-path: polygon(0 0, 28% 0, 28% 5px, 0 5px, 0 28%, 5px 28%, 5px 0, 0 0, 100% 0, 100% 28%, calc(100% - 5px) 28%, calc(100% - 5px) 5px, 72% 5px, 72% 0, 100% 0, 100% 100%, 72% 100%, 72% calc(100% - 5px), calc(100% - 5px) calc(100% - 5px), calc(100% - 5px) 72%, 100% 72%, 100% 100%, 0 100%, 0 72%, 5px 72%, 5px calc(100% - 5px), 28% calc(100% - 5px), 28% 100%, 0 100%, 0 0, 100% 0); }
.scan-guide::after { transform: scale(.86); border-color: rgba(255, 255, 255, .35); }
.scan-instruction, .scanner-status { margin: 0; color: #e2e8f0; font-size: 14px; text-align: center; }
.scanner-status { min-height: 20px; color: #a7f3d0; }
.scanner-actions { display: flex; width: min(620px, 100%); gap: 10px; margin: 0 auto; }
.scanner-actions button { flex: 1; min-height: 46px; border: 1px solid rgba(221, 236, 255, .37); border-radius: 10px; background: #213a5b; color: #fff; font-size: 15px; font-weight: 700; }

@media (max-width: 820px) {
  .intro { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  body { padding: 12px 10px calc(var(--app-banner-height, 220px) + 24px + env(safe-area-inset-bottom)); }
  .page-hero { padding: 22px 18px; border-radius: 19px; }
  .brand-row { gap: 9px; }
  .brand-mark { flex-basis: 28px; width: 28px; height: 28px; }
  .brand-name { font-size: 24px; }
  h1 { font-size: clamp(42px, 12vw, 58px); }
  .intro { grid-template-columns: 1fr; gap: 7px; margin-top: 22px; }
  .intro li { min-height: 66px; gap: 10px; padding: 10px 12px; font-size: 15px; }
  .intro li::before { flex-basis: 30px; width: 30px; height: 30px; font-size: 11px; }
  .entry-layout { margin-top: 12px; }
  .app-promo { bottom: max(8px, env(safe-area-inset-bottom)); width: calc(100% - 16px); max-height: 44vh; padding: 13px; border-radius: 18px; }
  #guestRaceForm { padding: 17px; border-radius: 18px; }
  .app-promo-main { grid-template-columns: 60px minmax(0, 1fr); gap: 11px; }
  .app-promo-logo { width: 60px; height: 60px; border-radius: 13px; }
  .app-promo h2 { font-size: 22px; }
  .app-promo p:not(.promo-kicker) { font-size: 13px; }
  .app-promo-actions { margin-top: 11px; }
  .racer-card { padding: 14px; }
  .racer-fields { grid-template-columns: minmax(0, 1fr) 102px; gap: 10px; }
  .avatar-picker img { width: 66px; height: 66px; }
}

@media (max-width: 350px) {
  .racer-fields { grid-template-columns: 1fr; }
  .avatar-picker { grid-template-columns: 66px minmax(0, 1fr); align-items: center; }
  .avatar-picker span { grid-column: 1 / -1; }
  .avatar-picker img { margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .get-app-button, .scan-button { transition: none; }
}
