:root {
  --bg-color: black;
  --text-color: white;
  --grid-color: #1d1e1f;
  --next-block-bg: #333333;
  --highscore-bg: rgba(255, 255, 0, 0.1);
  --score-bg: rgba(255, 255, 255, 0.1);
  --button-bg: #02a8ef;
  --button-hover: #0289cf;
  --modal-bg: #1d1e1f;
  --debug-info-bg: #333333;
  --footer-color: #bfbfc0;
}

body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
  position: relative;
  font-family: "Courier New", monospace;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-title {
  font-size: 36px;
  margin: 0;
}

.game-instructions {
  font-size: 14px;
  color: var(--footer-color);
  margin: 5px 0 20px;
  line-height: 1.5;
}

.container {
  display: flex;
  justify-content: center;
}

canvas,
.next-blocks canvas {
  background-color: var(--grid-color);
  border: none;
  border-radius: 2px;
  transition: background-color 0.3s;
}

.game-panel {
  margin-right: 20px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.score-board {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 20px;
}

.score-section {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 7px 12px 7px 18px;
  margin-bottom: 10px;
  width: 140px;
  border-radius: 2px;
  font-size: 18px;
}

.trophy-icon {
  width: 18px;
  height: 18px;
  margin: 0 10px 0 5px;
}

.score-label {
  font-size: 10px;
  font-family: sans-serif;
  margin-right: 10px;
}

.score-text {
  font-size: 20px;
  text-align: right;
}

.highscore-section {
  background-color: var(--highscore-bg);
}
.current-score-section {
  background-color: var(--score-bg);
}

.yellow {
  color: yellow;
}
.white {
  color: var(--text-color);
}

.next-blocks {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.next-blocks canvas {
  background-color: var(--next-block-bg);
  margin-bottom: 10px;
  width: 64px;
  height: 64px;
}

.footer {
  position: fixed;
  bottom: 10px;
  text-align: center;
  width: 100%;
  z-index: 1;
}

.footer a {
  color: var(--footer-color);
  text-decoration: none;
  transition: color 0.3s;
}

.footer a:hover {
  text-decoration: underline;
}

#debug-modal {
  background-color: var(--modal-bg);
  color: var(--text-color);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.3);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  max-width: 80%;
  z-index: 1000;
}

#debug-info {
  background-color: var(--debug-info-bg);
  color: var(--footer-color);
  padding: 10px;
  border-radius: 5px;
  font-size: 14px;
  overflow: auto;
  white-space: pre-wrap;
}

#close-debug,
#debug-button,
#mode-toggle {
  background-color: var(--button-bg);
  color: var(--text-color);
  font-size: 14px;
  border: none;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

#close-debug:hover,
#debug-button:hover,
#mode-toggle:hover {
  background-color: var(--button-hover);
}

#debug-button,
#mode-toggle {
  position: fixed;
  top: 10px;
  z-index: 9999;
}

#debug-button {
  right: 10px;
}
#mode-toggle {
  right: 100px;
}

#close-debug {
  margin-top: 10px;
  display: block;
  width: 100%;
  text-align: center;
  font-weight: bold;
}

#debug-button::before {
  content: "🐞";
  margin-right: 5px;
}

.mode-toggle .sun,
.mode-toggle .moon {
  width: 18px;
  height: 18px;
}

.mode-toggle .sun {
  display: none;
}
.mode-toggle .moon {
  display: inline;
}

.hashicorp-logos {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.hashicorp-logos img {
  width: auto;
  height: 3em;
}

/* Background Pattern */
html::before,
html::after {
  content: "";
  position: absolute;
  top: 0;
  width: 500px;
  height: 100%;
  background-image: url("dot-pattern.png");
  background-size: 400px 400px;
  background-repeat: repeat;
  opacity: 0.2;
  z-index: -1;
}

html::before {
  left: 0;
  background-position: left;
  mask-image: linear-gradient(to right, black 40%, transparent 100%);
}

html::after {
  right: 0;
  background-position: right;
  mask-image: linear-gradient(to left, black 40%, transparent 100%);
}

/* Light mode styles */
body.light-mode {
  --bg-color: white;
  --text-color: black;
  --grid-color: #e0e0e0;
  --next-block-bg: #f0f0f0;
  --highscore-bg: rgba(255, 255, 0, 0.2);
  --score-bg: rgba(0, 0, 0, 0.1);
  --button-bg: rgba(0, 0, 0, 0.1);
  --button-hover: rgba(0, 0, 0, 0.2);
}

body.light-mode .footer a {
  color: #666;
}
body.light-mode .trophy-icon {
  filter: brightness(0) invert(0);
}
body.light-mode .mode-toggle .sun {
  display: inline;
}
body.light-mode .mode-toggle .moon {
  display: none;
}
body.light-mode::before,
body.light-mode::after {
  opacity: 0.1;
  background-image: url("light-dot-pattern.png");
}
