/* style.css — CRT Terminal theme for Hunt the Wumpus.
   Ported from the mockup's inline JS style objects (crt theme only). */

:root {
  --bg: #170a24;
  --panel: rgba(255, 46, 196, 0.05);
  --border: rgba(255, 46, 196, 0.45);
  --magenta: #ff2ec4;   /* primary accent */
  --cyan: #2ee8ff;      /* secondary accent */
  --amber: #ffb703;     /* warning / shoot-mode */
  --text: #ece6f7;
  --dim: rgba(236, 230, 247, 0.55);
  --header-font: 'Press Start 2P', monospace;
  --body-font: 'Share Tech Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #05030a;
  color: var(--text);
  font-family: var(--body-font);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Keyframes (ported from the mockup's helmet <style>) ---- */
@keyframes wg-flicker { 0%,100%{ opacity:1; } 92%{ opacity:1; } 93%{ opacity:.82; } 94%{ opacity:1; } }
@keyframes wg-doorblink { 0%,100%{ opacity:1; } 33%{ opacity:0.1; } 66%{ opacity:1; } }

/* ---- Frame / bezel (frameStyle, CRT branch) ---- */
.frame {
  width: 900px;
  height: 640px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  background-image: repeating-linear-gradient(
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(255,255,255,0.03) 3px, rgba(0,0,0,0) 4px);
  border: 10px solid #050208;
  border-radius: 34px;
  box-shadow: 0 0 0 2px var(--border), 0 30px 80px rgba(0,0,0,0.6), inset 0 0 90px rgba(0,0,0,0.65);
  font-family: var(--body-font);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* Screen visibility is toggled by ui.js via .is-hidden. */
.is-hidden { display: none !important; }

/* ================= TITLE SCREEN ================= */
.title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px;
  text-align: center;
}
.title-glow {
  font-family: var(--header-font);
  font-size: 34px;
  letter-spacing: 4px;
  color: var(--magenta);
  text-shadow: 0 0 18px var(--magenta), 0 0 40px var(--magenta);
  animation: wg-flicker 6s infinite;
}
.subtitle {
  font-size: 14px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
}
.instructions-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 640px;
}
.instr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 1px;
}
.instr-icon { color: var(--amber); font-size: 16px; }
.footer-line { font-size: 11px; letter-spacing: 2px; color: var(--dim); }

/* Primary CTA button (startBtnStyle, CRT branch) */
.start-btn {
  font-family: var(--header-font);
  font-size: 15px;
  letter-spacing: 2px;
  color: #0a0510;
  background: var(--magenta);
  border: none;
  border-radius: 10px;
  padding: 16px 34px;
  cursor: pointer;
  box-shadow: 0 0 24px var(--magenta);
}
.start-btn:hover { filter: brightness(1.08); }

/* ================= BRIEFING SCREEN ================= */
.briefing-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 36px 48px;
  text-align: center;
}
.briefing-title {
  font-family: var(--header-font);
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--magenta);
  text-shadow: 0 0 14px var(--magenta);
}
.briefing-sub {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
  margin-top: -12px;
}
.briefing-cards {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 760px;
}
.briefing-card {
  flex: 1 1 220px;
  max-width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.briefing-card-icon {
  color: var(--amber);
  font-size: 22px;
  text-shadow: 0 0 10px var(--amber);
}
.briefing-card-name {
  font-family: var(--header-font);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--text);
}
.briefing-card-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--dim);
  letter-spacing: 0.5px;
}
.briefing-arrows {
  max-width: 640px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
  letter-spacing: 0.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}
.briefing-arrows-icon {
  color: var(--cyan);
  font-size: 16px;
  text-shadow: 0 0 8px var(--cyan);
  flex-shrink: 0;
}
.briefing-arrows-text { flex: 1; }
.briefing-arrows strong { color: var(--text); }

/* ================= PLAYING SCREEN ================= */
.play-wrap {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 260px;
  grid-template-rows: 48px 1fr 30px;
  gap: 14px;
  padding: 18px;
  min-height: 0;
}

