@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --background-color: #000000;
  --player-color: #535353;
  --floor-color: #2a2a2a;
  --obstacle-color: #ff6b6b;
  --text-color: #ffffff;
  --glow-color: rgba(255, 107, 107, 0.7);
  --star-color: #e0e0e0;
  --float-meter-color: #4cc9f0;
}

body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: "Press Start 2P", monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

canvas {
  display: block;
  background-color: var(--background-color);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}

#fly-progress-container {
  position: absolute;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transform: translateY(-50%);
}

#fly-progress-bar {
  width: 90px;
  height: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  border-radius: 5px;
  overflow: hidden;
  backdrop-filter: blur(5px);
  position: relative;
}

#fly-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--float-meter-color), #4cc9f0);
  width: 0%;
  transition: width 0.1s ease;
  border-radius: 4px;
}

#fly-progress-label {
  font-size: 0.7rem;
  font-weight: bold;
  color: var(--text-color);
  text-shadow: 2px 2px 0px #000;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 6px;
  border-radius: 3px;
  border: none;
  backdrop-filter: blur(5px);
  min-width: 26px;
  text-align: center;
}

#score {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-color);
  text-shadow: 2px 2px 0px #000;
  background: none;
  padding: 0;
  pointer-events: none;
}

.home-button {
  position: absolute;
  left: 10px;
  background: none;
  border: none;
  color: var(--text-color);
  padding: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: all;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
}

.home-button:hover {
  background: none;
  transform: translateY(-50%) scale(1.1);
  opacity: 0.8;
}

.home-button:active {
  transform: translateY(-50%) scale(0.95);
}

.home-button svg {
  width: 22px;
  height: 22px;
  transition: all 0.3s ease;
}

.sound-button {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-color);
  padding: 0;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: all;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
}

.sound-button svg {
  width: 22px;
  height: 22px;
  transition: all 0.3s ease;
}

.sound-button:hover {
  background: none;
  transform: translateY(-50%) scale(1.1);
  opacity: 0.8;
}

.sound-button:active {
  transform: translateY(-50%) scale(0.95);
}

.sound-button.muted {
  opacity: 0.5;
  background: none;
}

.sound-button.muted:hover {
  background: none;
  opacity: 0.6;
}


@keyframes fadeInScaleUp {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 30px var(--obstacle-color), 0 0 60px rgba(255, 107, 107, 0.3);
  }
  50% {
    box-shadow: 0 0 40px var(--obstacle-color), 0 0 80px rgba(255, 107, 107, 0.5);
  }
}

@keyframes titleGlow {
  0%, 100% {
    text-shadow: 0 0 10px var(--obstacle-color), 0 0 20px rgba(255, 107, 107, 0.5);
  }
  50% {
    text-shadow: 0 0 15px var(--obstacle-color), 0 0 30px rgba(255, 107, 107, 0.8);
  }
}

#message-box {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(20, 20, 20, 0.8));
  padding: 20px 30px;
  border-radius: 12px;
  backdrop-filter: blur(15px);
  border: 2px solid var(--obstacle-color);
  pointer-events: all;
  animation: fadeInScaleUp 0.5s ease-out forwards, glowPulse 2s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

#message-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 107, 107, 0.1), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

h1 {
  margin: 0 0 12px 0;
  font-size: 1.8rem;
  color: #ffffff;
  text-shadow: 0 0 10px var(--obstacle-color), 0 0 20px rgba(255, 107, 107, 0.5);
  animation: titleGlow 2s ease-in-out infinite;
  position: relative;
  z-index: 1;
  letter-spacing: 1px;
}

p {
  margin: 0 0 18px 0;
  font-size: 0.9rem;
  opacity: 0.95;
  color: #e0e0e0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

button {
  background: linear-gradient(135deg, var(--obstacle-color), #ff5252);
  color: #ffffff;
  border: 2px solid var(--obstacle-color);
  padding: 10px 24px;
  font-size: 0.85rem;
  font-weight: bold;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

button:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 107, 107, 0.5);
  background: linear-gradient(135deg, #ff5252, var(--obstacle-color));
}

button:hover::before {
  left: 100%;
}

button:active {
  transform: translateY(-2px) scale(1.02);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Desktop (≥1025px) */
@media screen and (min-width: 1025px) {
  #fly-progress-container {
    left: 10px;
    gap: 12px;
  }
  
  #fly-progress-bar {
    width: 110px;
    height: 14px;
  }
  
  #fly-progress-label {
    font-size: 0.85rem;
    padding: 4px 8px;
    min-width: 32px;
  }
  
  #score {
    font-size: 1.2rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 12px;
    width: 42px;
    height: 42px;
    padding: 0;
  }
  
  .home-button svg {
    width: 24px;
    height: 24px;
  }
  
  .sound-button {
    right: 12px;
    width: 42px;
    height: 42px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 24px;
    height: 24px;
  }
  
  
  h1 {
    font-size: 2.2rem;
  }
  
  p {
    font-size: 1rem;
  }
  
  button {
    padding: 12px 28px;
    font-size: 1rem;
  }
  
  #message-box {
    padding: 24px 36px;
  }
}

