* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Arial", sans-serif;
}

body {
  background-color: #0a0e17;
  color: white;
  overflow: hidden;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Make sure the game container takes up the full viewport */
.game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-color: #0f1623;
  overflow: hidden;
}

/* Add a loading indicator */
.game-container::before {
  content: "Loading...";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: clamp(18px, 4vw, 24px);
  z-index: 5;
  animation: fadeOut 2s forwards;
  animation-delay: 3s;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Make sure the canvas is visible and properly sized */
canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Thrust Button Styles */
.thrust-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: rgba(0, 184, 148, 0.8);
  border: 3px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  display: none; /* Hidden by default */
}

/* Show thrust button only on mobile devices */
@media (max-width: 768px) and (pointer: coarse) {
  .thrust-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Additional mobile detection - show on touch devices with small screens */
@media (max-width: 768px) and (hover: none) {
  .thrust-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.thrust-btn:hover,
.thrust-btn:active {
  background-color: rgba(0, 184, 148, 1);
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.thrust-btn.active {
  background-color: rgba(255, 157, 0, 0.9);
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Adjust thrust button for smaller screens */
@media (max-width: 768px) and (pointer: coarse) {
  .thrust-btn {
    width: 70px;
    height: 70px;
    font-size: 12px;
    bottom: 15px;
    right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-height: 500px) and (pointer: coarse) {
  .thrust-btn {
    width: 60px;
    height: 60px;
    font-size: 11px;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.meters {
  position: absolute;
  top: 10px;
  left: 10px;
}

.meters-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.meter {
  background-color: rgba(15, 22, 35, 0.9);
  padding: clamp(6px, 2vw, 10px);
  border-radius: 5px;
  min-width: clamp(120px, 25vw, 200px);
}

.meter-label {
  font-size: clamp(10px, 2.5vw, 14px);
  margin-bottom: 3px;
  color: #aaa;
}

.meter-bar {
  height: clamp(10px, 2.5vw, 15px);
  background-color: #1a2235;
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  background-color: #ff9d00;
  width: 100%;
  transition: width 0.2s;
}

.revenue-display {
  background-color: rgba(15, 22, 35, 0.9);
  padding: clamp(6px, 2vw, 10px);
  border-radius: 5px;
  min-width: clamp(80px, 20vw, 120px);
}

.personal-best-display {
  background-color: rgba(15, 22, 35, 0.9);
  padding: clamp(6px, 2vw, 10px);
  border-radius: 5px;
  min-width: clamp(80px, 20vw, 120px);
  border: 1px solid rgba(0, 184, 148, 0.3);
}

#revenueValue {
  font-size: clamp(12px, 3vw, 18px);
  font-weight: bold;
  color: #ff9d00;
}

#personalBestValue {
  font-size: clamp(12px, 3vw, 18px);
  font-weight: bold;
  color: #00b894;
}

.fuel-meter {
  min-width: clamp(120px, 25vw, 200px);
}

.game-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.global-high-score {
  background-color: rgba(15, 22, 35, 0.9);
  padding: clamp(6px, 2vw, 10px);
  border-radius: 5px;
  font-size: clamp(10px, 2vw, 12px);
  color: #aaa;
  text-align: right;
  border: 1px solid rgba(255, 215, 0, 0.3);
  min-width: clamp(100px, 22vw, 150px);
}

.high-score-label {
  font-size: clamp(8px, 1.8vw, 10px);
  color: #aaa;
  margin-bottom: 2px;
}

.high-score-name {
  font-size: clamp(10px, 2.2vw, 14px);
  color: #ffd700;
  font-weight: bold;
  margin-bottom: 2px;
}

.high-score-value {
  font-size: clamp(10px, 2.2vw, 14px);
  color: #ffd700;
  font-weight: bold;
}

button {
  padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 20px);
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto;
  font-size: clamp(10px, 2.5vw, 14px);
  min-height: 44px;
  min-width: 44px;
  /* Improve touch target */
  touch-action: manipulation;
}

.restart-btn {
  background-color: #00b894;
  color: white;
  margin-bottom: 8px;
}

.restart-btn:hover {
  background-color: #00a382;
}

.view-instructions-btn {
  background-color: #6c5ce7;
  color: white;
  font-size: clamp(10px, 2vw, 12px);
  padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2.5vw, 16px);
}

.view-instructions-btn:hover {
  background-color: #5a4fcf;
}

.export-btn {
  background-color: #e17055;
  color: white;
  font-size: clamp(9px, 2vw, 11px);
  padding: clamp(6px, 1.5vw, 8px) clamp(8px, 2vw, 12px);
  min-width: clamp(60px, 15vw, 80px);
}

.export-btn:hover {
  background-color: #d63031;
}

.export-btn:disabled {
  background-color: #636e72;
  cursor: not-allowed;
}

.register-btn {
  background-color: #00b894;
  color: white;
  width: 100%;
  padding: clamp(10px, 2.5vw, 12px);
  font-size: clamp(14px, 3vw, 16px);
  margin-top: 20px;
}

.register-btn:hover {
  background-color: #00a382;
}

.game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(15, 22, 35, 0.95);
  padding: clamp(20px, 5vw, 30px);
  border-radius: 10px;
  text-align: center;
  display: none;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.game-over h2 {
  font-size: clamp(24px, 6vw, 32px);
  margin-bottom: clamp(15px, 4vw, 20px);
  color: #ff4757;
}

.final-score {
  font-size: clamp(18px, 4.5vw, 24px);
  margin-bottom: clamp(10px, 3vw, 15px);
}

.score-status {
  font-size: clamp(12px, 3vw, 16px);
  margin-bottom: clamp(15px, 4vw, 20px);
  padding: clamp(8px, 2vw, 10px);
  border-radius: 5px;
}

.score-status.new-record {
  background-color: rgba(0, 184, 148, 0.2);
  color: #00b894;
  border: 1px solid #00b894;
}

.score-status.personal-best {
  background-color: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  border: 1px solid #ffd700;
}

.score-status.no-improvement {
  background-color: rgba(116, 125, 140, 0.2);
  color: #74b9ff;
  border: 1px solid #74b9ff;
}

#finalScore {
  color: #ff9d00;
  font-weight: bold;
}

.instructions {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(15, 22, 35, 0.95);
  padding: clamp(15px, 3vw, 20px);
  border-radius: 8px;
  text-align: center;
  font-size: clamp(10px, 2.2vw, 12px);
  color: #aaa;
  line-height: 1.4;
  max-width: 95vw;
  transition: opacity 1s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.instructions.fade-out {
  opacity: 0;
  pointer-events: none;
}

.instructions strong {
  color: #ff9d00;
  font-weight: bold;
}

.instructions p {
  margin: clamp(6px, 1.5vw, 8px) 0;
}

.instructions p:first-child {
  color: #00b894;
  font-size: clamp(12px, 2.5vw, 14px);
  margin-bottom: clamp(8px, 2vw, 12px);
}

.instructions-content {
  display: flex;
  gap: clamp(15px, 4vw, 30px);
  justify-content: center;
  align-items: flex-start;
  margin: clamp(10px, 2.5vw, 15px) 0;
}

.powerups-column,
.powerdowns-column {
  flex: 1;
  max-width: clamp(200px, 40vw, 300px);
}

.powerups-column h4,
.powerdowns-column h4 {
  color: #ff9d00;
  font-size: clamp(11px, 2.5vw, 13px);
  margin-bottom: clamp(8px, 2vw, 10px);
  text-align: center;
  font-weight: bold;
}

.powerups-column h4 {
  color: #00b894;
}

.powerdowns-column h4 {
  color: #ff4757;
}

.powerup-item,
.powerdown-item {
  display: flex;
  align-items: center;
  margin-bottom: clamp(4px, 1vw, 6px);
  font-size: clamp(9px, 2vw, 11px);
  text-align: left;
}

.powerup-icon,
.powerdown-icon {
  margin-right: clamp(6px, 1.5vw, 8px);
  font-size: clamp(12px, 2.5vw, 14px);
  width: clamp(16px, 3vw, 20px);
  text-align: center;
}

.controls-section {
  margin-bottom: clamp(10px, 2.5vw, 15px);
}

.main-objective {
  font-size: clamp(14px, 3vw, 16px) !important;
  color: #ff9d00 !important;
  margin-top: clamp(10px, 2.5vw, 15px) !important;
  font-weight: bold !important;
}

/* Portrait Orientation Warning for Mobile - but allow registration */
.portrait-warning {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999; /* Lower than modal overlay but higher than game */
  flex-direction: column;
}

.portrait-warning.show {
  display: flex;
}

.portrait-content {
  text-align: center;
  color: white;
  padding: 20px;
  max-width: 90%;
}

.portrait-content .phone-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

.portrait-content .rotate-icon {
  font-size: 3rem;
  margin-top: 20px;
  animation: rotate 2s linear infinite;
}

.portrait-content h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #ff9d00;
}

.portrait-content p {
  font-size: 1.2rem;
  color: #aaa;
  margin-bottom: 10px;
}

.portrait-content .game-title {
  font-size: 1.5rem;
  color: #00b894;
  margin-bottom: 20px;
  font-weight: bold;
}

/* Modal Styles - ALWAYS available regardless of orientation and OUTSIDE game container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10001; /* Higher than portrait warning and game container */
  pointer-events: auto;
  padding: 10px;
}

.modal-overlay.show {
  display: flex !important; /* Force display regardless of other CSS */
  touch-action: auto;
}

/* Enhanced modal content for all orientations */
.modal-content {
  background-color: #0f1623;
  border-radius: 10px;
  max-width: clamp(300px, 90vw, 700px);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
  /* Ensure proper touch behavior */
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(15px, 4vw, 20px) clamp(20px, 5vw, 25px) clamp(10px, 3vw, 15px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
  color: #ff9d00;
  font-size: clamp(18px, 4.5vw, 24px);
  margin: 0;
}

.close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: clamp(24px, 5vw, 28px);
  cursor: pointer;
  padding: 0;
  width: clamp(25px, 6vw, 30px);
  height: clamp(25px, 6vw, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  min-width: 44px;
  min-height: 44px;
}

.close-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.modal-body {
  padding: clamp(15px, 4vw, 20px) clamp(20px, 5vw, 25px) clamp(20px, 5vw, 25px);
  color: #aaa;
  line-height: 1.5;
}

.modal-body p {
  margin: clamp(8px, 2vw, 12px) 0;
  font-size: clamp(12px, 2.5vw, 14px);
}

.modal-body p:first-child {
  color: #00b894;
  font-size: clamp(14px, 3vw, 16px);
  margin-bottom: clamp(12px, 3vw, 15px);
}

.modal-body strong {
  color: #ff9d00;
  font-weight: bold;
}

.modal-body .main-objective {
  font-size: clamp(16px, 3.5vw, 18px) !important;
  color: #ff9d00 !important;
  margin-top: clamp(15px, 4vw, 20px) !important;
  font-weight: bold !important;
  text-align: center;
}

.modal-body .instructions-content {
  display: flex;
  gap: clamp(20px, 5vw, 30px);
  justify-content: center;
  align-items: flex-start;
  margin: clamp(15px, 4vw, 20px) 0;
}

.modal-body .powerups-column,
.modal-body .powerdowns-column {
  flex: 1;
  max-width: clamp(200px, 45vw, 280px);
}

.modal-body .powerups-column h4,
.modal-body .powerdowns-column h4 {
  color: #ff9d00;
  font-size: clamp(14px, 3vw, 16px);
  margin-bottom: clamp(12px, 3vw, 15px);
  text-align: center;
  font-weight: bold;
}

.modal-body .powerups-column h4 {
  color: #00b894;
}

.modal-body .powerdowns-column h4 {
  color: #ff4757;
}

.modal-body .powerup-item,
.modal-body .powerdown-item {
  display: flex;
  align-items: center;
  margin-bottom: clamp(8px, 2vw, 10px);
  font-size: clamp(12px, 2.5vw, 14px);
  text-align: left;
}

.modal-body .powerup-icon,
.modal-body .powerdown-icon {
  margin-right: clamp(8px, 2vw, 10px);
  font-size: clamp(14px, 3vw, 16px);
  width: clamp(20px, 4vw, 25px);
  text-align: center;
}

.modal-body .controls-section {
  margin-bottom: clamp(15px, 4vw, 20px);
  text-align: center;
}

.modal-body ul {
  margin: clamp(12px, 3vw, 15px) 0;
  padding-left: clamp(15px, 4vw, 20px);
}

.modal-body li {
  margin: clamp(6px, 1.5vw, 8px) 0;
  color: #aaa;
}

/* Form Styles - optimized for all orientations */
.form-group {
  margin-bottom: clamp(15px, 4vw, 20px);
}

.form-group label {
  display: block;
  margin-bottom: clamp(4px, 1vw, 5px);
  color: #ff9d00;
  font-weight: bold;
  font-size: clamp(12px, 2.5vw, 14px);
}

.form-group input {
  width: 100%;
  padding: clamp(8px, 2vw, 10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: clamp(12px, 2.5vw, 14px);
  min-height: 44px;
  /* Improve touch target size on mobile */
  touch-action: auto;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.form-group input:focus {
  outline: none;
  border-color: #ff9d00;
  background-color: rgba(255, 255, 255, 0.15);
}

.form-group input::placeholder {
  color: #aaa;
}

.form-hint {
  display: block;
  margin-top: clamp(3px, 1vw, 5px);
  font-size: clamp(10px, 2vw, 12px);
  color: #aaa;
  font-style: italic;
}

.powerup-icon-img {
  width: clamp(16px, 3vw, 20px);
  height: clamp(16px, 3vw, 20px);
  margin-right: clamp(6px, 1.5vw, 8px);
  object-fit: contain;
  border-radius: 3px;
}

.modal-body .powerup-icon-img {
  width: clamp(20px, 4vw, 25px);
  height: clamp(20px, 4vw, 25px);
  margin-right: clamp(8px, 2vw, 10px);
  object-fit: contain;
  border-radius: 3px;
}

/* Fallback for when images don't load */
.powerup-icon-img:not([src]),
.powerup-icon-img[src="/placeholder.svg"] {
  display: none;
}

.powerup-icon-img:not([src]) + span::before,
.powerup-icon-img[src="/placeholder.svg"] + span::before {
  content: "🟢";
  margin-right: clamp(6px, 1.5vw, 8px);
  font-size: clamp(12px, 2.5vw, 14px);
  width: clamp(16px, 3vw, 20px);
  text-align: center;
  display: inline-block;
}

/* Sync status responsive */
.sync-status {
  background-color: rgba(15, 22, 35, 0.9);
  padding: clamp(4px, 1vw, 6px) clamp(6px, 1.5vw, 8px);
  border-radius: 3px;
  font-size: clamp(8px, 1.8vw, 10px);
  color: #aaa;
  display: flex;
  align-items: center;
  gap: clamp(3px, 1vw, 5px);
  min-width: clamp(70px, 18vw, 100px);
}

/* Orientation message for mobile devices */
.orientation-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  flex-direction: column;
}

.orientation-content {
  text-align: center;
  color: white;
  padding: 20px;
}

.phone-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: bounce 2s infinite;
}

.rotate-icon {
  font-size: 3rem;
  margin-top: 20px;
  animation: rotate 2s linear infinite;
}

.orientation-message h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #ff9d00;
}

.orientation-message p {
  font-size: 1.2rem;
  color: #aaa;
}

/* Fullscreen Button Styles */
.fullscreen-btn {
  position: absolute;
  bottom: 120px; /* Position above thrust button */
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: rgba(15, 22, 35, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  padding: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.fullscreen-btn:hover,
.fullscreen-btn:active {
  background-color: rgba(0, 184, 148, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.fullscreen-btn svg {
  width: 24px;
  height: 24px;
  stroke: white;
  stroke-width: 2;
}

/* Show fullscreen button only on mobile devices */
@media (max-width: 768px) and (pointer: coarse) {
  .fullscreen-btn {
    display: flex;
  }
}

/* Adjust position for smaller mobile screens */
@media (max-width: 480px) {
  .fullscreen-btn {
    width: 50px;
    height: 50px;
    bottom: 110px;
    right: 15px;
  }

  .fullscreen-btn svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-height: 500px) {
  .fullscreen-btn {
    width: 45px;
    height: 45px;
    bottom: 80px;
    right: 10px;
  }

  .fullscreen-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Hide fullscreen button when in fullscreen mode */
:fullscreen .fullscreen-btn {
  display: none;
}

:-webkit-full-screen .fullscreen-btn {
  display: none;
}

:-moz-full-screen .fullscreen-btn {
  display: none;
}

:-ms-fullscreen .fullscreen-btn {
  display: none;
}

/* Portrait mobile specific modal adjustments */
@media (max-width: 768px) and (orientation: portrait) {
  .modal-overlay {
    z-index: 10001; /* Ensure it's above portrait warning */
    padding: 5px;
  }

  .modal-content {
    max-width: 95vw;
    max-height: 95vh;
    margin: 0;
  }

  .modal-header {
    padding: 12px 15px 8px;
  }

  .modal-header h2 {
    font-size: 20px;
  }

  .modal-body {
    padding: 12px 15px 15px;
  }

  .modal-body p {
    font-size: 14px;
    margin: 6px 0;
  }

  .modal-body p:first-child {
    font-size: 16px;
    margin-bottom: 10px;
  }

  /* Form adjustments for portrait mobile */
  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    font-size: 14px;
    margin-bottom: 3px;
  }

  .form-group input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 12px;
    min-height: 48px; /* Better touch target */
  }

  .register-btn {
    padding: 14px;
    font-size: 16px;
    margin-top: 15px;
    min-height: 48px;
  }

  .close-btn {
    width: 48px;
    height: 48px;
    font-size: 28px;
  }
}

/* Specific styles for registration modal in portrait */
@media (max-width: 768px) and (orientation: portrait) {
  #registrationModal .modal-content {
    /* Optimize for portrait registration */
    border-radius: 8px;
  }

  #registrationModal .modal-header h2 {
    color: #ff9d00;
    text-align: center;
    width: 100%;
  }

  #registrationModal .modal-body {
    text-align: left;
  }

  #registrationModal .form-group input {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.15);
    transition: border-color 0.2s ease;
  }

  #registrationModal .form-group input:focus {
    border-color: #ff9d00;
    background-color: rgba(255, 255, 255, 0.2);
    outline: none;
  }

  #registrationModal .register-btn {
    background: linear-gradient(135deg, #00b894, #00a382);
    border-radius: 8px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
  }

  #registrationModal .register-btn:hover,
  #registrationModal .register-btn:active {
    background: linear-gradient(135deg, #00a382, #008f70);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
  }
}

