/* Start screen. */
.tr-start {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 1em max(24px, env(safe-area-inset-right, 0px))
    max(40px, calc(env(safe-area-inset-bottom, 0px) + 24px))
    max(24px, env(safe-area-inset-left, 0px));
  overflow-y: auto;
}

.tr-logo {
  display: flex;
  justify-content: center;
  gap: 0.25em;
  margin: 0 0 0.6em !important;
}

.tr-logo span {
  display: grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 0.3em;
  color: #0b1220;
  font-size: 1.4em;
  font-weight: 800;
  box-shadow: inset 0 0.12em 0 rgba(255, 255, 255, 0.4),
    inset 0 -0.12em 0 rgba(0, 0, 0, 0.25);
}

.tr-logo [data-type="I"] {
  background: #9ddbe3;
}

.tr-logo [data-type="L"] {
  background: #f5c79a;
}

.tr-logo [data-type="T"] {
  background: #c9b0ec;
}

.tr-logo [data-type="S"] {
  background: #acdcb4;
}

.tr-logo [data-type="Z"] {
  background: #f1aaaa;
}

.tr-logo [data-type="J"] {
  background: #a8baf0;
}

.tr-pitch {
  color: #b4bfdc;
}

/* Start level slider (0-9, as on the Game Boy) and the ghost checkbox. */
.tr-setup {
  width: min(100%, 15em);
  margin: 0.8em auto 0.2em;
}

.tr-setup-title {
  margin: 0 0 0.2em !important;
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8f9cc4;
}

.tr-range {
  display: block;
  width: 100%;
  margin: 0;
  accent-color: #a8baf0;
  cursor: pointer;
}

.tr-range-ends {
  display: flex;
  justify-content: space-between;
  font-size: 0.8em;
  color: #93a0c4;
}

.tr-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin-top: 0.5em;
  color: #c7d2f0;
  cursor: pointer;
}

.tr-check input {
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  accent-color: #a8baf0;
  cursor: pointer;
}

/* The Game Boy rocket (rocket.js): shakes on its pad, then lifts off. Its
   size grows with the score tier. 3.6 s, tap to skip. */
.tr-rocket {
  --tr-rocket-size: 5rem;
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2em 1em 3rem;
  background: linear-gradient(180deg, #0b1220 0%, #1f2a4d 75%, #2a3358 100%);
  cursor: pointer;
}

.tr-rocket[data-tier="2"] {
  --tr-rocket-size: 6.5rem;
}

.tr-rocket[data-tier="3"] {
  --tr-rocket-size: 8rem;
}

.tr-rocket[data-tier="4"] {
  --tr-rocket-size: 9.5rem;
}

.tr-rocket::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3rem;
  background: #3a4a6e;
}

.tr-rocket-text {
  margin: 0;
  font-size: 1.8em;
  font-weight: 800;
  color: #f3e09a;
  animation: tr-fade 0.6s ease-out both;
}

.tr-rocket-ship {
  position: relative;
  z-index: 1;
  width: var(--tr-rocket-size);
  animation: tr-liftoff 3.6s ease-in forwards;
}

.tr-flame {
  transform-box: fill-box;
  transform-origin: top center;
  animation: tr-flame 0.12s linear infinite alternate;
}

.tr-rocket-smoke {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  width: calc(var(--tr-rocket-size) * 2.4);
  height: calc(var(--tr-rocket-size) * 0.8);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(238, 242, 251, 0.75), transparent);
  opacity: 0;
  animation: tr-smoke 3.6s ease-out forwards;
}

@keyframes tr-liftoff {
  0%,
  40% {
    transform: translateY(0);
  }
  5%,
  15%,
  25%,
  35% {
    transform: translateX(-0.06rem);
  }
  10%,
  20%,
  30% {
    transform: translateX(0.06rem);
  }
  100% {
    transform: translateY(-130dvh);
  }
}

@keyframes tr-flame {
  from {
    transform: scaleY(0.75);
  }
  to {
    transform: scaleY(1.15);
  }
}

@keyframes tr-smoke {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.3);
  }
  40% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(2.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tr-rocket-ship,
  .tr-flame,
  .tr-rocket-smoke {
    animation: none;
  }
}

/* Desktop and TV: 3% from the edges (overscan). */
@media (min-width: 960px) and (min-height: 500px) {
  .tr-start {
    padding: 2dvh max(3vw, env(safe-area-inset-right, 0px)) max(40px, 4dvh)
      max(3vw, env(safe-area-inset-left, 0px));
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .tr-start {
    padding-top: 0.5em;
  }

  /* Logo, best and Resume left; level, ghost and Play right: fits ~250px. */
  .tr-start .tr-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-auto-flow: dense;
    align-content: center;
    align-items: center;
    column-gap: 1.2em;
    width: min(100%, 36em);
  }

  .tr-start .tr-card > * {
    grid-column: 1;
  }

  .tr-start .tr-setup,
  .tr-start [data-id="tetris-play-button"] {
    grid-column: 2;
  }

  .tr-start .tr-setup {
    grid-row: 1 / span 2;
    margin: 0 auto;
  }

  .tr-logo span {
    font-size: 1em;
  }

  .tr-pitch {
    display: none;
  }
}
