/* ==========================================================================
   MusiQuiz — Tema Escuro Azul & Laranja (CSS3 Puro)
   Paleta: #012849 (Navy), #17617e (Ocean), #ff9412 (Orange), #e43100 (Vermilion)
   ========================================================================== */

:root {
  --bg-main: #01182d;
  --bg-surface: #012849;
  --bg-elevated: #0b3a60;
  --bg-hover: #17617e;
  --border-subtle: rgba(156, 214, 240, 0.14);
  --border-strong: rgba(156, 214, 240, 0.28);

  --text-primary: #f8fbff;
  --text-secondary: #a9cce0;
  --text-muted: #6c98b4;

  --accent: #ff9412;
  --accent-hover: #ffa83a;
  --accent-deep: #e43100;
  --accent-soft: rgba(255, 148, 18, 0.16);
  --accent-glow: rgba(255, 148, 18, 0.36);

  --ocean: #17617e;
  --ocean-bright: #38bdf8;
  --ocean-glow: rgba(56, 189, 248, 0.42);

  --danger: #e43100;
  --danger-soft: rgba(228, 49, 0, 0.18);
  --warning: #ff9412;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.45);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Shell Principal */
.app-shell {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 2rem;
}

/* Header */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo svg {
  display: block;
}

.brand-logo .eq-bar {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: eqPulse 2.2s ease-in-out infinite alternate;
  animation-delay: var(--d, 0s);
}

@keyframes eqPulse {
  0% { transform: scaleY(0.84); }
  100% { transform: scaleY(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .brand-logo .eq-bar {
    animation: none;
  }
}

.brand-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.edition-meta {
  margin: 0.1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-btn:focus-visible,
.btn:focus-visible,
.guess-input:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Main */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 1.25rem;
}

/* Banner de Erro */
.error-banner {
  background: var(--danger-soft);
  border: 1px solid rgba(228, 49, 0, 0.45);
  color: #ffd4d9;
  border-radius: var(--radius-md);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

.error-banner p {
  margin: 0;
}

/* Palco principal: Trecho da Letra */
.snippet-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 1.6rem 0.5rem 0.75rem;
  position: relative;
}

.snippet-card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  position: relative;
}

.finished-kicker {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.finished-kicker.danger {
  color: #ff9b80;
}

.attempt-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.snippet-quote {
  margin: 0.75rem 0 1.35rem;
  padding: 0;
  text-align: center;
  font-size: clamp(1.55rem, 4.5vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.32;
  color: var(--text-primary);
  position: relative;
}

.quote-mark {
  color: var(--accent);
  opacity: 0.9;
  font-weight: 900;
}

.skeleton-text {
  display: inline-block;
  color: var(--text-secondary);
  animation: pulseOpacity 1.4s ease-in-out infinite;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.dot {
  width: 28px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.25s ease, transform 0.25s ease;
}

.dot.current {
  background: rgba(255, 255, 255, 0.45);
}

.dot.wrong {
  background: var(--danger);
}

.dot.correct {
  background: var(--ocean-bright);
  box-shadow: 0 0 12px var(--ocean-glow);
}

/* Formulário de Palpite */
.guess-section {
  background: transparent;
  border: none;
  padding: 0;
}

.guess-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guess-input {
  width: 100%;
  padding: 0.88rem 1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.guess-input::placeholder {
  color: var(--text-muted);
}

.guess-input:focus {
  border-color: var(--accent);
  background: #0e4470;
}

.guess-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.82rem 1.35rem;
  border-radius: var(--radius-pill);
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn-sm {
  padding: 0.5rem 0.95rem;
  font-size: 0.84rem;
}

.btn-primary {
  background: var(--accent);
  color: #012849;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.form-feedback {
  margin: 0.55rem 0 0;
  min-height: 1.25rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
  text-align: center;
}

.form-feedback.error {
  color: #ff9b80;
}

.form-feedback.success {
  color: var(--accent-hover);
}

/* Banner de Fim de Jogo */
.finished-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.finished-banner.won {
  border-color: rgba(255, 148, 18, 0.5);
  background: var(--bg-surface);
}

.finished-banner.lost {
  border-color: rgba(228, 49, 0, 0.5);
  background: var(--bg-surface);
}

.finished-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.finished-song-title {
  margin: 0.25rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.finished-song-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Seções */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Dicas inline (dentro do card principal) */
.inline-hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1.25rem;
  position: relative;
}

.hint-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.44rem 0.9rem;
  border-radius: var(--radius-pill);
  background: rgba(23, 97, 126, 0.45);
  border: 1px solid rgba(156, 214, 240, 0.14);
  box-shadow: none;
}

.hint-pill.just-revealed {
  animation: revealHint 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.hint-pill-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.hint-pill-value {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Histórico de Tentativas */
.guess-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.72rem 0.95rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}

.history-item.empty {
  opacity: 0.45;
  border-style: dashed;
}

.history-item.wrong {
  border-color: rgba(228, 49, 0, 0.38);
  background: rgba(228, 49, 0, 0.11);
}

.history-item.correct {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(23, 97, 126, 0.35);
}

.history-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.history-index {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 1.25rem;
  flex-shrink: 0;
}

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

.history-text.muted {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 500;
}

.history-status {
  flex-shrink: 0;
  font-size: 0.95rem;
}

/* Footer */
.footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer p {
  margin: 0;
}

/* Modais */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: #02223f;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.modal-header {
  margin-bottom: 1.15rem;
  padding-right: 2rem;
}

.modal-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
}

.modal-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.modal-answer-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  margin-bottom: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-answer-box.lost {
  background: var(--bg-elevated);
  border-color: rgba(228, 49, 0, 0.45);
}

.modal-answer-kicker {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  font-weight: 700;
}

.modal-answer-title {
  font-size: 1.3rem;
  font-weight: 800;
}

.modal-answer-artist {
  font-size: 0.96rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.modal-answer-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.meta-pill {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.modal-squares {
  margin-top: 0.75rem;
  font-size: 1.25rem;
  letter-spacing: 0.18rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-number {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.modal-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.countdown-box {
  display: flex;
  flex-direction: column;
}

.countdown-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.countdown-time {
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Help Modal */
.help-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.help-body p {
  margin: 0 0 0.85rem;
}

.help-list {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--text-primary);
}

.help-note {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.84rem;
  margin-bottom: 0 !important;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #ffffff;
  color: #012849;
  padding: 0.72rem 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 200;
  animation: toastUp 0.24s ease;
}

/* Animações */
.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes revealHint {
  0% {
    opacity: 0.25;
    transform: translateY(8px) scale(0.97);
    box-shadow: 0 0 0 0 var(--accent-glow);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px) scale(1.015);
    box-shadow: 0 0 0 6px rgba(255, 148, 18, 0.18);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 0 rgba(255, 148, 18, 0);
  }
}

@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

@keyframes pulseOpacity {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.95; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastUp {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Responsivo */
@media (max-width: 520px) {
  .form-actions {
    grid-template-columns: 1fr;
  }

  .modal-footer-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