/* Instructions modal adjustments for portrait */
@media (max-width: 768px) and (orientation: portrait) {
  #instructionsModal .instructions-content {
    flex-direction: column;
    gap: 15px;
  }

  #instructionsModal .powerups-column,
  #instructionsModal .powerdowns-column {
    max-width: 100%;
  }

  #instructionsModal .powerup-item,
  #instructionsModal .powerdown-item {
    margin-bottom: 8px;
    font-size: 13px;
  }

  #instructionsModal .powerup-icon-img {
    width: 18px;
    height: 18px;
    margin-right: 8px;
  }
}

/* Ensure game content is blurred when portrait warning is shown, but not when modal is open */
.portrait-warning.show:not(.hide-for-registration) ~ .game-container {
  filter: blur(5px);
  pointer-events: none;
}

/* Don't blur when modal is open */
.modal-overlay.show ~ .game-container {
  filter: none !important;
  pointer-events: auto !important;
}

/* Additional rule to ensure portrait warning covers everything */
.portrait-warning.show {
  background-color: #0a0e17 !important; /* Solid background color matching body */
}

/* iOS fullscreen support - improved */
body.ios-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important; /* Use dynamic viewport height */
  overflow: hidden !important;
  -webkit-overflow-scrolling: touch;
  /* Force hardware acceleration */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

