:root {
  --bg-color: #000000;
  --panel-bg: rgba(0, 0, 0, 0.85);
  --text-color: #ffffff;
  --accent: #00ffff;
  --accent-pink: #ff00ff;
  --accent-yellow: #ffff00;
  --accent-green: #00ff00;
  --accent-orange: #ff8800;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: calc(var(--vh, 1vh) * 100);
  background: var(--bg-color);
  color: var(--text-color);
  font-family: 'Orbitron', sans-serif;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

canvas {
  display: block;
  touch-action: none;
  width: 100vw;
  height: calc(var(--vh, 1vh) * 100);
}

input,
textarea {
  -webkit-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

.label {
  padding: 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  pointer-events: none;
  text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent), 0 0 30px var(--accent);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 20;
}

#map-menu {
  z-index: 20;
}

#settings-menu {
  flex-direction: column;
  color: var(--text-color);
  z-index: 40;
}

#help-menu {
  flex-direction: column;
  color: var(--text-color);
  text-align: center;
  z-index: 40;
}

#main-menu,
#multiplayer-menu {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--accent);
  text-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent), 0 0 45px var(--accent);
  font-weight: bold;
}

#main-menu {
  z-index: 30;
}

#main-menu .control-button {
  margin: 10px 0;
}

#multiplayer-menu {
  z-index: 40;
  display: none;
}

#multiplayer-menu .control-button {
  /* Use symmetrical vertical margins so menu buttons align precisely */
  margin: 10px 0;
  box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
}

#multiplayer-menu input {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 6px;
  text-align: center;
  font-size: 20px;
  box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
  text-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
}

#pause-menu {
  flex-direction: column;
  z-index: 15;
}

.map-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 48px;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  transition:
    opacity 0.2s,
    transform 0.2s;
  text-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent), 0 0 45px var(--accent);
  opacity: 0.7;
}

.map-arrow:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

#prev-arrow {
  left: 10px;
}

#next-arrow {
  right: 10px;
}

.map-entry {
  text-align: center;
  position: relative;
}

.map-thumb {
  position: relative;
  width: 90vmin;
  height: 90vmin;
  margin: auto;
  border: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent), inset 0 0 30px rgba(0, 255, 255, 0.2);
  overflow: hidden;
}

.map-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 64px;
  padding: 20px 40px;
  background: var(--accent);
  color: var(--bg-color);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  opacity: 0.7;
  transition:
    opacity 0.3s,
    box-shadow 0.3s;
}

@media (hover: hover) {
  .map-button:hover {
    opacity: 1;
    box-shadow: 0 0 40px var(--accent), 0 0 80px var(--accent);
  }
}

.control-button {
  display: inline-block;
  padding: 8px 14px;
  margin: 2px;
  border-radius: 4px;
  border: 2px solid var(--accent);
  background: rgba(0, 0, 0, 0.6);
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
  cursor: pointer;
  user-select: none;
  transition:
    background-color 0.3s,
    box-shadow 0.3s,
    transform 0.1s;
  text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
  box-shadow: 0 0 10px var(--accent);
  position: relative;
  overflow: hidden;
}

.control-button.selected {
  background: var(--accent);
  color: var(--accent);
}

#speed-vote .control-button.selected,
#speed-controls .control-button.selected,
#difficulty-controls .control-button.selected {
  color: var(--bg-color);
}

.control-button.selected span {
  filter: none;
}

.countdown-button.selected {
  background: rgba(0, 0, 0, 0.4);
  color: var(--accent);
}

.countdown-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  opacity: 0.4;
  pointer-events: none;
}

@keyframes glow {
  0% {
    box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
  }
  50% {
    box-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent), 0 0 90px var(--accent);
  }
  100% {
    box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent);
  }
}

.glow {
  animation: glow 1s ease-in-out infinite;
}

.control-button:hover {
  box-shadow:
    0 0 20px var(--accent),
    0 0 40px var(--accent),
    0 0 60px var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 255, 0.1);
}

