/* Fouriele player — ported from Fouriele game interface design */

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

body.fouriele-game {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1419;
  color: #e2e8f0;
  min-height: 100dvh;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* Background — animated sine waves (waves-bg.js) */
.wave-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.wave-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Layout shell — balanced size, centered in viewport */
.game-shell {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 0 auto;
  padding: 0.35rem 1.25rem 1.25rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.game-nav {
  position: absolute;
  top: 0.5rem;
  right: 1.25rem;
  left: 1.25rem;
  width: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 0;
  flex-shrink: 0;
  z-index: 2;
}

.nav-back {
  margin-right: auto;
}

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

.nav-link {
  color: rgba(203, 213, 225, 0.75);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: #f1f5f9;
}

.nav-link-accent {
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

/* User menu */
.user-menu {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.user-menu-btn:hover {
  border-color: rgba(203, 213, 225, 0.5);
  background: rgba(30, 41, 59, 0.85);
}

.user-menu-chevron {
  font-size: 0.65rem;
  opacity: 0.7;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 10rem;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  z-index: 100;
}

.user-menu-dropdown a {
  display: block;
  padding: 0.65rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.user-menu-dropdown a:hover,
.user-menu-dropdown a.active {
  background: rgba(51, 65, 85, 0.8);
  color: #f1f5f9;
}

/* Guest banner */
.guest-banner {
  margin-top: 0.4rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: rgba(148, 163, 184, 0.95);
  text-align: center;
  line-height: 1.5;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 0.75rem;
}

.guest-banner a {
  color: #e2e8f0;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.guest-banner a:hover {
  color: #fff;
}

.guest-stats-note {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.85);
  margin-top: 0.5rem;
}

.game-header {
  text-align: center;
  margin-top: 0;
  margin-bottom: 0.85rem;
  padding-top: 0.15rem;
  flex-shrink: 0;
  width: 100%;
}

.game-title {
  font-size: clamp(3.25rem, 14vw, 5.25rem);
  font-weight: 800;
  background: linear-gradient(to right, #f3f4f6, #9ca3af, #6b7280);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.04em;
  line-height: 1;
}

.game-subtitle {
  margin-top: 0.4rem;
  color: rgba(148, 163, 184, 0.85);
  font-size: 1rem;
}

/* Player */
.player-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-top: auto;
  margin-bottom: 0;
  flex-shrink: 0;
}

.player-stage {
  position: relative;
  width: min(15rem, 48vw);
  height: min(15rem, 48vw);
  flex-shrink: 0;
  filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.22));
}

.frequency-rings {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.frequency-rings path.ring-path {
  fill: none;
  stroke-width: 2;
  transform-origin: 150px 150px;
  animation: ring-spin 24s linear infinite;
}

@keyframes ring-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.player-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-center-disc {
  width: 6.25rem;
  height: 6.25rem;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(30, 41, 59, 0.88));
  backdrop-filter: blur(8px);
  border: 2px solid rgba(107, 114, 128, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.center-play-btn {
  width: 4rem;
  height: 4rem;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #4b5563, #374151);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.center-play-btn:hover {
  background: linear-gradient(145deg, #6b7280, #4b5563);
  transform: scale(1.06);
}

.center-play-btn:active {
  transform: scale(0.96);
}

.center-play-btn svg {
  width: 28px;
  height: 28px;
}

/* Tier + score on one row below the circle */
.player-meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0;
  min-height: 0;
}

.tier-label {
  font-size: 0.75rem;
  color: rgba(203, 213, 225, 0.9);
  text-align: center;
  margin: 0;
  line-height: 1.3;
  max-width: 14rem;
}

.score-badge {
  position: static;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(156, 163, 175, 0.35);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  color: #d1d5db;
  white-space: nowrap;
  flex-shrink: 0;
}

.score-divider,
.score-max {
  color: rgba(148, 163, 184, 0.7);
}

.btn-reveal {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #cbd5e1;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  margin-top: 0.35rem;
}

.btn-reveal:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.5);
  border-color: rgba(203, 213, 225, 0.5);
}

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

/* Guess form */
.guess-section {
  width: 100%;
  max-width: 28rem;
  flex-shrink: 0;
  margin-top: 2.25rem;
}

.guess-form {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  width: 100%;
}

.search-container {
  position: relative;
  width: 100%;
}

#songGuess {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  border: 2px solid rgba(156, 163, 175, 0.3);
  border-radius: 0.85rem;
  color: #f8fafc;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#songGuess::placeholder {
  color: rgba(148, 163, 184, 0.5);
}

#songGuess:focus {
  border-color: rgba(203, 213, 225, 0.55);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.15);
}

