body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  row-gap: 24px;
  padding: 20px;
  padding-top: calc(32px + env(safe-area-inset-top));
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  transition: background-color 0.6s ease;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 39px;
  width: 100%;
  max-width: 100%;
  flex-shrink: 0;
}

#target-label {
  color: #fff;
  text-align: center;
  min-height: 140px;
  font-family: 'Cubic 11', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  width: 100%;
}

#home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#date-display {
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 3px;
  opacity: 0.5;
  font-family: 'Handjet', sans-serif;
  text-align: center;
}

#title-display {
  font-size: 80px;
  letter-spacing: 6px;
  text-align: center;
  text-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
}

#game-header {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  padding: 0 16px;
}

#round-indicator {
  font-size: 17px;
  letter-spacing: 3px;
  opacity: 0.5;
  margin-bottom: 12px;
}

#station-name {
  width: 100%;
  max-width: calc(100vw - 32px);
  height: auto;
  margin: 0 auto;
  padding: 0 16px;
  font-size: clamp(1.25rem, 4.5vw, 2rem);
  word-break: break-word;
  line-height: 1.1;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#map-wrapper {
  width: 100%;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.35s ease;
}

#map {
  display: flex;
  flex-wrap: wrap;
  line-height: 0;
  gap: 1.5px;
  transform-origin: top left;
  opacity: 0;
  transition: opacity 0.6s ease;
  filter: url(#pixelShadow);
}

.loaded #map {
  opacity: 1;
}

.game-active #map {
  opacity: 1;
}

#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  height: 160px;
  flex-shrink: 0;
}

  #difficulty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
}

#diff-header {
  font-size: 12px;
  color: #fff;
  opacity: 0.4;
  letter-spacing: 1px;
}

#diff-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

#diff-prev {
  margin-right: 8px;
}

#diff-next {
  margin-left: 8px;
}

#diff-label {
  font-family: 'Handjet', 'Cubic 11', sans-serif;
  font-size: 18px;
  letter-spacing: 3px;
  color: #fff;
  opacity: 0.8;
}

#diff-sub {
  font-size: 11px;
  color: #fff;
  opacity: 0.35;
  letter-spacing: 1px;
  min-width: 48px;
  text-align: center;
}

#dpad {
  display: none;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 0;
}

#btn-up     { grid-column: 2; grid-row: 1; }
#btn-left   { grid-column: 1; grid-row: 2; }
#btn-right  { grid-column: 3; grid-row: 2; }
#btn-down   { grid-column: 2; grid-row: 3; }

@media (min-width: 768px) {
  body {
    display: grid;
    grid-template-columns: 1fr 2fr;
    justify-items: center;
    min-height: 100vh;
    row-gap: 0;
    column-gap: 0;
    padding: 40px;
  }

  #game-container {
    display: contents;
  }

  #target-label {
    grid-column: 1;
    grid-row: 1 / 7;
    align-self: center;
    width: 100%;
    height: auto;
    min-height: 0;
    margin-top: -150px;
  }

  #home-header {
    padding-top: 100px;
  }

  .game-active #game-header {
    padding-top: 100px;
  }

  #difficulty {
    grid-column: 1;
    grid-row: 7;
    margin: -150px 0 0 0;
  }

  #controls {
    grid-column: 1;
    grid-row: 8;
    margin-top: -130px;
    height: auto;
    width: 100%;
  }

  #station-name {
    white-space: normal;
    word-break: break-word;
    font-size: clamp(1.75rem, 4.2vw, 3.15rem);
    letter-spacing: normal;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: min(80vw, 800px);
  }

  #map-wrapper {
    grid-column: 2;
    grid-row: 1 / 9;
    align-self: center;
    justify-self: center;
  }

  #next-round-row {
    grid-column: 1;
    grid-row: 9;
    justify-self: center;
    align-self: center;
  }

  #round-results {
    grid-column: 1;
    grid-row: 10;
    justify-self: center;
    align-self: start;
    padding-top: 16px;
  }

  #dpad {
    display: none;
  }

}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loaded #map {
  animation: fadeInMap 0.5s ease 0.3s both;
}

.loaded #home-header {
  animation: fadeInUp 0.4s ease 0.7s both;
}

.loaded #difficulty {
  animation: fadeInUp 0.4s ease 1.1s both;
}

#btn-start {
  opacity: 0;
  transition: opacity 0.4s ease 1.1s;
}

.loaded #btn-start {
  opacity: 1;
}
