* {
  user-select: none;
  touch-action: none;
}

body {
  --background-color: #e9f0f5;
  --wall-color: #2c3e4e;
  --joystick-color: #1e2f3a;
  --joystick-head-color: #ff7e5e;
  --ball-color: #ff6b4a;
  --end-color: #5d9b9b;
  --text-color: #1e2f3a;
  --hole-bg: #0b1b2b;
  --glow: rgba(255, 126, 94, 0.6);

  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #c0d9e8 0%, #b0cfde 100%);
  font-family:
    "Segoe UI",
    "Poppins",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Roboto",
    sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#center {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#game {
  display: grid;
  grid-template-columns: auto 120px;
  grid-template-rows: auto auto auto;
  gap: 20px;
  perspective: 800px;
  background: rgba(255, 255, 240, 0.2);
  backdrop-filter: blur(2px);
  border-radius: 64px;
  padding: 20px 25px;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

#maze {
  position: relative;
  grid-row: 1 / -1;
  grid-column: 1;
  width: 350px;
  height: 315px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fdf8ef;
  border-radius: 28px;
  box-shadow:
    inset 0 0 0 3px #fff8e7,
    0 12px 28px rgba(0, 0, 0, 0.3);
  transition: transform 0.05s linear;
}

#end {
  width: 65px;
  height: 65px;
  border: 5px dashed var(--end-color);
  border-radius: 50%;
  background: rgba(0, 249, 249, 0.15);
  backdrop-filter: blur(2px);
}

#joystick {
  position: relative;
  background-color: var(--joystick-color);
  border-radius: 50%;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  grid-row: 2;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

#joystick-head {
  position: relative;
  background-color: var(--joystick-head-color);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: grab;
  touch-action: none;
  box-shadow: 0 0 12px var(--glow);
  animation: glow-pulse 1.2s infinite alternate ease-in-out;
}

@keyframes glow-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 2px var(--glow);
  }
  100% {
    transform: scale(1.18);
    box-shadow: 0 0 18px var(--glow);
  }
}

.joystick-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}
.joystick-arrow:nth-of-type(1) {
  bottom: 70px;
  border-bottom: 14px solid var(--joystick-color);
}
.joystick-arrow:nth-of-type(2) {
  top: 70px;
  border-top: 14px solid var(--joystick-color);
}
.joystick-arrow:nth-of-type(3) {
  left: 70px;
  border-left: 14px solid var(--joystick-color);
  top: 50%;
  transform: translateY(-50%);
}
.joystick-arrow:nth-of-type(4) {
  right: 70px;
  border-right: 14px solid var(--joystick-color);
  top: 50%;
  transform: translateY(-50%);
}

#note {
  grid-row: 3;
  grid-column: 2;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1e2f3a;
  background: rgba(255, 250, 225, 0.9);
  backdrop-filter: blur(8px);
  border-radius: 35px;
  padding: 12px 10px;
  transition: opacity 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mode-buttons {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
}
.mode-btn {
  background: #2c3e4e;
  border: none;
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 40px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  touch-action: manipulation;
}
.mode-btn:active {
  transform: scale(0.96);
  background: #ff7e5e;
}
.mode-btn.easy {
  background: #3a6b5e;
}
.mode-btn.hard {
  background: #9e4e3e;
}

.restart-touch {
  background: #1e2f3a;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 60px;
  font-size: 0.8rem;
  margin-top: 6px;
  width: 100%;
  cursor: pointer;
}

.ball {
  position: absolute;
  margin-top: -5px;
  margin-left: -5px;
  border-radius: 50%;
  background-color: var(--ball-color);
  width: 10px;
  height: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition:
    left 0.02s,
    top 0.02s;
}

.wall {
  position: absolute;
  background-color: var(--wall-color);
  transform-origin: top center;
  margin-left: -5px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.wall::before,
.wall::after {
  display: block;
  content: "";
  width: 10px;
  height: 10px;
  background-color: inherit;
  border-radius: 50%;
  position: absolute;
}
.wall::before {
  top: -5px;
}
.wall::after {
  bottom: -5px;
}

.black-hole {
  position: absolute;
  margin-top: -9px;
  margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #111, #000);
  width: 18px;
  height: 18px;
  box-shadow:
    inset 0 0 4px rgba(255, 100, 0, 0.5),
    0 0 6px black;
}

@media (max-width: 580px) {
  #game {
    gap: 12px;
    padding: 12px 16px;
    grid-template-columns: auto 100px;
  }
  #joystick {
    width: 60px;
    height: 60px;
  }
  #joystick-head {
    width: 28px;
    height: 28px;
  }
  .joystick-arrow:nth-of-type(1) {
    bottom: 60px;
    border-bottom: 12px solid var(--joystick-color);
  }
  .joystick-arrow:nth-of-type(2) {
    top: 60px;
    border-top: 12px solid var(--joystick-color);
  }
  .joystick-arrow:nth-of-type(3) {
    left: 60px;
    border-left: 12px solid var(--joystick-color);
  }
  .joystick-arrow:nth-of-type(4) {
    right: 60px;
    border-right: 12px solid var(--joystick-color);
  }
  #note {
    font-size: 0.7rem;
    padding: 8px 6px;
  }
  .mode-btn {
    font-size: 0.75rem;
    padding: 5px 12px;
  }
}
@media (max-width: 500px) {
  #game {
    transform: scale(0.92);
    padding: 8px 10px;
  }
  body {
    padding: 5px;
  }
}
@media (max-width: 420px) {
  #game {
    transform: scale(0.85);
  }
}
@media (max-height: 480px) and (orientation: landscape) {
  #game {
    transform: scale(0.7);
    gap: 5px;
  }
  body {
    padding: 0;
  }
}
a {
  color: #ff7e5e;
  text-decoration: none;
  font-weight: bold;
}
