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

:root {
  --cyan: #00FFFF;
  --magenta: #FF00FF;
  --purple: #8B00FF;
  --bg: #0a0a1a;
  --bg2: #0d0d24;
  --bg3: #12122e;
  --dim: #1a1a3a;
  --text: #c0c0e0;
  --white: #ffffff;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* HUD */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(0,255,255,0.15);
  flex-shrink: 0;
  z-index: 10;
  gap: 8px;
  flex-wrap: wrap;
}

#game-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan), 0 0 30px var(--cyan), 0 0 60px rgba(0,255,255,0.3);
  animation: titleFlicker 4s infinite;
  letter-spacing: 3px;
  white-space: nowrap;
}

@keyframes titleFlicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.7; }
  97% { opacity: 1; }
  98% { opacity: 0.6; }
}

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

#turn-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--white);
  padding: 4px 14px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(0,255,255,0.3), inset 0 0 8px rgba(0,255,255,0.1);
  animation: turnPulse 2s ease-in-out infinite;
  white-space: nowrap;
}

@keyframes turnPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,255,255,0.3), inset 0 0 8px rgba(0,255,255,0.1); }
  50% { box-shadow: 0 0 16px rgba(0,255,255,0.5), inset 0 0 12px rgba(0,255,255,0.2); }
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.score-label {
  font-size: 0.65rem;
  opacity: 0.7;
  font-family: 'Orbitron', sans-serif;
}

.score-val {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

#score-player .score-val { color: var(--cyan); text-shadow: 0 0 8px var(--cyan); }
#score-ai .score-val { color: var(--magenta); text-shadow: 0 0 8px var(--magenta); }

#auth-status {
  font-size: 0.7rem;
  color: var(--text);
  opacity: 0.6;
}

/* Main Area */
#main-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 0;
}

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

/* Side Panel */
#side-panel {
  width: 220px;
  background: var(--bg2);
  border-left: 1px solid rgba(0,255,255,0.1);
  display: flex;
  flex-direction: column;
  padding: 10px;
  gap: 10px;
  overflow-y: auto;
  flex-shrink: 0;
}

.panel-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(0,255,255,0.4);
  letter-spacing: 2px;
  margin-bottom: 4px;
  opacity: 0.8;
}

#daily-timer-box {
  text-align: center;
  padding: 6px;
  border: 1px solid rgba(255,0,255,0.2);
  border-radius: 4px;
  background: rgba(255,0,255,0.03);
}

#daily-timer {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--magenta);
  text-shadow: 0 0 10px var(--magenta);
}

#ap-box { text-align: center; }

#ap-pips {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.ap-pip {
  width: 18px;
  height: 18px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0,255,255,0.4);
  transition: all 0.3s;
}

.ap-pip.filled {
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.ap-pip.empty {
  background: transparent;
  opacity: 0.3;
}

#action-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Buttons */
.neon-btn {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 8px 14px;
  border: 1px solid;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.2s;
  text-transform: uppercase;
}

.cyan-btn {
  color: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 6px rgba(0,255,255,0.2), inset 0 0 6px rgba(0,255,255,0.05);
}

.cyan-btn:hover:not(:disabled) {
  background: rgba(0,255,255,0.1);
  box-shadow: 0 0 16px rgba(0,255,255,0.5), inset 0 0 12px rgba(0,255,255,0.1);
}

.magenta-btn {
  color: var(--magenta);
  border-color: var(--magenta);
  box-shadow: 0 0 6px rgba(255,0,255,0.2), inset 0 0 6px rgba(255,0,255,0.05);
}

.magenta-btn:hover {
  background: rgba(255,0,255,0.1);
  box-shadow: 0 0 16px rgba(255,0,255,0.5), inset 0 0 12px rgba(255,0,255,0.1);
}

.neon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.big-btn {
  font-size: 0.9rem;
  padding: 14px 32px;
}

#powerups {
  display: flex;
  gap: 6px;
}

.powerup-btn {
  flex: 1;
  font-size: 0.6rem;
  padding: 6px 4px;
  color: var(--purple);
  border-color: var(--purple);
  box-shadow: 0 0 6px rgba(139,0,255,0.2);
}

.powerup-btn:hover:not(:disabled) {
  background: rgba(139,0,255,0.15);
  box-shadow: 0 0 14px rgba(139,0,255,0.5);
}

.powerup-btn.used {
  opacity: 0.2;
  text-decoration: line-through;
}

