:root {
  --black: #000;
  --yellow: #FFD659;
  --red: #E4002B;
  --blue: #007AC2;
  --white: #fff;
  --green: #00cc44;
  --panel: #0a0a0a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: Arial, Helvetica, sans-serif;
}
body {
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.livery {
  height: 8px;
  background: linear-gradient(90deg, var(--yellow) 0 34%, var(--red) 34% 66%, var(--blue) 66% 100%);
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 3px solid var(--yellow);
  background: #0a0a0a;
  position: sticky;
  top: 0;
  z-index: 5;
}
.mark {
  color: var(--yellow);
  font-weight: 900;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  display: block;
}
.title { color: var(--white); font-weight: 900; font-size: 1.2rem; line-height: 1.15; }
.nav { display: flex; gap: 8px; align-items: center; }
.nav a, .btn-link, #adminBtn {
  color: var(--white);
  text-decoration: none;
  border: 2px solid #444;
  background: #111;
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-weight: bold;
}
.nav a.nav-on, .nav a:hover, .btn-link, #adminBtn {
  border-color: var(--yellow);
  color: var(--yellow);
}
.admin-form { width: 100%; }
main { padding: 10px; }
.panel {
  background: var(--panel);
  border: 2px solid var(--yellow);
  box-shadow: 0 0 0 1px var(--red) inset;
  margin: 0 0 12px;
  padding: 10px;
}
.panel-head {
  border-bottom: 2px solid var(--blue);
  margin-bottom: 10px;
  padding-bottom: 8px;
}
h2 { margin: 0 0 4px; color: var(--yellow); font-size: 1rem; }
.sub, .hint, p, label, th, td, span, strong { color: var(--white); }
.sub, .hint { margin: 0; font-size: 0.84rem; line-height: 1.35; }
.countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  text-align: center;
}
.countdown div { border: 2px solid var(--yellow); padding: 8px 2px; }
.countdown span {
  display: block;
  color: var(--yellow);
  font-size: 1.35rem;
  font-weight: 900;
}
.countdown small { font-size: 0.7rem; }
.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.score-box {
  background: #000;
  border: 2px solid var(--yellow);
  padding: 10px 8px 10px 12px;
  position: relative;
}
.score-box::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--red);
}
.score-box .name {
  font-weight: bold;
  padding-left: 8px;
  background: none;
  border: none;
  color: var(--white);
  font-size: 0.95rem;
  text-align: left;
  min-height: 36px;
  cursor: pointer;
  text-decoration: underline;
  width: 100%;
}
.score-box .score, .num, #weekLbl, .pos { color: var(--yellow); font-weight: 900; }
.score-box .score { font-size: 1.5rem; padding-left: 8px; }
.pin-drop { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.pin-drop[hidden], .admin-form[hidden] { display: none !important; }
.pin-drop input { width: 90px; }
#board, #liveBoard {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
table {
  border-collapse: collapse;
  width: 100%;
}
#board table { min-width: 860px; }
th, td {
  border: 1px solid #333;
  padding: 7px 6px;
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}
#board th, #board td { white-space: nowrap; }
th { background: #111; color: var(--yellow); border-bottom: 2px solid var(--yellow); }
#board th:first-child, #board tr > th[rowspan] {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #111;
  box-shadow: 6px 0 8px rgba(0,0,0,0.45);
  min-width: 72px;
}
.worst-win, .worst-win * { color: var(--green) !important; font-weight: bold; }
.chk { color: var(--white) !important; }
.banner { border: 2px dashed var(--yellow); padding: 10px; margin-bottom: 12px; font-size: 0.9rem; }
.login-row, .week-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
input, button, select, textarea {
  background: #111;
  color: var(--white);
  border: 2px solid #444;
  padding: 10px 12px;
  font-size: 16px;
  max-width: 100%;
}
select, .login-row input, .week-row button, .card select {
  width: 100%;
}
button {
  cursor: pointer;
  min-height: 44px;
  font-weight: bold;
  border-color: var(--yellow);
  color: var(--yellow);
}
.msg { color: var(--yellow); min-height: 1.2em; }
.card { border: 2px solid var(--blue); padding: 12px; max-width: 640px; }
.quote { margin: 0 0 10px; color: var(--yellow); font-size: 1rem; line-height: 1.35; }
.row { display: grid; gap: 8px; margin-bottom: 12px; }
#pasteHtml { width: 100%; display: block; margin: 8px 0; min-height: 120px; }
.foot {
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 3px solid var(--red);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.foot .admin-form { width: auto; margin: 0; }
.live-table { min-width: 0; width: 100%; }
.live-table th, .live-table td {
  padding: 7px 6px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.live-p1 { color: var(--yellow); font-weight: 900; }
.flag-green { color: var(--green); }
.flag-yellow { color: var(--yellow); }
.flag-red { color: var(--red); }
.flag-check { color: var(--white); }
.live-picks-h { color: var(--yellow); font-size: 1rem; margin: 16px 0 8px; }
.live-picked td { border-color: var(--blue); }

@media (max-width: 799px) {
  .score-row:has(.score-box:nth-child(5):last-child) {
    grid-template-columns: 1fr 1fr;
  }
  .score-box:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 800px) {
  main { padding: 18px 24px; }
  .title { font-size: 1.8rem; }
  .countdown span { font-size: 2rem; }
  .score-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .score-box:last-child:nth-child(odd) { grid-column: auto; }
  th, td { font-size: 0.95rem; padding: 8px; }
  .live-table th, .live-table td { font-size: 0.95rem; }
  select, .login-row input, .week-row button, .card select { width: auto; }
}

/* Slot cars page — same chrome, a few extras for the season board */
.nav span.nav-on {
  color: var(--yellow);
  text-decoration: none;
  border: 2px solid var(--yellow);
  background: #111;
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-weight: bold;
}
.score-box .who {
  font-weight: bold;
  padding-left: 8px;
  color: var(--white);
  font-size: 0.95rem;
}
.score-box .car-name {
  padding-left: 8px;
  font-size: 0.84rem;
  color: var(--white);
}
.race-no { color: var(--yellow); font-weight: 900; font-size: 0.72rem; letter-spacing: 0.04em; display: block; }
.col-placeholder, .col-placeholder * { color: #888 !important; font-weight: normal; }
#slotBoard table { min-width: 520px; }
#slotBoard th { white-space: normal; min-width: 110px; }
