/* Fence — Mini Runner styles (pure CSS) */
:root {
  --bg: #0a0b15;
  --ink: #f5f7ff;
  --muted: #99a2c2;
  --accent: #7cf7ff;
  --accent2: #a3ff7c;
  --danger: #ff6b6b;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 50% -20%, #10204a 0%, var(--bg) 55%, #05060c 100%);
  color: var(--ink);
  font-family: ui-rounded, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#game-root {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== HUD ===== */
.hud, .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}

.hud {
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(10,11,21,0.85), rgba(10,11,21,0.35));
  z-index: 100; /* stays above overlay */
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-center {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 700;
}

.hud button, .hud .btn {
  background: #171a2b;
  color: var(--ink);
  border: 1px solid #2b2f4a;
  border-radius: 12px;
  padding: 6px 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.hud button:hover, .hud .btn:hover {
  filter: brightness(1.08);
}

.hud .hidden {
  display: none;
}

.bank {
  opacity: 0.9;
}

/* ===== GAME AREA ===== */
#stage-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 8px 12px 16px;
}

#game {
  width: min(94vw, 520px);
  height: calc(min(94vw, 520px) * 1.65);
  max-height: 85vh;
  border-radius: 16px;
  background: #0b0f22 url('assets/bg.svg') center/cover no-repeat;
  box-shadow: 0 20px 40px rgba(0,0,0,0.45), inset 0 0 0 2px rgba(124,247,255,0.1);
  touch-action: none;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.debug {
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #9cf;
}

/* ===== OVERLAY ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: calc(var(--hudH, 60px) + 12px) 12px 16px;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0),
    rgba(0,0,0,0.35) 30%,
    rgba(0,0,0,0.65)
  );
}

.overlay.hidden {
  display: none;
  pointer-events: none;
}

.overlay .card {
  width: min(92vw, 680px);
  max-height: calc(100vh - var(--hudH, 60px) - 48px);
  overflow: auto;
  background: #0d122b;
  border: 1px solid #1d2448;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.overlay .row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.overlay button {
  background: linear-gradient(180deg, #1b2450, #131a3a);
  color: #fff;
  border: 1px solid #2d3b8e;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== CONFETTI ===== */
#confetti {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

/* ===== UTILITIES ===== */
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.hidden { display: none; }

/* ===== SHOP ===== */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.shop-item {
  background: #0f1531;
  border: 1px solid #1d2448;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.shop-item h3 {
  margin: 0;
  font-size: 1.1rem;
}

.shop-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.shop-item .qty {
  color: var(--accent2);
  font-weight: 700;
}

.shop-item button {
  background: linear-gradient(180deg, #17325a, #11264a);
  color: #fff;
  border: 1px solid #27508e;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}

.shop-item button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== FOOTER ===== */
.foot {
  justify-content: center;
  color: var(--muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .hud {
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .hud button, .hud .btn {
    padding: 5px 8px;
    border-radius: 10px;
    font-size: 0.95rem;
  }

  .hud-center {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 10px 12px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 0.98rem;
  }

  .hud-left, .hud-right { gap: 6px; }

  .hud-right button {
    width: 34px;
    height: 32px;
    padding: 0;
    display: grid;
    place-items: center;
  }
}

@media (max-width: 480px) {
  .hud {
    padding: 6px 8px;
  }

  .hud button, .hud .btn {
    padding: 4px 7px;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  .hud-center {
    gap: 8px 10px;
    font-size: 0.85rem;
  }

  .overlay {
    padding: calc(var(--hudH, 56px) + 8px) 10px 12px;
  }
}

@media (max-width: 420px) {
  .shop-grid {
    grid-template-columns: 1fr;
  }
}
