/* ═══════════════════════════════════════════════════════════════════════════
   $CAPIT — Universal Game Shell
   Include on every game page: <link rel="stylesheet" href="capit_game_shell.css">
   This file owns layout, nav, HUD, modals, buttons, and responsive rules.
   Game-specific styles go inline or in a <style> block after this link.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --gold:    #FFD700;
  --gold2:   #ff8c00;
  --cyan:    #00e5ff;
  --purple:  #a855f7;
  --pink:    #ff2d78;
  --green:   #00ff88;
  --red:     #ff4466;
  --bg:      #030610;
  --bg2:     #06091a;
  --bg3:     #0a0f26;
  --card:    rgba(255,255,255,0.03);
  --border:  rgba(255,255,255,0.08);
  --font:    'Outfit', sans-serif;
  --mono:    'Space Grotesk', monospace;
  --radius:  16px;
  --shadow:  0 8px 40px rgba(0,0,0,.5);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: #fff;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }

/* ── Ambient background ─────────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(168,85,247,.1), transparent 55%),
    radial-gradient(ellipse at 90% 90%, rgba(0,229,255,.06), transparent 45%),
    radial-gradient(ellipse at 10% 80%, rgba(255,45,120,.06), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* ── Game Nav ───────────────────────────────────────────────────────────── */
.game-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: rgba(3,6,16,.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.game-nav-left  { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.game-nav-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.game-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,.45);
  font-size: 13px;
  font-weight: 600;
  transition: color .2s;
  white-space: nowrap;
}
.game-back-btn:hover { color: var(--gold); }
.game-back-btn::before { content: '←'; font-size: 16px; }

.game-nav-title {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* Wallet button in nav */
.game-wallet-btn {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: all .2s;
  white-space: nowrap;
  min-height: 36px;
}
.game-wallet-btn:hover { transform: translateY(-1px); box-shadow: 0 0 16px rgba(168,85,247,.5); }
.game-wallet-btn.connected { background: linear-gradient(135deg, var(--green), #00b860); color: #000; }

/* ── Game Page Wrapper ──────────────────────────────────────────────────── */
.game-page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
  min-height: calc(100vh - 56px);
}

/* ── Game Title Block ───────────────────────────────────────────────────── */
.game-title-block { text-align: center; margin-bottom: 20px; }
.game-title {
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  margin-bottom: 6px;
}
.game-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,.4);
}

/* ── HUD Bar ────────────────────────────────────────────────────────────── */
.game-hud {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 600px;
}
.hud-box {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  text-align: center;
  flex: 1;
  min-width: 80px;
}
.hud-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}
.hud-lbl {
  font-size: 10px;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 4px;
}
.hud-capit .hud-val { color: var(--green); }

/* ── Game Container ─────────────────────────────────────────────────────── */
.game-container {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}
/* Canvas games — make canvas fill container and scale responsively */
.game-container canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: none;
}

/* ── Status Line ────────────────────────────────────────────────────────── */
.game-status {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  min-height: 26px;
  margin: 12px 0;
  transition: color .3s;
}
.game-status.ok    { color: var(--green); }
.game-status.warn  { color: var(--gold); }
.game-status.error { color: var(--red); }

/* ── Action Buttons ─────────────────────────────────────────────────────── */
.game-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 14px;
  width: 100%;
  max-width: 600px;
}
.btn {
  padding: 12px 26px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: var(--font);
  letter-spacing: .2px;
  min-height: 44px; /* touch-friendly */
}
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none !important; }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #000;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 0 24px rgba(255,215,0,.4); }
.btn-secondary {
  background: transparent;
  color: #fff;
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--purple); color: var(--purple); background: rgba(168,85,247,.06); }
.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(255,68,102,.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(255,68,102,.1); }
.btn-success {
  background: linear-gradient(135deg, var(--green), #00b860);
  color: #000;
}
.btn-success:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 0 20px rgba(0,255,136,.3); }