/* Top HUD bar */
.hud-top {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 18px;
  font-size: 13px;
  letter-spacing: 2px;
}
.hud-label { color: var(--magenta); }
.hud-controls { display: flex; align-items: center; }

.mute-btn {
  font-family: var(--body-font);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--magenta);
  background: transparent;
  border: 1px solid var(--magenta);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  margin-right: 10px;
}
.mute-btn.muted { color: var(--dim); border-color: var(--dim); }

.shoot-btn {
  font-family: var(--body-font);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--amber);
  background: transparent;
  border: 1px solid var(--amber);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
}
.shoot-btn.armed { color: #0a0510; background: var(--amber); }

/* Chamber (first-person 3D view) */
.chamber {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  position: relative;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: radial-gradient(ellipse at 50% 38%, rgba(255,46,196,0.08) 0%, #05030a 78%);
  overflow: hidden;
  perspective: 900px;
}
.scene {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.floor {
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: 0;
  height: 78%;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  background-color: #03020a;
  transform: rotateX(58deg);
  transform-origin: bottom center;
}
.ceiling {
  position: absolute;
  left: -25%;
  right: -25%;
  top: 0;
  height: 32%;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  background-color: #020109;
  transform: rotateX(-58deg);
  transform-origin: top center;
}

/* Scattered gems/rocks on the floor plane (positions set inline by ui.js). */
.decor { position: absolute; }
.decor.gem { box-shadow: 0 0 10px var(--magenta); opacity: 0.95;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.decor.gem.secondary { box-shadow: 0 0 10px var(--cyan); }
.decor.rock {
  background: linear-gradient(160deg, #4a4458, #221f2c);
  clip-path: polygon(20% 0%, 80% 10%, 100% 55%, 70% 100%, 15% 90%, 0% 40%);
  box-shadow: 0 2px 3px rgba(0,0,0,0.5);
  opacity: 0.85;
}

/* Doorways — carousel placement (rotateY + translateZ), inline transform per door. */
.door {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 250px;
  margin-left: -75px;
  margin-top: -125px;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform .3s ease;
}
.door-arch {
  position: absolute;
  inset: 0;
  border: 2px solid var(--cyan);
  border-radius: 50% 50% 6px 6px / 22% 22% 6px 6px;
  box-shadow: 0 0 26px rgba(46,232,255,0.4), inset 0 0 34px rgba(0,0,0,0.65);
  background: radial-gradient(circle at 50% 32%, rgba(46,232,255,0.15) 0%, #030109 72%);
  transition: all .3s ease;
}
.door-glyph {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--header-font);
  font-size: 26px;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
  letter-spacing: 1px;
}
/* Shoot-mode armed: doors glow amber. */
.chamber.armed .door-arch {
  border-color: var(--amber);
  box-shadow: 0 0 26px rgba(255,183,3,0.4), inset 0 0 34px rgba(0,0,0,0.65);
  background: radial-gradient(circle at 50% 32%, rgba(255,183,3,0.15) 0%, #030109 72%);
}
.chamber.armed .door-glyph { color: var(--amber); text-shadow: 0 0 12px var(--amber); }

/* Door-number blink during a transition (set via .blink by ui.js). */
.door-glyph.blink { animation: wg-doorblink 0.34s steps(3) 1; }

/* Black fade overlay during transitions. */
.fade-overlay {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity 0.38s ease;
  pointer-events: none;
  z-index: 20;
}

/* Sidebar */
.sidebar {
  grid-row: 2 / 3;
  grid-column: 2 / 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.log-panel {
  flex: 1;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.log-header { font-size: 11px; letter-spacing: 2px; color: var(--magenta); margin-bottom: 4px; }
.log-line { font-size: 11px; line-height: 1.5; color: var(--dim); }
.log-room-tag { color: var(--magenta); font-weight: bold; }

.minimap-wrap {
  width: 100%;
  height: 160px;
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
}
.minimap-svg { width: 100%; height: 100%; overflow: visible; }

/* Bottom hint bar */
.hint-bar {
  grid-column: 1 / 3;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
  display: flex;
  align-items: center;
}

/* ---- Shoot path-entry UI (custom, not in mockup) ---- */
.shoot-panel {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(23, 10, 36, 0.92);
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 0 24px rgba(255,183,3,0.25), 0 10px 30px rgba(0,0,0,0.6);
}
.shoot-panel-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--amber);
  font-family: var(--header-font);
}
.shoot-slots { display: flex; gap: 8px; }
.shoot-slot {
  width: 46px;
  height: 46px;
  text-align: center;
  font-family: var(--header-font);
  font-size: 16px;
  color: var(--cyan);
  background: rgba(46,232,255,0.06);
  border: 1px solid var(--cyan);
  border-radius: 6px;
  outline: none;
}
.shoot-slot:focus { box-shadow: 0 0 10px var(--cyan); }
.shoot-actions { display: flex; gap: 10px; margin-top: 2px; }
.shoot-hint-text {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--dim);
  max-width: 300px;
  text-align: center;
}
.shoot-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  max-width: 300px;
}
.shoot-suggestions-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--dim);
  width: 100%;
  text-align: center;
}
.shoot-suggestion-chip {
  font-family: var(--body-font);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--cyan);
  background: rgba(46,232,255,0.08);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
}
.shoot-suggestion-chip:hover { background: rgba(46,232,255,0.2); }
.fire-btn {
  font-family: var(--header-font);
  font-size: 11px;
  letter-spacing: 1px;
  color: #0a0510;
  background: var(--amber);
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255,183,3,0.5);
}
.fire-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.abort-btn {
  font-family: var(--body-font);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
}

