/* ============================================================
   BaghChal.games — Himalayan Heritage Theme
   Slate Greys · Deep Browns · Aged Gold · Stone-Carved Board
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;700;800;900&family=Libre+Baskerville:wght@400;700&family=Noto+Sans+Devanagari:wght@400;600;700;800&display=swap');

:root {
  --bg: #111318;
  --bg2: #181b22;
  --bg3: #1f232e;
  --bg4: #282d3a;
  --bg-hover: #323848;
  --board-surface: #1a1e28;
  --line: #546080;
  --line2: #445068;
  --line-glow: rgba(84, 96, 128, 0.15);
  --dot: #3e4860;
  --dot2: #5a6888;
  --tiger: #e8a030;
  --tiger2: #c88420;
  --tiger3: #ffc848;
  --tiger-glow: rgba(232, 160, 48, 0.35);
  --goat: #48b870;
  --goat2: #38a058;
  --goat3: #60d888;
  --goat-glow: rgba(72, 184, 112, 0.3);
  --gold: #c8a44c;
  --gold2: #a88838;
  --gold3: #dcc068;
  --gold-glow: rgba(200, 164, 76, 0.2);
  --red: #d84040;
  --red-glow: rgba(216, 64, 64, 0.25);
  --text: #dcd8cc;
  --text2: #a0a0a8;
  --text3: #686878;
  --text4: #484858;
  --card: rgba(31, 35, 46, 0.9);
  --card2: rgba(40, 45, 58, 0.92);
  --border: rgba(72, 80, 108, 0.2);
  --border2: rgba(72, 80, 108, 0.35);
  --shadow: rgba(0, 0, 0, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Libre Baskerville', Georgia, serif;
  min-height: 100dvh;
  overflow-x: hidden;
  /* Subtle noise texture */
  background-image: radial-gradient(ellipse at 50% 0%, rgba(200, 164, 76, 0.03), transparent 60%);
}

/* ===== WELCOME SCREEN ===== */
#welcome {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 35%, rgba(200, 164, 76, 0.04), transparent 65%);
  transition: opacity 1s, visibility 1s;
}
#welcome.gone { opacity: 0; visibility: hidden; pointer-events: none; }

