:root {
  --game-bg-color: #000;
  --game-text-color: #fff;
  --game-accent-color: #0095dd;
  --game-secondary-color: #ff5722;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #333;
  color: white;
  font-family: Arial, sans-serif;
  text-align: center;
  padding: 20px;
  line-height: 1.6;
  min-height: 100vh;
  justify-content: flex-start;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

body.embedded {
  padding: 0;
  margin: 0;
}

body.embedded .game-footer,
body.embedded .sound-info,
body.embedded h1 {
  display: none;
}

.game-wrapper {
  position: relative;
  width: 800px;
  max-width: 100%;
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-container {
  position: relative;
  background: #000;
  border: 2px solid #444;
  width: 100%;
  height: 400px;
  border-radius: 5px;
  box-shadow: 0 0 20px rgba(0, 149, 221, 0.5);
  overflow: hidden;
  display: block;
  transition: transform 0.3s ease;
}

canvas {
  display: block;
  background: #000;
  margin: 0 auto;
  border: 2px solid white;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  flex-direction: column;
}

.loading-content {
  text-align: center;
  color: white;
  max-width: 80%;
  padding: 20px;
}

.spinner {
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top: 5px solid var(--game-accent-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

h1 {
  color: var(--game-accent-color);
  margin-bottom: 10px;
  font-size: 2.5em;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.game-description {
  margin-top: 15px;
  margin-bottom: 10px;
  font-size: 1.1em;
  color: var(--game-accent-color);
  font-weight: 500;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 10px;
}

.controls-info {
  margin-bottom: 15px;
  font-size: 0.9em;
  color: #ddd;
  padding: 0 10px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* Game Controls */
.game-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
  gap: 15px;
  padding: 5px 10px;
  border-radius: 8px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.control-btn {
  width: 40px;
  height: 40px;
  padding: 8px;
  margin: 0;
  background: #444;
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.2s, transform 0.1s;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
}

.control-btn:hover {
  background: #555;
}

.control-btn:active {
  transform: scale(0.95);
  background-color: var(--game-accent-color);
}

/* Mobile touch controls */
.mobile-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  display: none; /* Hidden by default, shown on mobile */
}

.touch-area {
  position: absolute;
  height: 50%;
  width: 100%;
  pointer-events: auto;
  background-color: rgba(255, 255, 255, 0.05);
  transition: background-color 0.2s;
}

.touch-area:active {
  background-color: rgba(255, 255, 255, 0.15);
}

.touch-up {
  top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.touch-down {
  bottom: 0;
}

/* Control indicators */
.mobile-controls::before,
.mobile-controls::after {
  content: "";
  position: fixed;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.6);
  right: 10px;
  z-index: 100;
  pointer-events: none;
  border: 2px solid var(--game-accent-color);
  display: none;
  background-repeat: no-repeat;
  background-position: center;
}

.mobile-controls::before {
  top: 25%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='rgba(255,255,255,0.8)' d='M7 14l5-5 5 5z'/%3E%3C/svg%3E");
}

.mobile-controls::after {
  top: 75%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='rgba(255,255,255,0.8)' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

/* Mobile-only elements */
.mobile-only {
  display: none; /* Hidden by default */
}

/* Menu controls */
.menu-controls {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin: 15px auto;
  padding: 10px 15px;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(0, 149, 221, 0.5);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  width: fit-content;
}

.menu-btn {
  width: 50px;
  height: 50px;
  font-size: 24px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border: 2px solid var(--game-accent-color);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
}

.menu-btn:active {
  transform: scale(0.95);
  background-color: rgba(0, 149, 221, 0.4);
}

/* State-specific display for menu controls */
body[data-game-state="menu"] .menu-controls,
body[data-game-state="pause_menu"] .menu-controls {
  display: none; /* Hidden by default, will be overridden on mobile */
}

.score {
  text-align: center;
  font-size: 24px;
  margin: 10px 0;
}

.game-info {
  margin-top: 10px;
  font-size: 18px;
  text-align: center;
}

.controls {
  margin-top: 10px;
  font-size: 14px;
  color: #aaa;
  text-align: center;
}

@keyframes screen-shake {
  0% {
    transform: translate(0);
  }
  10% {
    transform: translate(-5px, 5px);
  }
  20% {
    transform: translate(5px, -5px);
  }
  30% {
    transform: translate(-5px, -5px);
  }
  40% {
    transform: translate(5px, 5px);
  }
  50% {
    transform: translate(-5px, 5px);
  }
  60% {
    transform: translate(5px, -5px);
  }
  70% {
    transform: translate(-5px, -5px);
  }
  80% {
    transform: translate(5px, 5px);
  }
  90% {
    transform: translate(-5px, -5px);
  }
  100% {
    transform: translate(0);
  }
}

.screen-shake {
  animation: screen-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.sound-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
}

.sound-controls button {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  outline: none;
  padding: 5px;
}

.sound-controls button:hover {
  color: #ffcc00;
}

.warning-message {
  padding: 10px;
  background: rgba(255, 0, 0, 0.2);
  border: 1px solid red;
  margin: 10px;
  border-radius: 4px;
}

.sound-info {
  font-size: 0.8em;
  color: #999;
  margin-bottom: 20px;
  text-align: center;
  line-height: 1.5;
}

.sound-info a {
  color: var(--game-accent-color);
  text-decoration: none;
  display: inline-block;
  margin-top: 5px;
}

.sound-info a:hover {
  text-decoration: underline;
}

.createjs-powered {
  font-size: 11px;
  position: absolute;
  bottom: 5px;
  right: 5px;
  color: #666;
}

#forceStartButton {
  background-color: #4285f4;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s;
}

#forceStartButton:hover {
  background-color: #5294ff;
}

.game-footer {
  margin-top: 20px;
  font-size: 0.8em;
  color: #777;
}

.game-footer a {
  color: var(--game-accent-color);
  text-decoration: none;
}

.game-footer a:hover {
  text-decoration: underline;
}

body.embedded .game-container {
  margin: 0;
  border: none;
  width: 100%;
  height: 100%;
}

body.embedded canvas {
  border: none;
  width: 100%;
  height: 100%;
}

.game-container:fullscreen {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: black;
}

.game-container:fullscreen canvas {
  max-width: 100%;
  max-height: 100%;
}

@keyframes power-up-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.power-up-active {
  animation: power-up-pulse 1s infinite;
}

button {
  background-color: var(--game-accent-color);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #0077b6;
}

.game-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.menu-title {
  font-size: 2em;
  margin-bottom: 20px;
  color: var(--game-accent-color);
}

.menu-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 300px;
}

.option-buttons {
  display: flex;
  gap: 10px;
}

.option-btn {
  padding: 8px 16px;
  background-color: #333;
  border: 2px solid #555;
}

.option-btn.selected {
  background-color: var(--game-accent-color);
  border-color: white;
}

.menu-start-btn {
  margin-top: 20px;
  padding: 10px 30px;
  font-size: 1.2em;
  background-color: var(--game-secondary-color);
}

.menu-start-btn:hover {
  background-color: #e64a19;
}

/* Media Queries */
@media (max-width: 840px) {
  h1 {
    font-size: 24px;
  }

  .controls-info {
    font-size: 12px;
  }
}

@media (max-width: 850px) {
  .game-wrapper {
    width: 100%;
    max-width: calc(100vw - 40px);
  }

  .game-container {
    width: 100%;
    height: auto;
    aspect-ratio: 2/1;
  }

  canvas {
    width: 100%;
    height: auto;
    max-width: 100%;
  }

  body {
    padding: 10px;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.8em;
  }

  .controls-info {
    font-size: 0.8em;
    max-width: 90%;
  }

  .game-container {
    margin: 10px auto;
  }
}

/* Mobile/Touch Device Styles */
@media (pointer: coarse) {
  /* Show touch controls */
  .mobile-controls {
    display: block;
  }

  .mobile-controls::before,
  .mobile-controls::after {
    display: block;
  }

  /* Show mobile buttons */
  .mobile-only {
    display: flex;
  }

  /* Adjust game description */
  .game-description {
    font-size: 0.9em;
    max-width: 90%;
  }

  /* Hide keyboard control info */
  .controls-info {
    display: none;
  }

  /* Enhanced control button style */
  .control-btn {
    width: 50px;
    height: 50px;
    font-size: 22px;
  }

  /* Game controls style */
  .game-controls {
    order: 3;
    margin: 15px 0;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    z-index: 30;
  }

  /* Menu controls style */
  body[data-game-state="menu"] .menu-controls,
  body[data-game-state="pause_menu"] .menu-controls {
    display: flex;
  }

  .menu-controls {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
  }
}

/* Add these new styles after existing CSS */

/* Game controls container */
.game-controls-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 15px auto;
}

/* Mobile paddle controls container */
.mobile-paddle-controls {
  display: none; /* Hide by default, shown on mobile */
  width: 100%;
  max-width: 800px;
  margin: 15px auto;
  justify-content: space-between;
}

.paddle-control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.paddle-control-group.left {
  align-items: flex-start;
}

.paddle-control-group.right {
  align-items: flex-end;
}

.paddle-btn {
  width: 85px; /* 22% bigger than 70px */
  height: 85px; /* 22% bigger than 70px */
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  border: 2px solid var(--game-accent-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s; /* Added box-shadow transition */
  pointer-events: auto; /* Ensure buttons receive events */
  position: relative; /* For positioning the arrow */
  touch-action: manipulation; /* Prevent double-tap to zoom */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  box-shadow: 0 0 10px rgba(0, 149, 221, 0.3); /* Add subtle glow by default */
}

.paddle-btn:active {
  transform: scale(0.92); /* Slightly stronger scale effect */
  background-color: rgba(0, 149, 221, 0.6);
  box-shadow: 0 0 15px rgba(0, 149, 221, 0.8); /* Stronger glow when active */
}

/* Update the mobile-only media query to display our controls */
@media (pointer: coarse) {
  /* Show touch controls */
  .mobile-paddle-controls {
    display: flex;
  }

  /* Hide the original mobile-controls that were on canvas */
  .mobile-controls {
    display: none;
  }

  /* Make the game controls more mobile-friendly */
  .game-controls {
    order: 3;
    margin: 15px 0;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    z-index: 30;
  }

  /* Adjust for vertical layout on phones */
  @media (max-width: 480px) and (orientation: portrait) {
    .mobile-paddle-controls {
      flex-direction: row;
      justify-content: space-between;
    }

    .paddle-control-group {
      flex-direction: column;
    }

    .paddle-btn {
      width: 50px;
      height: 50px;
      font-size: 24px;
    }
  }

  /* Adjust for horizontal layout on phones */
  @media (max-width: 900px) and (orientation: landscape) {
    .mobile-paddle-controls {
      flex-direction: row;
      justify-content: space-between;
      max-width: 100%;
    }

    .paddle-control-group {
      flex-direction: row;
      gap: 20px;
    }
  }
}

/* Mobile paddle controls - centered circular control */
.mobile-paddle-controls {
  display: none; /* Hidden by default */
  position: fixed;
  bottom: 60px;
  left: 0;
  width: 100%;
  justify-content: center;
  align-items: center;
  z-index: 50;
  pointer-events: none; /* Make container transparent to clicks by default */
}

.paddle-control-center {
  position: relative;
  width: 180px; /* Increased from 140px (approx. 28.5% bigger for container) */
  height: 240px; /* Increased height to accommodate non-overlapping buttons */
  background-color: rgba(0, 0, 0, 0.6);
  border-radius: 20px; /* Changed from circle to rounded rectangle */
  border: 3px solid var(--game-accent-color);
  box-shadow: 0 0 15px rgba(0, 149, 221, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around; /* Changed from space-between for better spacing */
  padding: 20px 0;
  pointer-events: auto; /* Make this element capture pointer events */
  backdrop-filter: blur(4px); /* Add subtle blur effect */
}

.paddle-btn {
  width: 85px; /* 22% bigger than 70px */
  height: 85px; /* 22% bigger than 70px */
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  border: 2px solid var(--game-accent-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto; /* Ensure buttons receive events */
  position: relative; /* For positioning the arrow */
  touch-action: manipulation; /* Prevent double-tap to zoom */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  box-shadow: 0 0 10px rgba(0, 149, 221, 0.4),
    inset 0 0 8px rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

/* Add ripple effect container */
.paddle-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle,
    rgba(0, 149, 221, 0.8) 0%,
    rgba(0, 149, 221, 0) 70%
  );
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.5s ease-out, opacity 0.5s ease-out;
  opacity: 0;
  border-radius: 50%;
  pointer-events: none;
}

.paddle-btn:active {
  transform: scale(0.92);
  background-color: rgba(0, 149, 221, 0.2);
  box-shadow: 0 0 20px rgba(0, 149, 221, 0.8),
    inset 0 0 15px rgba(255, 255, 255, 0.4);
  border-color: white;
}

/* Activate the ripple on touch */
.paddle-btn:active::before {
  transform: translate(-50%, -50%) scale(1.5);
  opacity: 0.3;
}

/* Remove negative margins that were causing overlap */
.paddle-btn-up {
  margin-bottom: 20px; /* Increased spacing */
}

.paddle-btn-down {
  margin-top: 20px; /* Increased spacing */
}

/* Custom arrow styles */
.arrow-up,
.arrow-down {
  display: block;
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  position: absolute;
  pointer-events: none; /* Make the arrow non-interactive so clicks pass through to the button */
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
  transition: all 0.2s ease;
}

.arrow-up {
  border-bottom: 30px solid white;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
}

.arrow-down {
  border-top: 30px solid white;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -40%);
}

/* Add pulsing effect on touch */
@keyframes pulse {
  0% {
    opacity: 0.7;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
  }
  100% {
    opacity: 0.7;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
  }
}

.paddle-btn:active .arrow-up,
.paddle-btn:active .arrow-down {
  animation: pulse 0.5s infinite;
}

/* Update the mobile-only media query for our controls */
@media (pointer: coarse) {
  /* Only show paddle controls in portrait mode on mobile */
  @media (orientation: portrait) {
    .mobile-paddle-controls {
      display: flex;
    }

    /* Ensure menu controls don't overlap with paddle controls */
    .menu-controls {
      bottom: 320px; /* Increased to account for taller paddle control center */
    }
  }

  /* Hide the original mobile-controls that were on canvas */
  .mobile-controls {
    display: none;
  }

  /* Make the game controls more mobile-friendly */
  .game-controls {
    margin: 15px 0;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    z-index: 30;
  }
}
