/* ==========================================================================
   2D PIXEL ART / RETRO ARCADE BASKETBALL GAME UI
   FULLY RESPONSIVE — DESKTOP / TABLET / MOBILE
   ========================================================================== */

:root {
  --font-pixel: 'Press Start 2P', monospace, cursive;
  --font-arcade-alt: 'VT323', monospace;
  
  /* Retro Arcade Basketball Palette */
  --pixel-orange: #FF6600;
  --pixel-orange-light: #FF8533;
  --pixel-orange-dark: #B33600;
  --pixel-gold: #FFCC00;
  --pixel-yellow: #FFE600;
  --pixel-cream: #FFFDF0;
  --pixel-white: #FFFFFF;
  
  --pixel-bg-dark: #06080C;
  --pixel-surface: #121622;
  --pixel-surface-light: #1D2335;
  --pixel-border-dark: #000000;
  --pixel-border-mid: #2F384E;
  --pixel-border-light: #5A6987;
  
  --pixel-red: #E53935;
  --pixel-red-dark: #8E1010;
  --pixel-green: #00E676;
  --pixel-cyan: #00E5FF;
  
  /* Hard Pixel Shadows */
  --pixel-shadow-sm: 2px 2px 0px #000000;
  --pixel-shadow-md: 4px 4px 0px #000000;
  --pixel-shadow-lg: 6px 6px 0px #000000;
  --pixel-shadow-inset: inset -3px -3px 0px #07090E, inset 3px 3px 0px #2E374C;

  /* Safe Inset Variables */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--pixel-bg-dark);
  font-family: var(--font-pixel);
  color: var(--pixel-white);
  touch-action: none;
  -webkit-font-smoothing: none;
  position: fixed;
}

/* ==========================================================================
   Main Game Container & Responsive Canvas
   ========================================================================== */

.game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--pixel-bg-dark);
  overflow: hidden;
  touch-action: none;
}

canvas#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
}

/* ==========================================================================
   Arcade Scoreboard Header UI
   ========================================================================== */

.game-header {
  position: absolute;
  top: max(16px, calc(var(--safe-top) + 8px));
  left: max(16px, calc(var(--safe-left) + 8px));
  right: max(16px, calc(var(--safe-right) + 8px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 25;
  gap: 12px;
}

/* Retro Arcade Pixel Panels */
.pixel-panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--pixel-surface);
  border: 3px solid var(--pixel-border-dark);
  box-shadow: var(--pixel-shadow-inset), var(--pixel-shadow-md);
  padding: 8px 16px;
  min-width: 110px;
  position: relative;
  transition: transform 0.1s ease;
}

.score-badge {
  border-top: 3px solid var(--pixel-orange);
  background: linear-gradient(180deg, #181E30 0%, #0F131D 100%);
}

.score-badge::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--pixel-orange-dark);
}

.best-badge {
  border-top: 3px solid var(--pixel-gold);
  min-width: 95px;
}

.best-badge::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: #B38600;
}

.pixel-label {
  font-family: var(--font-pixel);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--pixel-orange-light);
  text-transform: uppercase;
  text-shadow: 1px 1px 0px #000;
  margin-bottom: 4px;
}

.best-badge .pixel-label {
  color: var(--pixel-gold);
}

.pixel-val {
  font-family: var(--font-pixel);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: var(--pixel-yellow);
  text-shadow: 2px 2px 0px #000000;
  letter-spacing: 0.08em;
}

.best-num {
  font-size: 16px;
  color: var(--pixel-cream);
}

/* Score Pulse Animation */
.score-badge.pulse {
  animation: pixelScorePulse 0.3s steps(3, start);
}

@keyframes pixelScorePulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.16); background: #351C08; }
  100% { transform: scale(1); }
}

/* Retro Streak Pill */
.pixel-streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #2B0D05;
  border: 3px solid var(--pixel-orange);
  box-shadow: 0 0 0 1px #000, var(--pixel-shadow-md);
  padding: 6px 12px;
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--pixel-yellow);
  text-shadow: 1px 1px 0 #000;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s steps(3, start);
  pointer-events: none;
}

.pixel-streak-pill.visible {
  opacity: 1;
  transform: translateY(0);
  animation: streakFlamePulse 0.8s steps(2, start) infinite;
}

@keyframes streakFlamePulse {
  0%, 100% { border-color: var(--pixel-orange); }
  50% { border-color: var(--pixel-yellow); }
}

.streak-icon {
  font-size: 13px;
  line-height: 1;
}