/* Tablet Landscape (769px-1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  #fly-progress-container {
    left: 10px;
    gap: 10px;
  }
  
  #fly-progress-bar {
    width: 85px;
    height: 12px;
  }
  
  #fly-progress-label {
    font-size: 0.75rem;
    padding: 3px 7px;
    min-width: 30px;
  }
  
  #score {
    font-size: 1rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
  }
  
  .home-button svg {
    width: 22px;
    height: 22px;
  }
  
  .sound-button {
    right: 10px;
    width: 40px;
    height: 40px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 22px;
    height: 22px;
  }
  
  
  h1 {
    font-size: 2rem;
  }
  
  p {
    font-size: 0.95rem;
  }
  
  button {
    padding: 10px 26px;
    font-size: 0.9rem;
  }
  
  #message-box {
    padding: 22px 32px;
  }
}

/* Tablet Portrait (641px-768px) */
@media screen and (min-width: 641px) and (max-width: 768px) {
  #fly-progress-container {
    left: 10px;
    gap: 8px;
  }
  
  #fly-progress-bar {
    width: 80px;
    height: 10px;
  }
  
  #fly-progress-label {
    font-size: 0.7rem;
    padding: 3px 6px;
    min-width: 28px;
  }
  
  #score {
    font-size: 0.95rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 10px;
    width: 38px;
    height: 38px;
    padding: 0;
  }
  
  .home-button svg {
    width: 22px;
    height: 22px;
  }
  
  .sound-button {
    right: 10px;
    width: 38px;
    height: 38px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 22px;
    height: 22px;
  }
  
  
  h1 {
    font-size: 1.8rem;
    margin-bottom: 12px;
  }
  
  p {
    font-size: 0.9rem;
    margin-bottom: 18px;
    line-height: 1.5;
  }
  
  button {
    padding: 10px 24px;
    font-size: 0.85rem;
  }
  
  #message-box {
    padding: 20px 28px;
    border-radius: 12px;
  }
  
  /* Adjust canvas for tablet landscape */
  canvas {
    max-width: 100vw;
    max-height: 100vh;
  }
}

/* Mobile (≤640px) */
@media screen and (max-width: 640px) {
  #fly-progress-container {
    left: 10px;
    gap: 6px;
  }
  
  #fly-progress-bar {
    width: 75px;
    height: 9px;
  }
  
  #fly-progress-label {
    font-size: 0.65rem;
    padding: 2px 5px;
    min-width: 26px;
  }
  
  #score {
    font-size: 0.9rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
  }
  
  .home-button svg {
    width: 20px;
    height: 20px;
  }
  
  .sound-button {
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 20px;
    height: 20px;
  }
  
  
  h1 {
    font-size: 1.6rem;
    margin-bottom: 10px;
    letter-spacing: 1px;
  }
  
  p {
    font-size: 0.85rem;
    margin-bottom: 16px;
    line-height: 1.4;
  }
  
  button {
    padding: 9px 22px;
    font-size: 0.8rem;
    border-radius: 10px;
  }
  
  #message-box {
    padding: 18px 26px;
    border-radius: 10px;
    margin: 0 20px;
  }
  
  /* Touch-friendly adjustments */
  button:hover {
    transform: none; /* Disable hover effects on touch devices */
  }
  
  button:active {
    transform: scale(0.95);
  }
}

/* Landscape Mobile (orientation: landscape) */
@media screen and (orientation: landscape) and (max-width: 1024px) {
  #fly-progress-container {
    left: 10px;
    gap: 5px;
  }
  
  #fly-progress-bar {
    width: 70px;
    height: 8px;
  }
  
  #fly-progress-label {
    font-size: 0.6rem;
    padding: 2px 5px;
    min-width: 24px;
  }
  
  #score {
    font-size: 0.85rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
  }
  
  .home-button svg {
    width: 16px;
    height: 16px;
  }
  
  .sound-button {
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 16px;
    height: 16px;
  }
  
  
  h1 {
    font-size: 1.3rem;
    margin-bottom: 8px;
  }
  
  p {
    font-size: 0.75rem;
    margin-bottom: 14px;
    line-height: 1.3;
  }
  
  button {
    padding: 8px 18px;
    font-size: 0.75rem;
  }
  
  #message-box {
    padding: 16px 22px;
    border-radius: 10px;
    margin: 0 15px;
  }
  
  /* Landscape-specific adjustments */
  body {
    font-size: 14px;
  }
}

