* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #26301f;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f2f4f2;
  user-select: none;
}

#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.panel {
  position: fixed;
  background: rgba(12, 16, 13, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 10px 12px;
  backdrop-filter: blur(3px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

#standings {
  top: 12px;
  left: 12px;
  min-width: 168px;
  font-size: 13px;
}

#standings .row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2.5px 2px;
}

#standings .row.self { background: rgba(255, 235, 59, 0.14); border-radius: 5px; }

#standings .pos { width: 22px; font-weight: 700; opacity: 0.85; }
#standings .chip { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.5); }
#standings .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
#standings .lp { opacity: 0.75; font-variant-numeric: tabular-nums; }

#raceInfo {
  top: 12px;
  right: 12px;
  text-align: right;
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

#raceInfo b { font-size: 19px; }

#topCenter {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  max-width: 92vw;
}

#phaseMsg {
  display: inline-block;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 1px;
  white-space: nowrap;
  background: rgba(12, 16, 13, 0.55);
  border-radius: 12px;
  padding: 6px 22px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}

#subMsg { font-size: 15px; margin-top: 5px; opacity: 0.95; text-shadow: 0 2px 8px rgba(0,0,0,0.75); }

#bigCount {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 130px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 28px rgba(255, 60, 40, 0.9), 0 4px 14px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  display: none;
}

#bigCount.pop { animation: pop 0.9s ease-out; display: block; }

@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#joinWrap {
  position: fixed;
  left: 50%;
  bottom: 17%;
  transform: translateX(-50%);
  text-align: center;
  display: none;
}

#nameLabel {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0.7;
  margin-bottom: 5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

#nameInput {
  display: block;
  width: 220px;
  margin: 0 auto 12px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  color: #f2f4f2;
  background: rgba(12, 16, 13, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 9px;
  outline: none;
  user-select: text;
  backdrop-filter: blur(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease;
}

#nameInput::placeholder { color: rgba(242, 244, 242, 0.45); }
#nameInput:focus { border-color: rgba(255, 235, 59, 0.7); }

#joinBtn {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 14px 44px;
  color: #fff;
  background: linear-gradient(180deg, #33c14e, #1d8a37);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  transition: transform 0.08s ease, filter 0.15s ease;
}

#joinBtn:hover:not(:disabled) { transform: scale(1.05); filter: brightness(1.1); }
#joinBtn:active:not(:disabled) { transform: scale(0.97); }
#joinBtn:disabled { background: linear-gradient(180deg, #4c554d, #39423b); cursor: default; opacity: 0.9; }

#joinMsg { margin-top: 8px; font-size: 15px; font-weight: 600; min-height: 20px; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }

#results {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  min-width: 300px;
  padding: 16px 20px;
  font-size: 15px;
}

#results h2 {
  text-align: center;
  font-size: 22px;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

#results .rrow {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 4px;
  border-radius: 6px;
}

#results .rrow.self { background: rgba(255, 235, 59, 0.14); }
#results .pos { width: 30px; font-weight: 800; }
#results .rpos.first { color: #ffd54f; }
#results .chip { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.5); }
#results .nm { flex: 1; }
#results .tm { font-variant-numeric: tabular-nums; opacity: 0.85; }

#hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  opacity: 0.65;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 10, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
}

#overlay .box { font-size: 20px; font-weight: 700; }