body.ios-fullscreen .game-container {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important; /* Use dynamic viewport height */
  z-index: 9999 !important;
  overflow: hidden !important;
}

/* Hide Safari UI elements when in iOS fullscreen */
body.ios-fullscreen {
  /* Hide the status bar area */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);

  /* Additional iOS specific hiding */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Force full height on iOS */
@supports (-webkit-touch-callout: none) {
  html,
  body {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
    overflow: hidden;
  }

  body.ios-fullscreen {
    /* Use the largest possible height */
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
  }

  body.ios-fullscreen .game-container {
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
  }
}

/* Update fullscreen button for iOS - show expand icon instead of SVG */
@supports (-webkit-touch-callout: none) {
  .fullscreen-btn {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .fullscreen-btn::before {
    content: "⛶";
    font-size: 20px;
  }

  .fullscreen-btn svg {
    display: none;
  }

  /* When in iOS fullscreen mode, show minimize icon */
  body.ios-fullscreen .fullscreen-btn::before {
    content: "⛉";
  }
}

/* Improve touch targets on iOS */
@media (max-width: 768px) and (-webkit-touch-callout: none) {
  .fullscreen-btn {
    width: 54px;
    height: 54px;
    bottom: 130px;
    right: 20px;
  }

  .thrust-btn {
    width: 74px;
    height: 74px;
  }
}

/* Additional iOS viewport fixes */
@supports (-webkit-touch-callout: none) {
  /* Prevent bounce scrolling */
  body {
    position: fixed;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure canvas takes full space */
  canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
  }
}

/* Improve touch targets on iOS */
@media (max-width: 768px) and (-webkit-touch-callout: none) {
  .fullscreen-btn {
    width: 54px;
    height: 54px;
    bottom: 130px;
    right: 20px;
  }

  .thrust-btn {
    width: 74px;
    height: 74px;
  }
}

/* iPhone Fullscreen Instruction Modal */
#iphoneFullscreenModal .modal-content {
  max-width: 400px;
  background: linear-gradient(135deg, #0f1623 0%, #1a2332 100%);
  border: 2px solid rgba(0, 184, 148, 0.3);
}

#iphoneFullscreenModal .modal-header h2 {
  color: #00b894;
  text-align: center;
  font-size: clamp(18px, 4vw, 22px);
}

