:root {
  /* Colors */
  --bg-deep: #030407;
  --bg-panel: rgba(10, 15, 30, 0.85);
  --bg-element: rgba(20, 30, 50, 0.6);
  
  --accent-cyan: #00f3ff;
  --accent-purple: #bc13fe;
  --accent-pink: #ff0055;
  --accent-green: #00ff9d;
  --accent-gold: #ffd700;
  
  --text-main: #e0f0ff;
  --text-dim: #7a8aa0;
  
  --border-light: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(0, 243, 255, 0.5);

  /* Dimensions */
  --grid-cell-size: 90px;
  --grid-gap: 8px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;

  /* Effects */
  --glass-blur: blur(16px);
  --shadow-glow: 0 0 20px rgba(0, 243, 255, 0.15);
  --font-ui: 'Rajdhani', sans-serif;
  --font-head: 'Orbitron', sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    linear-gradient(to bottom, rgba(3, 4, 7, 0.8), rgba(3, 4, 7, 0.4)),
    url(https://v423t1uiej4kh0_menlo.c.websim.ai/bg02.webp?v=46);
  background-size: cover;
  background-position: center bottom;
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Animations */
@keyframes hud-scan {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 100%; }
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Start Screen */
#start-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-panel);
  padding: 60px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glow);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(0, 243, 255, 0.1);
  backdrop-filter: var(--glass-blur);
  text-align: center;
  z-index: 100;
  min-width: 300px;
}

#start-screen h1 {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 3.5rem;
  margin: 0 0 40px 0;
  background: linear-gradient(180deg, #fff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
}

#start-screen button {
  width: 200px;
  margin: 10px;
  font-size: 1.2rem;
}

/* Game Screen Layout */
#game-screen {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  height: 100vh;
  box-sizing: border-box;
}

/* Stats Bar */
#stats {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: var(--bg-panel);
  border-top: 2px solid var(--accent-cyan);
  border-bottom: 1px solid var(--border-light);
  padding: 10px 30px;
  backdrop-filter: var(--glass-blur);
  clip-path: polygon(0 0, 100% 0, 98% 100%, 2% 100%);
}

#level-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
}

.level {
  font-size: 1.5rem;
  color: var(--accent-cyan);
  font-weight: 700;
}

.tier {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.tachyons {
  font-family: var(--font-head);
  font-size: 1.4rem;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Main Game Area */
#game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  perspective: 1000px;
}

.player-section {
  transition: all 0.5s ease;
}

/* Controls */
#controls-top, #controls-bottom {
  display: flex;
  justify-content: center;
  gap: 20px;
  pointer-events: none; /* Let clicks pass through container */
}
#controls-top > *, #controls-bottom > * {
  pointer-events: auto;
}

/* Button Styles */
button {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 1px;
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

/* Standard Action Button */
button {
  background: rgba(0, 243, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
  padding: 12px 24px;
}

button:hover:not(:disabled) {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.4);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* End Phase / Launch Button */
#end-phase {
  background: linear-gradient(135deg, var(--accent-pink) 0%, #a00040 100%);
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 20px 60px;
  border: none;
  text-shadow: 0 2px 0 rgba(0,0,0,0.5);
  box-shadow: 0 0 30px rgba(255, 0, 85, 0.3);
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
}

#end-phase:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 50px rgba(255, 0, 85, 0.6);
  background: linear-gradient(135deg, #ff1a6d 0%, #c00050 100%);
}

#advance-combat {
  background: var(--accent-gold);
  color: black;
  font-weight: 800;
}

/* Player Switch Buttons */
.player-control-btn {
  font-size: 0.9rem;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
}

.player-control-btn:hover:not(:disabled) {
  background: var(--text-main);
  color: black;
  border-color: white;
}

/* Inventory Placeholder */
/* Removed old placeholder sizing; now using a real right-side inventory */
/* #inventory-placeholder rules deleted */

/* Battle End Screen */
#battle-end-screen {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 7, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#battle-end-screen h2 {
  font-family: var(--font-head);
  color: var(--accent-cyan);
  font-size: 3rem;
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 24px;
}

#battle-end-screen button {
  font-size: 1.2em;
  padding: 20px 40px;
  background: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
}

.player-section {
  opacity: 0.5;
  transition: opacity 0.3s ease;
  position: relative;
  z-index: 1;
}

.player-section.active {
  opacity: 1;
}

.player-section.active::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border: 2px solid rgba(100, 100, 255, 0.3);
  border-radius: 12px;
  pointer-events: none;
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { 
    box-shadow: 0 0 10px rgba(100, 100, 255, 0.2);
    border-color: rgba(100, 100, 255, 0.3);
  }
  50% { 
    box-shadow: 0 0 20px rgba(100, 100, 255, 0.4);
    border-color: rgba(100, 100, 255, 0.5);
  }
}

#bottom-section {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}

/* Removed old inventory-placeholder visibility rules since it's now a real inventory */
/*
#inventory-placeholder {
  width: calc(var(--grid-cell-size) * 0.8 * 2 + var(--grid-gap));
  visibility: hidden;
  display: none;
}

body[data-players="1"] #inventory-placeholder {
  display: block;
}
*/

body[data-players="1"] #game-area {
  /* Keep items centered so the player grid aligns visually with the opponent grid */
  justify-content: center;
}