* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #07090f;
  color: #f4f6fb;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

.shell {
  max-width: 430px;
  margin: 0 auto;
}

.app {
  width: 100%;
  margin: 0 auto;
  padding: 18px;
}

header {
  margin: 12px 0 18px;
}

.label, .small {
  color: #8ea0c8;
  font-size: 11px;
  letter-spacing: 0.12em;
  font-weight: 700;
}

h1 {
  font-size: 24px;
  margin: 6px 0 0;
}

.card {
  background: #111624;
  border: 1px solid #26314f;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.lapline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.fastest-row {
  margin-top: 6px;
  color: #c9d5ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.fastest-row[hidden] {
  display: none;
}

.session-select {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: #07090f;
  color: #f4f6fb;
  border: 1px solid #26314f;
  border-radius: 8px;
  font: inherit;
}

.session-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.session-title {
  min-width: 0;
  color: #f4f6fb;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-badge {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid rgba(98, 245, 164, 0.55);
  border-radius: 6px;
  color: #62f5a4;
  font-size: 11px;
  font-weight: 700;
}

.mode-badge.is-replay {
  border-color: rgba(255, 216, 74, 0.65);
  color: #ffd84a;
}

#status {
  font-size: 14px;
  color: #f4f6fb;
}

#status.status-yellow {
  color: #ffd84a;
}

#status.status-red {
  color: #ff5c6c;
}

#status.status-green {
  color: #62f5a4;
}

#status.status-neutral {
  color: #f4f6fb;
}

.updated {
  margin-top: 8px;
  color: #8ea0c8;
  font-size: 12px;
}

.pre-race-start, .pre-race-grid-head {
  margin-top: 14px;
}

.pre-race-title {
  color: #8ea0c8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
}

.pre-race-time {
  margin-top: 3px;
  font-size: 22px;
  font-weight: 800;
}

.pre-race-browser-time, .pre-race-status {
  margin-top: 3px;
  color: #aab7d8;
  font-size: 12px;
}

.pre-race-grid {
  display: grid;
  gap: 7px;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.pre-race-grid li {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 8px;
  font-size: 13px;
}

.pre-race-grid b { color: #8ea0c8; }

.pre-race-log {
  border-color: #55678f;
  background: rgba(63, 83, 125, .16);
}

.pre-race-log .logmeta b {
  color: #c9d5ff;
  border-color: #667cae;
}

.pre-race-toggle {
  margin-top: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  color: #c9d5ff;
  font-size: 12px;
  cursor: pointer;
}

#focus {
  font-size: 13px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  margin-bottom: 0;
  white-space: pre-line;
}

.logitem {
  border: 1px solid transparent;
  border-top-color: #26314f;
  border-radius: 6px;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 8px;
  padding: 14px 8px;
}

.logitem:first-child {
  border-top: none;
}

.team-bar {
  width: 4px;
  min-height: 100%;
  background: transparent;
  border-radius: 2px;
}

.logcontent {
  min-width: 0;
}

.logmeta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logmeta span {
  color: #8ea0c8;
  font-size: 12px;
}

.logmeta b {
  border: 1px solid #47516d;
  border-radius: 4px;
  color: #aab7d8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  padding: 3px 5px;
}

.logitem p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.logitem-control {
  border-color: #47516d;
}

.logitem-red {
  border-color: #ff4d5d;
}

.logitem-issue {
  border-color: rgba(255, 120, 80, 0.85);
}

.logitem-yellow {
  border-color: #e8c84a;
}

.logitem-vsc {
  border-color: rgba(255, 210, 0, 0.9);
}

.logitem-fastest {
  border-color: rgba(184, 116, 255, 0.9);
}

.logitem-green {
  border-color: #62f5a4;
}

.logitem-session {
  border-color: rgba(80, 255, 140, 0.75);
}

.logitem-red .logmeta b,
.logitem-issue .logmeta b {
  border-color: #ff4d5d;
  color: #ff9aa3;
}

.logitem-red p,
.logitem-issue p {
  color: #ffd5d9;
}

.logitem-yellow .logmeta b,
.logitem-vsc .logmeta b {
  border-color: #e8c84a;
  color: #f3df7a;
}

.logitem-yellow p,
.logitem-vsc p {
  color: #fff0a8;
}

.logitem-fastest .logmeta b {
  border-color: rgba(184, 116, 255, 0.9);
  color: #d8b4ff;
}

.logitem-fastest p {
  color: #eadcff;
}

.logitem-green .logmeta b,
.logitem-session .logmeta b {
  border-color: #62f5a4;
  color: #9cffc7;
}

.logitem-green p,
.logitem-session p {
  color: #d5ffe5;
}

.driver-code {
  display: inline-block;
  font-weight: 800;
  margin-right: 0.35em;
}

.replay-console {
  display: none;
}

.console-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin: 18px 0 10px;
}

.console-header h2 {
  font-size: 16px;
  margin: 4px 0 0;
}