.fullscreen-steps {
  margin: 20px 0;
}

.step {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 15px;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border-left: 4px solid #ff9d00;
}

.step-number {
  background-color: #ff9d00;
  color: #0f1623;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  margin-right: 15px;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-content p {
  margin: 0 0 8px 0;
  font-size: clamp(14px, 3vw, 16px);
  color: white;
}

.safari-icon,
.home-screen-icon {
  font-size: 24px;
  text-align: center;
  margin-top: 5px;
}

.alternative-method {
  background-color: rgba(116, 185, 255, 0.1);
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid #74b9ff;
  margin: 20px 0;
}

.alternative-method p {
  margin: 0;
  font-size: clamp(12px, 2.5vw, 14px);
  color: #74b9ff;
  font-style: italic;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
  flex-direction: column;
}

.continue-btn,
.close-fullscreen-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  font-size: clamp(14px, 3vw, 16px);
  min-height: 48px;
  transition: all 0.2s ease;
}

.continue-btn {
  background-color: rgba(116, 125, 140, 0.8);
  color: white;
  border: 2px solid rgba(116, 125, 140, 0.5);
}

.continue-btn:hover,
.continue-btn:active {
  background-color: rgba(116, 125, 140, 1);
  border-color: rgba(116, 125, 140, 0.8);
}

.close-fullscreen-btn {
  background-color: #00b894;
  color: white;
  border: 2px solid rgba(0, 184, 148, 0.5);
}

.close-fullscreen-btn:hover,
.close-fullscreen-btn:active {
  background-color: #00a382;
  border-color: rgba(0, 184, 148, 0.8);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
  .step {
    padding: 12px;
    margin-bottom: 15px;
  }

  .step-number {
    width: 25px;
    height: 25px;
    font-size: 14px;
    margin-right: 12px;
  }

  .modal-actions {
    gap: 8px;
  }

  .continue-btn,
  .close-fullscreen-btn {
    padding: 14px 16px;
    font-size: 15px;
  }
}

/* Portrait mode adjustments */
@media (orientation: portrait) {
  #iphoneFullscreenModal .modal-content {
    max-width: 90vw;
  }

  .modal-actions {
    flex-direction: column;
  }
}

#exportBtn,#syncStatus{
  display: none;
}
