:root {
  --bg-color: #0a0b10;
  --panel-bg: rgba(18, 20, 32, 0.85);
  --primary-cyan: #00f3ff;
  --accent-pink: #ff0055;
  --accent-yellow: #ffe600;
  --text-color: #ffffff;
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-y: auto; /* Allows scrolling on smaller displays */
  padding: 10px 0;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 600px;
  padding: 10px;
}

/* Header UI */
#ui-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid rgba(0, 243, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.1);
}

#game-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--primary-cyan);
  text-shadow: 0 0 10px var(--primary-cyan);
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.7rem;
  color: #888;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
}

/* Responsive Canvas Wrapper */
#canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1; /* Maintains perfect square shape automatically */
  max-height: calc(100vh - 120px); /* Prevents spilling off the bottom of the screen */
  max-width: calc(100vh - 120px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.15);
  border: 2px solid rgba(0, 243, 255, 0.3);
}

#game-canvas {
  width: 100%;
  height: 100%;
  background-color: #050608;
  display: block;
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 11, 16, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
  padding: 10px;
  text-align: center;
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.glow-text {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--primary-cyan);
  text-shadow: 0 0 20px var(--primary-cyan);
}

.glow-text.danger {
  color: var(--accent-pink);
  text-shadow: 0 0 20px var(--accent-pink);
}

.subtitle {
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  color: #aaa;
}

.difficulty-select {
  display: flex;
  gap: 8px;
}

.diff-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
}

.diff-btn.active, .diff-btn:hover {
  border-color: var(--primary-cyan);
  background: rgba(0, 243, 255, 0.15);
  color: var(--primary-cyan);
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.primary-btn {
  background: var(--primary-cyan);
  color: #000;
  border: none;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 2px;
  padding: 10px 28px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 0 20px var(--primary-cyan);
  transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--primary-cyan);
}

/* Mobile Controls */
#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.dpad-row {
  display: flex;
  gap: 6px;
}

.dpad-btn {
  width: 45px;
  height: 45px;
  background: var(--panel-bg);
  border: 1px solid rgba(0, 243, 255, 0.3);
  color: var(--primary-cyan);
  font-size: 1.1rem;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.dpad-btn:active {
  background: var(--primary-cyan);
  color: #000;
}

@media (max-width: 768px) {
  #mobile-controls {
    display: flex;
  }
}
