/* Canvas */
canvas {
  width: 100%; 
  height: 100%;
  max-width: 100%;
  display: block;
}

/* Tank tracks */
.tank-track {
  position: absolute;
  width: 40px;
  height: 100%;
  left: 0;
  opacity: 0.3;

  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.05) 0px,
    rgba(255, 255, 255, 0.05) 4px,
    rgba(50, 50, 50, 0.05) 4px,
    rgba(50, 50, 50, 0.05) 8px
  );
  background-size: 100% 20px;

  will-change: transform;
}


/* Background obstacles */
.bg-obstacle {
  position: absolute;
  background-color: var(--primary-color);
  opacity: 0.2;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.3);
}

/* Radar animation */
.radar {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid rgba(41, 128, 185, 0.2);
  bottom: -20px;
  right: -100px;
  overflow: hidden;
  opacity: 0.3;
}

/* Crosshair */
.bg-crosshair {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(231, 76, 60, 0.3);
  opacity: 0.6;
}

.bg-crosshair:before, .bg-crosshair:after {
  content: "";
  position: absolute;
  background-color: rgba(231, 76, 60, 0.3);
}

.bg-crosshair:before {
  width: 1px;
  height: 60px;
  left: 50%;
  top: -5px;
  transform: translateX(-50%);
}

.bg-crosshair:after {
  width: 60px;
  height: 1px;
  top: 50%;
  left: -5px;
  transform: translateY(-50%);
}

/* Game controls */
.control-zone .dpad {
  position: fixed;
  left: 35px;
  bottom: calc(30px + var(--sab));
  pointer-events: auto;
  opacity: 0.5;
}

.control-zone .action-button {
  position: fixed; /* Keep it fixed relative to viewport */
  right: 20px;   /* Adjust positioning as needed */
  bottom: calc(60px + var(--sab));  /* Adjust positioning as needed */
  width: 100px;   /* Slightly smaller for balance */
  height: 100px;
  background-color: var(--accent-color);
  pointer-events: auto;
  border-radius: 50px; /* Squircle shape to match D-pad aesthetic */
  box-shadow: 0 5px 15px rgba(0,0,0,0.3), 0 0 10px var(--accent-color);
  opacity: 0.8;
}


:root {
  --dpad-size: 153px; /* Base size of the D-pad, adjust as needed */
  --dpad-button-size: 50px; /* Size of the visual 'button' segments */
  --dpad-button-offset: calc(var(--dpad-size) / 2 - var(--dpad-button-size) / 2 - 5px); /* Distance from center */
  --dpad-pivot-size: 30px;
  --dpad-active-color: rgba(200, 200, 200); /* Use your theme's accent */
  --dpad-inactive-color: rgba(90, 90, 90);
  --dpad-base-bg: rgba(30, 30, 30, 0.75);
  --dpad-border-color: rgba(80, 80, 80, 0.6);
}

.dpad {
  display: block; /* No longer grid */
  position: relative;
  width: var(--dpad-size);
  height: var(--dpad-size);
  border-radius: 81px; /* Rounded square or squircle for a modern D-pad feel */
  background-color: var(--dpad-base-bg);
  box-shadow: 
    inset 0 0 10px rgba(0, 0, 0, 0.4),
    0 5px 15px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--dpad-border-color);
  /* Ensure touch events are captured by this container */
  touch-action: none; 
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Optional: For extra background details like a subtle cross or circle */
.dpad-background-details {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  /* Example: A very faint cross
  background:
    linear-gradient(to right, transparent 48%, rgba(255,255,255,0.03) 49%, rgba(255,255,255,0.03) 51%, transparent 52%),
    linear-gradient(to bottom, transparent 48%, rgba(255,255,255,0.03) 49%, rgba(255,255,255,0.03) 51%, transparent 52%);
  */
  pointer-events: none;
}

.dpad-center-pivot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--dpad-pivot-size);
  height: var(--dpad-pivot-size);
  background-color: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
  border: 1px solid rgba(0,0,0,0.2);
  pointer-events: none; /* Crucial: does not intercept touch */
}

.dpad button {
  position: absolute;
  width: var(--dpad-button-size);
  height: var(--dpad-button-size);
  background-color: var(--dpad-inactive-color);
  color: var(--light-color);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px; /* Rounded corners for segments */
  font-size: 24px; /* For arrow icons */
  font-weight: bold;
  transition: background-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  pointer-events: none; /* Individual buttons don't need to capture events */
}

/* Positioning the visual button segments */
.dpad .up {
  top: calc(50% - var(--dpad-button-offset) - var(--dpad-button-size) / 2);
  left: 50%;
  transform: translateX(-50%);
}

.dpad .down {
  bottom: calc(50% - var(--dpad-button-offset) - var(--dpad-button-size) / 2);
  left: 50%;
  transform: translateX(-50%);
}

.dpad .left {
  left: calc(50% - var(--dpad-button-offset) - var(--dpad-button-size) / 2);
  top: 50%;
  transform: translateY(-50%);
}

.dpad .right {
  right: calc(50% - var(--dpad-button-offset) - var(--dpad-button-size) / 2);
  top: 50%;
  transform: translateY(-50%);
}


/* --- Visual Feedback for Active State (Controlled by JS via .dpad-visual-active) --- */
.dpad button.dpad-visual-active {
  background-color: var(--dpad-active-color) !important;
  /* Slightly inset and brighter for a 'pressed' feel */
  transform: scale(0.95); /* Default scale down */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 
              inset 0 0 8px rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.2);
}

