*,
*::after,
*::before {
  box-sizing: border-box;
  margin: 0;
}
html {
  font-size: 1.5rem;
}

body {
  display: grid;
  grid-template-rows: max-content 1fr max-content;
  height: 100dvh;
  background-color: #ccc;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  max-width: 800px;
  min-width: 300px;
  margin: 0 auto;
}

dialog {
  max-width: 800px;
}

header,
main,
footer {
  width: 100%;
  padding: 0.25rem 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 350px;
}

header {
  padding: 0.5rem 0.5rem 0.25rem 0.5rem;
  height: 2.5rem;
  font-size: 1.1rem;
  font-weight: bold;
  position: sticky;
  top: 0px;
  background-color: inherit;
  box-shadow: 0px 3px 3px #ccc;
  z-index: 100;
}

#backButton {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  text-decoration: none;
  color: #000;
  background: #bbb;
  aspect-ratio: 1;
  padding-inline: 0;
}

#editmodeButton {
  color: #000;
  background: #bbb;
  font-size: 0.5rem;
}

#resetButton, #stopButton {
  color: #fff;
  background: #c00;
  font-size: 0.5rem;
}

#buttonContainer,
.dialogControls {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

#fullscreenButton,
#closeButton {
  color: #000;
  background: #bbb;
  font-size: 0.75rem;
  min-height: 1.5rem;
  min-width: 1.5rem;
}

#fullscreenButton:focus,
#closeButton:focus {
  outline: none;
}

footer {
  height: 2.5rem;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  bottom: 0px;
  background-color: inherit;
  box-shadow: 0px -3px 3px #ccc;
}

main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: start;
}

.name {
  text-align: center;
}

.time,
.distance {
  font-size: 0.75em;
  text-wrap: nowrap;
}

.largetime {
  font-size: 1.5em;
}

#timer {
}

button,
.button {
  min-height: 2rem;
  border-radius: 0.5rem;
  border: none;
  color: #fff;
  font-size: inherit;
  cursor: pointer;
  background: linear-gradient(135deg, #1100ff, #0104b8);
  box-shadow: inset -5px -5px 5px rgba(0, 0, 0, 0.5), inset 5px 5px 5px rgba(255, 255, 255, 0.5),
    0px 0px 5px rgba(0, 0, 0, 0.5);
  padding-inline: 0.5em;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  user-select: none;
}

button:active,
.button:active,
.contest:active,
.laneButton:active,
.laneButtonCheckbox:checked + .laneButton {
  box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.3), inset -5px -5px 5px rgba(255, 255, 255, 0.3),
    0px 0px 10px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, #2facff, #0166b8);
}

#deleteButton {
  background: linear-gradient(135deg, #ff1100, #b80000);
  aspect-ratio: 1;
}

#minuteSpan {
  position: absolute;
  right: 40px;
  pointer-events: none;
}

#addContestButton,
#addContestantButton,
#addPresetButton,
.addContestantButton {
  aspect-ratio: 1;
  padding-bottom: 5px;
  padding-inline: 0px;
  margin-left: auto;
}
.addContestantButton {
grid-column: 3;
}
#continueButton {
  margin-left: auto;
}

.contestant {
  position: relative;
  padding:0.5em 0.25em;
  min-height: 5rem;
}

.active {
  background: #390 !important; /* Change hue to green instantly */
  transition: none !important; /* Disable transition when clicked */
}

.contestant:not(.active) {
  background: #1100ff; /* Transition back to blue */
  transition: background-color 10s cubic-bezier(0.17, 0.16, 0.99, 0.1); /* Re-enable transition after click */
}

.contest {
  grid-column: 1/3;
  min-height: 2em;
  padding: 0.25em 0;
  position: relative;
  overflow: hidden;
}

.contest > span {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.editPreset,
.editContestant {
  position: absolute;
  right: 0;
  top: 0;
  padding: 0.75rem 1rem;
  font-size: 0.5rem;
  color: #000;
  height: auto;
  background: rgb(238, 226, 62);
  box-shadow: inset -5px -5px 5px rgba(0, 0, 0, 0.5), inset 5px 5px 5px rgba(255, 255, 255, 0.5), 0px 0px 5px rgba(0, 0, 0, 0.5);
  border-radius: 0.5rem;
  font-weight:bold;
  max-height: 100%;
  display: flex;
  place-items: center;
}

.editPreset:active,
.editContestant:active {
  filter: brightness(150%);
  backdrop-filter: brightness(150%);
  box-shadow: inset 0 0 5px #000, 0 0 5px #000;
}

section {
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

.sectionLabel {
  grid-column: 1/3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #000;
  margin-bottom: 0.5rem;
}

.sectionControls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sectionCheckbox {
  height: 1rem;
  width: 1rem;
}

.sectionContent {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto;
  gap: 0.5rem;
  place-items: stretch;
  margin-bottom: 0.5rem;
  flex: 1;
  font-size:clamp(0.7em, 4vw, 1em);
}

.sectionContainer {
  display:flex;
  align-items: flex-start;
  gap: 0.5rem
}

/* 
.sectionContent .contest,
.sectionContent .contestant,
.sectionContent .laneButton {
  background: linear-gradient(135deg, #3d2fff, #0104b8);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  border-radius: 10px;
  box-shadow: inset -5px -5px 5px rgba(0, 0, 0, 0.3), inset 5px 5px 5px rgba(255, 255, 255, 0.3),
    0px 0px 10px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.sectionContent .contestant:active,
.sectionContent .contest:active,
.sectionContent .laneButtonCheckbox:checked + .laneButton {
  box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.3), inset -5px -5px 5px rgba(255, 255, 255, 0.3),
    0px 0px 10px rgba(0, 0, 0, 0.5);
  background: linear-gradient(135deg, #2facff, #0166b8);
} */

dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  background: #ccc;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5);
  width: 100vw;
  padding: 0.5rem;
  min-width: 350px;
  font-size: clamp(0.7em, 4vw, 1em);
}

dialog > div {
  display: flex;
  flex-direction: column;
}

.flex {
  display: flex;
  justify-content: space-between;
  gap: 0.25rem;
}
.flex > * {
  margin-bottom: 0px;
}

dialog::backdrop {
  backdrop-filter: blur(5px);
}

dialog label {
  font-weight: bold;
}

dialog button {
  margin-bottom: 0.5em;
}

h1 {
  font-size: 1.2em;
}

hr {
  margin-top: 5px;
  margin-bottom: 0.5em;
}

input,
select {
  font-size: inherit;
  width: 100%;
}
dialog input,
dialog select {
  margin-bottom: 0.5em;
}

.hidden {
  display: none !important;
}

.small {
  font-size: 0.75em;
  font-weight: normal;
}

.expandcollapse {
  cursor: pointer;
  width: 3em;
  display: flex;
  justify-content: end;
  align-items: center;
  padding-inline: 0.5em;
}

.expandcollapse:after {
  content: "\25B4";
}

.collapsed > *:not(:first-child) {
  display: none;
}

.collapsed .expandcollapse:after {
  content: "\25BE";
}

.editModeCollapseOverride > *:not(:first-child){
  display:flex !important;
}

.laneButton {
  grid-column: 1/3;
}

.laneButtonCheckbox {
  display: none;
}

.h100 {
  height: 100%;
}

#timer,
#countdown {
  font-variant-numeric: tabular-nums;
}

