:root{
  --bg:#f5f5f4;
  --ground:#cfcfcf;
  --accent:#1f2937;
}
html,body{
  height:100%;
  margin:0;
  background:var(--bg);
  -webkit-user-select:none;
  -webkit-tap-highlight-color: transparent;
}
canvas{
  display:block;
  width:100vw;
  height:100vh;
  touch-action: none;
}
.hud{
  position:absolute;
  right:12px;
  top:12px;
  color:var(--accent);
  font-family:system-ui,-apple-system,Segoe UI,Roboto;
  font-size:14px;
  background:rgba(255,255,255,0.6);
  padding:6px 10px;
  border-radius:8px;
  backdrop-filter: blur(6px);
}

/* kills button (top-left) */
#killsButton{
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 30;
  background: rgba(255,255,255,0.85);
  border: 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  min-width: 64px;
  text-align: center;
  touch-action: manipulation;
}
#killsButton:active{
  transform: translateY(1px);
}

/* coins button (below kills) */
#coinsButton{
  position: absolute;
  left: 12px;
  top: 56px;
  z-index: 30;
  background: rgba(255,255,255,0.92);
  border: 0;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  min-width: 64px;
  text-align: center;
  touch-action: manipulation;
}
#coinsButton:active{
  transform: translateY(1px);
}

/* toggle facing button (bottom-left) */
#toggleFacing{
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 30;
  background: rgba(255,255,255,0.9);
  border: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  min-width: 48px;
  text-align: center;
  touch-action: manipulation;
}
#toggleFacing.active{
  background: #1f2937;
  color: #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
#toggleFacing:active{
  transform: translateY(1px);
}

/* help button */
#helpButton{
  position: absolute;
  left: 12px;
  bottom: 72px;
  z-index: 30;
  background: rgba(255,255,255,0.95);
  border: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--accent);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  min-width: 56px;
  text-align: center;
  touch-action: manipulation;
}
#helpButton:active{ transform: translateY(1px); }

/* help overlay reuse .overlayCard but ensure readable */
#helpOverlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,12,0.5);
  z-index: 120;
  -webkit-user-select: none;
}
#helpOverlay .overlayCard{
  direction: rtl;
  max-width: 92vw;
  width: 460px;
  background: #fff;
  color: var(--accent);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 20px 46px rgba(10,10,10,0.36);
  text-align: right;
}
#helpOverlay .overlayCard h2{
  margin:0 0 6px 0;
  font-size:18px;
}
#helpOverlay .overlayCard ul{ list-style: disc; margin: 0 0 0 12px; padding-left: 14px; }
#helpOverlay #helpClose{
  background:#1f7a4a;
  color:#fff;
  border:0;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
}
#helpOverlay #helpClose:active{ transform: translateY(1px); }

/* start overlay styles */
#startOverlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,12,0.48);
  z-index: 60;
  -webkit-user-select: none;
}
#startOverlay .overlayCard{
  direction: rtl;
  max-width: 86vw;
  width: 460px;
  background: #fff;
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(10,10,10,0.25);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--accent);
  text-align: right;
}
#startOverlay h2{
  margin: 0 0 8px 0;
  font-size: 20px;
}
#startOverlay p{
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.35;
  color: #333;
}
#startButton{
  background: #1f7a4a;
  color: #fff;
  border: 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
}
#startButton:active{ transform: translateY(1px); }

/* splash logo in start overlay */
.splashLogo{
  display:flex;
  justify-content:center;
  margin-bottom:12px;
}
.splashLogo img{
  max-width: 160px;
  width: 36%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  background: rgba(255,255,255,0.02);
  object-fit: contain;
}

/* skin selector styles */
.skinsGrid{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.skinOption{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:6px;
  width:72px;
  padding:8px;
  border-radius:10px;
  border:1px solid rgba(16,16,16,0.06);
  background: #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,0.04);
  cursor:pointer;
  touch-action: manipulation;
  min-height:74px;
}
.skinOption .swatch{
  width:44px;
  height:36px;
  border-radius:6px;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,0.08);
  border:1px solid rgba(0,0,0,0.06);
}
.skinOption .label{
  font-size:12px;
  color:#333;
}
.skinOption[aria-pressed="true"], .skinOption.selected{
  outline: 2px solid #1f7a4a;
  transform: translateY(-2px);
}

/* ad overlay (periodic) */
#adOverlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,12,0.5);
  z-index: 80;
  -webkit-user-select: none;
}
#adOverlay .overlayCard{
  direction: rtl;
  max-width: 92vw;
  width: 420px;
  /* colorful, game-themed background */
  background: linear-gradient(135deg, #143f2b 0%, #2f7a4a 45%, #ffd36b 100%);
  color: #08110a;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 20px 46px rgba(10,10,10,0.36);
  text-align: center;
  border: 1px solid rgba(255,255,255,0.06);
}
#adOverlay .overlayCard h2{
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.32);
}
#adOverlay .overlayCard p{
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  margin: 0;
  line-height: 1.28;
  text-align: center;
}
#adOverlay .overlayCard #adText{
  font-size: 15px;
  margin-top: 6px;
}
#adOverlay h2{
  margin: 0 0 8px 0;
  font-size: 18px;
}
#adOverlay p{
  margin: 0;
  font-size: 14px;
  color:#222;
}
#adClose{
  background:#1f7a4a;
  color:#fff;
  border:0;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
}
#adClose:active{ transform: translateY(1px); }

/* shop overlay styles */
#shopOverlay{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,12,0.5);
  z-index: 100;
  -webkit-user-select: none;
}
#shopOverlay .overlayCard{
  direction: rtl;
  max-width: 92vw;
  width: 420px;
  background: #fff;
  color: var(--accent);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 20px 46px rgba(10,10,10,0.36);
  text-align: right;
}
#shopOverlay .overlayCard h2{
  margin:0 0 6px 0;
  font-size:18px;
}
.shopItem{
  padding:10px;
  border-radius:10px;
  border:0;
  background:#f3f3f3;
  font-size:14px;
  cursor:pointer;
}
.shopItem:active{ transform: translateY(1px); }
.shopItem.realMoney{
  background: linear-gradient(90deg,#ffe6a3,#ffd3a3);
  color:#5a3d00;
  opacity:0.7;
  cursor:not-allowed;
}
#shopClose{
  background:#1f7a4a;
  color:#fff;
  border:0;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
}
#shopClose:active{ transform: translateY(1px); }