/* Colour Battle - Flashy Styles */

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

:root {
  --bg-colour: #228B22;
  --panel-bg: rgba(255, 255, 255, 0.95);
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --success: #10b981;
  --error: #ef4444;
  --border: #e0e0e0;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Animated Background */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-colour);
  transition: background-color 1s ease;
  z-index: -1;
}

.background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(0,0,0,0.05) 0%, transparent 50%);
  animation: shimmer 8s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Swirling Lobby Background */
.background.lobby-mode {
  background: linear-gradient(-45deg,
    #ee7752, #e73c7e, #23a6d5, #23d5ab,
    #f093fb, #f5576c, #4facfe, #00f2fe,
    #667eea, #764ba2, #f093fb, #ee7752);
  background-size: 400% 400%;
  animation: gradient-swirl 15s ease infinite;
}

.background.lobby-mode::before {
  background:
    radial-gradient(circle at 30% 70%, rgba(255,255,255,0.3) 0%, transparent 40%),
    radial-gradient(circle at 70% 30%, rgba(255,255,255,0.2) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(0,0,0,0.1) 0%, transparent 60%);
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes gradient-swirl {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 100%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

/* Main Game Panel */
.game-panel {
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
}

.screen {
  background: var(--panel-bg);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.5);
  position: relative;
  overflow: hidden;
}

/* Removed decorative top strip */

.screen.hidden {
  display: none;
}

/* Float animation for header logo */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.header-logo {
  animation: float 3s ease-in-out infinite;
}

/* Lobby Screen */
#lobby-screen h1 {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #6366f1, #ec4899, #f59e0b);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1rem;
  font-weight: 500;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.section.hidden {
  display: none;
}

input[type="text"] {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: #fafafa;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

input[type="text"]::placeholder {
  color: #9ca3af;
}

.primary-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  background: var(--gradient-1);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Waiting Animation */
.waiting-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 1.5rem auto;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid var(--accent);
  border-radius: 50%;
  animation: pulse-ring 1.5s ease-out infinite;
}

.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 4px solid transparent;
  border-top-color: #ec4899;
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

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

.pulse-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  background: var(--gradient-1);
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.waiting-text {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.link-box {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}

.link-box input {
  flex: 1;
  font-size: 0.85rem;
  background: #f3f4f6;
  border-color: #e5e7eb;
}

.copy-btn {
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 12px;
  background: var(--gradient-1);
  color: white;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.join-text {
  font-size: 1.2rem;
  color: var(--text-primary);
  text-align: center;
  font-weight: 600;
}

/* Player Bar */
.player-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 16px;
  border: 1px solid #e2e8f0;
}

.player-bar .player-name {
  font-weight: 700;
  padding: 0.5rem 1.25rem;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  border-radius: 20px;
  font-size: 0.95rem;
  transition: all 0.4s ease;
}

.player-bar .player-name.active {
  background: var(--gradient-1);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
  transform: scale(1.08);
}

.vs-badge {
  font-weight: 800;
  font-size: 0.8rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Playing Screen */
.game-status {
  text-align: center;
  margin-bottom: 1.5rem;
}

.turn-indicator {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding: 0.5rem;
}

.turn-indicator.your-turn {
  color: var(--success);
  animation: glow-green 2s ease-in-out infinite;
}

@keyframes glow-green {
  0%, 100% { text-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
  50% { text-shadow: 0 0 20px rgba(16, 185, 129, 0.6); }
}

.turn-indicator.opponent-turn {
  color: var(--text-secondary);
}

.last-played {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.last-played.hidden {
  display: none;
}

.last-played .label {
  color: var(--text-secondary);
  font-weight: 500;
}

.last-played .colour-name {
  font-weight: 700;
  text-transform: capitalize;
  font-size: 1.1rem;
}

.colour-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Play Area */
.play-area {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.autocomplete-container {
  flex: 1;
  position: relative;
}

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: white;
  border: 2px solid var(--accent);
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 50;
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.autocomplete-option:hover,
.autocomplete-option.selected {
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
}

.autocomplete-option .swatch {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.autocomplete-option .name {
  flex: 1;
  text-transform: capitalize;
  font-weight: 600;
  font-size: 1rem;
}

.play-area .primary-btn {
  width: auto;
  padding: 1rem 2rem;
}

/* Move History */
.move-history-container {
  margin-top: 1.5rem;
}

.move-history-container h3 {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.move-history {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
}

.move-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s;
}

.move-item:hover {
  background: #f8fafc;
}

.move-item:last-child {
  border-bottom: none;
}

.move-item .move-number {
  font-size: 0.75rem;
  color: #9ca3af;
  min-width: 24px;
  font-weight: 600;
}

.move-item .move-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.move-item .move-colour {
  flex: 1;
  text-transform: capitalize;
  font-weight: 600;
}

.move-item .move-player {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Game Over Screen */
.result-display {
  text-align: center;
  padding: 2rem 1rem;
  margin-bottom: 1.5rem;
}

.result-display h2 {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.result-display.winner h2 {
  background: linear-gradient(135deg, #10b981, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: winner-pulse 1s ease-in-out infinite;
}

@keyframes winner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.result-display.loser h2 {
  color: var(--error);
}

.result-display p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
}

/* Win/Loss Animations */
@keyframes celebrate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-3deg); }
  75% { transform: scale(1.1) rotate(3deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

.result-display.winner {
  animation: celebrate 0.8s ease-in-out;
}

.result-display.loser {
  animation: shake 0.6s ease-in-out;
}

/* Druid Overlay */
.druid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.druid-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.druid-scene {
  text-align: center;
  position: relative;
}

.druid-figure {
  position: relative;
  width: 150px;
  height: 240px;
  margin: 0 auto 2rem;
  animation: druid-sway 3s ease-in-out infinite;
}

@keyframes druid-sway {
  0%, 100% { transform: rotate(-1deg); }
  50% { transform: rotate(1deg); }
}

.druid-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.6))
          drop-shadow(0 0 40px rgba(124, 58, 237, 0.4));
  animation: head-glow 2s ease-in-out infinite;
  z-index: 2;
}

@keyframes head-glow {
  0%, 100% {
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.6))
            drop-shadow(0 0 40px rgba(124, 58, 237, 0.4));
  }
  50% {
    filter: drop-shadow(0 0 30px rgba(196, 181, 253, 0.8))
            drop-shadow(0 0 60px rgba(167, 139, 250, 0.6));
  }
}

.druid-robe {
  position: absolute;
  top: 95px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 150px;
  background: linear-gradient(180deg, #2d1b4e 0%, #1a0f2e 50%, #0f0720 100%);
  clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 1;
}

.druid-robe::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 35px;
  height: 90px;
  background: linear-gradient(180deg, #4c1d95 0%, #2d1b4e 100%);
  opacity: 0.5;
}

.druid-staff {
  position: absolute;
  top: 60px;
  right: 5px;
  width: 10px;
  height: 190px;
  background: linear-gradient(180deg, #92400e 0%, #78350f 50%, #451a03 100%);
  border-radius: 5px;
  transform: rotate(15deg);
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  z-index: 0;
}

.druid-staff::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 25px;
  height: 25px;
  background: radial-gradient(circle, #c4b5fd 0%, #7c3aed 50%, #4c1d95 100%);
  border-radius: 50%;
  box-shadow: 0 0 20px #a78bfa, 0 0 40px #7c3aed;
  animation: staff-glow 1.5s ease-in-out infinite;
}

@keyframes staff-glow {
  0%, 100% {
    box-shadow: 0 0 20px #a78bfa, 0 0 40px #7c3aed;
    transform: translateX(-50%) scale(1);
  }
  50% {
    box-shadow: 0 0 35px #c4b5fd, 0 0 60px #a78bfa;
    transform: translateX(-50%) scale(1.15);
  }
}

.mystical-orbs {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  opacity: 0.6;
}

.orb-1 {
  width: 20px;
  height: 20px;
  background: #f472b6;
  box-shadow: 0 0 20px #f472b6;
  top: 20%;
  left: 10%;
  animation: orb-float 4s ease-in-out infinite;
}

.orb-2 {
  width: 15px;
  height: 15px;
  background: #60a5fa;
  box-shadow: 0 0 15px #60a5fa;
  top: 30%;
  right: 15%;
  animation: orb-float 3s ease-in-out infinite 0.5s;
}

.orb-3 {
  width: 12px;
  height: 12px;
  background: #34d399;
  box-shadow: 0 0 12px #34d399;
  bottom: 30%;
  left: 20%;
  animation: orb-float 3.5s ease-in-out infinite 1s;
}

@keyframes orb-float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
    opacity: 0.8;
  }
}

.druid-message {
  color: white;
  font-size: 1.3rem;
  font-weight: 600;
  text-shadow: 0 0 20px rgba(167, 139, 250, 0.5);
  animation: message-pulse 2s ease-in-out infinite;
}

.druid-message p {
  margin: 0;
}

@keyframes message-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 1rem 2rem;
  background: var(--text-primary);
  color: white;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 200;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(30px) scale(0.9);
  pointer-events: none;
}

.toast.success {
  background: linear-gradient(135deg, #10b981, #059669);
}

.toast.error {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Site Header with Baldo Link */
.site-header {
  width: 100%;
  text-align: center;
  margin-bottom: 1rem;
}

.baldo-link {
  display: inline-block;
  transition: transform 0.3s ease;
}

.baldo-link:hover {
  transform: scale(1.1);
}

.header-logo {
  width: 100px;
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
  transition: filter 0.3s ease;
}

.baldo-link:hover .header-logo {
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4));
}

/* Responsive */
@media (max-width: 600px) {
  .game-panel {
    padding: 1rem;
  }

  .screen {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .header-logo {
    width: 80px;
  }

  #lobby-screen h1 {
    font-size: 2rem;
  }

  .play-area {
    flex-direction: column;
  }

  .play-area .primary-btn {
    width: 100%;
  }

  .result-display h2 {
    font-size: 2rem;
  }

  .player-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .player-bar .player-name {
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
  }

  .druid-figure {
    transform: scale(0.8);
  }

  .druid-message {
    font-size: 1.1rem;
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .header-logo {
    width: 70px;
  }

  .screen {
    padding: 1.5rem 1rem;
  }

  #lobby-screen h1 {
    font-size: 1.75rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .primary-btn, .secondary-btn {
    padding: 0.9rem 1.5rem;
    font-size: 0.95rem;
  }

  .druid-figure {
    transform: scale(0.65);
  }
}

/* Scrollbar styling */
.move-history::-webkit-scrollbar,
.autocomplete-dropdown::-webkit-scrollbar {
  width: 6px;
}

.move-history::-webkit-scrollbar-track,
.autocomplete-dropdown::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.move-history::-webkit-scrollbar-thumb,
.autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  border-radius: 3px;
}

.move-history::-webkit-scrollbar-thumb:hover,
.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

/* Local Mode */
.local-hint {
  background: linear-gradient(135deg, #dbeafe, #e0e7ff);
  color: #4338ca;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: #9ca3af;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, #e5e7eb, transparent);
}

.divider span {
  padding: 0 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Secondary Button */
.secondary-btn {
  width: 100%;
  padding: 1rem 1.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: white;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.secondary-btn:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, #fafafa, #f0f0ff);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}
