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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #060508;
  color: #c8b8a8;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  max-width: 960px;
  aspect-ratio: 16 / 9;
}

#game-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid #2a2030;
  box-shadow:
    0 0 0 1px #120e16 inset,
    0 24px 80px rgba(0, 0, 0, 0.65);
  background: #0a080c;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  pointer-events: none;
}

#hud.hidden {
  display: none;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(8, 6, 10, 0.92) 0%, rgba(8, 6, 10, 0) 100%);
}

.hud-label {
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6a5a68;
  margin-bottom: 4px;
}

.bar-track {
  width: 160px;
  height: 8px;
  background: #1a1218;
  border: 1px solid #3a2838;
}

.bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6a1828, #a03040);
  transition: width 0.15s ease;
}

.zone-name {
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: #8a7a70;
}

.hud-zone {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mute-btn {
  pointer-events: auto;
  padding: 4px 8px;
  border: 1px solid #4a3848;
  background: rgba(12, 8, 14, 0.8);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.boss-hud {
  flex: 1;
  max-width: 280px;
  text-align: center;
}

.boss-hud.hidden {
  display: none;
}

.boss-name {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #a86878;
  margin-bottom: 4px;
}

.bar-track-boss {
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
}

.bar-fill-boss {
  background: linear-gradient(90deg, #5a1020, #c03048);
}

.hud-toast {
  margin: 0;
  padding: 6px 14px 10px;
  font-size: 0.72rem;
  color: #a89098;
  text-align: center;
  letter-spacing: 0.04em;
}

.hud-toast.hidden {
  display: none;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#overlay:not(.hidden) {
  pointer-events: auto;
}

#overlay.hidden {
  display: none;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 6, 0.82);
  backdrop-filter: blur(2px);
}

.menu-screen {
  position: relative;
  z-index: 1;
  width: min(92%, 420px);
  max-height: 92%;
  overflow: auto;
}

.menu-screen.hidden {
  display: none;
}

.menu-card {
  padding: 28px 24px;
  border: 1px solid #3a2838;
  background:
    linear-gradient(180deg, rgba(22, 16, 24, 0.98) 0%, rgba(10, 8, 12, 0.98) 100%);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.menu-card-sm {
  text-align: center;
}

.menu-badge {
  margin: 0 0 10px;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a4860;
}

.game-title {
  margin: 0 0 8px;
  font-family: 'Cinzel', serif;
  font-size: clamp(1.6rem, 5vw, 2rem);
  font-weight: 700;
  color: #d8c8b8;
  letter-spacing: 0.04em;
}

.game-title-sm {
  font-size: 1.35rem;
}

.tagline {
  margin: 0 0 12px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #8a8078;
}


.landscape-hint {
  margin: 0 0 14px;
  font-size: 0.72rem;
  color: #8a7868;
  line-height: 1.45;
}

.controls-mobile-head {
  margin: 14px 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6878;
}

.controls-mobile {
  margin: 0;
  padding-left: 18px;
}

.mature-gate {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid #4a2838;
  background: rgba(40, 16, 24, 0.35);
}

.mature-gate p {
  margin: 0 0 10px;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #a89098;
}

.mature-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.74rem;
  cursor: pointer;
}

.mature-check input {
  margin-top: 2px;
}

.menu-details {
  margin-top: 16px;
  font-size: 0.74rem;
  color: #7a7068;
}

.menu-details summary {
  cursor: pointer;
  color: #9a8878;
}

.menu-details ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.menu-details li {
  margin-bottom: 4px;
}

.menu-card h2 {
  margin: 0 0 8px;
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  color: #d0c0b0;
}

.death-copy,
.demo-charity {
  margin: 0 0 16px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #8a6870;
}

.demo-store-note {
  margin: 10px 0 0;
  font-size: 0.68rem;
  color: #6a6058;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

a.btn {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #6a2838 0%, #401820 100%);
  border-color: #8a4860;
  color: #f0e0d8;
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(180deg, #7a3040 0%, #502028 100%);
}

.btn-outline {
  background: transparent;
  border-color: #4a3848;
  color: #a89888;
}

.btn-outline:hover {
  border-color: #6a5868;
  color: #d0c0b0;
}

kbd {
  padding: 1px 5px;
  border: 1px solid #4a4048;
  border-radius: 3px;
  background: #1a1618;
  font-size: 0.85em;
}

.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.touch-controls.hidden {
  display: none;
}

.touch-cluster {
  position: absolute;
  bottom: 10px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-move {
  left: 12px;
}

.touch-actions {
  right: 12px;
  align-items: flex-end;
}

.touch-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(120, 90, 110, 0.55);
  background: rgba(18, 12, 20, 0.78);
  color: #c8b0a8;
  font-size: 1.1rem;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  -webkit-user-select: none;
}

.touch-btn-move {
  width: 58px;
  height: 58px;
  border-radius: 12px;
}

.touch-btn-jump {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font-size: 1.35rem;
  border-color: #6a4860;
  background: rgba(50, 24, 36, 0.85);
}

.touch-btn-attack {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  border-color: #8a5868;
}

.touch-btn-secondary {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  font-size: 0.95rem;
}

.touch-btn:active,
.touch-btn.is-pressed {
  background: rgba(80, 40, 55, 0.92);
  transform: scale(0.96);
}

body.mobile-touch .touch-btn::before {
  content: '';
  position: absolute;
  inset: -10px;
}

.touch-rest {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  padding: 10px 18px;
  border: 1px solid #6a4860;
  border-radius: 8px;
  background: rgba(30, 16, 24, 0.92);
  color: #e0c8c0;
  font: inherit;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}

.touch-rest.hidden {
  display: none;
}

@media (max-width: 520px) {
  .hud-bar {
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .bar-track {
    width: 140px;
  }

  .boss-hud {
    order: 3;
    width: 100%;
    max-width: none;
  }

  body.mobile-touch .touch-btn-move {
    width: 64px;
    height: 64px;
  }

  body.mobile-touch .touch-btn-jump {
    width: 76px;
    height: 76px;
  }

  body.mobile-touch .touch-btn-attack {
    width: 68px;
    height: 68px;
  }
}

/* --- Rotate prompt (portrait on touch) --- */
.mobile-block {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #080608;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.mobile-block.hidden { display: none; }

.mobile-block-card {
  text-align: center;
  max-width: 300px;
}
.mobile-block-icon {
  display: block;
  font-size: 2.8rem;
  margin-bottom: 20px;
}
.mobile-block-title {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 500;
  color: #c9a96e;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.mobile-block-body {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.75;
  color: #6a6070;
}

.rotate-prompt {
  position: fixed;
  top: var(--vv-offset-top, 0);
  left: var(--vv-offset-left, 0);
  width: var(--vv-width, 100%);
  height: var(--vv-height, 100%);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 4, 8, 0.94);
  backdrop-filter: blur(8px);
}

.rotate-prompt.hidden {
  display: none;
}

.rotate-prompt-card {
  text-align: center;
  max-width: 280px;
}

.rotate-icon {
  display: inline-block;
  font-size: 3rem;
  margin-bottom: 16px;
  animation: cp-rotate-hint 2.4s ease-in-out infinite;
}

@keyframes cp-rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  40%, 60% { transform: rotate(-90deg); }
}

.rotate-title {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin: 0 0 8px;
  color: #d8c8b8;
}

.rotate-sub {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #8a8078;
}

#pause-btn.pause-fab {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 25;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(120, 90, 110, 0.55);
  border-radius: 10px;
  background: rgba(18, 12, 20, 0.85);
  color: #c8b0a8;
  font-size: 1.1rem;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#pause-btn.pause-fab.hidden {
  display: none;
}

#pause-btn.pause-fab:active {
  transform: scale(0.96);
  background: rgba(50, 24, 36, 0.92);
}

/* --- Mobile play layout --- */
body.mobile-touch #app {
  padding: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
}

