:root {
  /* Colors */
  --color-bg-primary: #0a0a0a;
  --color-bg-secondary: #1a1a2e;
  --color-bg-pattern: #000000;
  --color-text-primary: #ffffff;
  --color-text-glow: #00ffff;
  --color-block-default: rgb(100, 100, 255);
  --color-block-player: rgb(255, 50, 50);
  --color-block-op: rgb(150, 255, 100);
  --color-drop-default: rgb(255, 255, 100);
  --color-drop-op: rgb(100, 100, 255);
  --color-border: rgb(23, 23, 23);
  --color-line-bg: lightgrey;
  --color-line-border: darkgrey;
  --color-win-circle-default: rgb(160, 4, 4);
  --color-level-0: #ff0000;
  --color-level-1: #00ff00;
  --color-level-2: #0000ff;
  --color-level-3: #ffff00;
  --color-level-4: #ffd700;
  --color-board-bg: rgba(0, 0, 0, 0.7);
  --color-grid-line: rgba(0, 255, 255, 0.1);

  /* Dimensions */
  --block-width: 34px;
  --block-height: 30px;
  --board-width: 340px;
  --board-height: 750px;
  --circle-size: 20px;
  --circle-speed: 10px;
  --line-height: 30px;
  --win-circle-size: 1rem;
  --win-circle-margin: 2px;

  /* Spacing */
  --spacing-small: 0.5rem;
  --spacing-medium: 120px;
  --gameboard-min-width: 1000px;

  /* Animation */
  --animation-duration: 0.8s;
  --animation-timing: linear;
  --circle-animation-interval: 20ms;
  --transition-delay: 100ms;
  --send-animation-delay: 900ms;
}

html {
  background: repeating-linear-gradient(
      0deg,
      var(--color-bg-pattern) 0px,
      var(--color-bg-pattern) 1px,
      transparent 1px,
      transparent 2px
    ),
    repeating-linear-gradient(
      90deg,
      var(--color-bg-pattern) 0px,
      var(--color-bg-pattern) 1px,
      transparent 1px,
      transparent 2px
    ),
    radial-gradient(
      circle at 20% 30%,
      rgba(26, 26, 46, 0.8) 0%,
      transparent 60%
    ),
    radial-gradient(
      circle at 80% 70%,
      rgba(10, 10, 20, 0.8) 0%,
      transparent 60%
    ),
    radial-gradient(
      circle at 50% 50%,
      rgba(0, 255, 255, 0.05) 0%,
      transparent 70%
    ),
    linear-gradient(
      135deg,
      #0a0a0a 0%,
      #1a1a2e 25%,
      #0f0f1e 50%,
      #1a1a2e 75%,
      #0a0a0a 100%
    );
  background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%, 100% 100%,
    100% 100%;
  background-color: var(--color-bg-pattern);
  color: var(--color-text-primary);
  min-height: -webkit-fill-available;
  min-height: 100vh;
  font-family: "Press Start 2P", "Courier New", monospace;
  position: relative;
  overflow-x: hidden;
}

/* CRT Scanline Effect */
html::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 1000;
  animation: scanline 8s linear infinite;
}

@keyframes scanline {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(4px);
  }
}

html * {
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

#line {
  position: absolute;
  display: inline-flex;
  height: var(--line-height);
}

label {
  display: flex;
  height: 100%;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

label span {
  margin-left: var(--spacing-small);
}

input[type="radio"] {
  cursor: pointer;
}

input[type="radio"]:disabled {
  cursor: not-allowed;
}

#line > span {
  width: var(--block-width);
  height: var(--line-height);
  background-color: var(--color-line-bg);
  border-radius: 2px;
  border: 1px solid var(--color-line-border);
  box-sizing: border-box;
}

#circle {
  display: inline-flex;
  width: var(--circle-size);
  height: var(--circle-size);
  border-radius: 9999px;
  position: absolute;
  /* 3D Sphere Effect */
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.1) 30%,
    transparent 60%
  );
  box-shadow: 
    /* Outer glow */ 0 0 10px currentColor, 0 0 20px currentColor,
    /* 3D depth shadow */ inset -3px -3px 8px rgba(0, 0, 0, 0.6),
    inset 3px 3px 8px rgba(255, 255, 255, 0.3),
    /* Drop shadow for depth */ 4px 4px 8px rgba(0, 0, 0, 0.8),
    2px 2px 4px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: circle3D 4s linear infinite;
  transform-style: preserve-3d;
}

