/* ── HEXSHROUD — Styles ──────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Share+Tech+Mono&display=swap');

:root {
  --bg-dark: #08080e;
  --bg-panel: #0e0e1a;
  --bg-hover: #18182a;
  --text-primary: #e0e0f0;
  --text-secondary: #9090b0;
  --text-dim: #505068;
  --accent: #b040e0;
  --accent-glow: #d060ff;
  --accent-rgb: 176, 64, 224;
  --player-a: #4080e0;
  --player-a-dim: #203880;
  --player-a-glow: rgba(64, 128, 224, 0.3);
  --player-b: #e04040;
  --player-b-dim: #802020;
  --player-b-glow: rgba(224, 64, 64, 0.3);
  --neutral: #1e1e30;
  --neutral-border: #2a2a42;
  --power-hex: #d4a020;
  --power-glow: rgba(212, 160, 32, 0.4);
  --danger: #e04040;
  --success: #40c040;
  --echo-active: #ffffff;
  --echo-inactive: #282838;
  --decay-pip: #ff8800;
  --brand-gold: #d4af37;
  --brand-gold-dim: rgba(212, 175, 55, 0.55);
  --border-radius: 6px;
  --transition: 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  background: var(--bg-dark);
  background-image:
    radial-gradient(ellipse at 30% 80%, rgba(176, 64, 224, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 20%, rgba(0, 200, 255, 0.03) 0%, transparent 50%);
  color: var(--text-primary);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.03) 2px, rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Screens ─────────────────────────────────────────────────────── */

.screen {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-screen.active {
  display: block;
}

/* ── Menu ─────────────────────────────────────────────────────────── */

.menu-container {
  text-align: center;
  max-width: 420px;
  padding: 2rem 2.5rem;
  background: linear-gradient(135deg, rgba(14, 14, 26, 0.95), rgba(16, 12, 28, 0.95));
  border: 1px solid rgba(176, 64, 224, 0.15);
  border-radius: var(--border-radius);
  box-shadow: 0 0 40px rgba(176, 64, 224, 0.06), inset 0 0 60px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* Corner accents */
.menu-container::before, .menu-container::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: rgba(176, 64, 224, 0.4);
  border-style: solid;
}
.menu-container::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.menu-container::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.title {
  font-family: 'Orbitron', sans-serif;
  font-size: 3.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.hex-accent {
  background: linear-gradient(135deg, #b040e0, #00c8ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 10px rgba(176, 64, 224, 0.4));
}

.subtitle {
  color: rgba(176, 64, 224, 0.5);
  font-size: 0.75rem;
  margin-bottom: 2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-glow);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.35);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--neutral-border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--neutral-border);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  box-shadow: 0 0 15px rgba(224, 64, 64, 0.4);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Lobby ────────────────────────────────────────────────────────── */

.lobby-container {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
}

.lobby-container h2 {
  margin-bottom: 1.5rem;
  color: var(--accent);
}

.lobby-section {
  margin: 1rem 0;
}

.lobby-divider {
  color: var(--text-dim);
  margin: 1.5rem 0;
}

.room-code {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  border: 1px solid var(--accent);
}

.room-code strong {
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  display: block;
  margin: 0.5rem 0;
}

.code-input {
  background: var(--bg-panel);
  border: 1px solid var(--neutral-border);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.3em;
  padding: 0.75rem;
  width: 200px;
  text-transform: uppercase;
}

.code-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Spinner ──────────────────────────────────────────────────────── */

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--neutral-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 1.5rem auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Tutorial ─────────────────────────────────────────────────────── */

.tutorial-container {
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

.tutorial-container h2 {
  color: var(--accent);
  margin-bottom: 1.5rem;
  text-align: center;
}

.tutorial-step {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--border-radius);
  border-left: 3px solid var(--accent);
}

.tutorial-step h3 {
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.tutorial-step p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.tutorial-step strong {
  color: var(--text-primary);
}

/* ── Game HUD ─────────────────────────────────────────────────────── */

.hud {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: rgba(8, 8, 14, 0.9);
  backdrop-filter: blur(10px);
  border-color: rgba(176, 64, 224, 0.08);
  border-style: solid;
  border-width: 0;
}

#hud-top { border-bottom-width: 1px; }
#hud-bottom { border-top-width: 1px; }

#hud-top {
  top: 0;
}

#hud-bottom {
  bottom: 0;
}