.control-button:active {
  transform: scale(0.95);
}

#settings-button {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 30;
}

#help-button {
  position: absolute;
  bottom: 10px;
  left: 110px;
  z-index: 30;
}

#back-button {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  display: none;
}

#fitScreen svg {
  width: 20px;
  height: 20px;
  display: block;
}

.controls {
  position: absolute;
  color: var(--text-color);
  z-index: 10;
}

#controls {
  bottom: 10px;
  left: 10px;
}

#speed-controls {
  bottom: 10px;
  right: 10px;
}

#difficulty-controls {
  bottom: 50px;
  right: 10px;
  z-index: 30;
}

#difficulty-info {
  margin-top: 4px;
  font-size: 14px;
  text-align: center;
  color: var(--text-color);
}

#debug-overlay {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  font-size: 12px;
}

#ai-weight-graph {
  position: absolute;
  top: 60px;
  left: 10px;
  z-index: 10;
  width: 33vw;
  color: var(--text-color);
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
}

#ai-weight-graph .row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

#ai-weight-graph .bar {
  flex: 1;
  display: flex;
  height: 5px;
  background: #333;
}

#ai-weight-graph .bar div {
  height: 5px;
}

#ai-weight-graph .legend {
  display: flex;
  flex-wrap: wrap;
  margin-top: 4px;
}

#ai-weight-graph .legend-item {
  display: flex;
  align-items: center;
  margin-right: 6px;
  margin-bottom: 2px;
}

#ai-weight-graph .legend-color {
  width: 12px;
  height: 5px;
  margin-right: 2px;
}

#hud {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-color);
  z-index: 10;
  text-align: right;
  text-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent);
}

#unit-bar-graph {
  width: 33vw;
  background-color: #333;
  height: 10px;
  display: flex;
  overflow: hidden;
}

#pause-menu {
  background: rgba(0, 0, 0, 0.7);
}

#results {
  position: absolute;
  top: 60px;
  left: 5%;
  width: 90%;
  background: #111;
  opacity: 0.9;
  z-index: 10;
}

@media (max-width: 600px) {
  .map-button {
    font-size: 32px;
    padding: 10px 20px;
  }

  .map-arrow {
    font-size: 32px;
  }
}

#fast-forward-overlay {
  top: auto;
  left: auto;
  bottom: 120px;
  right: 16px;
  width: auto;
  height: auto;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  background: none;
  color: var(--accent);
  font-family: 'Orbitron', sans-serif;
  z-index: 30;
  pointer-events: none;
}

#fast-forward-overlay .ff-message {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(5, 6, 8, 0.78);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.35);
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
}

#fast-forward-overlay .ff-title {
  font-size: 24px;
  letter-spacing: 1px;
}

#fast-forward-overlay .ff-subtitle {
  font-size: 14px;
  opacity: 0.85;
  text-align: right;
}

#speedFF.fast-forward-active {
  animation: ff-pulse 1s infinite;
}

@keyframes ff-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Animated grid background for menus */
.menu-grid-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(0deg, transparent 24%, rgba(0, 255, 255, 0.15) 25%, rgba(0, 255, 255, 0.15) 26%, transparent 27%, transparent 74%, rgba(0, 255, 255, 0.15) 75%, rgba(0, 255, 255, 0.15) 76%, transparent 77%, transparent),
    linear-gradient(90deg, transparent 24%, rgba(0, 255, 255, 0.15) 25%, rgba(0, 255, 255, 0.15) 26%, transparent 27%, transparent 74%, rgba(0, 255, 255, 0.15) 75%, rgba(0, 255, 255, 0.15) 76%, transparent 77%, transparent);
  background-size: 80px 80px;
  background-position: 0 0;
  animation: grid-move 8s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes grid-move {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 80px 80px;
  }
}

/* Radial glow overlay for menu */
.menu-glow-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, rgba(0, 255, 255, 0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 1;
  animation: pulse-glow 4s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}
