* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #000000;
  color: #d0d0d8;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#app-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(circle at center, #0c0c14 0%, #000000 100%);
}

#viewport-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100vw, calc((100dvh - 40px) * 4 / 3));
  height: min(calc(100dvh - 40px), calc(100vw * 3 / 4));
  background: #000000;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.95), 0 0 2px rgba(255, 255, 255, 0.15);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #000000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  cursor: crosshair;
  touch-action: none;
}

#game-canvas.hide-cursor {
  cursor: none;
}

#mobile-name-input {
  position: absolute;
  left: 20%;
  top: 52%;
  width: 60%;
  height: 16%;
  opacity: 0;
  pointer-events: none;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 18px;
  z-index: 10;
}

#loading-overlay {
  position: absolute;
  inset: 0;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.35s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-box {
  width: min(360px, 88vw);
  text-align: center;
  padding: 28px 24px;
  border: 1px solid #3a2a18;
  background: linear-gradient(180deg, #120d08 0%, #050508 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85);
}

.loader-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #f3b644;
  text-shadow: 0 2px 8px rgba(243, 182, 68, 0.45);
  margin-bottom: 6px;
}

.loader-subtitle {
  font-size: 11px;
  letter-spacing: 3px;
  color: #888899;
  margin-bottom: 20px;
}

.loader-bar-track {
  width: 100%;
  height: 10px;
  background: #1a1a24;
  border: 1px solid #443322;
  overflow: hidden;
  margin-bottom: 12px;
}

#loader-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #9e2a1b 0%, #f3b644 100%);
  transition: width 0.1s linear;
}

#loader-status {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #b0b0c0;
}

#hud-strip {
  min-height: 40px;
  width: min(100vw, calc((100dvh - 40px) * 4 / 3));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 4px 10px;
  background: #07070c;
  border-top: 1px solid #1d1d2b;
  font-size: 11px;
  color: #8e8ea0;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.arcade-back-link {
  color: #b8b8d0;
  text-decoration: none;
  background: #141422;
  border: 1px solid #2e2e46;
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}

.arcade-back-link:hover {
  color: #ffffff;
  border-color: #e6a83a;
  background: #222236;
}

.brand-badge {
  color: #e6a83a;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}

.telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #12121e;
  border: 1px solid #282840;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 10.5px;
  color: #b8b8cc;
  white-space: nowrap;
}

.telemetry-pill strong {
  color: #ffffff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.telemetry-pill .sep {
  color: #484862;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #36d976;
  box-shadow: 0 0 6px rgba(54, 217, 118, 0.85);
}

.hint-item kbd {
  background: #181824;
  border: 1px solid #323248;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 10px;
  color: #d8d8e8;
}

#hud-strip button {
  background: #161622;
  color: #d0d0e0;
  border: 1px solid #34344a;
  border-radius: 3px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

#hud-strip button:hover {
  background: #242438;
  border-color: #e6a83a;
  color: #ffffff;
}

.hud-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #b8b8cc;
  font-size: 11px;
  white-space: nowrap;
}

.hud-control input[type="range"] {
  width: 64px;
  height: 4px;
  accent-color: #e6a83a;
  cursor: pointer;
}

.hud-val {
  display: inline-block;
  min-width: 26px;
  text-align: right;
  color: #f3b644;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1060px) {
  .hint-item {
    display: none;
  }
}

@media (pointer: coarse), (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  #viewport-wrapper {
    width: 100vw;
    height: min(calc(100dvh - 78px), calc(100vw * 3 / 4));
  }
  #hud-strip {
    width: 100vw;
    justify-content: center;
    padding: 6px 8px;
  }
  .hud-left, .hud-right {
    justify-content: center;
  }
}