.search-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  max-height: 140px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.search-suggestion-item {
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

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

.search-suggestion-item:hover,
.search-suggestion-item.selected {
  background: rgba(51, 65, 85, 0.8);
}

.suggestion-title {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.9rem;
}

.suggestion-artist {
  color: #94a3b8;
  font-size: 0.8rem;
}

.suggestion-album {
  color: #64748b;
  font-size: 0.75rem;
}

.btn-submit {
  width: 100%;
  padding: 0.75rem 1.15rem;
  border: none;
  border-radius: 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(to right, #4b5563, #374151);
  box-shadow: 0 8px 24px rgba(75, 85, 99, 0.35);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-submit:hover:not(:disabled) {
  background: linear-gradient(to right, #6b7280, #4b5563);
  transform: scale(1.01);
  box-shadow: 0 10px 28px rgba(107, 114, 128, 0.4);
}

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

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

/* Results */
.results-section {
  width: 100%;
  max-width: 24rem;
  text-align: center;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 0.65rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  flex-shrink: 0;
}

.result-message p {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.correct-answer {
  margin-top: 0.25rem;
  color: #94a3b8;
  font-size: 0.8rem;
}

.game-hint {
  margin-top: 0.85rem;
  margin-bottom: auto;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.6);
  max-width: 26rem;
  line-height: 1.45;
  flex-shrink: 0;
}

.no-song {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
}

.audio-sources {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Stats block */
.user-stats-section {
  width: 100%;
  max-width: 24rem;
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 0.65rem;
  flex-shrink: 0;
}

.stats-heading {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: #e2e8f0;
}

.already-played-message {
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  margin-bottom: 0.4rem;
  color: #fcd34d;
  font-size: 0.75rem;
}

.average-score-card {
  text-align: center;
  margin-bottom: 0.5rem;
}

.average-score-card small {
  font-size: 0.7rem;
}

.average-score-label {
  display: block;
  color: #94a3b8;
  font-size: 0.7rem;
}

.average-score-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f1f5f9;
}

.points-distribution h4 {
  text-align: center;
  margin-bottom: 0.4rem;
  color: #cbd5e1;
  font-size: 0.75rem;
}

.bar-graph {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.25rem;
  height: 72px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.bar-label,
.bar-count {
  font-size: 0.7rem;
  color: #94a3b8;
}

.bar-container {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar {
  width: 70%;
  min-height: 2px;
  background: linear-gradient(to top, #4b5563, #9ca3af);
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
}

/* Short viewports — scale down slightly */
@media (max-height: 720px) {
  .game-shell {
    justify-content: flex-start;
    padding-top: 0.5rem;
  }

  .game-header {
    margin-bottom: 0.5rem;
  }

  .game-title {
    font-size: clamp(2.75rem, 11vw, 3.75rem);
  }

  .player-stage {
    width: min(12.5rem, 44vw);
    height: min(12.5rem, 44vw);
  }

  .player-section {
    margin-bottom: 0.65rem;
  }
}

@media (max-width: 480px) {
  .game-shell {
    padding: 0.4rem 0.75rem 0.5rem;
  }

  .nav-link-accent {
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
  }
}

/* When stats are visible, drop vertical centering on play block */
.game-shell:has(.user-stats-section[style*='block']) .player-section,
.game-shell:has(.user-stats-section[style*='block']) .game-hint {
  margin-top: 0;
  margin-bottom: 0;
}
