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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- Screens ---- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.hidden { display: none !important; }

/* ---- Menu ---- */
#menuScreen {
  background: linear-gradient(180deg, #1a0a2e 0%, #16213e 40%, #0a3d62 100%);
}

.menu-content {
  text-align: center;
  padding: 2rem;
}

.game-title {
  font-size: clamp(3rem, 12vw, 6rem);
  font-weight: 900;
  color: #ffdd57;
  text-shadow:
    3px 3px 0 #e67e22,
    6px 6px 0 #c0392b,
    0 0 40px rgba(255,221,87,0.4);
  letter-spacing: 0.1em;
  margin-bottom: 0.2em;
  animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1deg); }
}

.subtitle {
  font-size: clamp(1rem, 4vw, 1.6rem);
  color: #aaa;
  margin-bottom: 2rem;
  font-style: italic;
}

.instructions {
  font-size: clamp(0.75rem, 2.5vw, 1rem);
  color: #888;
  margin-top: 2rem;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.menu-btn {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 700;
  padding: 0.8em 2em;
  min-width: 220px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #e67e22, #e74c3c);
  box-shadow: 0 4px 15px rgba(231,76,60,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}

.menu-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(231,76,60,0.3);
}

/* ---- Game HUD ---- */
#gameHUD {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#gameHUD > * {
  pointer-events: auto;
}

/* Top bar */
#topBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  pointer-events: none;
}

#windDisplay {
  display: flex;
  align-items: center;
  gap: 8px;
}

#windLabel {
  color: #aaa;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

#windBar {
  width: 100px;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

#windIndicator {
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 100%;
  background: #3498db;
  border-radius: 4px;
  transition: all 0.3s;
}

#turnInfo {
  display: flex;
  align-items: center;
  gap: 10px;
}

#teamName {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

#turnTimer {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffdd57;
  min-width: 30px;
  text-align: center;
}

/* Team health */
#teamHealth {
  position: absolute;
  top: 40px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.team-hp {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  width: 28px;
}

.hp-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

#team1Fill { background: #ff4444; width: 100%; }
#team2Fill { background: #4488ff; width: 100%; }

/* Move controls */
#moveControls {
  position: absolute;
  bottom: 80px;
  left: 12px;
  display: flex;
  gap: 6px;
}

.move-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.move-btn:active {
  background: rgba(255,255,255,0.35);
}

/* Weapon bar */
#weaponBar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 4px;
  padding: 8px;
  background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, transparent 100%);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#weaponBar::-webkit-scrollbar { display: none; }

.weapon-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #ccc;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 56px;
}

.weapon-btn.selected {
  border-color: #ffdd57;
  background: rgba(255,221,87,0.15);
  color: #fff;
}

.weapon-btn:active {
  transform: scale(0.92);
}

.weapon-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.weapon-name {
  font-size: 0.55rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* Turn banner */
#turnBanner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: none;
}

#bannerText {
  display: block;
  font-size: clamp(1.5rem, 6vw, 2.5rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  padding: 0.5em 1.5em;
  background: rgba(0,0,0,0.6);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  animation: bannerIn 0.3s ease-out;
}

@keyframes bannerIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* Game over */
#gameOverScreen {
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
}

/* Landscape nudge for very small screens */
@media (max-height: 360px) {
  #moveControls { bottom: 64px; }
  #weaponBar { padding: 4px; }
  .weapon-btn { padding: 4px 8px; min-width: 48px; }
  .weapon-icon { font-size: 1.1rem; }
  .weapon-name { font-size: 0.5rem; }
  .move-btn { width: 40px; height: 40px; font-size: 1rem; }
}
