* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: #120b08;
  background-image: 
    linear-gradient(rgba(18, 11, 8, 0.75), rgba(18, 11, 8, 0.75)),
    radial-gradient(#3a1b12 15%, transparent 16%),
    radial-gradient(#2e140d 15%, transparent 16%);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  background-position: 0 0, 0 0, 16px 16px;
  color: #f0f6fc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  touch-action: none;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  width: 100%;
}

#game-container {
  box-sizing: content-box;
  position: relative;
  background-color: #000;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9), 0 0 20px rgba(255, 204, 0, 0.25);
  border: 6px solid #4a291a;
  border-radius: 8px;
  overflow: hidden;
  cursor: none;
  aspect-ratio: 4 / 3;
  width: min(92vw, calc(80vh * 4 / 3));
  max-height: 80vh;
}

#game-container.size-1x {
  width: 640px;
  height: 480px;
  max-width: 96vw;
  max-height: 84vh;
}

#game-container.size-2x {
  width: min(94vw, 1280px, calc(84vh * 4 / 3));
  max-height: 84vh;
}

#game-container:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-container:fullscreen #gameCanvas {
  width: min(100vw, calc(100vh * 4 / 3));
  height: min(100vh, calc(100vw * 3 / 4));
}

#game-container.show-cursor {
  cursor: pointer;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#game-container.size-1x #gameCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#bottom-bar {
  margin-top: 10px;
  width: min(92vw, calc(80vh * 4 / 3), 1024px);
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
}

#right-panel {
  flex: 1 1 360px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

#ui-overlay {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
}

.retro-btn {
  background: rgba(22, 27, 34, 0.85);
  color: #ffcc00;
  border: 2px solid #ffcc00;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.15s ease;
}

.retro-btn:hover {
  background: #ffcc00;
  color: #000;
  transform: translateY(-1px);
}

.retro-btn:active {
  transform: translateY(1px);
}

#scorecard {
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 12px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 8px;
  font-size: 12.5px;
  color: #c9d1d9;
}

.scorecard-title {
  color: #ffcc00;
  font-weight: bold;
  letter-spacing: 0.4px;
}

.score-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.score-item strong {
  color: #ffcc00;
  margin-left: 2px;
}

#instructions {
  flex: 1 1 340px;
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
  color: #c9d1d9;
}

#instructions strong {
  color: #ffcc00;
}
