* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #05070a;
  color: #eee6d0;
  font-family: 'Georgia', 'Trebuchet MS', serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}
/* right-mouse-button drag pans the camera; class is toggled in ui.js */
#board-canvas.panning {
  cursor: grabbing;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.splash-screen {
  background: #000;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.6s ease;
}
.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.splash-logo {
  width: 55%;
  max-width: 300px;
  height: auto;
  animation: splash-logo-in 0.9s ease;
}
@keyframes splash-logo-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Pin the logo to the top of the title screen instead of vertically
   centering the whole content block, so it stays put regardless of
   viewport height. .screen is a row-direction flex container, so the
   vertical axis is controlled by align-items, not justify-content. */
#screen-title {
  align-items: flex-start;
}
#screen-title .screen-content {
  padding-top: max(env(safe-area-inset-top, 0px), 5vh);
}

.screen-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* Source art is a fixed 480x800 portrait crop, which doesn't match every
   viewport. A single background-size:cover would zoom in and crop most of
   the image away on wide/landscape windows. Instead: a blurred, cropped
   copy fills the edges (::before) and the full, uncropped image sits on
   top at its natural aspect ratio (::after), so the whole picture is
   always visible with no hard letterbox bars. */
.screen-bg::before,
.screen-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-img);
  background-repeat: no-repeat;
  background-position: center;
}
.screen-bg::before {
  background-size: cover;
  filter: brightness(0.32) saturate(0.9) blur(18px);
  transform: scale(1.1);
}
.screen-bg::after {
  background-size: contain;
  filter: brightness(0.6) saturate(0.95);
}

.screen-content {
  position: relative;
  z-index: 1;
  max-width: 480px;
  width: 90%;
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.title-text {
  width: 100%;
  max-width: 420px;
  height: auto;
  filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.85));
  margin-bottom: 4px;
}

h2 {
  font-size: 1.5rem;
  color: #f4d35e;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  margin: 0 0 4px;
}

.tagline {
  color: #f4d35e;
  font-size: 1rem;
  margin: 0 0 10px;
}

.credit {
  color: #cfcabc;
  font-size: 0.75rem;
  margin-top: 18px;
  opacity: 0.8;
}

.version-tag {
  color: #f4d35e;
  font-size: 0.7rem;
  margin-top: 2px;
  opacity: 0.7;
  letter-spacing: 0.04em;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 22px;
  border-radius: 10px;
  border: 2px solid #f4d35e;
  background: rgba(20, 40, 30, 0.75);
  color: #f4d35e;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.96); background: rgba(40, 70, 50, 0.9); }
.btn-primary { font-weight: bold; }
.btn-link {
  border: none;
  background: none;
  text-decoration: underline;
  font-size: 0.9rem;
  color: #cfcabc;
}

.btn-install {
  font-size: 0.85rem;
  padding: 8px 16px;
  border-color: #cfcabc;
  background: rgba(10, 20, 15, 0.6);
  color: #cfcabc;
}

.maze-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin: 10px 0;
}

.maze-btn {
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 8px;
  border-radius: 12px;
  border: 2px solid #3f7a4a;
  background: rgba(15, 30, 22, 0.85);
  color: #eee6d0;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.maze-btn:active { transform: scale(0.96); }
.maze-btn:hover { border-color: #f4d35e; }
.maze-title { font-size: 1rem; font-weight: bold; color: #f4d35e; }
.maze-sub { font-size: 0.82rem; color: #cfcabc; }

.rules-content { text-align: left; }
.rules-list { padding-left: 20px; margin: 0 0 16px; }
.rules-list li { margin-bottom: 10px; line-height: 1.4; font-size: 0.92rem; color: #eee6d0; }

.stat-line { font-size: 1.1rem; margin: 2px 0; }
.stat-win { color: #7ee08a; }
.stat-lose { color: #e07e7e; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  top: env(safe-area-inset-top, 10px);
  right: 10px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
/* When installed on desktop with Window Controls Overlay active, the OS
   draws minimize/maximize/close buttons in this same top-right corner -
   drop below that strip instead of colliding with them. */
@media (display-mode: window-controls-overlay) {
  .hud-top {
    top: calc(env(titlebar-area-height, 40px) + 6px);
  }
}

.icon-btn {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  border: 0px solid #f4d35e;
  background: rgba(10, 20, 15, 0.75);
  padding: 6px;
  cursor: pointer;
}
.icon-btn img { width: 100%; height: 100%; object-fit: contain; }
.icon-btn:active { transform: scale(0.94); }

.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.hud-message {
  color: #fff;
  font-size: 1rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
  min-height: 1.3em;
  text-align: center;
  padding: 0 10px;
}

.hud-status {
  color: #f4d35e;
  font-size: 0.95rem;
  text-shadow: 0 2px 6px rgba(0,0,0,0.9);
}

/* Unlike the other full-bleed screens, the endgame banner should leave the
   freshly-revealed maze visible behind it - just a small readable plaque
   near the top instead of a screen-wide dark overlay. */
#banner-endgame {
  background: transparent;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
  pointer-events: none;
}
#banner-endgame .screen-content {
  pointer-events: auto;
  background: rgba(10, 16, 14, 0.82);
  border: 2px solid #f4d35e;
  border-radius: 16px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}
#endgame-title {
  font-size: 2rem;
}

@media (min-width: 700px) {
  .screen-content { max-width: 560px; }
  .title-text { max-width: 480px; }
}