/* Header Action Buttons */
.header-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pixel-icon-btn {
  min-width: 42px;
  min-height: 42px;
  width: 42px;
  height: 42px;
  background: var(--pixel-surface);
  border: 3px solid var(--pixel-border-dark);
  box-shadow: var(--pixel-shadow-inset), var(--pixel-shadow-sm);
  color: var(--pixel-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.05s ease;
  font-family: var(--font-pixel);
  touch-action: manipulation;
}

.pixel-icon-btn:hover {
  background: var(--pixel-surface-light);
}

.pixel-icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: inset 2px 2px 0px #000;
}

.icon {
  width: 18px;
  height: 18px;
}

.icon.hidden {
  display: none;
}

.pixel-gear-icon {
  font-size: 18px;
  line-height: 1;
}

/* ==========================================================================
   Shooting Instruction (Pixel Art Drag Hint)
   ========================================================================== */

.drag-hint {
  position: absolute;
  bottom: max(95px, calc(var(--safe-bottom) + 85px));
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.3s steps(3, start);
  max-width: 90%;
}

.drag-hint.hidden {
  opacity: 0;
}

.pixel-hint-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 13, 20, 0.92);
  border: 3px solid var(--pixel-border-dark);
  box-shadow: inset 1px 1px 0px rgba(255, 255, 255, 0.15), var(--pixel-shadow-md);
  padding: 6px 14px;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--pixel-cream);
  text-shadow: 1px 1px 0 #000;
  white-space: nowrap;
}

.hint-arrow {
  color: var(--pixel-orange);
  animation: hintArrowBlink 1s steps(2, start) infinite;
}

@keyframes hintArrowBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ==========================================================================
   Bottom Arcade Controls
   ========================================================================== */

.game-bottom-bar {
  position: absolute;
  bottom: max(20px, calc(var(--safe-bottom) + 12px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 25;
  pointer-events: auto;
  max-width: 95%;
}

/* Power Meter Segment Box */
.pixel-meter-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--pixel-surface);
  border: 3px solid var(--pixel-border-dark);
  box-shadow: var(--pixel-shadow-inset), var(--pixel-shadow-sm);
  padding: 6px 10px;
  min-width: 100px;
}

.meter-header {
  display: flex;
  justify-content: space-between;
}

.meter-title {
  font-size: 8px;
  color: var(--pixel-orange-light);
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #000;
}

.pixel-meter-track {
  width: 100%;
  height: 10px;
  background: #080A10;
  border: 2px solid #000000;
  position: relative;
  overflow: hidden;
}

.pixel-meter-fill {
  width: 0%;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--pixel-gold) 0px,
    var(--pixel-gold) 6px,
    #000000 6px,
    #000000 8px,
    var(--pixel-orange) 8px,
    var(--pixel-orange) 14px,
    #000000 14px,
    #000000 16px,
    var(--pixel-red) 16px,
    var(--pixel-red) 22px
  );
  transition: width 0.04s steps(10, start);
}

/* Chunky Arcade Buttons */
.pixel-btn {
  font-family: var(--font-pixel);
  cursor: pointer;
  border: 3px solid #000000;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  outline: none;
  touch-action: manipulation;
}

.arcade-btn-orange {
  height: 48px;
  min-height: 44px;
  padding: 0 24px;
  background: var(--pixel-orange);
  color: var(--pixel-white);
  font-size: 12px;
  box-shadow: 
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 var(--pixel-orange-dark),
    0 5px 0 var(--pixel-orange-dark),
    0 5px 0 #000000,
    var(--pixel-shadow-md);
  text-shadow: 2px 2px 0px #000000;
}

.arcade-btn-orange:hover {
  background: var(--pixel-orange-light);
}

.arcade-btn-orange:active {
  transform: translateY(4px);
  box-shadow: 
    inset 0 2px 0 rgba(0, 0, 0, 0.4),
    0 1px 0 var(--pixel-orange-dark),
    var(--pixel-shadow-sm);
}

.arcade-btn-dark {
  height: 48px;
  min-height: 44px;
  padding: 0 16px;
  background: #1C2333;
  color: var(--pixel-cream);
  font-size: 10px;
  box-shadow: 
    inset 0 3px 0 rgba(255, 255, 255, 0.2),
    inset 0 -3px 0 #0C101A,
    0 5px 0 #0C101A,
    0 5px 0 #000000,
    var(--pixel-shadow-md);
  text-shadow: 1px 1px 0px #000000;
}

.arcade-btn-dark:hover {
  background: #2A3347;
}

.arcade-btn-dark:active {
  transform: translateY(4px);
  box-shadow: 
    inset 0 2px 0 #000,
    0 1px 0 #0C101A,
    var(--pixel-shadow-sm);
}

/* ==========================================================================
   Pixel Art Floating Feedback (+1 / SWISH!)
   ========================================================================== */

.feedback-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
  overflow: hidden;
}

