:root {
  --saffron: #ff7a18;
  --saffron-dark: #e0610a;
  --green: #138808;
  --wa: #25d366;
  --ink: #2b2118;
  --card: #fffaf2;
  --muted: #7a6a5a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f6efe4;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(43, 33, 24, 0.35);
  z-index: 10;
  overflow-y: auto;
}
.card {
  width: 100%; max-width: 420px;
  background: var(--card);
  border-radius: 20px;
  padding: 22px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  text-align: center;
  margin: auto;
}
.logo { margin: 0; font-size: 40px; letter-spacing: -1px; color: var(--saffron); }
.logo span { color: var(--green); }
.tagline { margin: 2px 0 14px; color: var(--muted); }

input#name {
  width: 100%; font-size: 18px; padding: 12px 14px;
  border: 2px solid #e6d8c4; border-radius: 12px; outline: none;
  background: #fff; text-align: center;
  -webkit-user-select: text; user-select: text;
}
input#name:focus { border-color: var(--saffron); }

.skins-label { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
#skins { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
#skins canvas {
  flex: 0 0 auto; width: 48px; height: 48px;
  border-radius: 50%; border: 3px solid transparent; cursor: pointer;
}
#skins canvas.selected { border-color: var(--saffron); }

.btn {
  display: block; width: 100%;
  border: 0; border-radius: 12px;
  padding: 13px 14px; margin-top: 10px;
  font-size: 17px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--saffron); color: #fff; font-size: 20px; box-shadow: 0 4px 0 var(--saffron-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--saffron-dark); }
.btn.secondary { background: #fff; color: var(--ink); border: 2px solid #e6d8c4; font-size: 15px; }
.btn.whatsapp { background: var(--wa); color: #fff; }
.btn.link { background: none; color: var(--muted); font-weight: 500; font-size: 14px; }
.row { display: flex; flex-direction: column; }

#room-banner {
  background: #fff3e2; border: 2px dashed var(--saffron);
  border-radius: 12px; padding: 10px; margin-bottom: 12px;
}
#room-banner .btn { margin-top: 8px; padding: 10px; font-size: 15px; }
#room-code { font-size: 20px; letter-spacing: 2px; color: var(--saffron-dark); }

.howto { text-align: left; margin-top: 14px; font-size: 14px; }
.howto summary { cursor: pointer; color: var(--muted); }
.howto ul { padding-left: 18px; margin: 8px 0 0; line-height: 1.6; }
.conn { margin-top: 10px; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }

.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.statgrid div { background: #fff; border-radius: 12px; padding: 10px 4px; }
.statgrid b { display: block; font-size: 24px; color: var(--saffron-dark); }
.statgrid span { font-size: 12px; color: var(--muted); }

#round-list { text-align: left; padding-left: 28px; line-height: 1.8; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud button { pointer-events: auto; }

#leaderboard {
  position: absolute; top: 10px; right: 10px;
  min-width: 150px; max-width: 42vw;
  background: rgba(43, 33, 24, 0.55); color: #fff;
  border-radius: 12px; padding: 8px 12px; font-size: 13px;
}
#leaderboard h3 { margin: 0 0 4px; font-size: 14px; text-align: center; color: #ffd18a; }
#leaderboard ol { margin: 0; padding-left: 20px; }
#leaderboard li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#leaderboard li.me { color: #ffd18a; font-weight: 700; }
#lb-me { margin-top: 4px; font-size: 12px; color: #ffd18a; text-align: center; }

#killfeed { position: absolute; top: 10px; left: 10px; max-width: 52vw; font-size: 13px; }
#killfeed div {
  background: rgba(43, 33, 24, 0.55); color: #fff;
  padding: 4px 10px; border-radius: 10px; margin-bottom: 4px;
  animation: fade 5s forwards;
}
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#stats {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(43, 33, 24, 0.55); color: #fff;
  padding: 6px 12px; border-radius: 10px; font-weight: 700;
  display: flex; gap: 10px; align-items: baseline;
}
#ping { font-size: 11px; font-weight: 400; opacity: .8; }

#round-timer {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(43, 33, 24, 0.55); color: #fff;
  padding: 4px 12px; border-radius: 10px; font-weight: 700;
}
#hud-share {
  position: absolute; top: 44px; left: 50%; transform: translateX(-50%);
  background: var(--wa); color: #fff; border: 0; border-radius: 20px;
  padding: 6px 14px; font-weight: 700; font-size: 13px;
}

#minimap {
  position: absolute; right: 10px; bottom: 10px;
  width: 120px; height: 120px;
  background: rgba(43, 33, 24, 0.35); border-radius: 8px;
}
#touch-buttons { position: absolute; right: 14px; bottom: 144px; display: none; flex-direction: column; gap: 14px; }
#touch-buttons button {
  width: 68px; height: 68px; border-radius: 50%;
  border: 0; font-size: 28px;
  background: rgba(255, 122, 24, 0.85); box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
body.touch #touch-buttons { display: flex; }
body.touch #minimap { width: 90px; height: 90px; }
body.touch #touch-buttons { bottom: 114px; }

#toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 20;
  font-size: 14px;
}

@media (max-width: 600px) {
  #killfeed { top: 84px; }
}
@media (max-width: 480px) {
  #leaderboard { font-size: 11px; min-width: 120px; padding: 6px 8px; }
  #leaderboard h3 { font-size: 12px; }
  #killfeed { font-size: 11px; }
  .logo { font-size: 34px; }
}