.console-pill {
  border: 1px solid #47516d;
  border-radius: 999px;
  color: #aab7d8;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 9px;
  text-transform: uppercase;
}

.console-section {
  background: #111624;
  border: 1px solid #26314f;
  border-radius: 10px;
  margin-bottom: 8px;
  padding: 10px;
}

.console-label {
  color: #8ea0c8;
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.console-select,
.console-input,
.replay-console button {
  background: #07090f;
  border: 1px solid #26314f;
  border-radius: 8px;
  color: #f4f6fb;
  font: inherit;
  font-size: 11px;
  min-height: 30px;
  padding: 6px 8px;
}

.console-select {
  width: 100%;
}

.console-input {
  width: 100%;
}

.replay-console button {
  cursor: pointer;
}

.replay-control-button.is-active {
  background: #62f5a4;
  border-color: #62f5a4;
  color: #07110c;
  font-weight: 800;
}

.console-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.console-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.replay-lap-jump {
  margin-top: 8px;
}

.replay-lap-jump .console-input {
  flex: 1 1 72px;
  min-width: 72px;
}

.replay-lap-jump button {
  flex: 1 1 96px;
}

.console-muted {
  color: #8ea0c8;
  font-size: 11px;
  line-height: 1.4;
  margin-top: 6px;
}

.replay-seek {
  margin-top: 10px;
}

.replay-seek-labels {
  color: #8ea0c8;
  display: grid;
  font-size: 10px;
  grid-template-columns: 1fr auto 1fr;
  margin-bottom: 4px;
}

.replay-seek-labels span:last-child {
  text-align: right;
}

#replaySeekRange {
  width: 100%;
}

.console-state {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.console-state div {
  min-width: 0;
}

.console-state dt {
  color: #8ea0c8;
  font-size: 11px;
  margin-bottom: 3px;
}

.console-state dd {
  font-size: 12px;
  margin: 0;
  overflow-wrap: anywhere;
}

.console-box {
  background: #07090f;
  border: 1px solid #26314f;
  border-radius: 8px;
  color: #d8def0;
  font-size: 11px;
  line-height: 1.45;
  min-height: 38px;
  padding: 8px;
}

.console-toggle {
  align-items: center;
  color: #d8def0;
  display: inline-flex;
  font-size: 11px;
  gap: 6px;
}

.console-tags {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0;
}

.console-tags label {
  align-items: center;
  color: #d8def0;
  display: inline-flex;
  font-size: 11px;
  gap: 5px;
}

.console-textarea {
  background: #07090f;
  border: 1px solid #26314f;
  border-radius: 8px;
  color: #f4f6fb;
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
  min-height: 74px;
  padding: 8px;
  resize: vertical;
  width: 100%;
}

.debug-standings {
  align-self: start;
  background: #111624;
  border: 1px solid #26314f;
  border-radius: 12px;
  color: #f4f6fb;
  display: none;
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  padding: 12px;
  width: 100%;
}

.debug-standings-table {
  margin-top: 10px;
  overflow-x: auto;
}

.debug-standings table {
  border-collapse: collapse;
  min-width: 100%;
  width: 100%;
}

.debug-standings th,
.debug-standings td {
  border-bottom: 1px solid rgba(142, 160, 200, 0.18);
  padding: 5px 4px;
  text-align: right;
  white-space: nowrap;
}

.debug-standings th {
  color: #8ea0c8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.debug-standings th:nth-child(2),
.debug-standings td:nth-child(2),
.debug-standings th:nth-child(3),
.debug-standings td:nth-child(3) {
  text-align: left;
}

.debug-driver-number {
  color: #8ea0c8;
  font-weight: 700;
  margin-left: 4px;
}

.debug-placeholder {
  color: rgba(142, 160, 200, 0.45);
}

.debug-placeholder .driver-code,
.debug-placeholder .debug-driver-number {
  color: rgba(142, 160, 200, 0.45) !important;
}

.debug-empty {
  color: #8ea0c8;
}

@media (min-width: 981px) {
  .shell {
    align-items: start;
    display: grid;
    gap: 24px;
    grid-template-columns: minmax(220px, 280px) minmax(360px, 420px) minmax(240px, 320px);
    justify-content: center;
    margin: 0 auto;
    max-width: none;
    padding: 0;
    width: min(1460px, calc(100vw - 32px));
  }

  .shell-live {
    grid-template-columns: minmax(220px, 280px) minmax(360px, 420px);
    width: min(730px, calc(100vw - 32px));
  }

  .debug-standings {
    display: block;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    position: sticky;
    top: 16px;
  }

  .shell-live .debug-standings {
    display: block;
  }

  .app {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
  }

  .replay-console {
    align-self: start;
    display: block;
    height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 0;
    position: sticky;
    top: 16px;
    width: 100%;
  }
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .replay-console {
    display: none;
  }

  .debug-standings {
    display: none;
  }
}