/* Small Mobile (≤480px) */
@media screen and (max-width: 480px) {
  #fly-progress-container {
    left: 10px;
    gap: 6px;
  }
  
  #fly-progress-bar {
    width: 75px;
    height: 8px;
  }
  
  #fly-progress-label {
    font-size: 0.6rem;
    padding: 2px 5px;
    min-width: 24px;
  }
  
  #score {
    font-size: 0.85rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
  }
  
  .home-button svg {
    width: 16px;
    height: 16px;
  }
  
  .sound-button {
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 16px;
    height: 16px;
  }
  
  
  h1 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    letter-spacing: 1px;
  }
  
  p {
    font-size: 0.8rem;
    margin-bottom: 16px;
    line-height: 1.4;
    padding: 0 10px;
  }
  
  button {
    padding: 10px 22px;
    font-size: 0.8rem;
    border-radius: 10px;
    min-height: 44px; /* iOS touch target minimum */
  }
  
  #message-box {
    padding: 20px 18px;
    border-radius: 10px;
    margin: 0 15px;
    max-width: calc(100vw - 30px);
  }
  
  /* Mobile-specific adjustments */
  body {
    font-size: 14px;
  }
  
  /* Ensure full viewport usage */
  html, body {
    height: 100vh;
    height: -webkit-fill-available;
  }
  
  canvas {
    width: 100vw !important;
    height: 100vh !important;
    height: -webkit-fill-available !important;
  }
}

/* Extra Small Mobile (≤320px) */
@media screen and (max-width: 320px) {
  #fly-progress-container {
    left: 10px;
    gap: 4px;
  }
  
  #fly-progress-bar {
    width: 65px;
    height: 7px;
  }
  
  #fly-progress-label {
    font-size: 0.55rem;
    padding: 2px 4px;
    min-width: 22px;
  }
  
  #score {
    font-size: 0.8rem;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
    background: none;
  }
  
  .home-button {
    left: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
  }
  
  .home-button svg {
    width: 16px;
    height: 16px;
  }
  
  .sound-button {
    right: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
  }
  
  .sound-button svg {
    width: 16px;
    height: 16px;
  }
  
  
  h1 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }
  
  p {
    font-size: 0.7rem;
    margin-bottom: 14px;
    line-height: 1.3;
  }
  
  button {
    padding: 9px 18px;
    font-size: 0.7rem;
    min-height: 40px;
  }
  
  #message-box {
    padding: 16px 14px;
    border-radius: 8px;
    margin: 0 10px;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Disable hover effects on touch devices */
  button:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    background: linear-gradient(135deg, var(--obstacle-color), #ff5252);
  }
  
  button:hover::before {
    left: -100%;
  }
  
  /* Increase touch targets */
  button {
    min-height: 44px;
    min-width: 44px;
  }
}

/* High DPI/Retina Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  #message-box {
    animation: none;
  }
  
  h1 {
    animation: none;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  /* Already optimized for dark theme */
}

/* ===== MOBILE TOUCH CONTROLLER ===== */

#mobile-controller {
  position: fixed;
  left: 15px;
  bottom: 20px;
  display: none; /* Hidden by default, shown only on mobile */
  flex-direction: row;
  gap: 15px;
  z-index: 1000;
  pointer-events: all;
}

.controller-btn {
  background: linear-gradient(135deg, var(--obstacle-color), #ff5252);
  color: #ffffff;
  border: 3px solid var(--obstacle-color);
  padding: 0;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  position: relative;
  overflow: hidden;
}

.controller-btn .arrow,
.controller-btn .float-icon {
  position: relative;
  z-index: 2;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: bold;
}

.controller-btn .float-icon {
  font-family: "Press Start 2P", monospace;
  font-size: 1rem;
}

.controller-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.3s ease;
  z-index: 1;
}

.controller-btn:active {
  transform: scale(0.95);
  background: linear-gradient(135deg, #ff5252, var(--obstacle-color));
}

.controller-btn:active::before {
  left: 100%;
}

/* Show controller only on mobile devices */
@media screen and (max-width: 768px) {
  #mobile-controller {
    display: flex;
  }
}

/* Mobile Portrait Controller Styling */
@media screen and (max-width: 480px) and (orientation: portrait) {
  #mobile-controller {
    left: 12px;
    bottom: 15px;
    gap: 12px;
  }
  
  .controller-btn {
    width: 55px;
    height: 55px;
    border-radius: 50%;
  }
  
  .controller-btn .arrow {
    font-size: 1.3rem;
  }
  
  .controller-btn .float-icon {
    font-size: 0.9rem;
  }
}

/* Mobile Landscape Controller Styling */
@media screen and (max-width: 768px) and (orientation: landscape) {
  #mobile-controller {
    left: 10px;
    bottom: 10px;
    gap: 10px;
  }
  
  .controller-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
  }
  
  .controller-btn .arrow {
    font-size: 1.2rem;
  }
  
  .controller-btn .float-icon {
    font-size: 0.8rem;
  }
}

/* Very Small Mobile Controller */
@media screen and (max-width: 320px) {
  #mobile-controller {
    left: 8px;
    bottom: 10px;
    gap: 8px;
  }
  
  .controller-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
  }
  
  .controller-btn .arrow {
    font-size: 1rem;
  }
  
  .controller-btn .float-icon {
    font-size: 0.7rem;
  }
}

/* Touch Device Optimizations for Controller */
@media (hover: none) and (pointer: coarse) {
  .controller-btn:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    background: linear-gradient(135deg, var(--obstacle-color), #ff5252);
  }
  
  .controller-btn:hover::before {
    left: -100%;
  }
}

/* Print Styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  canvas {
    display: none;
  }
  
  #message-box {
    position: static;
    background: white;
    border: 1px solid black;
    color: black;
  }
  
  #mobile-controller {
    display: none !important;
  }
}