/* =========================================================
   CROSSGAMES - GAMEPLAY SCREEN & HUD STYLES
   ========================================================= */

.game-viewport-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 16px 40px 16px;
  gap: 14px;
}

/* In-Game HUD Top Bar */
.game-hud-top {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  background: rgba(18, 22, 38, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--shadow-sm);
  z-index: 20;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-glass-bright);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}
.hud-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.hud-level-badge {
  display: flex;
  flex-direction: column;
  padding-left: 6px;
}

.hud-game-name {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.hud-level-number {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

/* Middle HUD: Finish Line Distance Progress Bar */
.hud-middle {
  display: flex;
  flex-direction: column;
  padding: 0 12px;
}

.hud-progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.hud-label-distance {
  color: var(--accent-primary);
  font-family: var(--font-display);
}

.hud-progress-track {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: visible;
}

.hud-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

.hud-player-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
  transition: left 0.1s linear;
}

/* Right HUD */
.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-stat-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}

.hud-icon {
  font-size: 14px;
}

.timer-box .hud-val {
  color: var(--accent-primary);
  letter-spacing: 0.5px;
  min-width: 60px;
}

.coin-box .hud-val {
  color: #ffd166;
}

.shield-box .hud-val {
  color: #ff4b72;
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 3 / 2;
  background: #080a10;
  border: 2px solid var(--border-glass-bright);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Warning / Siren Flashing Border */
.danger-warning-border {
  position: absolute;
  inset: 0;
  border: 4px solid var(--color-danger);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.danger-warning-border.active {
  opacity: 1;
  animation: dangerFlash 0.5s ease-in-out infinite alternate;
}

@keyframes dangerFlash {
  from { opacity: 0.2; }
  to { opacity: 0.85; }
}

/* Floating Text Overlay */
.canvas-overlay-text {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}

.floating-text-item {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  animation: floatUpFade 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes floatUpFade {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.8);
  }
  20% {
    transform: translateY(-10px) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(1);
  }
}

/* Desktop Controls Hint */
.desktop-controls-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  flex-wrap: wrap;
}

.hint-item kbd {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass-bright);
  border-radius: 4px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  margin: 0 2px;
}

/* Mobile Virtual Controls */
.virtual-controls {
  display: none;
  width: 100%;
  max-width: 800px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  gap: 24px;
  user-select: none;
}

.dpad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-middle-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dpad-btn {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
}
.dpad-btn:active {
  background: var(--accent-primary);
  color: #0b0d14;
  transform: scale(0.92);
}

.dpad-center {
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.2);
}

.action-buttons-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.action-boost {
  background: linear-gradient(135deg, #ff007f, #7928ca);
  color: #fff;
}
.action-boost:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

.action-jump {
  background: var(--accent-gradient);
  color: #0b0d14;
}
.action-jump:active {
  transform: scale(0.92);
  filter: brightness(1.2);
}

.action-icon {
  font-size: 20px;
}
.action-label {
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-display);
}

@media (pointer: coarse), (max-width: 768px) {
  .virtual-controls {
    display: flex;
  }
  .desktop-controls-hint {
    display: none;
  }
}

@media (max-width: 600px) {
  .game-hud-top {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .hud-middle {
    grid-column: 1 / -1;
    order: 3;
    padding: 0;
  }
  .dpad-btn {
    width: 46px;
    height: 46px;
    font-size: 16px;
  }
  .dpad-center {
    width: 46px;
    height: 46px;
  }
  .action-btn {
    width: 58px;
    height: 58px;
  }
}