/* Adjust transform for .dpad-visual-active based on original positioning */
.dpad .up.dpad-visual-active {
  transform: translateX(-50%) scale(0.95);
}
.dpad .down.dpad-visual-active {
  transform: translateX(-50%) scale(0.95);
}
.dpad .left.dpad-visual-active {
  transform: translateY(-50%) scale(0.95);
}
.dpad .right.dpad-visual-active {
  transform: translateY(-50%) scale(0.95);
}


/* Optional: Add a subtle glow to the entire D-pad when actively touched */
.dpad.dpad-is-active {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0), 0 0 50px rgba(80, 80, 80, 0.8); /* Glow effect */
}


/*--------------------------------------------------------------------------*/
.action-button {
  width: 90px;
  height: 90px;
  background-color: var(--accent-color);
  color: var(--light-color);
  border: none;
  border-radius: 50%;
  font-size: 22px;
  font-weight: bold;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Stats display */
.stats-container {
  display: flex;
  height: 63px;
  background-color: rgba(20, 20, 20, 0.7);
  padding: 0 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 390px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin: 0 auto;
}

.team-scores-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  position: relative;
}

.team-score {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border-radius: 6px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.team-score.blue {
  background-color: rgba(0, 102, 255, 0.2);
  border-color: rgba(0, 102, 255, 0.3);
}

.team-score.red {
  background-color: rgba(255, 51, 51, 0.2);
  border-color: rgba(255, 51, 51, 0.3);
}

.team-score-value {
  font-size: 24px;
  font-weight: bold;
  color: #f8f8f8;
}

.team-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.countdown-container {
  text-align: center;
}

.countdown-container.waiting {
  background-color: rgba(20, 20, 20, 0.7);
  border: 1px solid #FFC107;
  border-radius: 8px;
  padding: 8px 12px;
}

.countdown-waiting {
  color: #FFC107 !important; /* Amber color for visibility */
  animation: pulse-waiting 1.5s infinite;
  font-weight: bold;
  font-size: 1.1em;
}

.countdown-warning {
  animation: pulse 1s infinite;
  color: #ff9800 !important;
}

.countdown-critical {
  animation: pulse 0.5s infinite;
  color: #f44336 !important;
}

/* Game over overlay */
.game-over-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(20, 20, 20, 0.9);
  padding: 20px 30px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  text-align: center;
  z-index: 1000;
  border: 2px solid var(--accent-color);
  max-width: 90%;
}

.game-over-message h2 {
  margin-top: 0;
  color: var(--accent-color);
  font-size: 24px;
  letter-spacing: 2px;
}

.game-over-message p {
  font-size: 18px;
  margin: 10px 0;
}

/* Stats Modal */
.stats-teams-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stats-team {
  background-color: rgba(40, 40, 40, 0.7);
  border-radius: 6px;
  padding: 15px;
}

.stats-team.blue {
  border-left: 4px solid #0066ff;
}

.stats-team.red {
  border-left: 4px solid #ff3333;
}

.stats-team-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-team-header h4 {
  flex: 1;
  margin: 0 10px;
  font-size: 16px;
}

.team-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.player-stat-row.disconnected-player {
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0.7;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-stat-row.disconnected-player .player-name {
  color: #999;
  font-style: italic;
}

.player-name {
  flex: 1;
  font-weight: 500;
}

.player-stats {
  display: flex;
  gap: 15px;
}

.player-kills {
  color: #4CAF50;
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

.player-deaths {
  color: #f44336;
  font-weight: bold;
  min-width: 30px;
  text-align: center;
}

/* Headers for stats columns */
.stats-columns-header {
  display: flex;
  justify-content: flex-end;
  padding: 0 8px 5px 8px;
  color: #aaa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stats-column-kills,
.stats-column-deaths {
  min-width: 30px;
  text-align: center;
  margin-left: 15px;
}

/* ============================================================
   CAREER MODE — Specialized UI for solo mission games
   Applied via .career-mode class on #gameContainer
   ============================================================ */

/* Hide team scores — no teams in career */
.career-mode .team-score.blue,
.career-mode .team-score.red {
  display: none;
}

/* Hide share/stats buttons — not relevant for career */
.career-mode #share-button,
.career-mode #stats-button {
  display: none;
}

/* Restyle stats-container as compact career header */
.career-mode .stats-container {
  height: auto;
  padding: 6px 10px;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.career-mode .team-scores-panel {
  justify-content: center;
}

/* Timer: clean and centered */
.career-mode .countdown-container {
  text-align: center;
}

.career-mode .countdown-container .stat-label {
  display: none; /* hide "Time Left" text — obvious from context */
}

.career-mode .countdown-container .stat-value {
  font-size: 18px;
  letter-spacing: 1px;
}

/* Hide combo/level bar — not relevant for solo missions */
.career-mode #combo-info {
  display: none;
}

/* Career objective bar — fits below the timer inside stats-container */
.career-mode .career-objectives-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 0 2px;
  flex-wrap: wrap;
}

.career-objective-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.3s ease;
  line-height: 1.4;
}

.career-objective-chip .chip-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.career-objective-chip .chip-label {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.career-objective-chip .chip-progress {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
  font-size: 10px;
}

/* Completed chip */
.career-objective-chip.completed {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.career-objective-chip.completed .chip-label {
  text-decoration: line-through;
  opacity: 0.7;
}

/* Failed chip */
.career-objective-chip.failed {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ============================================================ */

/* Layered Canvas System */
.game-zone canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: crisp-edges;
}

/* Main canvas - tanks, bullets, effects */
#tankCanvas {
  z-index: 1;
}

/* Ensure obstacle canvases don't interfere with controls */
.game-zone canvas:not(#tankCanvas) {
  pointer-events: none;
}