/* ==========================================
   AutoRick Tour of India - Style Sheet
   ========================================== */

/* Define Global Variables */
:root {
  --color-saffron: #FF9933;
  --color-white: #FFFFFF;
  --color-green: #138808;
  --color-navy: #000080;
  --color-rickshaw-yellow: #FFD54F;
  --color-rickshaw-green: #2E7D32;
  --color-danger: #D32F2F;
  --color-teal: #0D5C75;
  --color-bg-dark: #0A141D;
  --font-family: 'Outfit', sans-serif;
  --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.3);
  --border-glass: 1px solid rgba(255, 255, 255, 0.18);
  --bg-glass: rgba(10, 20, 29, 0.75);
}

/* Reset and Core Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: fixed; /* Lock viewport scroll and bounce on Safari Mobile */
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-dark);
  color: var(--color-white);
}

#app-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle, #102636 0%, #050b10 100%);
  padding: 10px;
}

/* aspect-ratio constrained container fitting screen bounds dynamically */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: min(460px, 57.14vh);  /* 400/700 aspect ratio upper-bound of screen height */
  max-height: min(820px, 175vw);   /* 700/400 aspect ratio upper-bound of screen width */
  aspect-ratio: 400 / 700;
  background-color: #333;
  border-radius: 24px;
  box-shadow: var(--shadow-premium), 0 0 40px rgba(13, 92, 117, 0.2);
  overflow: hidden;
  border: 4px solid rgba(13, 92, 117, 0.4);
  display: flex;
  flex-direction: column;
  margin: auto;
}

/* Canvas fills the container */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Utility Hidden State */
.hidden {
  display: none !important;
}

/* ==========================================
   HUD Layout
   ========================================== */
