/* Bridge Patrol — phase 1 (core sim, placeholder art) */

:root {
  --bg: #0c130e;
  --chrome: #131b15;
  --line: rgba(255, 255, 255, 0.12);
  --hairline: rgba(255, 255, 255, 0.08);
  --ink: #e9f0ea;
  --dim: #9fb2a4;
  --moss: #34c759;
  --gold: #ffd60a;
  --danger: #ff453a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* display:flex on containers would otherwise override the hidden attribute */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: manipulation;
}

#bp-root {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px;
}

/* ---------- HUD ---------- */
#bp-hud {
  width: min(960px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--chrome);
  border: 0.5px solid var(--line);
  border-radius: 14px;
  flex-wrap: wrap;
}

.hud-left, .hud-mid, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-stat {
  font-family: "DM Mono", monospace;
  font-size: 14px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-dim { color: var(--dim); }

.chest-meter {
  display: inline-block;
  width: 72px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  vertical-align: middle;
}

#chest-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width 0.25s ease;
}

#bp-hud button {
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  cursor: pointer;
}

#bp-hud button:hover { background: rgba(255, 255, 255, 0.15); }
#bp-hud button:focus-visible { outline: 2px solid var(--moss); outline-offset: 1px; }

#btn-wave {
  background: var(--moss);
  color: #06240f;
}
#btn-wave:hover { background: #46d968; }
#btn-wave:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--dim);
  cursor: default;
}

#btn-speed[aria-pressed="true"] { background: var(--gold); color: #241c02; }
#btn-pause[aria-pressed="true"] { background: var(--danger); color: #fff; }

/* ---------- Stage ---------- */
#bp-stage {
  position: relative;
  width: min(960px, 100%);
}

#bp-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 7;
  border: 0.5px solid var(--line);
  border-radius: 14px;
  background: #16211a;
  image-rendering: pixelated;
  cursor: pointer;
}

/* ---------- Popovers (build menu / tower panel) ---------- */
.bp-pop {
  position: absolute;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  max-height: calc(100% - 12px);
  overflow-y: auto;
  padding: 10px;
  background: rgba(19, 27, 21, 0.96);
  border: 0.5px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.bp-pop h3 {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
  padding-bottom: 2px;
}

.bp-pop .pop-sub {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--dim);
}

.bp-pop button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 0.5px solid var(--hairline);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}

.bp-pop button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.bp-pop button:focus-visible { outline: 2px solid var(--moss); outline-offset: 1px; }
.bp-pop button:disabled { opacity: 0.45; cursor: default; }

.bp-pop .cost {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--gold);
  white-space: nowrap;
}

.bp-pop .sell .cost { color: var(--dim); }

/* ---------- Full screens (title / game over) ---------- */
.bp-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 10, 7, 0.82);
  backdrop-filter: blur(6px);
}

.bp-card {
  max-width: 420px;
  width: 100%;
  text-align: center;
  background: var(--chrome);
  border: 0.5px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.bp-screen-top { z-index: 30; }

.bp-card-wide {
  max-width: 620px;
  max-height: 88dvh;
  overflow-y: auto;
  text-align: left;
}

.bp-card-wide h1 { font-size: 20px; text-align: center; }

.bp-logo { font-size: 52px; line-height: 1; }

.bp-card h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.bp-tag {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  color: var(--moss);
}

.bp-how {
  font-size: 13px;
  line-height: 1.55;
  color: var(--dim);
}

.bp-best {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--gold);
}

.bp-cta {
  font-family: "DM Sans", sans-serif;
  font-weight: 900;
  font-size: 15px;
  color: #06240f;
  background: var(--moss);
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  cursor: pointer;
  width: 100%;
}

.bp-cta:hover { background: #46d968; }
.bp-cta:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.bp-cta-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 0.5px solid var(--line);
}
.bp-cta-ghost:hover { background: rgba(255, 255, 255, 0.15); }

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
  #bp-root { padding: 6px; gap: 6px; }
  #bp-hud { padding: 6px 8px; gap: 6px; border-radius: 10px; }
  .hud-stat { font-size: 12px; }
  .chest-meter { width: 48px; }
  #bp-hud button { font-size: 12px; padding: 6px 9px; }
  #bp-canvas { border-radius: 10px; }
}

/* Bridge Patrol's battlefield is wide (12:7) — on a narrow portrait phone
   most of the screen is empty margin. Nudge toward landscape instead of
   silently leaving a cramped, mostly-black screen. */
#bp-rotate-hint {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  padding: 8px 14px;
  text-align: center;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: #06240f;
  background: #ffd60a;
}
@media (max-width: 600px) and (orientation: portrait) {
  #bp-rotate-hint { display: block; }
  #bp-root { padding-top: 34px; }
}
