/* ==========================================================================
   GIRALETRAS - DESIGN SYSTEM & STYLES
   ========================================================================== */

:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.4);

  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-yellow: #f59e0b;

  --color-available: #10b981;
  --color-used: #475569;
  --color-danger: #ef4444;

  --font-title: 'Fredoka', cursive, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-main: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --transition-fast: 0.2s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.15) 0%, transparent 40%);
}

.app-container {
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* --- HEADER --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.8rem;
  animation: spinSlow 20s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.logo-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  letter-spacing: 1px;
}

.logo-title .highlight {
  color: var(--accent-cyan);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.05);
}

/* --- SCREENS --- */
.screen {
  display: none;
  flex: 1;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- BUTTONS & INPUTS --- */
.btn {
  font-family: var(--font-title);
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

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

.btn-secondary {
  background: var(--accent-cyan);
  color: #0f172a;
}

.btn-secondary:hover:not(:disabled) {
  background: #22d3ee;
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.2rem;
}

.btn-xl {
  padding: 18px 36px;
  font-size: 1.4rem;
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 20px;
}

.form-group label {
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"], select.form-control {
  background: var(--bg-dark);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: var(--transition-fast);
}

input[type="text"]:focus, select.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* --- TELA LANDING --- */
.hero-card {
  background: var(--bg-card);
  padding: 36px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-main);
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.hero-card h2 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.hero-card .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 8px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
  padding: 0 10px;
}

.join-box {
  display: flex;
  gap: 8px;
}

.join-box input {
  flex: 1;
  text-align: center;
  font-weight: 700;
  letter-spacing: 2px;
}

/* --- TELA LOBBY --- */
.lobby-card {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-main);
  width: 100%;
  max-width: 640px;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 24px;
}

.lobby-header h2 {
  font-family: var(--font-title);
  font-size: 1.6rem;
}

.room-code-badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.room-code-badge strong {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--accent-yellow);
  letter-spacing: 2px;
}

.lobby-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

.players-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.player-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-item .avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.player-item .player-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-item .tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.settings-panel {
  background: rgba(0, 0, 0, 0.2);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-panel h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  font-family: var(--font-title);
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.setting-item:last-child {
  margin-bottom: 0;
}

.lobby-actions {
  margin-top: 28px;
  text-align: center;
}

.hint-text {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- TELA DO JOGO (GAME LAYOUT) --- */
.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  width: 100%;
  max-width: 1100px;
}

.sidebar-scoreboard {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  height: min-content;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.sidebar-header h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
}

.badge-round {
  background: var(--accent-cyan);
  color: #0f172a;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
}

.scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.score-card.active-turn {
  border-color: var(--accent-yellow);
  background: rgba(245, 158, 11, 0.1);
}

.score-card.eliminated {
  opacity: 0.4;
  filter: grayscale(1);
}

.score-card .player-details {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-card .pts {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--accent-yellow);
}

.game-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.turn-banner {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 28px;
  border-radius: var(--radius-full);
  margin-bottom: 20px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.turn-banner .turn-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.turn-banner strong {
  font-family: var(--font-title);
  font-size: 1.3rem;
  color: var(--accent-cyan);
}

/* --- TECLADO CIRCULAR --- */
.circular-keyboard-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circular-keyboard {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, var(--bg-card) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-main), inset 0 0 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.keyboard-center {
  position: absolute;
  width: 50%;
  height: 50%;
  border-radius: var(--radius-full);
  background: var(--bg-dark);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  z-index: 5;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.6);
}

.category-box {
  margin-bottom: 8px;
}

.category-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  display: block;
}

.category-text {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--accent-cyan);
  line-height: 1.2;
}

.timer-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.timer-display #timer-seconds {
  font-family: var(--font-title);
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--color-available);
  line-height: 1;
  transition: color 0.2s ease;
}

.timer-display.warning #timer-seconds {
  color: var(--color-danger);
  animation: pulseWarning 0.5s infinite alternate;
}

@keyframes pulseWarning {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

.timer-display small {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-left: 2px;
}

/* CONTÊINER DAS LETRAS */
.letters-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.letter-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, #2a384c, #1e293b);
  color: var(--text-main);
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  transition: all var(--transition-fast);
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.letter-btn:hover:not(:disabled):not(.used) {
  background: var(--primary);
  border-color: white;
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 15px var(--primary-glow);
  z-index: 10;
}

.letter-btn.used {
  background: var(--color-used);
  border-color: transparent;
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
  transform: translate(-50%, -50%) scale(0.9);
}

.letter-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* --- MODAL --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-main);
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.modal-card h2 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--accent-yellow);
  margin-bottom: 8px;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.modal-scoreboard {
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.modal-scoreboard h3 {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.modal-scores-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* --- TOASTS --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--primary);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-main);
  font-weight: 500;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- RESPONSIVIDADE --- */
@media (max-width: 850px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-scoreboard {
    order: 2;
  }

  .game-main {
    order: 1;
  }

  .circular-keyboard-wrapper {
    max-width: 360px;
  }

  .letter-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .timer-display #timer-seconds {
    font-size: 2.4rem;
  }

  .category-text {
    font-size: 0.95rem;
  }
}

@media (max-width: 480px) {
  .app-container {
    padding: 8px;
  }

  .hero-card, .lobby-card, .modal-card {
    padding: 20px;
  }

  .circular-keyboard-wrapper {
    max-width: 320px;
  }

  .letter-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
}