.score-floater {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-pixel);
  font-weight: 700;
  color: var(--pixel-yellow);
  text-shadow: 
    3px 3px 0px #000000,
    -2px -2px 0px #000000,
    2px -2px 0px #000000,
    -2px 2px 0px #000000;
  pointer-events: none;
  animation: pixelFloatBounce 0.9s steps(6, start) forwards;
}

.score-floater.swish {
  color: var(--pixel-green);
}

.score-floater .main-text {
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0.06em;
}

.score-floater .sub-text {
  font-size: 10px;
  letter-spacing: 0.12em;
  margin-top: 4px;
  color: var(--pixel-white);
  text-shadow: 2px 2px 0px #000000;
}

@keyframes pixelFloatBounce {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -15px) scale(1.15);
  }
  40% {
    transform: translate(-50%, -30px) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -48px);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -64px);
  }
}

/* ==========================================================================
   Overlay Screens (Start & Game Over Arcade Cabinets)
   ========================================================================== */

.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 8, 12, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s steps(2, start);
  padding: max(16px, var(--safe-top));
  overflow-y: auto;
}

.overlay-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.arcade-card-modal {
  background: #111520;
  border: 4px solid #000000;
  box-shadow: 
    inset 0 0 0 3px var(--pixel-orange),
    inset 0 0 0 5px #000000,
    var(--pixel-shadow-lg);
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.15s steps(3, start);
  margin: auto;
}

.overlay-screen.active .arcade-card-modal {
  transform: scale(1);
}

/* Retro Corner Pixel Blocks */
.modal-corner-tl, .modal-corner-tr, .modal-corner-bl, .modal-corner-br {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--pixel-gold);
  border: 2px solid #000;
}
.modal-corner-tl { top: -4px; left: -4px; }
.modal-corner-tr { top: -4px; right: -4px; }
.modal-corner-bl { bottom: -4px; left: -4px; }
.modal-corner-br { bottom: -4px; right: -4px; }

.pixel-tag {
  display: inline-block;
  padding: 4px 10px;
  background: #251206;
  border: 2px solid var(--pixel-orange);
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--pixel-gold);
  text-shadow: 1px 1px 0 #000;
}

.pixel-tag.red-tag {
  background: #2E0B0B;
  border-color: var(--pixel-red);
  color: #FFAAAA;
}

.pixel-title {
  font-family: var(--font-pixel);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--pixel-yellow);
  text-shadow: 
    4px 4px 0px var(--pixel-orange-dark),
    6px 6px 0px #000000;
  letter-spacing: 0.08em;
}

.pixel-title-small {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--pixel-cream);
  text-shadow: 3px 3px 0 #000;
  letter-spacing: 0.06em;
}

.pixel-subtitle {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--pixel-orange-light);
  text-transform: uppercase;
  margin-top: -6px;
  text-shadow: 1px 1px 0 #000;
}

.pixel-score-big {
  font-family: var(--font-pixel);
  font-size: 44px;
  line-height: 1;
  color: var(--pixel-yellow);
  text-shadow: 4px 4px 0px #000000;
  margin: 6px 0;
  letter-spacing: 0.06em;
}

.pixel-instruction-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 4px 0;
}

.pixel-instruction-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #090C12;
  border: 2px solid #000000;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  text-align: left;
}

.pixel-icon-bullet {
  font-size: 16px;
  line-height: 1;
}

.instruction-desc {
  font-size: 8.5px;
  line-height: 1.4;
  color: var(--pixel-cream);
  text-shadow: 1px 1px 0 #000;
}

.play-action-btn {
  width: 100%;
  height: 52px;
  min-height: 48px;
  font-size: 13px;
  margin-top: 6px;
}

.insert-coin-text {
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--pixel-border-light);
  animation: insertCoinFlash 1.2s steps(2, start) infinite;
}

@keyframes insertCoinFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pixel-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.pixel-stat-card {
  background: #0A0D14;
  border: 2px solid #000000;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.1);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-card-label {
  font-size: 7.5px;
  color: var(--pixel-orange-light);
  letter-spacing: 0.1em;
}

.stat-card-val {
  font-size: 16px;
  color: var(--pixel-white);
  text-shadow: 2px 2px 0 #000;
}

/* ==========================================================================
   Arcade Calibration Debug Menu
   ========================================================================== */

.debug-panel {
  position: absolute;
  bottom: max(85px, calc(var(--safe-bottom) + 80px));
  right: max(16px, calc(var(--safe-right) + 8px));
  background: #0B0E17;
  border: 3px solid var(--pixel-orange);
  box-shadow: 0 0 0 2px #000, var(--pixel-shadow-lg);
  padding: 14px;
  width: 300px;
  max-width: 90vw;
  z-index: 95;
  display: none;
  flex-direction: column;
  gap: 10px;
  color: var(--pixel-cream);
  font-family: var(--font-pixel);
}

