:root {
  --blue: #2f7bff;
  --blue-dark: #1b4fd6;
  --red: #ff4242;
  --red-dark: #d61b1b;
  --ink: #0c2a14;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0b3d1c;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------------------------------------------------- Scoreboard */
#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  z-index: 20;
  font-weight: 800;
}
.score { font-size: 26px; line-height: 1; }
.score.blue { color: #bcd4ff; text-shadow: 0 0 8px rgba(47,123,255,.6); }
.score.red  { color: #ffc9c9; text-shadow: 0 0 8px rgba(255,66,66,.6); }
.score-sep  { color: #fff; opacity: .7; font-size: 22px; }

/* ------------------------------------------------------- Action buttons */
#actions {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  right: 22px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 16px;
  z-index: 20;
}
.act-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform .06s ease, background .15s ease;
}
.act-btn:active { transform: scale(0.9); }
.act-btn.attack { background: rgba(47, 123, 255, 0.55); border-color: #bcd4ff; }
.act-btn.defense { background: rgba(255, 66, 66, 0.5); border-color: #ffc9c9; }
#btnB { width: 66px; height: 66px; font-size: 15px; }

/* ----------------------------------------------------------- Overlays */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  z-index: 30;
  text-align: center;
}
#overlayText {
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  padding: 0 24px;
  line-height: 1.5;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
#rematchBtn {
  padding: 14px 30px;
  font-size: 19px;
  font-weight: 800;
  color: #0c2a14;
  background: #ffe04a;
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.hidden { display: none !important; }
