@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Inter:wght@400;500;700&display=swap');

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --bg-dark: #0f172a;
  --bg-darker: #020617;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --secondary: #ec4899;
  
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
  font-family: var(--font-body);
  background: radial-gradient(circle at top, var(--bg-dark), var(--bg-darker));
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
}

button {
  font-family: var(--font-heading);
  cursor: pointer;
  outline: none;
  border: none;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
  box-shadow: var(--glass-shadow);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 20px rgba(236, 72, 153, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
}

.animate-pulse-alert {
  animation: pulse 2s infinite;
}

/* === APP CSS === */

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
}

.title {
  font-size: 3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2rem;
  text-align: center;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.setup-screen {
  width: 100%;
  max-width: 800px;
  padding: 2.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.control-group h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.counter {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover:not(:disabled) {
  background: var(--primary);
  transform: scale(1.1);
}

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

.count-display {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 40px;
  text-align: center;
}

.roles-section {
  margin-top: 2rem;
}

.roles-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-btn {
  background: var(--secondary);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.info-btn:hover {
  transform: scale(1.1) rotate(10deg);
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.role-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.75rem;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.role-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.role-card.selected {
  background: rgba(139, 92, 246, 0.3);
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.5);
}

.btn-primary {
  width: 100%;
  padding: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
  transition: all 0.3s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  transition: color 0.2s;
}

.close-btn:hover {
  color: white;
}

.role-desc {
  margin-bottom: 1.5rem;
}
.role-desc h4 {
  color: var(--primary);
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}
.role-desc p {
  color: var(--text-muted);
  line-height: 1.5;
}

/* Reveal Screen */
.reveal-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  height: 70vh;
}

.player-title {
  font-size: 2.5rem;
  margin-bottom: 2rem;
}

.flip-card {
  background-color: transparent;
  width: min(95vw, 450px, calc(60vh * 0.8));
  aspect-ratio: 4 / 5;
  perspective: 1000px;
  cursor: pointer;
  margin-bottom: 2rem;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
}

.flip-card-front {
  background: linear-gradient(135deg, #1e293b, #0f172a);
}
.flip-card-front::after {
  content: '?';
  font-size: 5rem;
  color: rgba(255,255,255,0.1);
  position: absolute;
}
.flip-card-front p {
  font-size: 1.5rem;
  color: var(--text-muted);
  z-index: 1;
}

.flip-card-back {
  background: var(--bg-dark);
  transform: rotateY(180deg);
  overflow: hidden;
}

.role-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.85;
}

.role-name-overlay {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 1.5rem;
  background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
  font-size: 2rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Timer Screen */
.timer-screen {
  text-align: center;
}

.timer-circle {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 8px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 3rem auto;
  font-size: 5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  background: rgba(0,0,0,0.2);
  box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 0 30px rgba(139, 92, 246, 0.2);
  transition: all 0.3s;
}

.timer-circle.finished {
  border-color: var(--secondary);
  color: var(--secondary);
  box-shadow: inset 0 0 50px rgba(236, 72, 153, 0.2), 0 0 50px rgba(236, 72, 153, 0.5);
}

.vote-alert {
  font-size: 4rem;
  font-weight: 800;
  color: var(--secondary);
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.timer-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-secondary {
  padding: 1rem 2rem;
  font-size: 1.25rem;
  font-weight: 700;
  background: rgba(255,255,255,0.1);
  color: white;
  border-radius: 0.75rem;
  border: 1px solid rgba(255,255,255,0.2);
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  .app-container {
    padding: 1rem;
  }
  
  .title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
  }
  
  .setup-screen {
    padding: 1.5rem;
  }
  
  .control-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .roles-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  
  .timer-circle {
    width: 200px;
    height: 200px;
    font-size: 3.5rem;
  }
  
  .vote-alert {
    font-size: 2.5rem;
  }
  
  .timer-controls {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-secondary, .btn-primary {
    width: 100%;
  }
}