.debug-panel.active {
  display: flex;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pixel-diag-title {
  font-size: 9px;
  color: var(--pixel-gold);
  text-shadow: 1px 1px 0 #000;
}

.pixel-debug-close {
  background: transparent;
  border: none;
  color: var(--pixel-red);
  font-family: var(--font-pixel);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.debug-tip {
  font-size: 7.5px;
  color: #8E9BAE;
  line-height: 1.4;
}

.debug-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debug-row label {
  font-size: 8px;
  color: #CBD5E1;
  display: flex;
  justify-content: space-between;
}

.debug-row input[type="range"] {
  width: 100%;
  accent-color: var(--pixel-orange);
  cursor: pointer;
}

.debug-copy-btn {
  height: 36px;
  font-size: 8.5px;
  margin-top: 4px;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Desktop, Tablet, Mobile)
   ========================================================================== */

/* Tablet & Smaller Screens */
@media (max-width: 768px) {
  .game-header {
    gap: 8px;
  }

  .pixel-panel {
    padding: 6px 12px;
    min-width: 95px;
  }

  .pixel-val {
    font-size: 18px;
  }

  .best-badge {
    min-width: 85px;
  }

  .best-num {
    font-size: 14px;
  }
}

/* Mobile Phones (Portrait) */
@media (max-width: 600px) {
  .game-header {
    top: max(8px, var(--safe-top));
    left: max(8px, var(--safe-left));
    right: max(8px, var(--safe-right));
    gap: 6px;
  }

  .pixel-panel {
    padding: 5px 8px;
    min-width: 78px;
    border-width: 2px;
  }

  .pixel-label {
    font-size: 7px;
    margin-bottom: 2px;
  }

  .pixel-val {
    font-size: 15px;
  }

  .best-badge {
    min-width: 68px;
  }

  .best-num {
    font-size: 12px;
  }

  .pixel-streak-pill {
    padding: 4px 8px;
    font-size: 8px;
  }

  .pixel-icon-btn {
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    border-width: 2px;
  }

  .icon {
    width: 16px;
    height: 16px;
  }

  .drag-hint {
    bottom: max(75px, calc(var(--safe-bottom) + 65px));
  }

  .pixel-hint-box {
    font-size: 6.5px;
    padding: 5px 8px;
    letter-spacing: 0.05em;
  }

  .game-bottom-bar {
    bottom: max(10px, var(--safe-bottom));
    gap: 8px;
    width: calc(100% - 20px);
    justify-content: center;
  }

  .pixel-meter-box {
    min-width: 70px;
    padding: 4px 6px;
    border-width: 2px;
  }

  .meter-title {
    font-size: 6.5px;
  }

  .pixel-meter-track {
    height: 8px;
  }

  .pixel-btn {
    height: 44px;
    min-height: 44px;
  }

  .arcade-btn-orange {
    font-size: 10px;
    padding: 0 16px;
    flex: 1;
    max-width: 140px;
  }

  .arcade-btn-dark {
    font-size: 8.5px;
    padding: 0 12px;
  }

  .arcade-card-modal {
    padding: 20px 16px;
    gap: 10px;
  }

  .pixel-title {
    font-size: 24px;
  }

  .pixel-subtitle {
    font-size: 8.5px;
  }

  .pixel-score-big {
    font-size: 32px;
  }

  .instruction-desc {
    font-size: 7px;
  }

  .play-action-btn {
    height: 46px;
    font-size: 11px;
  }
}

/* Mobile Landscape & Short Screen Heights */
@media (max-height: 520px) {
  .game-header {
    top: max(4px, var(--safe-top));
    left: max(8px, var(--safe-left));
    right: max(8px, var(--safe-right));
  }

  .pixel-panel {
    padding: 3px 8px;
    min-width: 70px;
  }

  .pixel-label {
    font-size: 6.5px;
    margin-bottom: 1px;
  }

  .pixel-val {
    font-size: 13px;
  }

  .best-num {
    font-size: 11px;
  }

  .pixel-icon-btn {
    min-width: 32px;
    min-height: 32px;
    width: 32px;
    height: 32px;
  }

  .drag-hint {
    bottom: max(55px, calc(var(--safe-bottom) + 50px));
  }

  .game-bottom-bar {
    bottom: max(6px, var(--safe-bottom));
  }

  .pixel-btn {
    height: 36px;
    min-height: 36px;
  }

  .arcade-card-modal {
    padding: 14px 16px;
    gap: 8px;
    max-height: 90vh;
  }

  .pixel-title {
    font-size: 18px;
  }

  .pixel-score-big {
    font-size: 26px;
  }

  .pixel-instruction-group {
    display: none;
  }
}
