* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  font-family: 'Comic Sans MS', 'Chalkboard SE', cursive;
  overflow: hidden;
}

#header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: linear-gradient(135deg, #16213e, #0f3460);
  color: white;
  z-index: 10;
}

.player-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.player-info-right {
  flex-direction: row-reverse;
}

.player-name {
  font-size: 20px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.player1-color { color: #ff6b6b; }
.player2-color { color: #51cf66; }

.hp-bar-container {
  width: 180px;
  height: 24px;
  background: rgba(0,0,0,0.6);
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(0,0,0,0.3);
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 10px;
  background: #51cf66;
  transition: width 0.4s ease, background 0.3s ease;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.2), inset 0 2px 4px rgba(255,255,255,0.2);
}

.hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: bold;
  color: white;
  text-shadow: 1px 1px 3px rgba(0,0,0,1), 0 0 6px rgba(0,0,0,0.5);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 1px;
}

#center-info {
  text-align: center;
}

#turn-indicator {
  font-size: 22px;
  font-weight: bold;
  color: #ffd43b;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#winner-text {
  font-size: 28px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 10px #ffd700;
  display: none;
}

#lang-btn {
  background: #533483;
  color: white;
  border: 2px solid #e94560;
  border-radius: 10px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s;
}
#lang-btn:hover { transform: scale(1.1); }

canvas {
  display: block;
  cursor: crosshair;
  flex: 1;
  min-height: 0;
}

#controls {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  background: linear-gradient(135deg, #16213e, #0f3460);
  flex-wrap: wrap;
}

.ctrl-btn {
  background: linear-gradient(135deg, #e94560, #533483);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  user-select: none;
  -webkit-user-select: none;
}
.ctrl-btn:hover { transform: scale(1.08); box-shadow: 0 6px 12px rgba(0,0,0,0.4); }
.ctrl-btn:active { transform: scale(0.95); }
.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#proj-type-group {
  display: flex;
  gap: 6px;
}

.proj-btn {
  padding: 10px 16px;
  font-size: 18px;
}

.proj-btn.selected {
  box-shadow: 0 0 0 3px #ffd43b, 0 4px 8px rgba(0,0,0,0.3);
  transform: scale(1.12);
}

#angle-display {
  color: #ffd43b;
  font-size: 18px;
  font-weight: bold;
  min-width: 80px;
  text-align: center;
}

#power-bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  color: white;
  font-size: 16px;
  font-weight: bold;
}

#power-bar-outer {
  width: 200px;
  height: 34px;
  background: repeating-linear-gradient(
    45deg,
    #1a1a2e,
    #1a1a2e 5px,
    #222244 5px,
    #222244 10px
  );
  border-radius: 17px;
  border: 3px solid #ffd43b;
  overflow: hidden;
  position: relative;
  box-shadow: 0 0 12px rgba(255,212,59,0.5), inset 0 2px 4px rgba(0,0,0,0.5);
}

#power-bar-outer.active {
  border-color: #ff6b6b;
  box-shadow: 0 0 20px rgba(255,107,107,0.7), inset 0 2px 4px rgba(0,0,0,0.5);
  animation: pulseBar 0.5s ease-in-out infinite;
}

@keyframes pulseBar {
  0%, 100% { box-shadow: 0 0 12px rgba(255,107,107,0.5); }
  50% { box-shadow: 0 0 25px rgba(255,107,107,0.9); }
}

#power-bar-inner {
  height: 100%;
  width: 0%;
  border-radius: 14px;
  transition: none;
  background: linear-gradient(90deg, #51cf66, #ffd43b, #ff6b6b, #e94560);
  box-shadow: 0 0 10px rgba(233,69,96,0.6);
}

#goat-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 180px;
  z-index: 100;
  pointer-events: none;
  filter: drop-shadow(0 0 30px rgba(255,215,0,0.9)) drop-shadow(0 0 60px rgba(255,0,0,0.4));
  opacity: 0;
  transition: none;
}
#goat-popup.show {
  animation: goatEntry 1.5s ease-out forwards;
}

@keyframes goatEntry {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0) rotate(-30deg); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.6) rotate(20deg); }
  30% { transform: translate(-50%, -50%) scale(1.2) rotate(-15deg); }
  45% { transform: translate(-50%, -50%) scale(1.5) rotate(10deg); }
  60% { transform: translate(-50%, -50%) scale(1.1) rotate(-8deg); }
  80% { transform: translate(-50%, -50%) scale(1.3) rotate(5deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.3) rotate(25deg); opacity: 0; }
}

.flying-goat {
  position: fixed;
  z-index: 99;
  pointer-events: none;
  animation: flyGoat 1.2s ease-out forwards;
}

@keyframes flyGoat {
  0% { opacity: 1; transform: scale(0) rotate(0); }
  30% { opacity: 1; transform: scale(1.2) rotate(var(--fly-rot, 180deg)) translateX(calc(var(--fly-x, 50px) * 0.3)); }
  100% { opacity: 0; transform: scale(0.5) rotate(var(--fly-rot, 360deg)) translateX(var(--fly-x, 100px)) translateY(-120px); }
}

#start-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 15px;
  overflow-y: auto;
  padding: 20px 10px;
}

#start-screen h1 {
  font-size: 42px;
  color: #ffd43b;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
  text-align: center;
}

#start-screen .star {
  font-size: 60px;
  animation: spin 3s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.name-input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.name-input-group label {
  font-size: 18px;
  font-weight: bold;
}

.name-input-group input {
  padding: 10px 20px;
  font-family: inherit;
  font-size: 18px;
  border-radius: 10px;
  border: 3px solid;
  text-align: center;
  width: 200px;
  outline: none;
}

.p1-input label { color: #ff6b6b; }
.p1-input input { border-color: #ff6b6b; }
.p2-input label { color: #51cf66; }
.p2-input input { border-color: #51cf66; }

#start-btn {
  background: linear-gradient(135deg, #ffd43b, #e94560);
  color: white;
  border: none;
  border-radius: 15px;
  padding: 15px 50px;
  font-family: inherit;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
  margin-top: 10px;
}
#start-btn:hover { transform: scale(1.1); }

#start-lang-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #533483;
  color: white;
  border: 2px solid #e94560;
  border-radius: 10px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.hit-effect {
  position: fixed;
  font-size: 40px;
  pointer-events: none;
  z-index: 50;
  animation: hitFloat 1s ease-out forwards;
}

@keyframes hitFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.5); }
}

@keyframes pulseSuper {
  0%, 100% { box-shadow: 0 0 8px #c864ff, 0 4px 8px rgba(0,0,0,0.3); transform: scale(1); }
  50% { box-shadow: 0 0 20px #c864ff, 0 0 40px rgba(200,100,255,0.5); transform: scale(1.08); }
}

/* Start screen setup */
.setup-columns {
  display: flex;
  gap: 40px;
  justify-content: center;
  flex-wrap: wrap;
}

.player-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 15px 20px;
  border: 2px solid rgba(255,255,255,0.1);
}

.setup-label {
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: bold;
}

.color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #ffd43b; transform: scale(1.2); box-shadow: 0 0 8px rgba(255,212,59,0.6); }

.helmet-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  justify-items: center;
}

.helmet-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.3);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, border-color 0.15s;
}
.helmet-btn:hover { transform: scale(1.1); }
.helmet-btn.selected { border-color: #ffd43b; background: rgba(255,212,59,0.2); transform: scale(1.15); }
