:root {
  --bg: #180D17;
  --bg-2: #21121F;
  --surface: #2A1826;
  --surface-2: #3B2235;
  --border: rgba(245, 239, 230, 0.1);
  --accent: #F2B84B;
  --accent-dim: #C99A44;
  --miss: #D65D6E;
  --success: #7FCB9C;
  --text: #F5EFE6;
  --text-dim: #BFAEB6;
  --text-faint: #8B7A82;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", sans-serif;
}

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

html, body {
  background: radial-gradient(ellipse 120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 60px;
  position: relative;
  overflow-x: hidden;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* EN-TÊTE */

.top-bar {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 4px;
  z-index: 2;
}

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

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.18);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 7px 16px;
}

.score-label {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 600;
}

.score-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

main {
  width: 100%;
  max-width: 640px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view.hidden { display: none; }

/* ÉCRAN CATÉGORIES */

#view-categories {
  width: 100%;
  text-align: center;
  padding-top: 40px;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.hero-sub {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 420px;
  margin: 18px auto 40px;
  line-height: 1.6;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  width: 100%;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, background 0.2s ease;
}

.category-card:hover {
  transform: translateY(-3px);
  border-color: rgba(242, 184, 75, 0.4);
  background: var(--surface-2);
}

.category-icon { font-size: 30px; }

.category-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.category-count {
  font-size: 12px;
  color: var(--text-faint);
}

/* ÉCRAN DE JEU */

#view-game {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}

.btn-back {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  margin-bottom: 20px;
  transition: color 0.15s ease;
}
.btn-back:hover { color: var(--text); }

.player-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.play-button {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #211106;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 40px rgba(242, 184, 75, 0.28);
  transition: transform 0.15s ease;
}
.play-button:active { transform: scale(0.95); }
.play-button:disabled { opacity: 0.5; cursor: default; }

.play-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
}

.play-button.playing .play-ring {
  animation: pulse-ring 1.1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}

.icon-loading { display: none; animation: spin 0.9s linear infinite; }
.play-button.loading .icon-play { display: none; }
.play-button.loading .icon-loading { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.current-clip-length {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.session-progress {
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rounds-track {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 30px;
}

.round-segment {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.round-segment::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.round-segment.used::after { transform: scaleX(1); }
.round-segment.missed::after { background: var(--miss); }
.round-segment.current { background: var(--surface-2); box-shadow: 0 0 0 2px var(--accent); }

.guess-zone {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 460px;
  margin-bottom: 14px;
}

.guess-input-wrapper {
  position: relative;
  flex: 1;
}

.guess-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.guess-input:focus { border-color: var(--accent); }
.guess-input:disabled { opacity: 0.5; }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }

.autocomplete-item {
  padding: 11px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.1s ease;
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(242, 184, 75, 0.12);
}

.btn-guess {
  background: var(--accent);
  color: #211106;
  border: none;
  border-radius: 14px;
  padding: 0 22px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-guess:hover:not(:disabled) { transform: translateY(-1px); }
.btn-guess:disabled { opacity: 0.4; cursor: default; }

.btn-skip {
  background: none;
  border: none;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
  margin-bottom: 24px;
  transition: color 0.15s ease;
}
.btn-skip:hover:not(:disabled) { color: var(--text-dim); }
.btn-skip:disabled { opacity: 0.3; cursor: default; }

.guess-history {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 460px;
}

.guess-history li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.guess-history li .miss-icon {
  color: var(--miss);
  font-size: 15px;
  flex-shrink: 0;
}

/* ÉCRAN RÉSULTAT */

#view-result {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 50px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.result-status {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--success);
  margin-bottom: 18px;
}
.result-status.missed { color: var(--miss); }

.result-artwork {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  margin-bottom: 20px;
}

.result-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.3;
}

.result-artist {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}

.result-points {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--accent);
  margin: 22px 0 10px;
}

.result-session-total {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 26px;
}

.session-end-score {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 56px;
  color: var(--accent);
  line-height: 1;
  margin-top: 4px;
}

.session-end-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin: 10px 0 26px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-primary { background: var(--accent); color: #211106; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-primary:hover, .btn-secondary:hover { transform: translateY(-1px); }

/* TOAST */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #F5EFE6;
  color: #211106;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .guess-zone { flex-direction: column; }
  .btn-guess { padding: 14px; }
}
