@import url('/lukesconian/style.css');

/* Respect hidden attributes for modal/panels. */
[hidden] {
  display: none !important;
}

/* Full-width Bearsconian layout without page clutter. */
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #000 !important;
}

:root {
  --bearsconian-vh: 100vh;
  --bearsconian-vh: 100dvh;
}

.game-shell {
  padding: 0;
  width: 100%;
  height: var(--bearsconian-vh);
  min-height: var(--bearsconian-vh);
  background: #000 !important;
}

.game-frame {
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  height: var(--bearsconian-vh);
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #000 !important;
}

#game {
  display: block;
  width: min(100vw, calc(var(--bearsconian-vh) * 1.3));
  height: min(var(--bearsconian-vh), calc(100vw / 1.3));
  max-width: 100vw;
  max-height: var(--bearsconian-vh);
  border-radius: 0;
  background: #000 !important;
}

/* Keep aspect ratio in Fullscreen API mode (avoid stretch). */
.game-frame:fullscreen #game {
  width: min(100vw, calc(var(--bearsconian-vh) * 1.3));
  height: min(var(--bearsconian-vh), calc(100vw / 1.3));
  max-width: 100vw;
  max-height: var(--bearsconian-vh);
}

body {
  overflow: hidden;
  font-family: "VT323", monospace;
  letter-spacing: 0.3px;
  background: #000 !important;
}

/* Force pixel font across all Bearsconian UI chrome. */
body,
body *:not(canvas) {
  font-family: "VT323", monospace !important;
}

button,
input,
.leaderboard-panel,
.game-overlay-panel,
.name-entry-card {
  font-family: "VT323", monospace;
}

.game-overlay-panel.is-game-over {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.leaderboard-panel {
  z-index: 7;
}

.title-screen {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}

.title-splash-media {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.title-splash-image,
.title-splash-video {
  width: 100%;
  height: 100%;
  max-height: none;
  image-rendering: auto;
  object-fit: cover;
  display: block;
}

.title-splash-video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.title-screen.is-video-ready .title-splash-video {
  opacity: 1;
}

.postgame-scores-screen {
  position: absolute;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.84);
  padding: 1rem;
}

.postgame-scores-card {
  width: min(92vw, 520px);
  max-height: 84vh;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(7, 10, 18, 0.92);
  padding: 1rem 1.1rem;
  text-align: center;
}

.postgame-scores-card h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 3.2vw, 2.8rem);
  letter-spacing: 1.5px;
  color: #ffb266;
}

.postgame-scores-card ol {
  margin: 0 auto 0.9rem;
  padding: 0 0 0 1.3rem;
  width: min(92%, 360px);
  text-align: left;
}

.postgame-scores-card li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  color: #f2f5ff;
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  margin-bottom: 0.16rem;
}

.postgame-scores-screen .continue-prompt {
  margin-top: 0.4rem;
}

.continue-prompt {
  margin: 0;
  color: #f8fbff;
  font-size: clamp(1.4rem, 2.8vw, 2.4rem);
  letter-spacing: 1.2px;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.24);
}

.continue-prompt.is-armed {
  animation: continuePromptPulse 1s ease-in-out infinite;
}

.title-screen .continue-prompt {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  z-index: 2;
  white-space: nowrap;
}

@keyframes continuePromptPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.36; }
}

.touch-controls {
  position: fixed;
  left: 50%;
  bottom: 0.7rem;
  transform: translateX(-50%);
  z-index: 2500;
  margin-top: 0;
  background: #000 !important;
}

.quick-actions {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.55rem;
  z-index: 2600;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #eaf1ff;
  font-size: 1.18rem;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 0 8px rgba(16, 22, 40, 0.65);
  opacity: 0.88;
}

/* Neutralize inherited fullscreen absolute positioning in quick-actions row. */
.quick-actions .fullscreen-btn,
.quick-actions .mute-btn {
  position: static;
  right: auto;
  bottom: auto;
  margin: 0;
}

.icon-btn.is-on {
  color: #ffcf75;
  opacity: 1;
}

.icon-btn:active {
  transform: scale(0.95);
}

@media (max-width: 900px) {
  .icon-btn { width: 44px; height: 44px; }
  .menu-actions button,
  .name-entry-actions button,
  .touch-btn { min-height: 44px; }
}

.install-help-card {
  text-align: left;
}

.install-help-card h3 {
  margin-top: 0;
}

@media (min-width: 900px) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .game-shell {
    display: block;
    height: var(--bearsconian-vh);
    padding-bottom: 0;
  }

  .game-frame {
    align-items: center;
    justify-content: center;
    height: var(--bearsconian-vh);
  }

  #game {
    width: min(100vw, calc(var(--bearsconian-vh) * 1.3));
    height: min(var(--bearsconian-vh), calc(100vw / 1.3));
    margin-top: 0;
  }

  .touch-controls {
    width: 100%;
    left: 50%;
    bottom: max(6px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    justify-content: center;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
    pointer-events: none;
  }

  .analog-pad {
    width: 124px;
    height: 124px;
    position: fixed;
    left: 12vw;
    top: 74vh;
    opacity: 0.34;
    transition: opacity 90ms ease, filter 90ms ease;
    filter: saturate(0.92);
  }

  .analog-pad.is-floating-active {
    opacity: 1;
    filter: saturate(1.08);
  }

  .analog-knob {
    width: 50px;
    height: 50px;
    margin-left: -25px;
    margin-top: -25px;
  }

  .touch-actions {
    pointer-events: auto;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .game-shell {
    height: var(--bearsconian-vh);
    /* Reserve roughly a quarter of portrait height for controls. */
    padding-bottom: max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom)));
  }

  .game-frame {
    align-items: flex-start;
    justify-content: center;
  }

  #game {
    /*
      Portrait crop mode: scale height up and allow horizontal overflow,
      so sides are cropped and the visible play area feels taller.
    */
    height: calc(var(--bearsconian-vh) - 230px);
    width: calc((var(--bearsconian-vh) - 230px) * 1.3);
    max-width: none;
    max-height: none;
  }

  .title-screen .continue-prompt {
    bottom: max(72px, calc(var(--bearsconian-vh) * 0.1));
    font-size: clamp(1.25rem, 6vw, 1.8rem);
  }

  .touch-controls {
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom)));
    bottom: 0;
    padding: 0 max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .quick-actions {
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .analog-pad {
    width: min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px));
    height: min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px));
    position: static;
    left: auto;
    top: auto;
    bottom: auto;
    transform: translateY(-12px);
    opacity: 1;
    filter: none;
  }

  .analog-knob {
    width: calc(min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px)) * 0.42);
    height: calc(min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px)) * 0.42);
    margin-left: calc(min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px)) * -0.21);
    margin-top: calc(min(52vw, calc(max(calc(var(--bearsconian-vh) * 0.25), calc(var(--bearsconian-vh) * 0.24 + env(safe-area-inset-bottom))) - 8px)) * -0.21);
  }

  .touch-actions {
    display: none;
  }
}

/* Touch devices playing from Den Crawler Bear's safe room get the stick at any width. */
html.force-touch .touch-controls { display: flex !important; }