/* Animated seal with chase animation inside */
.w-seal { width: 180px; height: 180px; position: relative; margin-bottom: 28px; animation: sealIn 1s ease backwards 0.2s; }
.w-seal-ring { position: absolute; inset: 0; border: 2px solid var(--gold2); border-radius: 50%; animation: spin 20s linear infinite; opacity: 0.45; }
.w-seal-ring2 { position: absolute; inset: 14px; border: 1.5px solid var(--text4); border-radius: 50%; animation: spin 28s linear infinite reverse; opacity: 0.25; }
.w-seal-inner {
  position: absolute; inset: 30px;
  background: linear-gradient(145deg, #252a38, #1a1e28);
  border: 1.5px solid var(--gold2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 28px var(--shadow);
  overflow: hidden;
}

/* Tiger chasing goat animation inside the seal */
.chase-scene {
  position: relative; width: 100%; height: 100%;
}
.chase-track {
  position: absolute; inset: 0;
  animation: spin 4s linear infinite;
}
.chase-tiger, .chase-goat {
  position: absolute; font-size: 22px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}
.chase-tiger { top: 12%; left: 50%; transform: translateX(-50%) scaleX(-1); }
.chase-goat { bottom: 12%; left: 50%; transform: translateX(-50%); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sealIn { from { opacity: 0; transform: scale(0.55) rotate(-25deg); } }

.w-np { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 3.4rem; font-weight: 800; color: var(--gold); text-shadow: 0 0 35px var(--gold-glow); animation: wf 0.7s ease backwards 0.6s; }
.w-en { font-family: 'Playfair Display', serif; font-size: 2rem; font-weight: 800; color: var(--text); letter-spacing: 0.1em; animation: wf 0.7s ease backwards 0.85s; }
.w-en b { color: var(--gold); }
.w-line { width: 130px; height: 2px; margin: 16px 0; background: linear-gradient(90deg, transparent, var(--gold2), transparent); animation: wf 0.7s ease backwards 1s; }
.w-sub { font-size: 1.08rem; color: var(--text2); animation: wf 0.7s ease backwards 1.1s; text-align: center; padding: 0 24px; }
.w-sub2 { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 0.92rem; color: var(--text3); margin-top: 4px; animation: wf 0.7s ease backwards 1.2s; }

.w-btn {
  margin-top: 36px; padding: 16px 56px;
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  border: none; border-radius: 50px;
  color: var(--bg); font-family: 'Playfair Display', serif;
  font-size: 1.25rem; font-weight: 800; letter-spacing: 0.06em;
  cursor: pointer; transition: all 0.3s;
  animation: wf 0.7s ease backwards 1.5s;
  box-shadow: 0 4px 28px var(--gold-glow);
}
.w-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 40px rgba(200, 164, 76, 0.35); }

@keyframes wf { from { opacity: 0; transform: translateY(14px); } }

/* ===== NAVIGATION ===== */
.topline { width: 100%; height: 3px; background: linear-gradient(90deg, var(--bg), var(--tiger), var(--gold), var(--goat), var(--bg)); }

.nav {
  width: 100%; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(24, 27, 34, 0.95);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
}
.nav-logo { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.nav-seal {
  width: 38px; height: 38px;
  background: linear-gradient(145deg, var(--bg3), var(--bg4));
  border: 1.5px solid var(--gold2); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px var(--shadow);
}
.nav-seal span { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 13px; font-weight: 800; color: var(--gold); }
.nav-brand { font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 800; color: var(--text); }
.nav-brand b { color: var(--gold); }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px; color: var(--text2); font-size: 0.92rem; font-weight: 700;
  border-radius: 22px; cursor: pointer; border: 1.5px solid transparent;
  background: none; font-family: 'Libre Baskerville', serif; transition: all 0.2s;
}
.nav-link:hover, .nav-link.on { color: var(--gold); border-color: var(--border2); background: var(--bg3); }

/* ===== PAGES ===== */
.page { display: none; width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.page.on { display: block; }

/* ===== TIP CARDS (replacing ads) ===== */
.tip-card {
  background: linear-gradient(135deg, var(--bg3), var(--bg4));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex; align-items: flex-start; gap: 12px;
  min-height: 60px;
  transition: opacity 0.5s ease;
}
.tip-card.tip-fade { animation: tipIn 0.5s ease; }
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.tip-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }
.tip-cat {
  font-family: 'Playfair Display', serif;
  font-size: 0.65rem; font-weight: 700;
  color: var(--gold); text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 2px;
}
.tip-text { font-size: 0.85rem; color: var(--text2); line-height: 1.6; }

.tip-wide { max-width: 660px; width: 100%; margin: 10px auto; }
.tip-side { width: 160px; min-height: 200px; flex-shrink: 0; flex-direction: column; }
.tip-bottom { max-width: 320px; width: 100%; margin: 10px auto; }
.tip-rect { max-width: 300px; width: 100%; margin: 12px auto; min-height: 120px; }

@media (max-width: 960px) { .tip-side { display: none; } }

/* ===== GAME LAYOUT ===== */
.game-pg { display: flex; flex-direction: column; align-items: center; padding-bottom: 36px; }
.game-main { display: flex; gap: 16px; width: 100%; justify-content: center; align-items: flex-start; margin: 10px 0; }
.game-center { display: flex; flex-direction: column; align-items: center; flex: 1; max-width: 700px; min-width: 0; }

/* Turn banner with animated glow */
.turn-banner {
  width: 100%; max-width: 680px; padding: 14px 24px;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-bottom: 10px; transition: all 0.5s; position: relative; overflow: hidden;
}
.turn-banner.tiger-turn { background: rgba(232, 160, 48, 0.06); border: 1.5px solid rgba(232, 160, 48, 0.18); }
.turn-banner.goat-turn { background: rgba(72, 184, 112, 0.05); border: 1.5px solid rgba(72, 184, 112, 0.14); }
.turn-glow { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity 0.5s; }
.tiger-turn .turn-glow { opacity: 1; background: radial-gradient(ellipse at center, rgba(232, 160, 48, 0.05), transparent 70%); animation: tglow 2.5s ease infinite; }
.goat-turn .turn-glow { opacity: 1; background: radial-gradient(ellipse at center, rgba(72, 184, 112, 0.04), transparent 70%); animation: tglow 2.5s ease infinite; }
@keyframes tglow { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.turn-icon { font-size: 32px; position: relative; z-index: 1; }
.turn-info { position: relative; z-index: 1; text-align: center; }
.turn-label { font-family: 'Playfair Display', serif; font-size: 1.2rem; font-weight: 800; }
.turn-label.tl-tiger { color: var(--tiger); }
.turn-label.tl-goat { color: var(--goat); }
.turn-sub { font-size: 0.88rem; color: var(--text3); }

/* Side panels */
.side-panel { width: 76px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 40px; }
.sp-title { font-family: 'Playfair Display', serif; font-size: 0.65rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; writing-mode: vertical-rl; transform: rotate(180deg); margin-bottom: 4px; }
.captured-goats { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.captured-goat {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg4); border: 1px solid var(--border);
  opacity: 0.2; transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.captured-goat.taken {
  opacity: 1;
  background: linear-gradient(145deg, #3a2828, #2a1c1c);
  border-color: var(--red);
  box-shadow: 0 2px 10px var(--red-glow);
  animation: goatTaken 0.5s ease;
}
.captured-goat.taken::after {
  content: '✕'; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; font-size: 15px; color: var(--red); font-weight: 700;
}
@keyframes goatTaken { from { transform: scale(0) rotate(-180deg); } to { transform: scale(1) rotate(0); } }

.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px; text-align: center; width: 68px; }
.stat-label { font-size: 0.56rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.stat-val { font-family: 'Playfair Display', serif; font-size: 1.4rem; font-weight: 800; color: var(--text); }

@media (max-width: 680px) {
  .side-panel { width: 50px; padding-top: 10px; }
  .captured-goat { width: 26px; height: 26px; }
  .captured-goat.taken::after { font-size: 11px; }
  .stat-box { width: 48px; padding: 5px; }
  .stat-val { font-size: 1.05rem; }
  .sp-title { font-size: 0.55rem; }
}

/* Board — Stone-carved appearance */
.board-wrap { position: relative; width: 100%; max-width: 680px; aspect-ratio: 1; }
.board-frame {
  position: absolute; inset: -10px; border-radius: 18px; z-index: 0;
  background: linear-gradient(145deg, #222838, #1a1e28, #161a22, #1e2230);
  border: 2.5px solid rgba(100, 110, 140, 0.2);
  box-shadow:
    0 10px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.02),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}
/* Stone texture overlay */
.board-frame::before {
  content: ''; position: absolute; inset: 0; border-radius: 16px; opacity: 0.05;
  background:
    repeating-linear-gradient(95deg, transparent, transparent 22px, rgba(100, 110, 140, 0.2) 22px, rgba(100, 110, 140, 0.2) 24px),
    repeating-linear-gradient(5deg, transparent, transparent 35px, rgba(80, 90, 110, 0.15) 35px, rgba(80, 90, 110, 0.15) 37px);
}
/* Carved inner border */
.board-frame::after {
  content: ''; position: absolute; inset: 9px;
  border: 1px solid rgba(200, 164, 76, 0.06);
  border-radius: 12px;
}

canvas#cv { position: relative; z-index: 1; width: 100%; height: 100%; cursor: pointer; touch-action: none; }

/* Win overlay */
.gmsg {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.85);
  background: rgba(17, 19, 24, 0.97);
  border: 2px solid var(--gold);
  border-radius: 18px; padding: 36px 48px; text-align: center;
  z-index: 10; opacity: 0; pointer-events: none;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 14px 60px rgba(0, 0, 0, 0.6), 0 0 35px var(--gold-glow);
}
.gmsg.show { opacity: 1; transform: translate(-50%, -50%) scale(1); pointer-events: all; }
.gmsg h2 { font-family: 'Playfair Display', serif; font-size: 1.8rem; font-weight: 900; }
.gmsg p { color: var(--text2); font-size: 1.05rem; margin: 8px 0 24px; }

/* Controls */
.ctrls { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; justify-content: center; }
.bt {
  font-family: 'Playfair Display', serif; font-weight: 700; font-size: 0.92rem;
  letter-spacing: 0.03em; padding: 10px 26px; border: 1.5px solid var(--border2);
  border-radius: 25px; cursor: pointer; transition: all 0.25s;
  background: var(--bg3); color: var(--text2);
}
.bt:hover { border-color: var(--gold2); color: var(--gold); box-shadow: 0 3px 14px var(--gold-glow); transform: translateY(-1px); }
.bt-p { background: linear-gradient(135deg, var(--gold2), var(--gold)); border-color: transparent; color: var(--bg); }
.bt-p:hover { box-shadow: 0 4px 22px var(--gold-glow); }

/* Goat tray */
.goat-tray { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; max-width: 360px; margin: 8px 0; }
.goat-tray-dot {
  width: 17px; height: 17px; border-radius: 50%;
  background: linear-gradient(145deg, var(--goat3), var(--goat2));
  border: 1px solid rgba(72, 184, 112, 0.2);
  transition: all 0.3s; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.goat-tray-dot.placed { opacity: 0.12; transform: scale(0.6); }
.goat-rem-label { font-size: 0.8rem; color: var(--text3); text-align: center; width: 100%; margin-bottom: 3px; font-weight: 700; }

/* ===== MODAL ===== */
.mo { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(8px); z-index: 100; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.mo.show { opacity: 1; pointer-events: all; }
.mo-box { background: var(--bg3); border: 1.5px solid var(--border2); border-radius: 18px; padding: 30px; max-width: 420px; width: 92%; transform: translateY(20px); transition: transform 0.3s; box-shadow: 0 14px 55px rgba(0, 0, 0, 0.5); }
.mo.show .mo-box { transform: translateY(0); }
.mo-box h2 { font-family: 'Playfair Display', serif; font-size: 1.5rem; text-align: center; margin-bottom: 22px; color: var(--gold); }

.mb { width: 100%; padding: 15px 16px; background: var(--bg2); border: 1.5px solid var(--border); border-radius: 14px; color: var(--text); font-family: 'Libre Baskerville', serif; font-size: 0.98rem; cursor: pointer; margin-bottom: 8px; text-align: left; transition: all 0.2s; display: flex; align-items: center; gap: 14px; }
.mb:hover { border-color: var(--gold2); background: var(--bg4); box-shadow: 0 3px 16px var(--gold-glow); }
.mb-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: var(--bg); border: 1px solid var(--border); flex-shrink: 0; }
.mb-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.02rem; color: var(--text); }
.mb-desc { font-size: 0.8rem; color: var(--text3); }
.mb-off { opacity: 0.28; cursor: default; }

.ai-levels { display: flex; gap: 8px; margin-top: 16px; }
.ai-lvl { flex: 1; padding: 16px 8px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg2); color: var(--text); font-family: 'Libre Baskerville', serif; cursor: pointer; text-align: center; transition: all 0.25s; }
.ai-lvl:hover { border-color: var(--gold2); box-shadow: 0 3px 16px var(--gold-glow); transform: translateY(-2px); }
.ai-lvl-icon { font-size: 26px; display: block; margin-bottom: 5px; }
.ai-lvl-name { font-family: 'Playfair Display', serif; font-weight: 800; font-size: 0.98rem; color: var(--text); display: block; }
.ai-lvl-desc { font-size: 0.7rem; color: var(--text3); display: block; margin-top: 2px; }

.side-pick { display: flex; gap: 10px; margin-top: 16px; }
.sb { flex: 1; padding: 16px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--bg2); color: var(--text); font-family: 'Libre Baskerville', serif; cursor: pointer; text-align: center; transition: all 0.25s; }
.sb:hover { border-color: var(--gold2); box-shadow: 0 3px 16px var(--gold-glow); transform: translateY(-2px); }
.sb-icon { font-size: 32px; display: block; margin-bottom: 5px; }
.sb-label { font-family: 'Playfair Display', serif; font-weight: 800; font-size: 1.02rem; }

/* ===== CONTENT PAGES ===== */
.guide-pg { padding: 28px 16px 60px; }
.gh { text-align: center; margin-bottom: 36px; }
.gh h1 { font-family: 'Playfair Display', serif; font-size: 2.5rem; font-weight: 900; color: var(--gold); }
.gh .np { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 1.15rem; color: var(--text2); font-weight: 600; }
.gh p { color: var(--text2); margin-top: 8px; font-size: 1.08rem; }
.gs { background: var(--card); border: 1.5px solid var(--border); border-radius: 16px; padding: 28px; margin-bottom: 18px; }
.gs h2 { font-family: 'Playfair Display', serif; font-size: 1.45rem; font-weight: 800; color: var(--gold); margin-bottom: 14px; }
.gs p, .gs li { font-size: 1.02rem; color: var(--text2); line-height: 1.9; }
.gs ul { padding-left: 20px; margin: 8px 0; }
.gs li { margin-bottom: 6px; }
.gg { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.gc { background: var(--bg2); border: 1.5px solid var(--border); border-radius: 14px; padding: 20px; text-align: center; }
.gc-i { font-size: 38px; margin-bottom: 8px; }
.gc h3 { font-family: 'Playfair Display', serif; font-size: 1.12rem; color: var(--text); margin-bottom: 5px; }
.gc p { font-size: 0.9rem; color: var(--text2); line-height: 1.6; }
.ht { color: var(--tiger); font-weight: 700; }
.hgt { color: var(--goat); font-weight: 700; }
.hgl { color: var(--gold); }
@media (max-width: 600px) { .gg { grid-template-columns: 1fr; } }

.priv-pg { padding: 28px 16px 60px; }
.priv-pg h1 { font-family: 'Playfair Display', serif; font-size: 2.5rem; font-weight: 900; color: var(--gold); text-align: center; margin-bottom: 4px; }
.priv-pg .lu { text-align: center; color: var(--text3); font-size: 0.9rem; margin-bottom: 28px; }
.ps { background: var(--card); border: 1.5px solid var(--border); border-radius: 16px; padding: 28px; margin-bottom: 16px; }
.ps h2 { font-family: 'Playfair Display', serif; font-size: 1.22rem; font-weight: 800; color: var(--text); margin-bottom: 10px; }
.ps p { font-size: 0.98rem; color: var(--text2); line-height: 1.85; margin-bottom: 6px; }
.ps ul { padding-left: 18px; margin: 6px 0; }
.ps li { font-size: 0.98rem; color: var(--text2); line-height: 1.75; margin-bottom: 4px; }

/* ===== FOOTER ===== */
.ft { width: 100%; border-top: 1px solid var(--border); background: var(--bg2); padding: 28px 16px; text-align: center; }
.ft-d { color: var(--gold2); font-size: 1rem; margin-bottom: 8px; letter-spacing: 0.5em; }
.ft-b { font-family: 'Noto Sans Devanagari', sans-serif; font-size: 1.2rem; color: var(--gold); font-weight: 800; }
.ft-be { font-family: 'Playfair Display', serif; font-size: 0.95rem; color: var(--text2); }
.ft-be b { color: var(--gold); }
.ft-links { margin: 10px 0; display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.ft-l { color: var(--text2); font-size: 0.9rem; cursor: pointer; transition: color 0.2s; font-weight: 700; }
.ft-l:hover { color: var(--gold); }
.ft-c { font-size: 0.74rem; color: var(--text3); margin-top: 10px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 420px) {
  .w-np { font-size: 2.5rem; }
  .w-en { font-size: 1.4rem; }
  .nav-brand { font-size: 1rem; }
  .nav-link { padding: 6px 10px; font-size: 0.84rem; }
  .turn-label { font-size: 1.02rem; }
  .board-frame { inset: -6px; }
}
@media (min-width: 1024px) {
  .board-wrap { max-width: 720px; }
}