#game-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none; /* Let canvas capture touch clicks outside buttons */
}

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.hud-card {
  background: rgba(10, 20, 29, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: var(--border-glass);
  padding: 6px 10px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 75px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.hud-card .label {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: var(--color-saffron);
}

.hud-card .value {
  font-size: 15px;
  font-weight: 900;
  color: var(--color-white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.score-card {
  border-color: var(--color-rickshaw-yellow);
}

.score-card .value {
  color: var(--color-rickshaw-yellow);
}

/* Integrated Health Card in Top Bar */
.health-card {
  flex: 1.3;
  max-width: 160px;
  padding: 6px 10px;
  border-color: #00E676;
}

.health-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 3px;
}

.health-num {
  font-size: 9px;
  font-weight: 800;
  color: #00E676;
}

.health-card .gauge-bar-outer {
  height: 8px;
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.gauge-bar-inner {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease-out;
}

.gauge-bar-inner.health {
  background: linear-gradient(90deg, #FF1744, #FFEA00, #00E676);
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.5);
}

.gauge-bar-inner.shield {
  background: linear-gradient(90deg, #00E676, #00E5FF);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

/* Floating Alerts Area (Centered between top and bottom) */
.hud-alerts-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  pointer-events: none;
}

/* Shield Gauge Container */
.shield-gauge {
  background: rgba(10, 20, 29, 0.85);
  border: 1px solid #00E5FF;
  padding: 6px 12px;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
  width: 180px;
}

.shield-gauge .gauge-label {
  font-size: 9px;
  font-weight: 800;
  color: #00E5FF;
  text-align: center;
  display: block;
  margin-bottom: 3px;
}

.shield-gauge .gauge-bar-outer {
  height: 6px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 3px;
}

/* Passenger Notification Card */
.passenger-card {
  flex-direction: row;
  gap: 8px;
  background: rgba(13, 92, 117, 0.95);
  border-color: #00E5FF;
  padding: 8px 16px;
  border-radius: 20px;
  animation: float 2s ease-in-out infinite;
}

.passenger-icon {
  font-size: 16px;
}

.passenger-text {
  font-size: 11px;
  font-weight: 800;
  color: #FFFFFF;
}

/* Sacred Cow Blessing Toast Card */
.blessing-card {
  flex-direction: row;
  gap: 8px;
  background: linear-gradient(135deg, rgba(255, 143, 0, 0.95), rgba(255, 193, 7, 0.95));
  border-color: #FFF176;
  padding: 8px 16px;
  border-radius: 22px;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.8), 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: pulse-glow 1s ease-in-out infinite alternate;
}

.blessing-icon {
  font-size: 16px;
}

.blessing-text {
  font-size: 12px;
  font-weight: 900;
  color: #212121;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

@keyframes pulse-glow {
  from { transform: scale(1); box-shadow: 0 0 12px rgba(255, 215, 0, 0.6); }
  to { transform: scale(1.05); box-shadow: 0 0 22px rgba(255, 215, 0, 0.95); }
}

/* HUD Bottom Actions (Pinned cleanly to bottom) */
.hud-bottom-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  pointer-events: none;
}

.action-btn {
  pointer-events: auto;
  cursor: pointer;
  min-width: 75px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-btn:active {
  transform: scale(0.92);
}

.camera-card {
  border-color: #00E5FF;
}

.camera-card:active {
  background: rgba(0, 229, 255, 0.2);
}

.camera-card .value {
  color: #00E5FF;
  font-size: 10px;
  margin-top: 1px;
}

.exit-card {
  border-color: #FF5252;
}

.exit-card:active {
  background: rgba(255, 82, 82, 0.2);
}

.exit-card .value {
  color: #FF5252;
  font-size: 10px;
  margin-top: 1px;
}

.meter-card {
  border-color: #80DEEA;
  min-width: 90px;
}

.meter-card .value {
  font-size: 13px;
  color: #80DEEA;
}

/* ==========================================
   Overlay Menus (Splash, How to Play, Game Over)
   ========================================== */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 10, 15, 0.85);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

.overlay-card {
  width: 100%;
  max-width: 400px;
  max-height: 96%;
  border-radius: 24px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow-premium);
  border: var(--border-glass);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.start-card {
  background: linear-gradient(180deg, #0A1D37 0%, #0F2D59 100%);
  border-color: rgba(255, 153, 51, 0.4);
}

.glassmorphic {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Splash/Title design */
.splash-banner {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 3px solid var(--color-rickshaw-yellow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.splash-image {
  width: 100%;
  height: auto;
  display: block;
}

.game-title {
  font-size: 21px;
  font-weight: 900;
  margin-bottom: 4px;
  background: linear-gradient(45deg, var(--color-rickshaw-yellow), var(--color-saffron), #FF1744);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  letter-spacing: -0.5px;
}

.game-subtitle {
  font-size: 11.5px;
  font-weight: 600;
  color: #B2DFDB;
  margin-bottom: 12px;
}

/* Menu buttons */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.btn {
  font-family: var(--font-family);
  font-size: 13.5px;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn:active {
  transform: scale(0.95);
}

.primary-btn {
  background: linear-gradient(135deg, var(--color-saffron) 0%, #E65100 100%);
  color: var(--color-white);
  box-shadow: 0 6px 20px rgba(230, 81, 0, 0.4);
  border-bottom: 4px solid #B33600;
}

.primary-btn:hover {
  background: linear-gradient(135deg, #FFB74D 0%, #F57C00 100%);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-white);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.sound-btn {
  background: rgba(13, 92, 117, 0.25);
  color: #4DB6AC;
  border: 1px solid rgba(77, 182, 172, 0.3);
  transition: all 0.25s ease;
}

.sound-btn.mode-all {
  background: linear-gradient(135deg, #FF9800, #F57C00) !important;
  color: #FFFFFF !important;
  border: 1px solid #FFB74D !important;
  box-shadow: 0 4px 15px rgba(255, 152, 0, 0.45) !important;
}

.sound-btn.mode-fx {
  background: rgba(13, 92, 117, 0.85) !important;
  color: #FFD54F !important;
  border: 1px solid var(--color-rickshaw-yellow) !important;
  box-shadow: 0 4px 15px rgba(255, 213, 79, 0.3) !important;
}

.sound-btn.mode-muted {
  background: #263238 !important;
  color: #90A4AE !important;
  border: 1px solid #546E7A !important;
  box-shadow: none !important;
  opacity: 0.85;
}

/* Instruction Screen specifics */
#how-to-play-screen h2 {
  font-size: 20px;
  font-weight: 900;
  color: var(--color-rickshaw-yellow);
  margin-bottom: 16px;
}

.instructions-content {
  text-align: left;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 8px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom Scrollbar for Instructions */
.instructions-content::-webkit-scrollbar {
  width: 6px;
}

.instructions-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.instructions-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.instruction-group h3 {
  font-size: 13px;
  font-weight: 800;
  color: var(--color-saffron);
  margin-bottom: 6px;
}

.instruction-group p {
  font-size: 11px;
  line-height: 1.5;
  color: #CFD8DC;
}

.items-list {
  list-style: none;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.items-list li {
  font-size: 11px;
  color: #CFD8DC;
  display: flex;
  align-items: center;
  gap: 6px;
}

.items-list .icon {
  font-size: 14px;
  min-width: 20px;
  text-align: center;
}

/* Game Over Card Specifics */
.gameover-card {
  border-color: rgba(211, 47, 47, 0.4);
}

.gameover-title {
  font-size: 26px;
  font-weight: 900;
  color: #FF5252;
  margin-bottom: 6px;
}

.gameover-message {
  font-size: 12px;
  color: #B0BEC5;
  margin-bottom: 24px;
}

.stats-summary {
  display: flex;
  width: 100%;
  gap: 16px;
  margin-bottom: 28px;
}

.summary-item {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-label {
  font-size: 10px;
  font-weight: 800;
  color: #90A4AE;
  display: block;
  margin-bottom: 4px;
}

.summary-value {
  font-size: 20px;
  font-weight: 900;
  color: var(--color-rickshaw-yellow);
}

/* Rewarded Video Revive Button */
.revive-btn {
  background: linear-gradient(135deg, #00C853, #00E676) !important;
  color: #05240E !important;
  font-weight: 900 !important;
  font-size: 14px !important;
  border: 1px solid #B9F6CA !important;
  box-shadow: 0 4px 18px rgba(0, 230, 118, 0.45);
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.revive-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 230, 118, 0.65);
  background: linear-gradient(135deg, #00E676, #69F0AE) !important;
}

.pulse-glow {
  animation: pulse-glow-anim 1.6s infinite alternate;
}

@keyframes pulse-glow-anim {
  0% { box-shadow: 0 0 10px rgba(0, 230, 118, 0.3); transform: scale(1); }
  100% { box-shadow: 0 0 22px rgba(0, 230, 118, 0.7); transform: scale(1.02); }
}

.ad-tag {
  background: rgba(0, 0, 0, 0.35);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  letter-spacing: 0.5px;
}

/* ==========================================
   Mobile On-Screen Controls
   ========================================== */
#touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px;
  z-index: 50;
  pointer-events: none; /* Allows click-throughs to canvas where necessary */
}

.touch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.touch-btn {
  pointer-events: auto; /* Active touch target */
  background: rgba(10, 20, 29, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: var(--color-white);
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 900;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
  transition: all 0.1s ease;
}

.touch-btn:active {
  transform: scale(0.9);
  background: rgba(13, 92, 117, 0.95);
  border-color: var(--color-rickshaw-yellow);
}

.steer-btn {
  width: 70px;
  height: 70px;
  border-radius: 20px;
  font-size: 24px;
}

.horn-btn {
  flex: 1;
  height: 60px;
  border-radius: 30px;
  font-size: 14px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #0288D1, #0097A7);
  box-shadow: 0 4px 12px rgba(0, 151, 167, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.horn-btn:active {
  background: linear-gradient(135deg, #039BE5, #00ACC1);
}

/* ==========================================
   Animations
   ========================================== */
@keyframes pulse-anim {
  0% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(230, 81, 0, 0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 10px 25px rgba(230, 81, 0, 0.6);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(230, 81, 0, 0.4);
  }
}

.pulse-anim {
  animation: pulse-anim 1.8s infinite ease-in-out;
}

@keyframes float {
  0% { transform: translate(-50%, 0px); }
  50% { transform: translate(-50%, -6px); }
  100% { transform: translate(-50%, 0px); }
}

/* Ensure absolute centering for absolute float overlay */
#passenger-status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  white-space: nowrap;
}
#passenger-status {
  animation: float 2.5s infinite ease-in-out;
}

/* Screen shake for collision */
.shake {
  animation: shake-anim 0.4s ease;
}

@keyframes shake-anim {
  0%, 100% { transform: translate(0, 0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-4px, -2px); }
  20%, 40%, 60%, 80% { transform: translate(4px, 2px); }
}

/* ==========================================
   Start Screen Route Carousel & Cards
   ========================================== */
.carousel-container {
  width: 100%;
  margin: 16px 0 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.carousel-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--color-rickshaw-yellow);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.route-carousel {
  display: flex;
  gap: 10px;
  width: 100%;
  overflow-x: auto;
  padding: 6px 4px 10px 4px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 213, 79, 0.4) rgba(0, 0, 0, 0.1);
  -webkit-overflow-scrolling: touch;
  /* Unlocks iOS Safari horizontal gesture swipe lock */
  user-select: auto !important;
  -webkit-user-select: auto !important;
  touch-action: pan-x !important;
}
.route-carousel::-webkit-scrollbar {
  height: 5px;
}
.route-carousel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}
.route-carousel::-webkit-scrollbar-thumb {
  background: rgba(255, 213, 79, 0.5);
  border-radius: 4px;
}
.route-card {
  position: relative;
  flex: 0 0 102px;
  scroll-snap-align: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* Unlocks iOS Safari horizontal gesture swipe lock on child touches */
  user-select: auto !important;
  -webkit-user-select: auto !important;
  touch-action: pan-x !important;
}
.route-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--color-rickshaw-yellow);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(255, 213, 79, 0.2);
}
.route-card:active {
  transform: scale(0.95);
}
.route-emoji {
  font-size: 20px;
  margin-bottom: 4px;
}
.route-name {
  font-size: 11px;
  font-weight: 900;
  color: var(--color-white);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.route-landmark {
  font-size: 8px;
  font-weight: 600;
  color: #B0BEC5;
}

/* ==========================================
   Visual Keyboard Instructions Layout
   ========================================== */
.visual-instructions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}
.visual-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.visual-keys {
  display: flex;
  align-items: center;
  gap: 5px;
}
.key-cap {
  background: linear-gradient(180deg, #ECEFF1 0%, #B0BEC5 100%);
  color: #263238;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: 0 3px 0 #78909C, 0 4px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid #FFF;
  text-align: center;
}
.space-key {
  padding: 6px 20px;
  font-size: 10px;
}
.key-or {
  font-size: 10px;
  font-weight: 800;
  color: #90A4AE;
  margin: 0 2px;
}
.visual-action {
  font-size: 11px;
  font-weight: 800;
  color: #ECEFF1;
  text-align: right;
}
.visual-divider {
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  margin: 4px 0;
}
.visual-items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}
.visual-item-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.badge-icon {
  font-size: 18px;
  margin-bottom: 3px;
}
.badge-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--color-rickshaw-yellow);
}
.badge-desc {
  font-size: 8px;
  font-weight: 600;
  color: #B0BEC5;
}

/* Responsive Mobile Web Adaptations */
@media (max-width: 480px) {
  #app-container {
    padding: 0;
  }
  #game-container {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    aspect-ratio: 400 / 700;
    margin: auto;
  }
}

/* Hide on-screen touch buttons if user has hover (mouse cursor) */
@media (hover: hover) and (pointer: fine) {
  #touch-controls {
    display: none !important;
  }
}
