* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: #fff;
  display: flex;
  flex-direction: column;
}

/* Compact top bar — keeps canvas visible inside TapBrisk iframe / fullscreen */
.hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.heading {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#themeToggle {
  font-size: 1.1rem;
  border: none;
  background: transparent;
  color: #fdfdfd;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}

.play-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem;
  position: relative;
}

#myCanvas {
  /* Buffer stays 600×600; CSS scales to fit remaining viewport (no crop). */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100% - 2.4rem);
  aspect-ratio: 1;
  background: radial-gradient(circle, #0d47a1, #000);
  border-radius: 8px;
  border: 2px solid #64b5f6;
  box-shadow: 0 0 20px rgba(0, 140, 255, 0.25);
  touch-action: none;
}

.game-option {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.65rem 1rem;
  width: 100%;
  max-width: 28rem;
  font-size: 0.75rem;
}

.speed-container,
#size-container {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

label {
  white-space: nowrap;
  opacity: 0.9;
}

input[type="range"] {
  width: 5.5rem;
  max-width: 28vw;
  cursor: pointer;
  accent-color: #64b5f6;
}

button {
  padding: 0.3rem 0.75rem;
  border: none;
  background: linear-gradient(90deg, #42a5f5, #1e88e5);
  color: white;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

button:hover {
  background: linear-gradient(90deg, #64b5f6, #2196f3);
}

.alert {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 1rem;
}

.alert strong {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.success {
  border: none;
}

.failure {
  border: none;
}

.close {
  background: linear-gradient(90deg, #66bb6a, #43a047);
}

.close:hover {
  background: linear-gradient(90deg, #81c784, #388e3c);
}

body.light-mode {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  color: #1a237e;
}

body.light-mode .hud {
  background: rgba(255, 255, 255, 0.7);
}

body.light-mode .heading,
body.light-mode label {
  color: #0d47a1;
}

body.light-mode #themeToggle {
  color: #0d47a1;
}
