*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  height: 100vh;
  overflow: hidden;
}

/* ===== SETUP OVERLAY ===== */

#setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#setup-box {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 2.5rem 3rem;
  min-width: 380px;
  text-align: center;
}

.game-logo-setup {
  display: block;
  max-width: 300px;
  width: 100%;
  margin: 0 auto 1.5rem;
  object-fit: contain;
  animation: logo-glow 2s ease-in-out infinite alternate;
}

.game-logo-header {
  height: 58px;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
  animation: logo-glow 2s ease-in-out infinite alternate;
}

@keyframes logo-glow {
  from { filter: drop-shadow(0 0 4px rgba(233, 69, 96, 0.6)) drop-shadow(0 0 10px rgba(233, 69, 96, 0.3)); }
  to   { filter: drop-shadow(0 0 10px rgba(233, 69, 96, 1))  drop-shadow(0 0 24px rgba(255, 80, 60, 0.7)); }
}

.setup-player-label {
  font-size: 1rem;
  font-weight: 600;
  color: #8b949e;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  align-items: stretch;
}

.setup-field-label {
  font-size: 0.8rem;
  color: #8b949e;
  text-align: left;
  margin-bottom: 2px;
}

.setup-form input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.setup-form input[type="text"]:focus {
  border-color: #e94560;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.color-row .setup-field-label {
  flex: 1;
  margin: 0;
}

.color-row input[type="color"] {
  width: 52px;
  height: 34px;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 2px;
}

.setup-next-btn {
  margin-top: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: #e94560;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.setup-next-btn:hover {
  background: #c73652;
}

.setup-next-btn:active {
  transform: scale(0.97);
}

/* ===== GAME OVER OVERLAY ===== */

#gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#gameover-box {
  background: #161b22;
  border: 2px solid var(--winner-primary, #e94560);
  border-radius: 12px;
  padding: 3rem 4rem;
  text-align: center;
  box-shadow: 0 0 48px var(--winner-primary, #e94560);
}

#gameover-title {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--winner-primary, #e94560);
  margin-bottom: 0.5rem;
}

#gameover-sub {
  color: #8b949e;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

#restart-btn {
  padding: 0.75rem 2.5rem;
  background: var(--winner-primary, #e94560);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#restart-btn:hover {
  background: var(--winner-secondary, #c73652);
}

/* ===== MOUNTAINS ===== */

.mt-glow {
  animation: mt-pulse 2.8s ease-in-out infinite alternate;
}

@keyframes mt-pulse {
  from { opacity: 0.3; }
  to   { opacity: 1; }
}

/* ===== FORCE FIELD ===== */

.ff-glow {
  animation: ff-pulse 1.6s ease-in-out infinite alternate;
}
.ff-ring {
  animation: ff-pulse 1.6s ease-in-out infinite alternate;
  animation-delay: 0.1s;
}
@keyframes ff-pulse {
  from { opacity: 0.3; }
  to   { opacity: 1; }
}

/* ===== GAME LAYOUT ===== */

#game-layout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  grid-template-rows: 48px 1fr 52px;
  height: 100vh;
}

/* ===== HEADER ===== */

#game-header {
  grid-column: 1 / -1;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.75rem;
  z-index: 50;
}

#header-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 800;
  color: #c9d1d9;
  letter-spacing: 0.04em;
}

#header-version {
  font-size: 0.65rem;
  font-weight: 400;
  color: #484f58;
  margin-left: 0.5rem;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

/* ===== PLAYER PANELS ===== */

.player-panel {
  background: #161b22;
  border-right: 1px solid #21262d;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  transition: border-color 0.3s;
}

#p2-panel {
  border-right: none;
  border-left: 1px solid #21262d;
}

.player-panel.active {
  border-right-color: var(--player-primary, #e94560);
}

#p2-panel.active {
  border-left-color: var(--player-primary, #2a9d8f);
  border-right: none;
}

.panel-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #21262d;
}

.player-colors {
  display: flex;
  gap: 6px;
}

.color-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.15);
}

.player-name {
  font-size: 1rem;
  font-weight: 700;
  color: #f0f6fc;
}

.player-resources {
  font-size: 0.85rem;
  color: #f5c518;
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.opponent-panel {
  filter: saturate(0.55) brightness(0.78);
  pointer-events: none;
}

.opponent-panel .player-name::after {
  content: ' (opponent)';
  color: #6e7681;
  font-weight: 400;
  font-size: 0.7rem;
}

.cooldown-text {
  margin-left: 6px;
  padding: 1px 6px;
  background: rgba(64, 200, 255, 0.18);
  border: 1px solid rgba(64, 200, 255, 0.45);
  border-radius: 999px;
  color: #9cdcff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.room-code-display {
  text-align: center;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 800;
  font-size: 2.4rem;
  letter-spacing: 0.4em;
  color: #f5c518;
  background: #21262d;
  border: 1px solid #30363d;
  padding: 0.8rem 0.5rem 0.8rem 0.9rem;
  border-radius: 8px;
  margin: 0.6rem 0;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #484f58;
}

.instructions-text {
  font-size: 0.78rem;
  color: #8b949e;
  line-height: 1.5;
  padding: 0.3rem 0;
}

.unit-info-text {
  font-size: 0.8rem;
  color: #c9d1d9;
  padding: 0.2rem 0;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.action-btn {
  padding: 0.42rem 0.6rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 5px;
  color: #c9d1d9;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.3;
}

.action-btn:hover:not(:disabled) {
  background: #2d333b;
  border-color: #6e7681;
}

.action-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.action-btn.active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

.action-btn.active .btn-cost {
  color: #ffd0d8;
}

.btn-cost {
  color: #f5c518;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-left: 4px;
}

.btn-cancel {
  background: #2d1b1e;
  border-color: #6e2232;
  color: #f47067;
}

.btn-cancel:hover:not(:disabled) {
  background: #3d2025;
  border-color: #f47067;
}

.panel-spacer {
  flex: 1;
}

/* ===== BOARD CONTAINER ===== */

#board-container {
  overflow: hidden;
  background: #0d1117;
}

#board {
  display: block;
  cursor: crosshair;
}

/* ===== STATUS BAR ===== */

#status-bar {
  grid-column: 1 / -1;
  background: #161b22;
  border-top: 1px solid #21262d;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 0.85rem;
  color: #8b949e;
  overflow: hidden;
  gap: 0.75rem;
}

#status-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.zoom-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.zoom-btn:hover {
  background: #30363d;
}

#zoom-level {
  font-size: 0.75rem;
  color: #8b949e;
  min-width: 38px;
  text-align: center;
}

#menu-container {
  position: relative;
  flex-shrink: 0;
}

#menu-btn {
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

#menu-btn:hover {
  background: #30363d;
}

#menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 140px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.5);
  z-index: 100;
}

#menu-dropdown button {
  background: transparent;
  color: #c9d1d9;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

#menu-dropdown button:hover {
  background: #21262d;
}

#surrender-btn:hover {
  color: #f85149 !important;
}

/* ===== UTILITIES ===== */

.hidden {
  display: none !important;
}