@keyframes circle3D {
  0% {
    transform: rotateZ(0deg);
  }
  25% {
    transform: rotateZ(90deg);
  }
  50% {
    transform: rotateZ(180deg);
  }
  75% {
    transform: rotateZ(270deg);
  }
  100% {
    transform: rotateZ(360deg);
  }
}

header {
  text-align: center;
  padding: 2rem 0;
  position: relative;
  z-index: 10;
}

.game-title {
  font-family: "Press Start 2P", cursive;
  font-size: 3.5rem;
  color: var(--color-text-primary);
  text-shadow: 0 0 10px var(--color-text-glow), 0 0 20px var(--color-text-glow),
    0 0 30px var(--color-text-glow), 4px 4px 0px rgba(0, 0, 0, 0.8),
    8px 8px 0px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.2em;
  margin: 0;
  animation: titleGlow 2s ease-in-out infinite alternate;
  text-transform: uppercase;
}

@keyframes titleGlow {
  0% {
    text-shadow: 0 0 10px var(--color-text-glow),
      0 0 20px var(--color-text-glow), 0 0 30px var(--color-text-glow),
      4px 4px 0px rgba(0, 0, 0, 0.8), 8px 8px 0px rgba(0, 0, 0, 0.6);
  }
  100% {
    text-shadow: 0 0 20px var(--color-text-glow),
      0 0 30px var(--color-text-glow), 0 0 40px var(--color-text-glow),
      4px 4px 0px rgba(0, 0, 0, 0.8), 8px 8px 0px rgba(0, 0, 0, 0.6);
  }
}

footer {
  text-align: center;
  font-family: "Press Start 2P", cursive;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
}

footer {
  position: fixed;
  bottom: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: var(--spacing-small);
}

footer p {
  margin: 0;
}

#gameboard {
  min-width: var(--gameboard-min-width);
  margin-top: var(--spacing-medium);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.1), inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.game-controls-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

#playerBoard,
#opBoard {
  z-index: -1;
  width: var(--board-width);
  height: var(--board-height);
  background: repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent calc(var(--block-height) - 1px),
      var(--color-grid-line) calc(var(--block-height) - 1px),
      var(--color-grid-line) var(--block-height)
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent calc(var(--block-width) - 1px),
      var(--color-grid-line) calc(var(--block-width) - 1px),
      var(--color-grid-line) var(--block-width)
    ),
    var(--color-board-bg);
  background-color: var(--color-board-bg);
  position: relative;
  border: 3px solid rgba(0, 255, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.send-block-section {
  position: absolute;
  display: flex;
  flex-wrap: wrap;
  width: var(--board-width);
  z-index: 100;
  pointer-events: none;
}

.block {
  position: absolute;
  background-color: var(--color-block-default);
  border-radius: 2px;
  border: 1px solid var(--color-border);
  box-sizing: border-box;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4),
    0 0 8px rgba(0, 0, 0, 0.3);
}

.send-block {
  position: relative;
  width: var(--block-width);
  height: var(--block-height);
  border-radius: 2px;
  border: 1px solid var(--color-border);
  box-sizing: border-box;
  background-color: var(--color-block-default);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4),
    0 0 8px rgba(0, 0, 0, 0.3);
}

.send-block.empty {
  border: none;
  background-color: transparent;
  box-shadow: none;
}

.drop {
  position: absolute;
  background-color: var(--color-drop-default);
  border-radius: 2px;
  border: 1px solid var(--color-border);
  box-sizing: border-box;
  width: var(--block-width);
  height: var(--block-height);
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4),
    0 0 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(255, 255, 100, 0.5);
  animation: dropPulse 1s ease-in-out infinite;
}

@keyframes dropPulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4),
      0 0 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(255, 255, 100, 0.5);
  }
  50% {
    opacity: 0.98;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.5),
      0 0 8px rgba(0, 0, 0, 0.3), 0 0 16px rgba(255, 255, 100, 0.7);
  }
}

.block-player {
  background-color: var(--color-block-player);
}

.block-op {
  background-color: var(--color-block-op);
}

.drop-op {
  background-color: var(--color-drop-op);
}

.level-0 {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.4) 0%,
    var(--color-level-0) 40%,
    #cc0000 100%
  );
  color: var(--color-level-0);
}

.level-1 {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.4) 0%,
    var(--color-level-1) 40%,
    #00cc00 100%
  );
  color: var(--color-level-1);
}

.level-2 {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.4) 0%,
    var(--color-level-2) 40%,
    #0000cc 100%
  );
  color: var(--color-level-2);
}

