* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: "Mulish", sans-serif;
  background: rgb(11, 16, 23);
  color: rgb(244, 247, 251);
}

body {
  background: rgb(11, 16, 23);
}

h1,
h2,
h3,
h4,
h5 {
  font-family: "Merriweather", Georgia, serif;
}

#login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
}

#login-container > div {
  width: 100%;
  max-width: 420px;
  display: flex;
  gap: 0.75rem;
  padding: 1.2rem;
  background: rgba(16, 23, 34, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
}

.demo-key-hint {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border: 1px solid rgba(40, 199, 111, 0.3);
  border-radius: 14px;
  background: rgba(40, 199, 111, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.demo-key-hint span {
  color: rgb(212, 249, 226);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.demo-key-hint code {
  padding: 0.75rem 0.85rem;
  overflow-wrap: anywhere;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: rgb(244, 247, 251);
}

.demo-key-hint button {
  width: 100%;
  border-color: rgba(40, 199, 111, 0.3);
  background: rgb(29, 58, 42);
  color: rgb(201, 255, 224);
}

.demo-key-hint button:hover {
  background: rgb(36, 80, 52);
}

#access-key {
  flex: 1;
}

#error-message {
  margin: 0;
  color: rgb(255, 140, 155);
  min-height: 1.2rem;
  font-size: 0.95rem;
}

input {
  padding: 0.78rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgb(18, 26, 37);
  color: rgb(244, 247, 251);
  font: inherit;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input::placeholder {
  color: rgb(114, 132, 154);
}

input:focus {
  outline: none;
  border-color: rgb(255, 91, 46);
  box-shadow: 0 0 0 4px rgba(255, 91, 46, 0.14);
  background: rgb(22, 32, 45);
}

button {
  padding: 0.78rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgb(32, 45, 61);
  color: rgb(244, 247, 251);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgb(39, 56, 77);
}

#login-btn,
#add-session-btn,
#add-driver-btn,
#start-race-btn,
#end-session-btn {
  border-color: rgba(255, 91, 46, 0.35);
  background: rgb(255, 91, 46);
  color: rgb(255, 255, 255);
  box-shadow: 0 8px 18px rgba(255, 91, 46, 0.2);
}

#login-btn:hover,
#add-session-btn:hover,
#add-driver-btn:hover,
#start-race-btn:hover,
#end-session-btn:hover {
  background: rgb(244, 86, 40);
  box-shadow: 0 10px 22px rgba(255, 91, 46, 0.28);
}

#logout-btn {
  padding: 0.65rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgb(28, 39, 53);
  color: rgb(244, 247, 251);
}

#logout-btn:hover {
  background: rgb(37, 52, 70);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 23, 0.88);
  backdrop-filter: blur(14px);
}

.top-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 1rem 1.5rem;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
}

.page-title {
  margin: 0;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: rgb(244, 247, 251);
}

.page-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin-top: 0.45rem;
  border-radius: 999px;
  background: rgb(255, 91, 46);
  box-shadow: 0 0 18px rgba(255, 91, 46, 0.28);
}

.panel {
  background: rgb(20, 28, 40);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.panel-header {
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.panel-title {
  margin: 0;
  font-family: "Merriweather", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: rgb(244, 247, 251);
}

#session-detail-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

#session-detail-content::-webkit-scrollbar {
  width: 10px;
}

#session-detail-content::-webkit-scrollbar-thumb {
  background: rgb(46, 67, 93);
  border-radius: 999px;
}

.session-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgb(23, 32, 46);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.session-summary p {
  margin: 0;
  color: rgb(211, 221, 232);
}

.session-summary strong {
  color: rgb(244, 247, 251);
}

#detail-session-name,
#next-session-name,
#detail-session-status,
#next-session-status {
  display: inline-block;
  max-width: min(100%, 18rem);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.drivers-section {
  margin-top: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

#drivers-heading {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.drivers-list {
  display: flex;
  flex-direction: column;
}

.compact-drivers-grid-head,
.compact-driver-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 20px;
  align-items: center;
  width: 100%;
  overflow: hidden;
}

.compact-drivers-grid-head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgb(143, 163, 184);
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.02);
}

.compact-driver-item {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drivers-list > .compact-driver-item:last-child,
.compact-drivers-list > .compact-driver-item:last-child {
  border-bottom: 0;
}

.compact-driver-name {
  min-width: 0;
  overflow: hidden;
  color: rgb(244, 247, 251);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-driver-car {
  min-width: 60px;
  color: rgb(255, 91, 46);
  font-weight: 700;
  text-align: left;
}

.empty-state,
.info-message {
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.02);
  color: rgb(143, 163, 184);
}

.hidden {
  display: none !important;
}

.fullscreen-toggle {
  width: min(220px, calc(100vw - 48px));
  padding: 14px 16px;
  border: 1px solid rgb(51, 65, 85);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.82);
  color: inherit;
  font: inherit;
  width: auto;
  cursor: pointer;
}

.fullscreen-toggle:hover {
  background: rgba(30, 41, 59, 0.92);
}

.fullscreen-toggle:focus-visible {
  outline: 2px solid rgb(226, 232, 240);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .top-bar-inner {
    padding: 1rem;
  }

  .session-summary {
    grid-template-columns: 1fr;
  }
}

.session-status {
  display: block;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(240, 184, 78, 0.45);
  border-radius: 999px;
  background: rgba(240, 184, 78, 0.14);
  color: rgb(174, 187, 201);
  font-weight: 700;
  margin-right: 0;
  min-width: 0;
  max-width: min(100%, 26rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#session-status-badge {
    margin: 0 0 0 auto;
}

[data-session-state="active"] .session-status {
  border-color: rgba(41, 194, 117, 0.45);
  background: rgba(41, 194, 117, 0.14);
  color: rgb(245, 247, 251);
}

[data-session-state="disabled"] .session-status {
  border-color: rgba(240, 184, 78, 0.45);
  background: rgba(240, 184, 78, 0.14);
}

[data-session-state="ended"] .session-status {
  border-color: rgba(222, 91, 109, 0.42);
  background: rgba(222, 91, 109, 0.12);
}

@media (max-width: 470px) {
  .top-bar-inner {
    flex-wrap: wrap;
    align-items: center;
  }

  .top-bar-inner > .page-title {
    width: 100%;
  }

  #session-status-badge {
    margin-left: 0;
  }

  .session-status {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    text-align: center;
  }

  #logout-btn {
    flex: 0 0 auto;
    margin: 0 auto;
    width: 100%;
  }
}