/* ── Chip Row (for betting games) ───────────────────────────────────────── */
.chip-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 10px 0;
}
.chip {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 3px dashed;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  line-height: 1.1;
  user-select: none;
}
.chip:hover { transform: scale(1.15) rotate(5deg); }
.chip-5   { background: rgba(255,68,102,.15); border-color: var(--red);    color: var(--red); }
.chip-25  { background: rgba(0,229,255,.15);  border-color: var(--cyan);   color: var(--cyan); }
.chip-100 { background: rgba(255,215,0,.15);  border-color: var(--gold);   color: var(--gold); }
.chip-500 { background: rgba(168,85,247,.15); border-color: var(--purple); color: var(--purple); }

/* ── Win / Loss Modal ───────────────────────────────────────────────────── */
.game-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3,6,16,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.game-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.game-modal {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 0 80px rgba(168,85,247,.2);
  transform: translateY(20px);
  transition: transform .3s;
}
.game-modal-overlay.visible .game-modal { transform: translateY(0); }

.game-modal-icon   { font-size: 64px; margin-bottom: 16px; display: block; }
.game-modal-title  { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.game-modal-reward {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 900;
  color: var(--green);
  margin: 12px 0 24px;
  text-shadow: 0 0 24px rgba(0,255,136,.4);
}
.game-modal-reward.loss { color: var(--red); text-shadow: 0 0 24px rgba(255,68,102,.3); }
.game-modal-sub { font-size: 13px; color: rgba(255,255,255,.45); margin-bottom: 24px; line-height: 1.6; }
.game-modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Win — gold glow border */
.game-modal.win  { border-color: rgba(255,215,0,.3); box-shadow: 0 0 80px rgba(255,215,0,.15); }
.game-modal.loss { border-color: rgba(255,68,102,.2); }

/* ── Earn Toast ─────────────────────────────────────────────────────────── */
@keyframes earn-pop {
  0%   { opacity: 0; transform: translateY(10px) scale(.8); }
  15%  { opacity: 1; transform: translateY(0) scale(1.05); }
  80%  { opacity: 1; transform: translateY(-16px) scale(1); }
  100% { opacity: 0; transform: translateY(-28px) scale(.95); }
}
.earn-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,255,136,.12);
  border: 1px solid rgba(0,255,136,.4);
  border-radius: 50px;
  padding: 10px 24px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--green);
  pointer-events: none;
  z-index: 9500;
  white-space: nowrap;
  animation: earn-pop 2.2s ease forwards;
}

/* ── Difficulty Badge ───────────────────────────────────────────────────── */
.difficulty-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.diff-btn {
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: rgba(255,255,255,.45);
  font-family: var(--font);
  transition: all .2s;
}
.diff-btn.active, .diff-btn:hover { border-color: var(--purple); color: var(--purple); background: rgba(168,85,247,.08); }
.diff-btn.active { background: rgba(168,85,247,.15); }

/* ── Earn Info Strip ────────────────────────────────────────────────────── */
.earn-strip {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255,255,255,.25);
  text-align: center;
  margin-top: 10px;
  letter-spacing: .5px;
}
.earn-strip span { color: var(--gold); }

/* ── Mobile D-Pad ───────────────────────────────────────────────────────── */
.dpad {
  display: none;
  position: relative;
  width: 132px;
  height: 132px;
  margin: 16px auto 0;
  user-select: none;
}
.dpad-btn {
  position: absolute;
  width: 44px; height: 44px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.dpad-btn:active { background: rgba(168,85,247,.25); }
.dpad-up    { top: 0;   left: 44px; }
.dpad-down  { bottom:0; left: 44px; }
.dpad-left  { top: 44px; left: 0; }
.dpad-right { top: 44px; right: 0; }
.dpad-center{ top: 44px; left: 44px; background: rgba(168,85,247,.12); border-radius: 50%; font-size: 14px; }
@media (max-width: 600px) { .dpad { display: flex; } }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .game-page       { padding: 16px 12px 40px; }
  .game-container  { border-radius: 14px; }
  .game-hud        { gap: 8px; }
  .hud-box         { padding: 8px 12px; min-width: 70px; }
  .hud-val         { font-size: 18px; }
  .btn             { padding: 11px 18px; font-size: 13px; }
  .game-modal      { padding: 32px 20px; }
  .game-modal-icon { font-size: 48px; }
  .game-modal-reward { font-size: 26px; }
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,.3); border-radius: 3px; }
