*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: "Press Start 2P", monospace;
  color: #fff;
}

#game-container {
  width: 100%;
  height: 100%;
}

#game-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform: translateZ(0);
}

#ui-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  pointer-events: auto;
}

.top-bar a,
.top-bar button {
  pointer-events: auto;
  font-family: inherit;
  font-size: 0.55rem;
  line-height: 1.6;
  text-decoration: none;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid #fff;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

.top-bar a:hover,
.top-bar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.hint {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  font-size: 0.55rem;
  line-height: 1.6;
  text-align: center;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  max-width: calc(100% - 2rem);
}

.hint.visible {
  opacity: 1;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.75);
  pointer-events: auto;
  z-index: 20;
}

#modal-overlay.open {
  display: flex;
}

.modal {
  width: min(100%, 520px);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: #16213e;
  border: 4px solid #fff;
  padding: 1.25rem;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.45);
}

.modal h2 {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #f1c40f;
}

.modal p {
  margin: 0 0 1.25rem;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #ecf0f1;
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-links a,
.modal-close {
  font-family: inherit;
  font-size: 0.55rem;
  line-height: 1.6;
  text-decoration: none;
  color: #fff;
  background: #2ecc71;
  border: 2px solid #fff;
  padding: 0.55rem 0.75rem;
}

.modal-links a.secondary {
  background: #3498db;
}

.modal-close {
  margin-top: 1rem;
  background: #555;
  cursor: pointer;
}

.modal-links a:hover,
.modal-close:hover {
  filter: brightness(1.1);
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: #1a1a2e;
  z-index: 30;
  font-size: 0.7rem;
  line-height: 1.8;
}

#loading.hidden {
  display: none;
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-bar a,
  .top-bar button {
    text-align: center;
  }

  .hint {
    font-size: 0.5rem;
  }
}
