.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-width: 0;
  background: #08051d;
}
.hud {
  display: flex;
  gap: 42px;
  align-items: center;
  min-height: 82px;
  padding: 12px 24px;
  background: #0b0622;
  border-bottom: 1px solid var(--line);
}
.hud > div {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-label {
  color: #aaa6c4;
  font-size: 0.75rem;
  line-height: 1.3;
  max-width: 70px;
}
.hud strong {
  font:
    2.4rem/1 Redaction,
    Georgia,
    serif;
  font-variant-numeric: tabular-nums;
}
.credits-stat strong {
  color: var(--lilac);
}
.hud .best-stat {
  margin-left: auto;
}
.hud .best-stat strong {
  font-size: 1.8rem;
}
.icon-button {
  font-size: 1.5rem;
  min-width: 44px;
}
.game-stage {
  position: relative;
  isolation: isolate;
  min-width: 0;
  min-height: 180px;
  overflow: hidden;
  background: var(--electric);
}
#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: pixelated;
}
.map-label {
  position: absolute;
  right: 18px;
  bottom: 14px;
  font: 0.6875rem monospace;
  letter-spacing: 0.12em;
  color: #d1cbff;
  pointer-events: none;
}
.welcome-card {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 350px;
  max-height: calc(100% - 32px);
  overflow: auto;
  background: #000114f5;
  border: 1px solid #c0baff66;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 5px 5px 0 #c0baff80;
  scrollbar-color: #c0baff #000114;
}
.welcome-player {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.welcome-player img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  image-rendering: pixelated;
}
.welcome-player span {
  font-size: 0.75rem;
  color: var(--lilac);
}
.welcome-card h1 {
  margin-bottom: 16px;
}
.welcome-card > p {
  font-size: 1rem;
  line-height: 1.5;
}
.reward-rule {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font: 0.875rem monospace;
  color: var(--lilac);
}
.welcome-card .small-copy {
  font-size: 0.875rem;
  margin-bottom: 18px;
}
.welcome-controls {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 12px;
}
.touch-hint {
  display: none;
}
.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  background: #00011430;
  text-shadow: 0 3px 20px #000114;
}
.countdown > span {
  font:
    6rem/1 Redaction,
    Georgia,
    serif;
}
.countdown small {
  font-size: 1rem;
}
.pickup-notice {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  font-size: 0.875rem;
  color: #f2f2f2;
  background: #000114dd;
  border-radius: 5px;
  padding: 8px 12px;
  pointer-events: none;
  white-space: nowrap;
}
.pickup-notice:empty {
  display: none;
}
.control-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: #0b0622;
  min-height: 76px;
}
.desktop-instructions {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 0.875rem;
  flex-wrap: wrap;
}
.run-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.touch-controls {
  display: none;
}
.game-shell[data-boost="true"] .game-stage {
  box-shadow: inset 0 0 0 3px #c0baff;
}
.game-shell[data-boost="true"] .boost-button {
  background: #f2f2f2;
}
.game-shell[data-state="ready"] .control-dock {
  display: none;
}
.joystick {
  width: 122px;
  height: 122px;
  position: relative;
  border-radius: 50%;
  border: 1px solid #c0baff66;
  background: #c0baff12;
  touch-action: none;
  user-select: none;
  overscroll-behavior: contain;
}
.joystick > span:not(.thumb) {
  position: absolute;
  color: #c0baff;
  font: 16px monospace;
  pointer-events: none;
}
.joystick .north {
  top: 6px;
  left: 55px;
}
.joystick .south {
  bottom: 6px;
  left: 55px;
}
.joystick .west {
  left: 8px;
  top: 52px;
}
.joystick .east {
  right: 8px;
  top: 52px;
}
.joystick .thumb {
  position: absolute;
  width: 44px;
  height: 44px;
  left: 38px;
  top: 38px;
  border-radius: 50%;
  background: #c0baff;
  box-shadow: 0 4px 10px #0006;
  pointer-events: none;
}
.steering {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.control-toggle {
  font-size: 0.75rem;
  color: #c4bfd9;
  background: none;
  border: 0;
  min-height: 44px;
  padding: 8px;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 0;
  width: 132px;
  height: 132px;
}
.dpad button {
  width: 44px;
  height: 44px;
  background: #c0baff18;
  border: 1px solid #c0baff66;
  border-radius: 5px;
  font-size: 1.15rem;
  touch-action: none;
}
.dpad button:active {
  background: var(--lilac);
  color: var(--ink);
}
.dpad button[data-dir="up"] {
  grid-column: 2;
  grid-row: 1;
}
.dpad button[data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}
.dpad button[data-dir="down"] {
  grid-column: 2;
  grid-row: 3;
}
.dpad button[data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}
.boost-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #c0baff;
  color: #000114;
  border: 0;
  border-radius: 50%;
  width: 94px;
  height: 94px;
  font-size: 2rem;
  line-height: 1;
  touch-action: none;
  user-select: none;
  flex-shrink: 0;
}
.boost-button span {
  font-size: 0.75rem;
  margin-top: 8px;
}
@media (max-width: 767px), (pointer: coarse) {
  .hud {
    padding: 10px 14px;
    gap: 20px;
    min-height: 76px;
  }
  .hud > div {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 4px;
  }
  .stat-label {
    max-width: none;
    font-size: 0.6875rem;
  }
  .hud strong {
    font-size: 2rem;
  }
  .hud .best-stat strong {
    font-size: 1.65rem;
  }
  .hud .best-stat {
    margin-left: auto;
  }
  .hud .icon-button {
    margin-left: 0;
    padding: 6px;
  }
  .control-dock {
    padding: 8px 16px;
    gap: 8px;
    position: relative;
    min-height: 182px;
  }
  .desktop-instructions {
    display: none;
  }
  .touch-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    width: 100%;
    max-width: 370px;
  }
  .run-actions {
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
  }
  .run-actions button {
    font-size: 0.75rem;
    padding: 8px;
  }
  .welcome-card {
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 32px);
    max-width: 355px;
    padding: 20px;
  }
  .welcome-card h1 {
    font-size: 2.6rem;
  }
  .welcome-player {
    margin-bottom: 10px;
  }
  .welcome-card h1 {
    margin-bottom: 12px;
  }
  .welcome-card .reward-rule {
    margin: 12px 0;
  }
  .touch-hint {
    display: block;
  }
  .desktop-hint {
    display: none;
  }
  .map-label {
    display: none;
  }
}
@media (max-width: 420px) {
  .run-actions {
    position: absolute;
    right: 14px;
    bottom: 8px;
    flex-direction: row;
  }
  .control-dock {
    padding-bottom: 35px;
    min-height: 193px;
  }
  .touch-controls {
    max-width: none;
    padding-right: 9px;
  }
  .boost-button {
    align-self: flex-start;
    margin-top: 13px;
  }
  .hud {
    gap: 13px;
  }
  .hud .best-stat {
    margin-left: auto;
  }
  .hud .icon-button {
    min-width: 40px;
  }
  .hud strong {
    font-size: 1.9rem;
  }
  .welcome-card .small-copy {
    margin-bottom: 14px;
  }
}
@media (max-height: 550px) and (min-width: 600px) {
  #app {
    min-height: 320px;
  }
  .site-header {
    min-height: 46px;
  }
  .site-footer {
    min-height: 30px;
  }
  .game-shell {
    grid-template-columns: minmax(0, 1fr) 165px;
    grid-template-rows: 56px minmax(0, 1fr);
  }
  .hud {
    grid-column: 1 / -1;
    min-height: 56px;
    padding: 6px 18px;
  }
  .hud > div {
    flex-direction: row;
    gap: 10px;
  }
  .hud strong,
  .hud .best-stat strong {
    font-size: 1.6rem;
  }
  .game-stage {
    grid-row: 2;
    grid-column: 1;
    min-height: 0;
  }
  .control-dock {
    grid-row: 2;
    grid-column: 2;
    min-height: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    border-top: 0;
    border-left: 1px solid var(--line);
    gap: 0;
  }
  .desktop-instructions {
    display: none;
  }
  .touch-controls {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
  }
  .run-actions {
    display: flex;
    flex-direction: row;
    gap: 0;
    position: static;
  }
  .run-actions button {
    min-height: 34px;
    padding: 4px;
    font-size: 0.6875rem;
  }
  .welcome-card {
    max-height: calc(100% - 20px);
    top: 10px;
    left: 18px;
    transform: none;
    width: 310px;
    padding: 15px;
  }
  .welcome-card h1 {
    font-size: 2rem;
  }
  .welcome-card h1 br {
    display: none;
  }
  .welcome-card .welcome-player,
  .welcome-card .small-copy,
  .welcome-controls {
    display: none;
  }
  .welcome-card > p {
    font-size: 0.875rem;
  }
  .reward-rule {
    margin: 10px 0;
    font-size: 0.75rem;
  }
  .game-shell[data-state="ready"] .game-stage {
    grid-column: 1 / -1;
  }
  .touch-hint {
    display: block;
  }
  .desktop-hint {
    display: none;
  }
  .game-shell {
    grid-template-columns: minmax(0, 1fr) 210px;
  }
  .touch-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .boost-button {
    width: 50px;
    height: 76px;
    border-radius: 8px;
    font-size: 1.3rem;
    line-height: 1.1;
    flex-direction: column;
    gap: 4px;
  }
  .boost-button span {
    font-size: 0.6875rem;
    margin: 0;
    max-width: 44px;
  }
  .control-dock {
    padding: 8px;
    justify-content: center;
    gap: 2px;
  }
  .control-toggle {
    font-size: 0.6875rem;
    padding: 4px;
  }
  .run-actions button {
    min-height: 44px;
    font-size: 0.75rem;
    padding: 8px;
  }
  .dpad {
    width: 132px;
    height: 132px;
  }
}
@media (max-width: 767px) and (max-height: 700px) {
  .welcome-player {
    display: none;
  }
  .welcome-card .small-copy {
    display: none;
  }
  .welcome-card h1 {
    font-size: 2.2rem;
  }
  .welcome-card {
    padding: 18px;
  }
  .welcome-card .reward-rule {
    margin: 12px 0;
  }
  .welcome-controls {
    margin-top: 10px;
  }
}
/* Touch components also support short, wide viewports on fine-pointer devices. */
.map-label {
  left: 16px;
  right: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  background: #10082eee;
  color: #f2efff;
  max-width: calc(100% - 32px);
  font-size: 12px;
  line-height: 1.4;
}
#venue-name {
  color: #c0baff;
  white-space: nowrap;
}
#route-goal {
  text-transform: none;
  letter-spacing: 0;
}
.game-shell[data-state="ready"] .map-label {
  display: none;
}
@media (max-width: 500px) {
  .map-label {
    left: 8px;
    max-width: calc(100% - 16px);
    gap: 8px;
    padding: 6px 8px;
    font-size: 11px;
  }
  .welcome-card .small-copy {
    font-size: 14px;
  }
}
@media (min-width: 768px) {
  .hud {
    min-height: 64px;
    padding: 8px 20px;
  }
  .hud strong {
    font-size: 2rem;
  }
  .control-dock {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}
