:root {
  --ink: #14213d;
  --cream: #fff8ec;
  --gold: #f5b942;
  --green: #0f8b6f;
  --coral: #f26659;
  --glass: rgba(255, 255, 255, 0.84);
  --line: rgba(255, 255, 255, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #101827;
}

button {
  min-height: 2.65rem;
  border: 0;
  border-radius: 0.65rem;
  padding: 0.65rem 0.95rem;
  color: white;
  background: linear-gradient(135deg, var(--coral), #d64045);
  box-shadow: 0 12px 28px rgba(20, 33, 61, 0.22);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.runner-shell {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#runnerCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#runnerCanvas.hit {
  animation: hitShake 0.22s linear;
}

.hud {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.72rem 0.85rem;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  box-shadow: 0 18px 45px rgba(20, 33, 61, 0.18);
  backdrop-filter: blur(16px);
}

.hud strong {
  font-weight: 950;
}

.hud span {
  font-size: 0.92rem;
  font-weight: 750;
}

.top-left {
  top: 1rem;
  left: 1rem;
  flex-direction: column;
  align-items: flex-start;
}

.top-right {
  top: 1rem;
  right: 1rem;
}

.bottom-left {
  bottom: 1rem;
  left: 1rem;
  max-width: min(34rem, calc(100% - 2rem));
}

.bottom-right {
  right: 1rem;
  bottom: 1rem;
}

.bottom-right button {
  min-height: 2.35rem;
  padding: 0.52rem 0.75rem;
  color: var(--ink);
  background: white;
}

.mobile-controls {
  position: absolute;
  z-index: 5;
  right: 1rem;
  bottom: 5rem;
  display: none;
  grid-template-columns: repeat(2, minmax(5rem, 1fr));
  gap: 0.55rem;
}

.mobile-controls button {
  min-height: 3rem;
  background: rgba(20, 33, 61, 0.9);
}

.runner-controls {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, minmax(4.8rem, 1fr));
  gap: 0.55rem;
  width: min(28rem, calc(100% - 2rem));
  transform: translateX(-50%);
}

.runner-controls button {
  min-height: 3rem;
  padding: 0.5rem 0.7rem;
  color: white;
  background: rgba(20, 33, 61, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 26px rgba(20, 33, 61, 0.2);
}

.start-overlay,
.finish-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    linear-gradient(90deg, rgba(16, 24, 39, 0.83), rgba(16, 24, 39, 0.28)),
    url("5.png") center / cover;
}

.finish-overlay {
  background:
    linear-gradient(90deg, rgba(15, 139, 111, 0.84), rgba(20, 33, 61, 0.4)),
    url("10.png") center / cover;
}

.hidden {
  display: none;
}

.start-copy {
  width: min(42rem, 100%);
  margin-right: auto;
  padding-left: clamp(0rem, 4vw, 3rem);
  color: white;
}

.start-copy h1 {
  max-width: 11ch;
  margin: 0.1rem 0 0.85rem;
  font-size: clamp(3rem, 9vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.start-copy p {
  max-width: 36rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.6;
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 950;
  text-transform: uppercase;
}

.controls-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.1rem 0 1.35rem;
}

.controls-list span {
  min-height: 2rem;
  padding: 0.42rem 0.65rem;
  color: white;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  font-weight: 750;
}

.runner-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 12rem));
  gap: 0.75rem;
  margin: 1.1rem 0 0.6rem;
}

.runner-choice {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  min-height: 4.6rem;
  color: white;
  text-align: left;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: none;
}

.runner-choice.active {
  border-color: var(--gold);
  background: rgba(245, 185, 66, 0.24);
}

.mini-avatar {
  position: relative;
  display: inline-block;
  width: 2.7rem;
  height: 3.2rem;
  border-radius: 999px 999px 0.8rem 0.8rem;
  background: linear-gradient(160deg, var(--coral), #7b1e48);
}

.mini-avatar.male {
  background: linear-gradient(160deg, var(--green), #1552a3);
}

.mini-avatar::before {
  position: absolute;
  top: -0.55rem;
  left: 50%;
  width: 1.55rem;
  height: 1.55rem;
  background: #6f3f2a;
  border-radius: 50%;
  content: "";
  transform: translateX(-50%);
}

.mini-avatar::after {
  position: absolute;
  top: -0.78rem;
  left: 50%;
  width: 1.9rem;
  height: 0.8rem;
  background: #17100d;
  border-radius: 999px;
  content: "";
  transform: translateX(-50%);
}

dialog {
  width: min(44rem, calc(100% - 2rem));
  padding: 0;
  color: var(--ink);
  background: white;
  border: 0;
  border-radius: 0.9rem;
  box-shadow: 0 25px 70px rgba(20, 33, 61, 0.36);
}

dialog::backdrop {
  background: rgba(20, 33, 61, 0.62);
  backdrop-filter: blur(8px);
}

.quiz-card {
  padding: clamp(1rem, 4vw, 2rem);
}

.quiz-card h1 {
  margin: 0.3rem 0 1.2rem;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.quiz-options button {
  min-height: 4.3rem;
  color: var(--ink);
  background: #fff7df;
  border: 1px solid rgba(20, 33, 61, 0.14);
  box-shadow: none;
}

#quizFeedback {
  color: #5f6b7a;
  font-weight: 700;
}

@keyframes hitShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(7px);
  }
  75% {
    transform: translateX(-4px);
  }
}

@media (max-width: 760px) {
  .top-right {
    top: 5.1rem;
    left: 1rem;
    right: auto;
  }

  .bottom-right {
    display: none;
  }

  .mobile-controls {
    display: none;
  }

  .runner-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    bottom: 0.75rem;
  }

  .quiz-options {
    grid-template-columns: 1fr;
  }

  .start-copy {
    padding-left: 0;
  }

  .hud {
    max-width: calc(100% - 2rem);
  }

  .runner-picker {
    grid-template-columns: 1fr;
  }
}
