/* ============================================================
   MINER RUSH — Shared styles (game + swap)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;600;700;800;900&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-deep: #1a0e0c;
  --bg-mid: #2c1712;
  --bg-dark: #150907;
  --rock-1: #5c342c;
  --rock-2: #7a4a40;
  --rock-3: #a06a5c;
  --gold: #ffce54;
  --gold-deep: #e6a428;
  --gold-light: #ffe08a;
  --cyan: #5fe0e8;
  --cyan-deep: #2fb6c2;
  --cream: #f6ead9;
  --red: #ff5c5c;
  --glass-bg: rgba(44, 23, 18, 0.78);
  --glass-border: rgba(230, 164, 40, 0.55);
  --radius: 22px;
  --shadow-card: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 206, 84, 0.12);
  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-body: 'Outfit', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--cream);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body.swap-page { overflow: auto; }

/* ---------- Rock tile background ---------- */
.cave-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--bg-deep);
  background-image:
    linear-gradient(180deg, rgba(21, 9, 7, 0.35), rgba(21, 9, 7, 0.55)),
    repeating-linear-gradient(
      0deg,
      #5c342c 0px, #5c342c 28px,
      #4a2a22 28px, #4a2a22 30px,
      #7a4a40 30px, #7a4a40 56px,
      #3d2018 56px, #3d2018 58px,
      #2c1712 58px, #2c1712 84px,
      #a06a5c 84px, #a06a5c 86px
    ),
    repeating-linear-gradient(
      90deg,
      #5c342c 0px, #5c342c 34px,
      #3a1e18 34px, #3a1e18 36px,
      #7a4a40 36px, #7a4a40 68px,
      #2c1712 68px, #2c1712 70px,
      #6b4036 70px, #6b4036 102px
    );
  background-size: auto, 100% 120px, 140px 100%;
  background-blend-mode: multiply, normal, soft-light;
}

.cave-bg::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -10%;
  transform: translateX(-50%);
  width: min(52vw, 420px);
  height: 120%;
  background:
    radial-gradient(ellipse 70% 40% at 50% 20%, rgba(21, 9, 7, 0.2), transparent 70%),
    linear-gradient(90deg,
      transparent 0%,
      rgba(21, 9, 7, 0.92) 18%,
      #0d0504 50%,
      rgba(21, 9, 7, 0.92) 82%,
      transparent 100%
    );
  border-radius: 45% 45% 40% 40% / 8% 8% 12% 12%;
  filter: blur(1px);
  pointer-events: none;
  opacity: 0.95;
}

/* ---------- Top nav ---------- */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(21, 9, 7, 0.85), transparent);
  pointer-events: none;
}
.top-nav > * { pointer-events: auto; }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.brand span { color: var(--cream); }