/* ================= GAME OVER SCREEN ================= */
.over-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px;
  text-align: center;
}
.over-title {
  font-family: var(--header-font);
  font-size: 28px;
  letter-spacing: 3px;
  text-shadow: 0 0 18px currentColor;
}
.over-title.won { color: var(--magenta); }
.over-title.lost { color: var(--amber); }
.over-sub { font-size: 13px; color: var(--dim); letter-spacing: 1px; max-width: 480px; }

/* ============================================================
   SHORT-VIEWPORT LANDSCAPE (mobile phones held sideways)
   Target: Pixel 10 landscape ~915x412, iPhone ~844x390,
   larger Android ~932x430. Keyed on short height + landscape
   so tall/desktop viewports are completely unaffected.
   ============================================================ */
@media (max-height: 550px) and (orientation: landscape) {

  /* Let the body fill the small screen with no forced centering gaps. */
  html, body {
    min-height: 100svh;
    align-items: stretch;
    justify-content: stretch;
  }

  /* Frame becomes fluid: fill the viewport instead of fixed 900x640.
     svh/dvh avoid the mobile browser-chrome jump. Thin bezel + small
     radius so almost all pixels go to gameplay. */
  .frame {
    width: 100vw;
    height: 100svh;
    height: 100dvh;
    border-width: 4px;
    border-radius: 14px;
    box-shadow: 0 0 0 1px var(--border), inset 0 0 60px rgba(0,0,0,0.65);
  }

  /* ---------- TITLE SCREEN (compact) ---------- */
  .title-wrap { gap: 12px; padding: 14px 20px; }
  .title-glow { font-size: 20px; letter-spacing: 2px; }
  .subtitle { font-size: 10px; letter-spacing: 3px; }
  .instructions-row { gap: 8px 20px; max-width: 720px; }
  .instr-item { font-size: 10px; }
  .instr-icon { font-size: 13px; }
  .footer-line { font-size: 9px; }
  .start-btn { font-size: 12px; padding: 12px 26px; }

  /* ---------- BRIEFING SCREEN (compact, scroll if needed) ---------- */
  .briefing-wrap {
    gap: 10px;
    padding: 12px 20px;
    justify-content: flex-start;
    overflow-y: auto;
  }
  .briefing-title { font-size: 16px; }
  .briefing-sub { font-size: 9px; margin-top: -6px; }
  .briefing-cards { gap: 10px; max-width: 100%; }
  .briefing-card { flex: 1 1 180px; max-width: 220px; padding: 10px 12px; gap: 5px; }
  .briefing-card-icon { font-size: 17px; }
  .briefing-card-name { font-size: 10px; }
  .briefing-card-desc { font-size: 9.5px; line-height: 1.35; }
  .briefing-arrows { font-size: 9.5px; line-height: 1.4; max-width: 100%; }
  .briefing-arrows-icon { font-size: 13px; }
  .briefing-wrap .start-btn { font-size: 11px; padding: 10px 22px; flex-shrink: 0; }

  /* ---------- PLAYING SCREEN (tight responsive grid) ---------- */
  .play-wrap {
    grid-template-columns: 1fr clamp(160px, 24vw, 210px);
    grid-template-rows: 34px 1fr 20px;
    gap: 8px;
    padding: 8px;
  }

  .hud-top { padding: 0 12px; font-size: 11px; letter-spacing: 1px; }
  .mute-btn { font-size: 9px; padding: 6px 9px; margin-right: 6px; letter-spacing: 1px; }
  .shoot-btn { font-size: 9px; padding: 6px 9px; letter-spacing: 1px; }

  /* Increase perspective (weaker => less exaggerated) and pull the whole
     3D scene toward the viewer with translateZ so the fixed
     translateZ(260px) doors sit comfortably inside the shorter chamber.
     Keeps preserve-3d intact (no flattening from a 2D scale). */
  .chamber { perspective: 620px; }
  .scene { transform: translateZ(-70px); }

  /* ---------- SIDEBAR (narrower, shorter minimap) ---------- */
  .sidebar { gap: 8px; }
  .log-panel { padding: 8px 10px; gap: 4px; }
  .log-header { font-size: 9px; margin-bottom: 2px; }
  .log-line { font-size: 9.5px; line-height: 1.35; }
  .minimap-wrap { height: clamp(84px, 24svh, 120px); padding: 4px; }

  .hint-bar { font-size: 9px; letter-spacing: 0.5px; }

  /* ---------- SHOOT PANEL (compact, guaranteed to fit) ---------- */
  .shoot-panel {
    bottom: 8px;
    padding: 8px 12px;
    gap: 5px;
    max-width: calc(100% - 16px);
  }
  .shoot-panel-title { font-size: 8px; letter-spacing: 1px; }
  .shoot-slots { gap: 5px; }
  .shoot-slot { width: 34px; height: 34px; font-size: 13px; }
  .shoot-hint-text { font-size: 8.5px; line-height: 1.25; max-width: 340px; }
  .shoot-suggestions { gap: 4px; max-width: 340px; }
  .shoot-suggestions-label { font-size: 8.5px; }
  .shoot-suggestion-chip { font-size: 10px; padding: 3px 8px; }
  .shoot-actions { gap: 8px; margin-top: 0; }
  .fire-btn { font-size: 10px; padding: 8px 14px; }
  .abort-btn { font-size: 10px; padding: 8px 12px; }

  /* ---------- GAME OVER SCREEN (compact) ---------- */
  .over-wrap { gap: 12px; padding: 18px; }
  .over-title { font-size: 20px; }
  .over-sub { font-size: 11px; max-width: 90%; }
}

/* Very short viewports (e.g. small phones ~390px tall in landscape):
   trim the shoot panel further so it never overruns the chamber. */
@media (max-height: 410px) and (orientation: landscape) {
  .chamber { perspective: 560px; }
  .scene { transform: translateZ(-90px); }
  .shoot-hint-text { display: none; }
  .shoot-slot { width: 30px; height: 30px; font-size: 12px; }
  .briefing-card-desc { display: none; }
}
