/* =====================================================
   phase1.css – Built-in Mega Man game gateway (v2)
   Mobile-first: canvas + controls sized for phones.
   ===================================================== */

#phase1 {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--c-black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.6rem;
  overflow: hidden;
  /* Prevent rubber-band scroll / pinch while playing */
  touch-action: none;
}
#phase1.hidden { display: none !important; }

#phase1-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  max-width: 520px;
  padding: 0 0.5rem;
  animation: fadeIn 0.6s var(--ease-smooth);
}

/* Tagline */
#phase1-tagline {
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 2.2vw, 1.1rem);
  font-weight: 300;
  letter-spacing: 0.18em;
  color: var(--c-grey-6);
  text-transform: lowercase;
  text-align: center;
}

/* ── Game Shell ── */
#game-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  border: 2px solid var(--c-grey-3);
  box-shadow:
    0 0 0 1px #111,
    0 0 60px rgba(100,180,255,0.07),
    inset 0 0 30px rgba(0,0,0,0.5);
  user-select: none;
  -webkit-user-select: none;
}

/* HUD */
#game-hud {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #000;
  padding: 6px 10px;
  border-bottom: 1px solid #222;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: #aaa;
  letter-spacing: 0.08em;
  height: 32px;
}

#hud-lives { display: flex; align-items: center; gap: 4px; }
#hud-lives-icon { color: #ffcc00; font-size: 0.7rem; }
#hud-lives-count { color: #fff; font-weight: bold; }

#hud-score-wrap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
#hud-score-label { font-size: 0.58rem; color: #555; letter-spacing: 0.1em; }
#hud-score { color: #fff; font-size: 0.85rem; }

#hud-health-wrap, #hud-boss-wrap {
  display: flex; align-items: center; gap: 4px;
}
#hud-boss-wrap.hidden { display: none !important; }
#hud-boss-label { font-size: 0.55rem; color: #f55; }

#hud-health-bar, #hud-boss-bar {
  width: 80px;
  height: 9px;
  background: #111;
  border: 1px solid #333;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
#hud-health-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--hp, 100%);
  background: linear-gradient(to right, #2a9d2a, #4dff4d);
  transition: width 0.15s;
}
#hud-boss-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--hp, 100%);
  background: linear-gradient(to right, #c00, #ff5555);
  transition: width 0.15s;
}

/* Canvas — fluid width, fixed aspect ratio (512:432) */
#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 512 / 432;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #050d1a;
  cursor: none;
  touch-action: none;
}

/* Overlay screens */
.game-overlay {
  position: absolute;
  inset: 32px 0 0 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.game-overlay.hidden { display: none !important; }

#overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding: 1.5rem;
}
#overlay-logo {
  font-family: 'Courier New', monospace;
  font-size: clamp(1.3rem, 6vw, 2.2rem);
  font-weight: bold;
  color: #4db8ff;
  letter-spacing: 0.2em;
  text-shadow: 0 0 20px rgba(77,184,255,0.6);
  animation: glow 2s ease-in-out infinite alternate;
}
@keyframes glow {
  from { text-shadow: 0 0 10px rgba(77,184,255,0.4); }
  to   { text-shadow: 0 0 30px rgba(77,184,255,0.9); }
}
#overlay-msg {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #ccc;
  letter-spacing: 0.06em;
}
#overlay-sub {
  font-family: 'Courier New', monospace;
  font-size: 0.68rem;
  color: #555;
  letter-spacing: 0.1em;
}
#overlay-btn {
  margin-top: 0.5rem;
  padding: 0.85rem 2.5rem;
  border: 1px solid #4db8ff;
  color: #4db8ff;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  animation: btnPulse 1.2s ease-in-out infinite;
  /* Larger tap target */
  min-height: 48px;
  touch-action: manipulation;
}
#overlay-btn:hover,
#overlay-btn:active {
  background: #4db8ff;
  color: #000;
  animation: none;
}
@keyframes btnPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ══════════════════════════════════════════════
   MOBILE CONTROLS — primary control scheme.
   Big, thumb-friendly buttons laid out like a
   typical mobile platformer (D-pad left, actions right).
══════════════════════════════════════════════ */
#mobile-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 14px 14px 18px;
  background: #000;
  border-top: 1px solid #222;
}