body.mobile-touch #game-shell {
  width: 100%;
  max-width: none;
  height: 100%;
  aspect-ratio: auto;
}

body.mobile-touch #game-frame {
  border: none;
  box-shadow: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body.mobile-touch.mobile-landscape #game-frame {
  position: absolute;
  top: var(--vv-offset-top, 0);
  left: var(--vv-offset-left, 0);
  width: var(--vv-width, 100%);
  height: var(--vv-height, 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

body.mobile-touch.mobile-landscape #game {
  touch-action: none;
  margin: 0 auto;
}

body.mobile-touch.mobile-landscape #hud:not(.hidden) {
  position: absolute;
  top: max(4px, env(safe-area-inset-top));
  left: max(4px, env(safe-area-inset-left));
  right: max(56px, calc(env(safe-area-inset-right) + 48px));
  z-index: 20;
}

body.mobile-touch.mobile-landscape .hud-bar {
  padding: 4px 6px;
  gap: 6px;
}

body.mobile-touch.mobile-landscape .hud-toast {
  position: fixed;
  top: max(52px, calc(env(safe-area-inset-top) + 44px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  max-width: min(90vw, 420px);
  padding: 8px 12px;
  background: rgba(12, 8, 14, 0.88);
  border: 1px solid #3a2838;
  border-radius: 6px;
}

body.mobile-touch.mobile-landscape .touch-cluster {
  bottom: max(10px, env(safe-area-inset-bottom));
}

body.mobile-touch.mobile-landscape .touch-move {
  left: max(12px, env(safe-area-inset-left));
}

body.mobile-touch.mobile-landscape .touch-actions {
  right: max(12px, env(safe-area-inset-right));
}

body.mobile-touch.mobile-landscape .touch-btn-move {
  width: 72px;
  height: 72px;
}

body.mobile-touch.mobile-landscape .touch-btn-jump {
  width: 84px;
  height: 84px;
}

body.mobile-touch.mobile-landscape .touch-btn-attack {
  width: 76px;
  height: 76px;
}

body.mobile-touch.mobile-landscape .touch-btn-secondary {
  width: 56px;
  height: 56px;
}

body.mobile-touch.mobile-landscape .touch-btn::before {
  inset: -14px;
}

body.mobile-touch.mobile-landscape #pause-btn.pause-fab {
  width: 48px;
  height: 48px;
}

@media (orientation: landscape) and (max-height: 520px) {
  body.mobile-touch.mobile-landscape .rotate-prompt {
    display: none !important;
  }
}