.level-3 {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.4) 0%,
    var(--color-level-3) 40%,
    #cccc00 100%
  );
  color: var(--color-level-3);
}

.level-4 {
  background: radial-gradient(
    circle at 30% 30%,
    rgba(255, 255, 255, 0.5) 0%,
    var(--color-level-4) 40%,
    #cc9900 100%
  );
  color: var(--color-level-4);
}

.end-game-message {
  position: absolute;
  font-family: "Press Start 2P", cursive;
  font-size: 4rem;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  visibility: hidden;
  color: #ff0000;
  width: fit-content;
  text-wrap-mode: nowrap;
  text-shadow: 0 0 20px #ff0000, 0 0 40px #ff0000,
    4px 4px 0px rgba(0, 0, 0, 0.8), 8px 8px 0px rgba(0, 0, 0, 0.6);
  z-index: 100;
  animation: gameOverPulse 0.5s ease-in-out infinite;
}

.end-game-message.visible {
  visibility: visible;
}

@keyframes gameOverPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
  }
}

#playerWin {
  display: flex;
  flex-direction: column-reverse;
  position: absolute;
  bottom: 20px;
  left: 370px;
}

#opWin {
  display: flex;
  flex-direction: column-reverse;
  position: absolute;
  bottom: 20px;
  right: 370px;
}

#soloWin {
  display: flex;
  position: absolute;
  top: -24px;
  left: 660px;
}

#soloWin .win-circle:nth-child(1) {
  background-color: red;
}

#soloWin .win-circle:nth-child(2) {
  background-color: green;
}

#soloWin .win-circle:nth-child(3) {
  background-color: blue;
}

#soloWin .win-circle:nth-child(4) {
  background-color: yellow;
}

#soloWin .win-circle:nth-child(5) {
  background-color: gold;
}

.win-circle {
  width: var(--win-circle-size);
  height: var(--win-circle-size);
  margin: var(--win-circle-margin);
  border-radius: 9999px;
  background-color: var(--color-win-circle-default);
}

.play-mode {
  display: flex;
  height: fit-content;
  flex-direction: column;
  align-items: center;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

.play-mode legend {
  display: none;
}

.play-mode label {
  margin: var(--spacing-small) 0;
  font-family: "Press Start 2P", cursive;
  font-size: 0.7rem;
  color: var(--color-text-primary);
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8);
  transition: all 0.2s ease;
}

.play-mode label:hover {
  color: var(--color-text-glow);
  text-shadow: 0 0 10px var(--color-text-glow), 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.play-mode input[type="radio"]:checked + span {
  color: var(--color-text-glow);
  text-shadow: 0 0 10px var(--color-text-glow), 2px 2px 0px rgba(0, 0, 0, 0.8);
}

.play-mode input[type="radio"] {
  outline: none;
}

.play-mode input[type="radio"]:focus {
  outline: none;
}

.keyboard-controls {
  margin-top: 0.8rem;
  margin-left: 1rem;
  margin-right: 1rem;
  padding: 0.6rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.1), inset 0 0 10px rgba(0, 0, 0, 0.3);
  width: calc(100% - 2rem);
  box-sizing: border-box;
}

.controls-title {
  font-family: "Press Start 2P", cursive;
  font-size: 0.7rem;
  color: var(--color-text-glow);
  text-shadow: 0 0 8px var(--color-text-glow), 1px 1px 0px rgba(0, 0, 0, 0.8);
  margin: 0 0 0.8rem 0;
  text-align: center;
}

.controls-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.controls-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
}

.control-label {
  font-family: "Press Start 2P", cursive;
  font-size: 0.55rem;
  color: var(--color-text-primary);
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
  margin-bottom: 0.3rem;
  border-bottom: 1px solid rgba(0, 255, 255, 0.3);
  padding-bottom: 0.3rem;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  color: var(--color-text-primary);
  text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
  line-height: 1.4;
}

.control-item kbd {
  display: inline-block;
  padding: 0.3rem 0.5rem;
  background: rgba(0, 255, 255, 0.2);
  border: 1px solid rgba(0, 255, 255, 0.4);
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.3),
    inset 0 0 4px rgba(255, 255, 255, 0.1), 1px 1px 3px rgba(0, 0, 0, 0.6);
  color: var(--color-text-glow);
  text-shadow: 0 0 4px var(--color-text-glow);
  min-width: 2rem;
  text-align: center;
  font-family: "Press Start 2P", cursive;
  font-size: 0.5rem;
  line-height: 1.2;
  flex-shrink: 0;
}

.control-item span {
  flex: 1;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.5rem;
}