#waitingForStart {
  background: url(loading.gif);
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  width: 3em;
  height: 1em;
}

.loading {
  background: #999;
  color: transparent;
  position: relative;
}

.loading:before {
  content: "";
  display: block;
  background: url(loading.gif);
  background-position: center;
  background-size: 1.25em;
  background-repeat: no-repeat;
  position: absolute;
  inset: 0;
}

#loadMoreButton {
  background: #999;
}

.alreadySelected {
  background: rgb(163, 2, 2);
}

.errorMessage {
  color: red;
  font-family: monospace;
}

#tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

#selectableNames {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  cursor:pointer;
  max-height:50vh;
  overflow-y: scroll;
}

.tag {
  display: flex;
  align-items: center;
  border: 2px solid #666;
  background-color: #999;
  border-radius: 100vw;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  margin-bottom: 0.25rem;
}



.addTag, .removeTag {
  display: flex;
  cursor: pointer;
  width: 1.5em;
  height:  1.5em;
  border-radius: 100vw;
  background-color: #666;
  color: #000;
  font-size: 0.75em;
  text-align: center;
  margin-right:-0.5em;
  margin-left:0.25em;
  align-items: center;
  justify-content: center;
  line-height: 1em;
}

.removeTag {
  color: #b80000;
}


.removeTag:hover, .addTag:hover, .tag:hover > .addTag {
  background-color: #ccc;
}

.expandcollapse > input {
  height: 1em;
}

#timer,
#countdown,
#waitingForStart,
#endMessage {
  display: none;
}

#canvasContainer {
  background-color: #ccc;
  grid-column-start: 1;
  grid-column-end: span 2;
  position: relative;
}

#fullscreenCloseButton {
  position: absolute;
  top: 1em;
  right: 1em;
  font-size: 0.75rem;
  min-height: 1.5rem;
  min-width: 1.5rem;
  cursor: pointer;
  z-index: 1000;
  color: #000;
  background: #bbb;
}

#userSection .sectionContent {
  grid-template-columns: 1fr;
}

#userSection .contestant{
  height:unset;
  min-height:unset;
  align-items: flex-start;
  padding:0.25em 1em;
  align-items: baseline;
}
#userSection .small {
  padding-inline:0.5em
}

#userSection .editContestant{
  position: absolute;
  right: 0;
  top: 0;
  bottom:0;
  padding: 0 1rem;
  font-size: 0.5rem;
  color: #000;
  background: rgb(238, 226, 62);
  box-shadow: inset -5px -5px 5px rgba(0, 0, 0, 0.5), inset 5px 5px 5px rgba(255, 255, 255, 0.5), 0px 0px 5px rgba(0, 0, 0, 0.5);
  border-radius: 0.5rem;
  font-weight: bold;
  display:flex;
  place-items: center;
}


#contestsTable { 
  border:1px solid black;
  border-collapse: collapse;
  overflow-x: scroll;
}

#contestsTable th, #contestsTable td { 
  border:1px solid black;
}

#contestsTable button {
  width: 100%;
  height: 100%;
  min-height: unset;
  margin: 0;
  background: #c00;
}
#contestsTable td:first-of-type {
  min-width:12ch;
  overflow:hidden;
}

#contestsTable td {
  padding-inline:0.25em;
}


#stopContestDialog label {
  cursor:pointer;
  display:flex;
  align-items:center;

}

#stopContestDialog input[type="radio"] {
  display: none;
}

#stopContestDialog div {
  gap:0.5em;
}


#stopContestDialog label.button {
  font-weight: unset;
}
#stopContestDialog input[type="radio"]:checked + label {
  background: rgb(238, 226, 62);;
  color: black;
}

#contestantDialog #inputContainer{
  display:flex;
  gap:0.5em;
}