/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; } /* garante ocultar também elementos SVG */

:root {
  --bg: #121212;
  --bg-elev: #1c1c1e;
  --bg-elev2: #242427;
  --line: #2c2c30;
  --line-soft: #3a3a3f;
  --text: #f2f2f4;
  --text-dim: #9a9aa2;
  --text-faint: #6c6c74;
  --green: #2ecc5f;
  --green-deep: #23a94d;
  --red: #e2453b;
  --yellow: #e6b32a;
  --skip: #3a3a40;
  --radius: 12px;
  --maxw: 560px;
  --shadow: 0 12px 40px rgba(0,0,0,.55);
}

html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1f1f24 0%, rgba(31,31,36,0) 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  width: 100%;
  max-width: var(--maxw);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 16px 6px;
}
.brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-align: center;
  user-select: none;
}
.brand span { color: var(--green); }
.topbar-right { display: flex; justify-content: flex-end; gap: 6px; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-elev); color: var(--text); }
.topbar-spacer { justify-self: start; }

/* ---------- Game layout ---------- */
.game {
  width: 100%;
  max-width: var(--maxw);
  padding: 8px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.mode-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.seg {
  display: inline-flex;
  align-items: center;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background .18s, color .18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--bg-elev2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }

/* Título visível (rota de gênero) ou só para leitores de tela (home) —
   cada página passa a ter um <h1> real e único, sem depender só da marca. */
.page-heading {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.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;
}

/* Abas de gênero: a lista é dinâmica (vem do banco) e pode não caber na tela —
   rola horizontalmente em vez de espremer ou cortar os rótulos. */
#genre-tabs {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#genre-tabs::-webkit-scrollbar { display: none; }

/* ---------- Guess rows ---------- */
.guesses { display: flex; flex-direction: column; gap: 8px; }
.guess-slot {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--text);
  transition: border-color .18s, background .18s, transform .1s;
}
.guess-slot.current {
  border-color: var(--line-soft);
  box-shadow: 0 0 0 1px var(--line-soft) inset;
}
.guess-slot.filled { justify-content: space-between; gap: 10px; }
.guess-slot .g-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-slot .g-text b { font-weight: 700; }
.guess-slot .g-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; opacity: .85; flex-shrink: 0;
}
.guess-slot.skip { background: #2a2a2e; color: var(--text-dim); justify-content: center; font-weight: 600; }
.guess-slot.wrong  { background: rgba(226,69,59,.16);  border-color: rgba(226,69,59,.5); }
.guess-slot.artist { background: rgba(230,179,42,.15);  border-color: rgba(230,179,42,.5); }
.guess-slot.correct{ background: rgba(46,204,95,.18);   border-color: rgba(46,204,95,.6); }
.guess-slot.wrong .g-tag  { color: #ff8078; }
.guess-slot.artist .g-tag { color: #f2ca57; }
.guess-slot.correct .g-tag{ color: #6ee89a; }

/* ---------- Player ---------- */
.player { display: flex; flex-direction: column; align-items: center; gap: 16px; }

.track-wrap { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.track-label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.track-label #clip-label { color: var(--text); white-space: nowrap; }
.clip-pointer-row { position: relative; height: 8px; }
.clip-pointer {
  position: absolute; top: 0;
  left: calc(var(--clip-pos, 0) * 1%);
  transform: translateX(-50%);
  transition: left .35s ease;
}
.clip-pointer::after {
  content: "▾"; display: block; text-align: center;
  font-size: 11px; line-height: .6; color: var(--text-faint);
}
.track {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
}
.track-fill {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #34343a, #45454c);
  width: 0%;
  transition: width .35s ease;
}
.track-progress {
  position: absolute; top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  width: 0%;
}
.track-marker {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--text);
  left: 0%;
  opacity: .0;
}
.track-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-faint); }

.play-btn {
  width: 66px; height: 66px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, var(--green), var(--green-deep));
  color: #06210f;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(46,204,95,.35);
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn:active { transform: scale(.97); }
.play-btn .ic-play { margin-left: 3px; }
.play-btn.loading { filter: saturate(.4) brightness(.9); cursor: progress; }
.play-btn .ic-load { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Guess input ---------- */
.guess-row { width: 100%; display: flex; gap: 8px; }
.search-wrap { position: relative; flex: 1; }
.search-ic {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
#search {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 13px 36px 13px 38px;
  font-size: 15px;
  transition: border-color .15s, background .15s;
}
#search::placeholder { color: var(--text-faint); }
#search:focus { border-color: var(--line-soft); background: var(--bg-elev2); }
.clear-search {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--text-faint);
  font-size: 22px; line-height: 1; width: 28px; height: 28px; border-radius: 50%;
}
.clear-search:hover { color: var(--text); background: var(--bg-elev2); }

.suggestions {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-elev2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: var(--shadow);
  z-index: 20;
  display: none;
}
.suggestions.open { display: block; }
.suggestions li {
  padding: 11px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex; gap: 8px; align-items: baseline;
}
.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover, .suggestions li.active { background: var(--bg-elev); }
.suggestions li .s-title { color: var(--text); }
.suggestions li .s-artist { color: var(--text-dim); font-weight: 600; }
.suggestions li .s-artist::before { content: "— "; color: var(--text-faint); font-weight: 400; }

.skip-btn {
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0 18px;
  font-weight: 700;
  font-size: 14px;
  min-width: 84px;
  transition: background .15s, border-color .15s;
}
.skip-btn:hover { background: #303035; }

.submit-btn {
  width: 100%;
  background: linear-gradient(180deg, var(--green), var(--green-deep));
  color: #06210f;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  transition: opacity .15s, filter .15s, transform .1s;
}
.submit-btn:hover:not(:disabled) { filter: brightness(1.05); }
.submit-btn:active:not(:disabled) { transform: scale(.99); }
.submit-btn:disabled { opacity: .4; cursor: not-allowed; background: var(--bg-elev2); color: var(--text-dim); }

/* ---------- Revelar dica ---------- */
.hint-area { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hint-display { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.hint-display:empty { display: none; }
.hint-chip {
  background: var(--bg-elev); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--text-dim);
}
.hint-chip b { color: var(--text); font-weight: 800; }
.hint-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elev2); border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 700;
  transition: background .15s, color .15s, opacity .15s;
}
.hint-btn:hover:not(:disabled) { background: var(--line); color: var(--text); }
.hint-btn:disabled { opacity: .5; cursor: default; }
.hint-btn svg { color: var(--yellow); flex-shrink: 0; }

/* ---------- Overlays / modais ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.66);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fade .18s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 26px 24px 24px;
  box-shadow: var(--shadow);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 24px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.modal-sub { text-align: center; color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: none; color: var(--text-dim);
  font-size: 26px; line-height: 1; width: 34px; height: 34px; border-radius: 50%;
}
.modal-close:hover { background: var(--bg-elev2); color: var(--text); }
.modal-foot { text-align: center; color: var(--text-dim); font-size: 14px; margin-top: 18px; }

/* Como jogar */
.howto-track { display: flex; gap: 4px; margin: 0 0 18px; }
.seg-demo { flex: 1; height: 10px; border-radius: 4px; background: var(--bg-elev2); border: 1px solid var(--line); }
.seg-demo.on { background: var(--green); border-color: var(--green); }
.seg-demo.cur { background: var(--line-soft); }
.howto-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.howto-list li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text); }
.howto-list .dot { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.howto-list .dot.play { background: var(--green); color: #06210f; border-radius: 50%; }
.howto-list .dot.red { background: var(--red); }
.howto-list .dot.yellow { background: var(--yellow); }
.howto-list .dot.green { background: var(--green); }
.howto-list .chip { background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* Fim de jogo */
.modal.end { padding: 0; overflow: hidden; }
.end-close {
  z-index: 2; color: rgba(255,255,255,.85);
}
.end-close:hover { background: rgba(0,0,0,.2); color: #fff; }
.end-head { padding: 16px 44px; text-align: center; }
.end-head h2 { color: #fff; }
.end-head.win { background: linear-gradient(180deg, var(--green), var(--green-deep)); }
.end-head.lose { background: linear-gradient(180deg, #e2453b, #b83229); }
.end-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 18px; }
.song-reveal { display: flex; gap: 14px; align-items: center; }
.reveal-cover {
  width: 64px; height: 64px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-elev2) center/cover no-repeat;
  border: 1px solid var(--line);
}
.reveal-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reveal-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 700; }
.reveal-meta strong { font-size: 18px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reveal-artist { color: var(--text-dim); font-size: 14px; }

.dist { display: flex; flex-direction: column; gap: 8px; }
.dist-title { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); font-weight: 700; }
.dist-bars { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dist-row .dist-k { width: 14px; color: var(--text-dim); text-align: center; font-weight: 700; }
.dist-row .dist-bar-wrap { flex: 1; background: var(--bg-elev2); border-radius: 5px; overflow: hidden; height: 20px; }
.dist-row .dist-bar {
  height: 100%; min-width: 22px;
  background: var(--skip);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 7px; color: var(--text); font-size: 11px; font-weight: 700;
  transition: width .5s ease;
}
.dist-row.hit .dist-bar { background: var(--green); color: #06210f; }
.dist-row.loss .dist-k { color: var(--red); }

.end-stats { display: flex; justify-content: space-around; gap: 8px; text-align: center; }
.end-stats .es { display: flex; flex-direction: column; }
.end-stats .es b { font-size: 22px; font-weight: 800; }
.end-stats .es span { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; }

#full-audio { width: 100%; margin-top: 2px; }
.end-actions { display: flex; gap: 10px; }
.ghost-btn {
  flex: 1; background: var(--bg-elev2); border: 1px solid var(--line-soft); color: var(--text);
  border-radius: var(--radius); padding: 13px; font-weight: 700; font-size: 14px; transition: background .15s;
}
.ghost-btn:hover { background: #303035; }
.ghost-btn.small { flex: none; width: 100%; margin-top: 8px; font-size: 13px; padding: 10px; color: var(--text-dim); }
.primary-btn {
  flex: 1.4; background: linear-gradient(180deg, var(--green), var(--green-deep)); color: #06210f;
  border: none; border-radius: var(--radius); padding: 13px; font-weight: 800; font-size: 14px; transition: filter .15s;
}
.primary-btn:hover { filter: brightness(1.05); }
.danger-btn {
  flex: 1.4; background: linear-gradient(180deg, #e2453b, #b83229); color: #fff;
  border: none; border-radius: var(--radius); padding: 13px; font-weight: 800; font-size: 14px; transition: filter .15s;
}
.danger-btn:hover { filter: brightness(1.1); }
.danger-btn:disabled { opacity: .6; }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.end-timer { text-align: center; font-size: 12px; color: var(--text-faint); }

/* Estatísticas */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 22px; }
.stat-grid .es { text-align: center; }
.stat-grid .es b { font-size: 24px; font-weight: 800; display: block; }
.stat-grid .es span { font-size: 10.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; }

/* Aviso de recurso bloqueado (estatísticas/compartilhamento exigem login) */
.locked-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 22px 18px;
  margin-bottom: 22px;
  background: var(--bg-elev2);
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius);
  color: var(--text-dim);
}
.locked-note svg { color: var(--text-faint); }
.locked-note p { font-size: 13.5px; line-height: 1.4; max-width: 320px; }
.locked-note-link {
  display: inline-block;
  color: var(--bg);
  background: var(--green);
  font-weight: 800;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 999px;
  text-decoration: none;
  transition: background .15s;
}
.locked-note-link:hover { background: var(--green-deep); }

/* ---------- Perfil: cabeçalho da conta e histórico de atividade ---------- */
.acct-head {
  width: 100%; display: flex; align-items: center; gap: 14px;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.acct-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg-elev2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: var(--green);
  overflow: hidden;
}
.acct-avatar img { width: 100%; height: 100%; object-fit: cover; }
.acct-info { min-width: 0; flex: 1; }
.acct-info .acct-name { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-info .acct-email { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.history-card { width: 100%; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.history-row { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: none; }
.h-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.h-dot.win { background: var(--green); }
.h-dot.loss { background: var(--red); }
.h-main { min-width: 0; flex: 1; }
.h-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-artist { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-genre {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px;
  padding: 3px 8px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--line);
  color: var(--text-dim); flex-shrink: 0;
}
.h-score { text-align: right; flex-shrink: 0; width: 44px; }
.h-score b { display: block; font-size: 12.5px; font-weight: 800; }
.h-score .h-when { font-size: 10px; color: var(--text-faint); }
.history-empty { padding: 32px 16px; text-align: center; font-size: 13px; color: var(--text-dim); }

/* ---------- Trilhos de anúncio (AdSense) ---------- */
.ad-rail {
  position: fixed;
  top: 84px;
  width: 160px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ad-rail.left  { left:  calc(50% - (var(--maxw) / 2) - 200px); }
.ad-rail.right { right: calc(50% - (var(--maxw) / 2) - 200px); }
.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  user-select: none;
}
/* sem espaço para os trilhos: some, o jogo continua centralizado */
@media (max-width: 1100px) { .ad-rail { display: none !important; } }

/* Banner mobile: abaixo dos controles, separado por uma linha para não
   ser confundido com a interface do jogo (evita cliques acidentais). */
.ad-mobile {
  width: 100%;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-height: 60px;
}
.ad-mobile .adsbygoogle { display: block; width: 100%; }
/* em telas largas quem aparece são os trilhos laterais, não o banner */
@media (min-width: 1101px) { .ad-mobile { display: none !important; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #000; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 200; border: 1px solid var(--line-soft);
  box-shadow: var(--shadow); animation: toastin .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsivo ---------- */
@media (max-width: 480px) {
  .brand { font-size: 26px; }
  .seg { padding: 8px 12px; font-size: 13px; }
  .game { gap: 14px; padding-bottom: 28px; }
  .play-btn { width: 60px; height: 60px; }
}
@media (max-width: 380px) {
  #genre-tabs .seg { padding: 8px 14px; }
}