/* Move Log */
#log-box {
  flex: 1;
  min-height: 80px;
  display: flex;
  flex-direction: column;
}

#move-log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.65rem;
  color: var(--cyan);
  padding: 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(0,255,255,0.08);
  border-radius: 3px;
  line-height: 1.6;
}

#move-log .log-enemy {
  color: var(--magenta);
}

#move-log .log-system {
  color: var(--purple);
}

/* Footer */
#game-footer {
  padding: 4px 16px;
  background: var(--bg2);
  border-top: 1px solid rgba(0,255,255,0.08);
  font-size: 0.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  color: rgba(0,255,255,0.3);
}

#game-footer a {
  color: var(--cyan);
  text-decoration: none;
  text-shadow: 0 0 6px rgba(0,255,255,0.3);
}

#game-footer a:hover {
  text-shadow: 0 0 12px var(--cyan);
}

/* Overlays */
.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5,5,15,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay.hidden { display: none; }

.overlay-panel {
  background: var(--bg2);
  border: 1px solid rgba(0,255,255,0.2);
  border-radius: 6px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 40px rgba(0,255,255,0.1), 0 0 80px rgba(255,0,255,0.05);
}

.overlay-panel h2 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan), 0 0 30px rgba(0,255,255,0.3);
  margin-bottom: 16px;
  letter-spacing: 3px;
}

#daily-desc {
  font-size: 0.9rem;
  color: var(--white);
  margin-bottom: 10px;
  line-height: 1.6;
}

#daily-seed-info {
  font-size: 0.7rem;
  color: var(--magenta);
  opacity: 0.6;
  margin-bottom: 20px;
}

/* Game Over */
.gameover-panel h2 {
  color: var(--magenta);
  text-shadow: 0 0 12px var(--magenta), 0 0 30px rgba(255,0,255,0.3);
}

#go-territory {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan);
  margin: 10px 0;
}

#go-stars {
  font-size: 2rem;
  margin: 8px 0;
  color: #FFD700;
  text-shadow: 0 0 12px rgba(255,215,0,0.6);
}

#go-breakdown {
  font-size: 0.75rem;
  color: var(--text);
  margin: 12px 0;
  line-height: 1.8;
}

#go-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

#go-next-daily {
  font-size: 0.7rem;
  color: var(--magenta);
  margin-top: 12px;
  opacity: 0.7;
}

/* Leaderboard */
.lb-panel {
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
}

#lb-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  justify-content: center;
}

.lb-tab {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.6rem;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid rgba(0,255,255,0.2);
  color: var(--text);
  cursor: pointer;
  border-radius: 3px;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.lb-tab.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,255,255,0.08);
  box-shadow: 0 0 8px rgba(0,255,255,0.3);
}

#lb-content {
  min-height: 100px;
}

#lb-list {
  text-align: left;
}

.lb-entry {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.72rem;
  gap: 10px;
}

.lb-entry.me {
  background: rgba(255,0,255,0.08);
  border: 1px solid rgba(255,0,255,0.2);
  border-radius: 3px;
}

.lb-rank {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  width: 28px;
  color: var(--cyan);
}

.lb-name { flex: 1; color: var(--white); }
.lb-score { font-family: 'Orbitron', sans-serif; font-weight: 700; color: var(--cyan); text-shadow: 0 0 6px rgba(0,255,255,0.3); }
.lb-stars { color: #FFD700; margin-left: 6px; }
.lb-turns { font-size: 0.6rem; opacity: 0.5; margin-left: 6px; }

/* Mobile */
@media (max-width: 768px) {
  #main-area {
    flex-direction: column;
  }
  
  #side-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(0,255,255,0.1);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 6px;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
  }

  #daily-timer-box { display: none; }
  
  #ap-box { flex-basis: 100%; }
  
  #action-buttons {
    flex-direction: row;
    flex: 1;
  }
  
  #powerups-box { flex-basis: 100%; }
  
  #log-box {
    flex-basis: 100%;
    min-height: 50px;
    max-height: 60px;
  }
  
  #hud {
    padding: 4px 8px;
  }
  
  #game-title { font-size: 0.75rem; letter-spacing: 1px; }
  #turn-display { font-size: 0.7rem; padding: 3px 8px; }
  
  .neon-btn { font-size: 0.6rem; padding: 6px 8px; letter-spacing: 1px; }
}

@media (max-width: 480px) {
  #hud-right { gap: 6px; }
  #btn-rankings { display: none; }
  .score-val { font-size: 0.85rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,255,255,0.2); border-radius: 2px; }