.hud-left {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-label {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}

.player-a { background: var(--player-a); }
.player-b { background: var(--player-b); }

.hex-count {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.round-display {
  text-align: center;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#round-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-danger {
  background: var(--danger);
  color: white;
  animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.energy-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

#energy-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

#energy-label strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#timer-text {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: right;
}

.timer-danger {
  color: var(--danger) !important;
  animation: pulse-badge 0.5s ease-in-out infinite;
}

/* ── Game Canvas ──────────────────────────────────────────────────── */

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Music Toggle ────────────────────────────────────────────────── */

.hud-music-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  padding: 6px 14px;
  border: 1px solid rgba(255,200,0,0.2);
  border-radius: 4px;
  background: rgba(255,200,0,0.06);
  color: rgba(255,200,100,0.5);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.hud-music-btn:hover {
  background: rgba(255,200,0,0.12);
  color: #ffcc66;
  border-color: rgba(255,200,0,0.4);
  box-shadow: 0 0 8px rgba(255,200,0,0.08);
}
.hud-music-btn.muted {
  opacity: 0.4;
  color: #667;
  border-color: rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

/* ── Opponent Ready ───────────────────────────────────────────────── */

.opponent-ready {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(64, 192, 64, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 0.4rem 1rem;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 15;
  animation: fadeSlideIn 0.3s ease;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Victory Overlay ──────────────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(14, 14, 26, 0.97), rgba(16, 12, 28, 0.97));
  border-radius: var(--border-radius);
  border: 1px solid rgba(176, 64, 224, 0.2);
  max-width: 400px;
  box-shadow: 0 0 30px rgba(176, 64, 224, 0.08);
}

.overlay-content h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.overlay-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.victory-stats {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.victory-stats div {
  margin: 0.3rem 0;
}

.victory-stats .player-a { color: var(--player-a); font-weight: 600; }
.victory-stats .player-b { color: var(--player-b); font-weight: 600; }

.overlay-content .btn {
  margin: 0.3rem;
}

/* ── Footer Brand ────────────────────────────────────────────────── */

.footer-brand {
  display: block;
  margin-top: 2rem;
  font-size: 0.7rem;
  color: var(--brand-gold-dim);
  letter-spacing: 0.03em;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.footer-brand a {
  color: var(--brand-gold);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-brand a:hover {
  color: #f1d27a;
  text-decoration: underline;
}

.footer-cross {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.footer-cross a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-cross a:hover {
  color: var(--accent-glow);
  text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .title { font-size: 3rem; }
  .btn { padding: 0.6rem 1.2rem; font-size: 0.9rem; }
  .hud { padding: 0.4rem 0.6rem; }
  .hex-count { font-size: 1.2rem; }
}

/* ── Share Components ──────────────────────────────────────────── */

.menu-share-section {
  margin-top: 1.25rem;
  text-align: center;
}

.btn-menu-share {
  background: transparent;
  color: #a050ff;
  border: 1px solid rgba(160, 80, 255, 0.25);
  font-size: 0.85rem;
  padding: 0.5rem 1.5rem;
  letter-spacing: 0.04em;
}
.btn-menu-share:hover {
  background: rgba(160, 80, 255, 0.08);
  border-color: #a050ff;
  color: #b080ff;
  box-shadow: 0 0 12px rgba(160, 80, 255, 0.15);
}

.share-section {
  margin: 1rem 0;
  text-align: center;
}

.share-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.share-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-share {
  background: rgba(160, 80, 255, 0.1);
  color: #b080ff;
  border: 1px solid rgba(160, 80, 255, 0.25);
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.btn-share:hover {
  background: rgba(160, 80, 255, 0.2);
  border-color: #a050ff;
  color: #c8a0ff;
  box-shadow: 0 0 10px rgba(160, 80, 255, 0.2);
}
.btn-share.copied {
  background: rgba(64, 192, 64, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.share-modal-content {
  min-width: 300px;
}
