@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;
}

#score {
  position: absolute;
  top: 4px;
  right: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
  text-shadow: 2px 2px 0px #000;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: 6px;
  border: 2px solid var(--obstacle-color);
  backdrop-filter: blur(5px);
}

@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: 40px 50px;
  border-radius: 20px;
  backdrop-filter: blur(15px);
  border: 3px 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 20px 0;
  font-size: 3rem;
  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: 2px;
}

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

button {
  background: linear-gradient(135deg, var(--obstacle-color), #ff5252);
  color: #ffffff;
  border: 2px solid var(--obstacle-color);
  padding: 15px 35px;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  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 ===== */

/* Large Desktop (1920px and up) */
@media screen and (min-width: 1920px) {
  #score {
    font-size: 2rem;
    top: 8px;
    right: 20px;
    padding: 12px 18px;
  }
  
  h1 {
    font-size: 4rem;
  }
  
  p {
    font-size: 1.5rem;
  }
  
  button {
    padding: 20px 45px;
    font-size: 1.3rem;
  }
  
  #message-box {
    padding: 50px 60px;
  }
}

/* Desktop (1200px to 1919px) - Current web experience */
@media screen and (min-width: 1200px) and (max-width: 1919px) {
  /* Keep current styles - this is the default web experience */
}

/* Laptop/Medium Desktop (992px to 1199px) */
@media screen and (min-width: 992px) and (max-width: 1199px) {
  #score {
    font-size: 1.3rem;
    top: 6px;
    right: 15px;
    padding: 10px 14px;
  }
  
  h1 {
    font-size: 2.5rem;
  }
  
  p {
    font-size: 1.1rem;
  }
  
  button {
    padding: 12px 30px;
    font-size: 1rem;
  }
  
  #message-box {
    padding: 35px 45px;
  }
}

/* Tablet Landscape (768px to 991px) */
@media screen and (min-width: 768px) and (max-width: 991px) {
  #score {
    font-size: 1.2rem;
    top: 8px;
    right: 12px;
    padding: 8px 12px;
  }
  
  h1 {
    font-size: 2.2rem;
    margin-bottom: 15px;
  }
  
  p {
    font-size: 1rem;
    margin-bottom: 25px;
    line-height: 1.5;
  }
  
  button {
    padding: 12px 28px;
    font-size: 0.95rem;
  }
  
  #message-box {
    padding: 30px 40px;
    border-radius: 15px;
  }
  
  /* Adjust canvas for tablet landscape */
  canvas {
    max-width: 100vw;
    max-height: 100vh;
  }
}

/* Tablet Portrait (481px to 767px) */
@media screen and (min-width: 481px) and (max-width: 767px) {
  #score {
    font-size: 1.1rem;
    top: 10px;
    right: 10px;
    padding: 6px 10px;
  }
  
  h1 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    letter-spacing: 1px;
  }
  
  p {
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.4;
  }
  
  button {
    padding: 10px 25px;
    font-size: 0.9rem;
    border-radius: 12px;
  }
  
  #message-box {
    padding: 25px 35px;
    border-radius: 12px;
    margin: 0 20px;
  }
  
  /* Touch-friendly adjustments */
  button:hover {
    transform: none; /* Disable hover effects on touch devices */
  }
  
  button:active {
    transform: scale(0.95);
  }
}

/* Mobile Landscape (320px to 480px) */
@media screen and (min-width: 320px) and (max-width: 480px) and (orientation: landscape) {
  #score {
    font-size: 1rem;
    top: 5px;
    right: 8px;
    padding: 4px 8px;
  }
  
  h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
  }
  
  p {
    font-size: 0.8rem;
    margin-bottom: 15px;
    line-height: 1.3;
  }
  
  button {
    padding: 8px 20px;
    font-size: 0.8rem;
  }
  
  #message-box {
    padding: 20px 25px;
    border-radius: 10px;
    margin: 0 15px;
  }
  
  /* Landscape-specific adjustments */
  body {
    font-size: 14px;
  }
}

/* Mobile Portrait (320px to 480px) */
@media screen and (min-width: 320px) and (max-width: 480px) and (orientation: portrait) {
  #score {
    font-size: 1rem;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
  }
  
  h1 {
    font-size: 1.6rem;
    margin-bottom: 15px;
    letter-spacing: 1px;
  }
  
  p {
    font-size: 0.85rem;
    margin-bottom: 20px;
    line-height: 1.4;
    padding: 0 10px;
  }
  
  button {
    padding: 12px 25px;
    font-size: 0.85rem;
    border-radius: 10px;
    min-height: 44px; /* iOS touch target minimum */
  }
  
  #message-box {
    padding: 25px 20px;
    border-radius: 12px;
    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;
  }
}

/* Very Small Mobile (up to 320px) */
@media screen and (max-width: 320px) {
  #score {
    font-size: 0.9rem;
    top: 6px;
    right: 6px;
    padding: 4px 8px;
  }
  
  h1 {
    font-size: 1.3rem;
    margin-bottom: 10px;
  }
  
  p {
    font-size: 0.75rem;
    margin-bottom: 15px;
    line-height: 1.3;
  }
  
  button {
    padding: 10px 20px;
    font-size: 0.75rem;
    min-height: 40px;
  }
  
  #message-box {
    padding: 20px 15px;
    border-radius: 10px;
    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;
  }
}