.nav-links {
  display: flex;
  gap: 8px;
}
.nav-links a {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  color: var(--cream);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(230, 164, 40, 0.35);
  background: rgba(44, 23, 18, 0.55);
  backdrop-filter: blur(8px);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nav-links a:hover,
.nav-links a.active {
  background: linear-gradient(180deg, var(--gold-light), var(--gold-deep));
  color: #1a0e0c;
  border-color: transparent;
}

/* ---------- Glass card ---------- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.12s, filter 0.12s, box-shadow 0.12s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.06); }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 40%, var(--gold-deep) 100%);
  color: #1a0e0c;
  box-shadow: 0 6px 20px rgba(230, 164, 40, 0.35), inset 0 1px 0 rgba(255,255,255,0.35);
}
.btn-cyan {
  background: linear-gradient(180deg, var(--cyan) 0%, var(--cyan-deep) 100%);
  color: #0a1a1c;
  box-shadow: 0 6px 20px rgba(47, 182, 194, 0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-ghost {
  background: rgba(44, 23, 18, 0.45);
  color: var(--cream);
  border: 1.5px solid rgba(230, 164, 40, 0.5);
  box-shadow: none;
}
.btn-ghost:hover { background: rgba(92, 52, 44, 0.5); }

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  flex-shrink: 0;
}
.btn-round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  border: 2px solid var(--red);
  background: rgba(44, 23, 18, 0.7);
  color: var(--red);
  font-size: 18px;
}

.btn-sm {
  padding: 10px 16px;
  font-size: 14px;
  border-radius: 12px;
  width: auto;
}

/* ---------- Screens / overlays ---------- */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 16px 24px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}
.screen.active {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.menu-card {
  width: min(360px, 92vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.logo-title {
  line-height: 0.95;
  margin-bottom: 4px;
}
.logo-title .miner {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(36px, 10vw, 48px);
  color: var(--cream);
  letter-spacing: 0.06em;
  text-shadow: 0 3px 12px rgba(0,0,0,0.5);
}
.logo-title .rush {
  display: block;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(42px, 12vw, 56px);
  color: var(--gold);
  letter-spacing: 0.04em;
  text-shadow: 0 0 24px rgba(255, 206, 84, 0.35), 0 4px 14px rgba(0,0,0,0.5);
}
.tagline {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(246, 234, 217, 0.75);
  margin-bottom: 8px;
}

.stats-row {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
  margin-bottom: 6px;
}
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(21, 9, 7, 0.55);
  border: 1px solid rgba(230, 164, 40, 0.25);
  font-size: 14px;
  font-weight: 600;
}
.stat-pill .label { color: rgba(246, 234, 217, 0.7); font-weight: 500; font-size: 13px; }
.stat-pill .value { color: var(--gold); font-family: var(--font-display); font-weight: 700; font-size: 14px; }

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.mute-fab {
  position: fixed;
  top: 56px;
  left: 14px;
  z-index: 40;
}

/* How To Play */
.howto-card {
  width: min(420px, 94vw);
  max-height: min(90vh, 640px);
  overflow-y: auto;
  text-align: left;
}
.howto-card h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 18px;
}
.howto-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.howto-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.howto-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(21, 9, 7, 0.45);
  border-radius: 10px;
  border: 1px solid rgba(230, 164, 40, 0.2);
}
.howto-list h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 3px;
}
.howto-list p {
  font-size: 13px;
  line-height: 1.45;
  color: rgba(246, 234, 217, 0.88);
}

/* Pause / Cave-In */
.pause-card, .cavein-card {
  width: min(340px, 90vw);
  text-align: center;
}
.pause-card h2, .cavein-card h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 28px;
  color: var(--cream);
  margin-bottom: 18px;
}
.cavein-card h2 { color: var(--cream); }
.pause-actions, .cavein-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.result-stat {
  background: rgba(21, 9, 7, 0.5);
  border-radius: 14px;
  padding: 14px 10px;
  border: 1px solid rgba(230, 164, 40, 0.18);
}
.result-stat .num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  color: var(--gold);
  line-height: 1.1;
}
.result-stat .lbl {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(246, 234, 217, 0.65);
  margin-top: 4px;
  text-transform: uppercase;
}

/* ---------- Game canvas layer ---------- */
#game-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
#game-canvas:active { cursor: grabbing; }

/* HUD */
.hud {
  position: absolute;
  top: 52px;
  left: 0; right: 0;
  z-index: 5;
  display: none;
  padding: 0 14px;
  pointer-events: none;
}
.hud.visible { display: flex; justify-content: space-between; align-items: flex-start; }
.hud > * { pointer-events: auto; }