#mc-dpad, #mc-actions {
  display: flex;
  gap: 14px;
}

#mc-actions {
  flex-direction: row-reverse; /* jump (X) on outside-right, shoot (Z) inner */
}

.mc-btn {
  width: 72px;
  height: 72px;
  background: #111;
  border: 2px solid #333;
  border-radius: 16px;
  color: #aaa;
  font-size: 1.5rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.08s, color 0.08s, border-color 0.08s, transform 0.08s;
}

.mc-btn:active,
.mc-btn.pressed {
  background: #2a5a8a;
  color: #fff;
  border-color: #4db8ff;
  transform: scale(0.94);
}

.mc-action {
  background: #1a1a2e;
  border-color: #3a3a5e;
  color: #8888cc;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  border-radius: 50%;
}
.mc-action.pressed,
.mc-action:active {
  background: #3a2a6a;
  border-color: #aa88ff;
  color: #fff;
}

#mc-jump { color: #ffcc66; border-color: #5a4a2a; }
#mc-jump.pressed, #mc-jump:active { border-color: #ffcc66; }

#mc-shoot { color: #4db8ff; border-color: #2a4a6a; }
#mc-shoot.pressed, #mc-shoot:active { border-color: #4db8ff; }

/* Slightly larger controls on bigger phones / small tablets */
@media (min-width: 480px) {
  .mc-btn { width: 84px; height: 84px; font-size: 1.7rem; }
  #mc-dpad, #mc-actions { gap: 18px; }
}

/* On genuinely large viewports (desktop), shrink controls a touch
   and show the keyboard hint more prominently — but controls stay
   visible since touch/mouse can still use them. */
@media (min-width: 900px) {
  #mobile-controls { padding: 10px 16px 14px; }
  .mc-btn { width: 56px; height: 56px; font-size: 1.2rem; }
  #mc-dpad, #mc-actions { gap: 10px; }
}

/* Controls hint */
#controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  justify-content: center;
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--c-grey-4);
  text-transform: uppercase;
  max-width: 520px;
  text-align: center;
}
#controls-hint span {
  border: 1px solid var(--c-grey-3);
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
}
kbd {
  font-family: inherit;
  background: var(--c-grey-3);
  color: var(--c-white);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Skip button */
#skip-btn {
  padding: 0.4rem 1.1rem;
  border: 1px solid #444;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #666;
  font-family: 'Courier New', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 36px;
  touch-action: manipulation;
  transition: color 0.2s, border-color 0.2s;
}
#skip-btn:hover,
#skip-btn:active {
  color: #ff8844;
  border-color: #ff8844;
}

/* Hide keyboard hints on small screens but always show skip */
@media (max-width: 700px) {
  #controls-hint span { display: none; }
  #controls-hint { gap: 0; }
  #skip-btn { display: inline-flex; }
}

/* Transition overlay */
#phase1-transition {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: var(--c-white);
  opacity: 0;
}
#phase1-transition.shatter {
  animation: shatter 0.9s var(--ease-smooth) forwards;
}
@keyframes shatter {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); filter: blur(6px); }
}

/* ══════════════════════════════════════════════
   LETTER SCREEN – full-screen message after game clear
══════════════════════════════════════════════ */
#letter-screen {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: var(--c-black);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem var(--content-pad);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s var(--ease-smooth);
}
#letter-screen.hidden { display: none !important; }
#letter-screen.visible {
  opacity: 1;
  pointer-events: auto;
}
#letter-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#letter-screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  max-width: 640px;
  width: 100%;
  animation: letterReveal 1.2s var(--ease-smooth) 0.4s both;
}

@keyframes letterReveal {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

#letter-screen-text {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 300;
  font-style: italic;
  line-height: 2;
  color: var(--c-grey-6);
  letter-spacing: 0.02em;
  text-align: center;
  white-space: pre-wrap;
}

#letter-screen-btn {
  padding: 0.9rem 2.8rem;
  border: 1px solid #4db8ff;
  color: #4db8ff;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.16em;
  background: transparent;
  cursor: pointer;
  min-height: 52px;
  touch-action: manipulation;
  animation: btnPulse 1.4s ease-in-out infinite;
  transition: background 0.2s, color 0.2s;
}
#letter-screen-btn:hover,
#letter-screen-btn:active {
  background: #4db8ff;
  color: #000;
  animation: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
