* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: none;
  font-family: Roboto, serif;
}

.player, .btn {
  /* Disable highlighting text of buttons */
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none; /* Safari */
  -khtml-user-select: none; /* Konqueror HTML */
  -moz-user-select: none; /* Old versions of Firefox */
  -ms-user-select: none; /* Internet Explorer/Edge */
  user-select: none; /* Standard syntax */
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100dvh;
  background-color: #222;
  padding: 15px;
}

.scoreboard {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  margin: 10px 0;
  gap: 20px;
  width: 100%;

  .player {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 20px;
    font-weight: 500;
    text-shadow: 0 0 5px #11111166;
    transition: opacity 600ms ease;

    .player-name {
      text-align: center;
      font-size: 18px;
      line-height: 1.15;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      line-clamp: 2;
      overflow: hidden; 
    }

    .player-score {
      font-size: 42px;
      font-weight: 700;
      line-height: 1;
    }
  }
}

#disk-container {
  position: relative;
}

canvas {
  margin: 10px 0;
}

#pending-score {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #f5f5f5;
  font-size: 70px;
  text-shadow: 0 0 6px #777;
  font-weight: 500;
}

#controls {
  margin: auto 0 10px;
  display: grid;
  grid-template-columns: max-content max-content;
  gap: 15px;

  .btn {
    --padding-y: 15px;
    padding: var(--padding-y) 25px;
    font-size: 18px;
    font-weight: 500;
    border: none;
    border-radius: calc(0.75rem + var(--padding-y));
    background-color: #444;
    color: #f5f5f5;
    cursor: pointer;
    box-shadow: 0 0 5px #000;

    i {
      margin-right: 8px;
    }
  }
}

body {
  --dialog-transition-duration: 0.3s;
  --dialog-starting-scale: 0.95;
  --dialog-starting-translate-y: 30px;
}

dialog {
  border: none;
  border-radius: 10px;
  padding: 20px;
  background-color: #333;
  box-shadow: 0 0 10px #000;
  color: #f5f5f5;
  margin: auto;
  width: 75%;

  /* animation */
  opacity: 0;
  transform: scale(var(--dialog-starting-scale)) translateY(var(--dialog-starting-translate-y));
  transition: 
    opacity var(--dialog-transition-duration) ease-out, 
    transform var(--dialog-transition-duration) ease-out, 
    overlay var(--dialog-transition-duration) ease-out allow-discrete,
    display var(--dialog-transition-duration) ease-out allow-discrete;

  &[open] {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  h2 {
    margin-bottom: 15px;
    font-weight: 600;
  }

  .close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: #f5f5f5;
    font-size: 20px;
    cursor: pointer;
  }

  input[type="text"] {
    width: 100%;
    padding: 10px 10px 5px;
    font-size: 18px;
    border: none;
    border-bottom: 2px solid #f5f5f5;
    background: transparent;
    color: #f5f5f5;
    margin-bottom: 15px;
  }

  .dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
  }

  .btn {
    --padding-y: 10px;
    margin-top: 15px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    background-color: #444;
    color: #f5f5f5;
    cursor: pointer;
    box-shadow: 0 0 5px #000;
    padding: var(--padding-y) 22px;
    border-radius: calc(0.75rem + var(--padding-y));

    i {
      margin-right: 8px;
    }
  }

  &::backdrop {
    background: #00000077;
    opacity: 0;
    transition: opacity var(--dialog-transition-duration) ease-out;
  }

  &[open]::backdrop {
    opacity: 1;
  }
}

@starting-style {
  dialog[open] {
    opacity: 0;
    transform: scale(var(--dialog-starting-scale)) translateY(var(--dialog-starting-translate-y));
  }
}

#add-player-modal, #edit-player-modal, #confirm-delete-modal {
  margin-top: 40%;
}

#history-modal * {
  touch-action: pan-y;
  /* -webkit-overflow-scrolling: touch; */
}

#history-entries-list {
  max-height: 400px;
  overflow-y: auto;
}

