@import url("https://fonts.googleapis.com/css?family=Press+Start+2P");

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "Press Start 2P", cursive;
  font-size: 2em;
  color: #e2e8f0;
  background: radial-gradient(circle at 20% 20%, #0284c7 0%, rgba(2, 132, 199, 0) 45%),
    radial-gradient(circle at 80% 30%, #22c55e 0%, rgba(34, 197, 94, 0) 50%),
    #0b1220;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.game-container {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.9), rgba(15, 23, 42, 0.95));
}

.below {
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.leaderboard {
  width: min(520px, 92vw);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.35);
}

#controls svg path {
  fill: #ffffff;
}

.leaderboard-title {
  font-weight: 900;
  font-size: 14px;
  color: #f8fafc;
  margin-bottom: 8px;
}

.leaderboard ol {
  margin: 0;
  padding-left: 20px;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.6;
}

.leaderboard li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.leaderboard .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0b1220;
  border: 1px solid rgba(226, 232, 240, 0.2);
  object-fit: cover;
}

.leaderboard .name {
  font-weight: 800;
  color: #f8fafc;
}

.leaderboard .score {
  margin-left: auto;
  color: #facc15;
  font-weight: 900;
}

#tedDashStage {
  position: absolute;
  inset: 0;
}

#tedDashStage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.modal {
  visibility: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.modal.active {
  visibility: visible;
  opacity: 1;
}

.modal-content {
  background-color: #fff;
  color: #0f172a;
  font-size: small;
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: min(92%, 600px);
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 20px;
}

.modal-content ul {
  text-align: left;
  padding: 20px;
  list-style: disc;
}

.modal-content ul li {
  margin: 8px 0;
  margin-top: 10px;
}

#close-modal {
  background-color: #ffffff;
  color: #0f172a;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Press Start 2P", cursive;
  font-size: 16px;
}

#close-modal:hover {
  background-color: #e2e8f0;
}

button {
  outline: none;
  cursor: pointer;
  border: none;
  box-shadow: 3px 5px 0px 0px rgba(0, 0, 0, 0.75);
}

#counter {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #0f172a;
  font-weight: bold;
  background-color: #f8fafc;
  padding: 18px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
  z-index: 5;
}

#end {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  z-index: 6;
}

#end button {
  background-color: #ffffff;
  color: #0f172a;
  padding: 20px 50px 20px 50px;
  font-family: inherit;
  font-size: inherit;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#controls {
  position: absolute;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 4;
  pointer-events: none;
  padding-bottom: 18px;
}

#controls div {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  grid-column-gap: 10px;
  grid-row-gap: 10px;
  margin-bottom: 20px;
  pointer-events: auto;
}

#controls button {
  width: 100%;
  height: 100%;
  background-color: #1d4ed8;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.35);
}

#controls button:first-of-type {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

#controls #left {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

#controls #right {
  grid-column: 3 / 4;
  grid-row: 2 / 3;
}

#controls #backward {
  grid-column: 2 / 3;
  grid-row: 3 / 4;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
  pointer-events: none;
}

.hud .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(226, 232, 240, 0.18);
  color: #f8fafc;
  font-size: 14px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
}

.hud .pill img {
  width: 20px;
  height: 20px;
  display: block;
}

.hud .pill.bucks {
  background: rgba(14, 116, 144, 0.72);
  border-color: rgba(56, 189, 248, 0.35);
}

.hud .delta {
  min-height: 18px;
  font-size: 13px;
  font-weight: 900;
  color: #f8fafc;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
}

.hud .delta.pos {
  color: #facc15;
}

.hud .delta.bucks {
  color: #38bdf8;
}

.leaderboard-btn {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 7;
  padding: 10px 14px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.35);
}

#tedDashLeaderboardModal .modal-content {
  max-width: 520px;
}

#tedDashLeaderboardModal ol {
  margin: 0;
  padding-left: 20px;
  text-align: left;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.6;
}

#tedDashLeaderboardModal li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

#tedDashLeaderboardModal .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

#tedDashLeaderboardModal .name {
  font-weight: 800;
}

#tedDashLeaderboardModal .score {
  margin-left: auto;
  font-weight: 900;
  color: #0ea5e9;
}

body.free-mode .hud {
  display: none !important;
}

#controls button:first-of-type {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

@media (max-width: 600px) {
    .leaderboard-btn {
      bottom: 190px;
      left: 16px;
    }
  html,
  body {
    font-size: 1.1em;
    height: 100dvh;
    overflow: hidden;
  }

  .below {
    display: none;
  }

  #counter {
    padding: 12px;
    top: 10px;
    right: 10px;
  }

  #controls {
    align-items: flex-end;
    padding-bottom: 22px;
  }

  #controls div {
    position: relative;
    width: 180px;
    height: 180px;
    margin-bottom: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(226, 232, 240, 0.2);
    display: block;
  }

  #controls button {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
  }

  #controls #forward {
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  #controls #backward {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
  }

  #controls #left {
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
  }

  #controls #right {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }
}
