/* client/style.css */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #0a0a0f;
  color: #fff;
  font-family: 'Segoe UI', monospace;
  overflow: hidden;
  /* CrazyGames compliance */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: none;
}

canvas#gameCanvas { display: block; position: fixed; inset: 0; }

/* ── Start overlay ─────────────────────────────────────────────────────── */
#overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 100; gap: 14px;
}
#overlay h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: .2em; color: #7bed9f;
  text-shadow: 0 0 24px #7bed9f;
}
#overlay .tagline { color: #888; font-size: .85rem; text-align: center; padding: 0 1rem; }
#nameInput {
  background: #1a1a2e; border: 2px solid #333; color: #fff;
  padding: 10px 20px; font-size: 1rem; border-radius: 8px; outline: none;
  text-align: center; width: min(260px, 80vw); transition: border-color .2s;
  -webkit-user-select: text; user-select: text;
}
#nameInput:focus { border-color: #7bed9f; }
#playBtn {
  background: #7bed9f; color: #0a0a0f; border: none;
  padding: 12px 40px; font-size: 1rem; font-weight: 700;
  border-radius: 8px; cursor: pointer; letter-spacing: .05em;
  box-shadow: 0 0 22px rgba(123,237,159,.45); transition: transform .1s, box-shadow .1s;
}
#playBtn:hover { transform: scale(1.05); box-shadow: 0 0 32px rgba(123,237,159,.7); }
#overlay .controls-hint { font-size: .75rem; color: #555; }

/* ── Leaderboard ───────────────────────────────────────────────────────── */
#leaderboard {
  position: fixed; top: 10px; right: 10px;
  background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: 10px 14px; min-width: 170px;
  z-index: 10; backdrop-filter: blur(6px);
}
#leaderboard h3 { font-size: .7rem; letter-spacing: .12em; color: #777; margin-bottom: 8px; }
.lb-entry { display: flex; gap: 8px; align-items: center; font-size: .8rem; margin-bottom: 4px; }
.lb-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.lb-name  { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-tiles { color: #aaa; font-size: .72rem; }

/* ── Stats box ─────────────────────────────────────────────────────────── */
#statsBox {
  position: fixed; bottom: 10px; left: 10px;
  background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px; padding: 9px 14px; z-index: 10; backdrop-filter: blur(6px);
}
.stat-line { font-size: .78rem; color: #bbb; line-height: 1.55; }
.stat-val  { font-weight: 700; color: #fff; }

/* ── Power-up HUD ──────────────────────────────────────────────────────── */
#powerupHud {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.7); border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 8px 18px; z-index: 10; backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#powerupHud.active { opacity: 1; }
#powerupIcon { font-size: 1.4rem; }
#powerupBar  { width: 72px; height: 5px; background: #333; border-radius: 3px; overflow: hidden; }
#powerupFill { height: 100%; border-radius: 3px; transition: width .1s linear; }
#powerupLabel{ font-size: .75rem; color: #ddd; white-space: nowrap; }

/* ── Kill message ──────────────────────────────────────────────────────── */
#killMsg {
  position: fixed; top: 44%; left: 50%; transform: translate(-50%,-50%);
  font-size: 1.2rem; font-weight: 700; color: #ffd700;
  text-shadow: 0 0 18px rgba(255,215,0,.8);
  opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 20;
  white-space: nowrap;
}

/* ── Respawn message ───────────────────────────────────────────────────── */
#respawnMsg {
  position: fixed; top: 48%; left: 50%; transform: translate(-50%,-50%);
  font-size: 1.1rem; color: #ff6b6b;
  text-shadow: 0 0 10px rgba(255,107,107,.6);
  opacity: 0; pointer-events: none; z-index: 20;
}

/* ── Idle warning ──────────────────────────────────────────────────────── */
#idleWarning {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%);
  background: rgba(255,100,0,.2); border: 1px solid #ff6400;
  border-radius: 8px; padding: 8px 20px; font-size: .85rem; color: #ff9944;
  opacity: 0; transition: opacity .3s; z-index: 20; pointer-events: none;
  white-space: nowrap;
}

/* ── Minimap ───────────────────────────────────────────────────────────── */
#minimap {
  position: fixed; bottom: 10px; right: 10px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 4px;
  z-index: 10; image-rendering: pixelated;
}

/* ── Ad overlay ────────────────────────────────────────────────────────── */
#adOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  z-index: 500; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.ad-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,.2);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ad-text { font-size: .85rem; color: #888; }

/* ── D-pad (coarse pointer = touch) ───────────────────────────────────── */
#dpad {
  position: fixed; bottom: 90px; right: 14px;
  display: none;
  grid-template-areas: '. up .' 'left stop right' '. down .';
  grid-template-columns: repeat(3, 46px);
  grid-template-rows:    repeat(3, 46px);
  gap: 4px; z-index: 30;
}
@media (pointer: coarse) { #dpad { display: grid; } }
.dpad-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px; color: #fff; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
.dpad-btn:active { background: rgba(255,255,255,.3); }
#dpad-up    { grid-area: up; }
#dpad-left  { grid-area: left; }
#dpad-stop  { grid-area: stop; font-size: .65rem; letter-spacing: .03em; }
#dpad-right { grid-area: right; }
#dpad-down  { grid-area: down; }

/* ── Footer ────────────────────────────────────────────────────────────── */
#footer {
  position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-size: .65rem; color: #444; z-index: 5; pointer-events: auto;
  white-space: nowrap;
}
#footer a { color: #555; text-decoration: underline; }
#footer a:hover { color: #888; }

/* ── Responsive tweaks ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #leaderboard { min-width: 130px; font-size: .72rem; padding: 7px 10px; }
  #statsBox    { padding: 6px 10px; }
  #minimap     { display: none; }  /* hide minimap on very small screens */
}