.hud-left { display: flex; gap: 8px; }
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.hud-depth {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.hud-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}
.hud-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.hud-stat.gems { color: var(--cyan); }
.hearts {
  display: flex;
  gap: 4px;
  font-size: 18px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
.hearts .empty { opacity: 0.25; filter: grayscale(1); }

.powerup-badges {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
  background: rgba(21,9,7,0.65);
  border: 1px solid rgba(95,224,232,0.4);
  color: var(--cyan);
  font-weight: 600;
}
.badge.shield { border-color: rgba(168, 85, 247, 0.5); color: #c084fc; }
.badge.magnet { border-color: rgba(255, 206, 84, 0.5); color: var(--gold); }

/* Loading */
.loading-card {
  text-align: center;
  padding: 40px;
}
.loading-card .spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 3px solid rgba(230,164,40,0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Demo banner */
.demo-banner {
  background: linear-gradient(90deg, rgba(255,92,92,0.2), rgba(230,164,40,0.25), rgba(255,92,92,0.2));
  border-bottom: 1px solid rgba(255, 92, 92, 0.4);
  color: var(--cream);
  text-align: center;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  position: relative;
  z-index: 60;
}
.demo-banner strong { color: var(--gold); }

/* ---------- Swap page ---------- */
.swap-layout {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 72px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.swap-card {
  width: min(440px, 96vw);
}

.swap-card h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 6px;
}
.swap-sub {
  text-align: center;
  font-size: 13px;
  color: rgba(246,234,217,0.65);
  margin-bottom: 20px;
}

.token-row {
  background: rgba(21, 9, 7, 0.55);
  border: 1px solid rgba(230, 164, 40, 0.22);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.token-row-label {
  font-size: 12px;
  color: rgba(246,234,217,0.55);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.token-row-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.token-row input[type="number"] {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--cream);
  -moz-appearance: textfield;
}
.token-row input::-webkit-outer-spin-button,
.token-row input::-webkit-inner-spin-button { -webkit-appearance: none; }

.token-select {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(92, 52, 44, 0.55);
  border: 1px solid rgba(230, 164, 40, 0.35);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--cream);
  position: relative;
}
.token-select select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.token-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  font-family: var(--font-display);
}
.token-icon.sol { background: linear-gradient(135deg, #9945FF, #14F195); color: #fff; font-size: 11px; }
.token-icon.doge { background: linear-gradient(135deg, #c2a633, #f0d060); color: #1a0e0c; font-size: 12px; }
.token-icon.gold { background: linear-gradient(135deg, var(--gold-deep), var(--gold-light)); color: #1a0e0c; font-size: 12px; }
.token-icon.usdc { background: linear-gradient(135deg, #2775ca, #5b9fef); color: #fff; font-size: 10px; }

.swap-arrow {
  display: flex;
  justify-content: center;
  margin: -4px 0;
  position: relative;
  z-index: 2;
}
.swap-arrow button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid rgba(230,164,40,0.45);
  background: var(--bg-mid);
  color: var(--gold);
  font-size: 18px;
  cursor: pointer;
}
.swap-arrow button:hover { background: var(--rock-1); }

.swap-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 18px;
  font-size: 13px;
  color: rgba(246,234,217,0.7);
}
.swap-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.swap-meta-row strong { color: var(--gold); font-weight: 600; }

.slippage-ctrl {
  display: flex;
  gap: 6px;
  align-items: center;
}
.slippage-ctrl button {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(230,164,40,0.3);
  background: rgba(21,9,7,0.4);
  color: var(--cream);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.slippage-ctrl button.active {
  background: linear-gradient(180deg, var(--gold-light), var(--gold-deep));
  color: #1a0e0c;
  border-color: transparent;
}

.wallet-status {
  text-align: center;
  font-size: 12px;
  color: rgba(246,234,217,0.5);
  margin-top: 12px;
}
.wallet-status.connected { color: var(--cyan); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 4, 3, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s;
}
.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}
.modal-card {
  width: min(360px, 94vw);
  text-align: center;
}
.modal-card h3 {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 10px;
}
.modal-card p {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(246,234,217,0.85);
  margin-bottom: 18px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  z-index: 200;
  background: rgba(44, 23, 18, 0.95);
  border: 1.5px solid var(--cyan);
  border-radius: 14px;
  padding: 14px 20px;
  max-width: min(400px, 92vw);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast .toast-title {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--cyan);
  margin-bottom: 4px;
}
.toast .toast-body {
  font-size: 12px;
  color: var(--cream);
  word-break: break-all;
}
.toast .demo-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--red);
  border: 1px solid var(--red);
  padding: 2px 8px;
  border-radius: 6px;
}

/* Recent trades */
.trades-card {
  width: min(440px, 96vw);
}
.trades-card h2 {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 12px;
  letter-spacing: 0.06em;
}
.trade-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trade-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(21,9,7,0.45);
  border-radius: 10px;
  border: 1px solid rgba(230,164,40,0.12);
  font-size: 13px;
}
.trade-list .pair { color: var(--cream); font-weight: 600; }
.trade-list .amt { color: var(--gold); font-family: var(--font-display); font-size: 12px; }
.trade-list .time { color: rgba(246,234,217,0.4); font-size: 11px; }

.footer-note {
  font-size: 11px;
  color: rgba(246,234,217,0.4);
  text-align: center;
  max-width: 400px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .logo-title .miner { font-size: 34px; }
  .logo-title .rush { font-size: 40px; }
  .howto-card { padding: 20px 16px; }
}
