body[data-role="race-control"] {
  padding: 20px;
  overflow: hidden;
}

.race-control-page {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: rgb(244, 247, 251);
  overflow: hidden;
}

.race-view-section {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  min-height: 0;
}

.pre-view-section,
.race-ongoing,
.end-session {
  width: 100%;
  min-height: 0;
}

.pre-view-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.race-control-form {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 15%;
  margin: 10px;
}

#detail-session-status {
  color: rgb(255, 120, 79);
  font-weight: 700;
}

.race-ongoing,
.end-session {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#start-race-btn {
  width: 80%;
  height: 100%;
  flex: 1;
}

#end-session-btn {
  width: 100%;
  height: 100%;
  font-size: 8cqw;
}

#end-session-form {
  width: 90%;
  height: 90%;
  margin: 10px auto;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(4, 1fr);
  gap: 25px;
  flex: 1;
  padding: 10px;
}

.btn-control {
  width: 100%;
  height: 100%;
  font-size: 1.2rem;
  opacity: 0.5;
  transition: all 0.2s;
}

.control-grid .btn-control {
  background: none;
}

.control-grid #safe-btn {
  background: rgb(22, 163, 74);
}

.control-grid #safe-btn.active {
  opacity: 1;
  background-color: rgb(34, 197, 94);
  color: rgb(0, 0, 0);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
  border: 2px solid rgb(255, 255, 255);
  transform: scale(1.02);
}

.control-grid #hazard-btn {
  background: rgb(250, 204, 21);
}

.control-grid #hazard-btn.active {
  opacity: 1;
  background-color: rgb(253, 224, 71);
  color: rgb(0, 0, 0);
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.4);
  border: 2px solid rgb(255, 255, 255);
  transform: scale(1.02);
}

.control-grid #danger-btn {
  background: rgb(220, 38, 38);
}

.control-grid #danger-btn.active {
  opacity: 1;
  background-color: rgb(239, 68, 68);
  color: rgb(0, 0, 0);
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
  border: 2px solid rgb(255, 255, 255);
  transform: scale(1.02);
}

.control-grid #finish-btn {
  background: rgb(32, 45, 61);
}

.finish-race-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
  z-index: 9999;

  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.finish-race-overlay.hidden {
    display: none !important;
}

#finish-race {
  background: rgb(20, 28, 40);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);

  width: 90%;
  max-width: 600px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: center;
}

#finish-race.finish-grid {
  background: rgb(20, 28, 40);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);

  width: 90% !important;
  max-width: 400px;
  height: auto;
  min-height: fit-content;

  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

  grid-template-columns: none;
  grid-template-rows: none;
}

.finish-confirm-btn {
    background: rgb(255, 91, 46) !important;
    color: rgb(255, 255, 255) !important;
    padding: 1.5rem !important;
    font-size: 1.4rem !important;
    order: 1;
}

.btn-go-back {
    background: rgb(26, 37, 51) !important;
    color: rgb(211, 221, 232) !important;
    order: 2;
}

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

@media (min-width: 600px) {
  .control-grid {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .btn-finish {
    grid-column: span 3;
  }
}

@media (max-width: 720px) {
  body[data-role="race-control"] {
    padding: 0;
  }

  .race-control-page {
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
  }

  .race-view-section {
    padding: 1rem;
    gap: 1rem;
  }
}