.history-entry {
  display: flex;
  justify-content: space-between;
  padding: 12px 8px;
  
  &:not(:last-child) {
    border-bottom: 1px solid #555;
  }

  .history-description {
    font-size: 16px;
  }

  .history-timestamp {
    font-size: 14px;
    white-space: nowrap;
  }
}

#past-games-modal * {
  touch-action: pan-y;
  /* -webkit-overflow-scrolling: touch; */
  --expand-collapse-duration: 600ms;
}

#past-game-entries-list {
  max-height: 400px;
  overflow-y: auto;
}

:root {
  interpolate-size: allow-keywords;
}

.no-games {
  padding: 15px 5px;
  font-size: 18px;
}

#past-games-modal:has(.no-games) .dialog-buttons {
  display: none;
}

.past-game-entry:not(.no-games) {
  border-top: 1px solid #555;
  border-bottom: 1px solid #555;
  display: grid;
  grid-template-columns: 1fr max-content;
  position: relative;

  details {
    overflow: hidden;

    summary {
      display: grid;
      grid-template-columns: 25px 1fr;
      grid-template-rows: min-content 1fr;
      row-gap: 4px;
      padding: 10px;

      &::marker, &::-webkit-details-marker { 
        display:none; 
      }

      i {
        grid-row: span 2;
        align-self: center;
        justify-self: center;
        margin-right: 8px;
        transition: rotate var(--expand-collapse-duration) ease;
      }
    }

    &[open] summary i {
      rotate: 90deg;
    }

    .past-game-content {
      border-top: 1px solid #555;
    }

    .past-game-note-input {
      margin: 5px 10px 0;
      width: calc(100% - 20px);
    }

    .past-game-scores-list {
      display: grid;
      grid-template-columns: max-content 1fr;
      column-gap: 12px;
      row-gap: 6px;
      overflow: hidden;
      font-size: 1.1rem;
      padding: 15px 15px 5px;
    }

    &::details-content {
      block-size: 0;
      transition:
        block-size var(--expand-collapse-duration) ease,
        content-visibility var(--expand-collapse-duration) ease;
      transition-behavior: allow-discrete;
    }

    &[open]::details-content {
      block-size: auto;
    }
  }

  .dialog-buttons {
    padding-bottom: 15px;
  }
}



#confirm-past-game-delete-modal {
  .message {
    margin-bottom: 15px;
  }
  .game-details {
    margin-bottom: 15px;

    &.empty {
      display: none;
    }
  }
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 12px 8px;
  font-size: 20px;

  &:not(:last-child) {
    border-bottom: 1px solid #555;
  }

  .leaderboard-rank {
    display: grid;
    place-items: center;
    font-size: 16px;
    width: 30px;
  }

  .leaderboard-name {
    flex-grow: 1;
    text-align: left;
    margin-left: 10px;
    font-weight: 500;
  }

  .leaderboard-score {
    width: 60px;
    text-align: right;
  }
}

@keyframes draw-ring {
  to {
    stroke-dashoffset: 0;
  }
}

.ring {
  --path-length: 0;
  --duration: 600ms;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 5px)) rotate(-90deg) scaleX(-1);
  pointer-events: none;
  stroke-dashoffset: var(--path-length);
  stroke-dasharray: var(--path-length);
  opacity: 0.3;
  animation: draw-ring var(--duration) linear forwards;
}

@keyframes fill-button {
  95% {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
  }
  to {
    width: 100%;
    border-radius: inherit;
  }
}

#reset-game-modal .btn {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.btn-fill {
  --duration: 600ms;
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background-color: rgba(94, 17, 17, 0.4);
  border-radius: inherit;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.btn-fill.fill {
  animation: fill-button var(--duration) ease-in-out forwards;
}

.to-front {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.weak {
  color: #aaa !important;
}

.btn-danger {
  background-color: #a33 !important;
  /* background-color: linear-gradient(to right, #7d2424, #a33 25%, #a33 100%) !important; */
}

footer {
  color: #f5f5f5;
  margin: auto 0 0;

  a {
    color: #f5f5f5;
  }
}