/* TypeTheSong - stile pubblico: nero, linee bianche sottili, niente fronzoli */
:root {
  --bg: #000;
  --fg: #fff;
  --dim: rgba(255, 255, 255, 0.22);
  --mid: rgba(255, 255, 255, 0.5);
  --line: rgba(255, 255, 255, 0.2);
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fx: 0.6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font-family: var(--mono); font-weight: 300; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 1px solid var(--line); padding: 10px 18px; cursor: pointer; letter-spacing: 0.16em; font-size: 12px; text-transform: uppercase; }
button:hover, button:focus-visible { border-color: var(--fg); outline: none; }
.mono-s { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mid); }

/* ---------- intro + menu ---------- */
.screen { min-height: 100%; display: flex; flex-direction: column; }
#intro { align-items: center; justify-content: center; text-align: center; gap: 22px; cursor: pointer; padding: 40px; }
#intro h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 9vw, 104px); letter-spacing: 0.04em; margin: 0; }
#intro .sub { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 2.4vw, 26px); color: var(--mid); margin: 0; }
#intro .rule { width: 64px; height: 1px; background: var(--line); margin: 12px 0; }
#intro .credits { font-size: 11px; letter-spacing: 0.2em; color: var(--mid); line-height: 2; text-transform: uppercase; }
#intro .press { margin-top: 36px; font-size: 11px; letter-spacing: 0.3em; color: var(--mid); animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

#library { max-width: 920px; width: 100%; margin: 0 auto; padding: 48px 28px 80px; gap: 28px; }
#library header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
#library h2 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0; letter-spacing: 0.03em; }
.tools { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
#q { flex: 1 1 280px; background: none; border: none; border-bottom: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 15px; padding: 10px 2px; letter-spacing: 0.06em; }
#q:focus { outline: none; border-color: var(--fg); }
#q::placeholder { color: var(--mid); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; font-size: 11px; }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
#list { list-style: none; margin: 0; padding: 0; }
#list li a { display: flex; align-items: center; gap: 18px; padding: 14px 6px; border-bottom: 1px solid var(--line); text-decoration: none; transition: background 0.2s; }
#list li a:hover, #list li a:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.cov { width: 56px; height: 56px; flex: none; border: 1px solid var(--line); background: #0a0a0a; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cov img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cov svg { width: 22px; height: 22px; opacity: 0.4; }
.meta { flex: 1; min-width: 0; }
.meta .t { font-family: var(--serif); font-size: 24px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .a { font-size: 11px; letter-spacing: 0.14em; color: var(--mid); text-transform: uppercase; }
.badge { font-size: 10px; letter-spacing: 0.16em; border: 1px solid var(--line); padding: 4px 10px; text-transform: uppercase; color: var(--mid); }
#empty { color: var(--mid); font-size: 12px; letter-spacing: 0.1em; padding: 24px 6px; }

/* ---------- gioco ---------- */
body.game { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.hud { display: flex; justify-content: space-between; align-items: center; padding: 28px 40px 0; transition: opacity 1.6s; }
.hud .who { display: flex; align-items: center; gap: 16px; }
.hud .cov { width: 52px; height: 52px; }
.hud .t { font-family: var(--serif); font-size: 22px; font-weight: 500; letter-spacing: 0.02em; }
.hud .a { font-size: 11px; letter-spacing: 0.14em; color: var(--mid); text-transform: uppercase; margin-top: 3px; }
.hud .right { display: flex; align-items: center; gap: 18px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
.hud .right .badge { color: var(--fg); }
#lives { color: var(--mid); }

.stage { position: relative; flex: 1; }
.line { position: absolute; left: 0; right: 0; top: 46%; padding: 0 8vw; text-align: center; font-family: var(--serif); font-size: clamp(26px, 4.6vw, 64px); line-height: 1.25; opacity: 0; transform: translateY(-50%); transition: top 0.6s ease, opacity 0.6s ease, transform 0.6s ease; pointer-events: none; }
.line.cur { opacity: 1; }
.line.prev { top: 24%; opacity: 0.3; transform: translateY(-50%) scale(0.7); }
.line.next { top: 68%; opacity: 0.14; transform: translateY(-50%) scale(0.7); }
.w { display: inline-block; margin: 0 0.14em; white-space: nowrap; }
.c { color: var(--dim); transition: color 0.12s, text-shadow 0.4s; }
.c.on { color: var(--fg); }
.c.pulse { text-shadow: 0 0 calc(26px * var(--fx)) rgba(255, 255, 255, 0.95); }
.c.at { box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.9); }
.w.shake { animation: shake 0.28s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.w.breath { animation: breath 0.9s ease; }
@keyframes breath { 0%, 100% { transform: scale(1); } 50% { transform: scale(calc(1 + 0.06 * var(--fx))); } }

.timer { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); width: 280px; text-align: center; transition: opacity 0.4s; }
.timer .track { height: 1px; background: var(--line); }
.timer .fill { height: 1px; background: var(--fg); width: 100%; }
.timer .lbl { margin-top: 10px; font-size: 10px; letter-spacing: 0.2em; color: var(--mid); }

.foot { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 40px 22px; gap: 20px; }
.hint { font-size: 11px; letter-spacing: 0.14em; color: rgba(255, 255, 255, 0.45); line-height: 2; text-transform: uppercase; }
#playerBox { position: relative; z-index: 60; width: 200px; height: 200px; border: 1px solid rgba(255, 255, 255, 0.4); background: #0a0a0a; flex: none; }
#playerBox iframe, #playerBox #yt { width: 200px; height: 200px; display: block; }
#progress { height: 1px; background: var(--line); margin: 0 40px 20px; }
#progress i { display: block; height: 1px; width: 0; background: rgba(255, 255, 255, 0.8); transition: width 0.3s; }

body.failing .stage, body.failing .hud { opacity: 0.35; transition: opacity 2s; }

#overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.78); opacity: 0; pointer-events: none; transition: opacity 0.9s; }
#overlay.show { opacity: 1; pointer-events: auto; }
#overlay .box { text-align: center; padding: 0 24px; max-width: 900px; }
#overlay .k { font-size: 12px; letter-spacing: 0.3em; color: var(--mid); text-transform: uppercase; }
#overlay .big { font-family: var(--serif); font-size: clamp(30px, 5vw, 60px); margin: 22px 0; line-height: 1.2; }
#overlay .rule { width: 64px; height: 1px; background: var(--line); margin: 22px auto; }
#overlay .info { font-size: 12px; letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.65); text-transform: uppercase; line-height: 2.2; }
#overlay .actions { margin-top: 34px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
#overlay .btn1 { border-color: rgba(255, 255, 255, 0.6); }

#fx { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.dust { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: 0; animation: dust 1.1s ease-out forwards; }
@keyframes dust { 0% { opacity: calc(0.9 * var(--fx)); transform: translate(0, 0); } 100% { opacity: 0; transform: translate(var(--dx), -46px); } }
.ripple { position: absolute; border: 1px solid #fff; border-radius: 50%; width: 10px; height: 10px; opacity: 0; animation: ripple 1.2s ease-out forwards; }
@keyframes ripple { 0% { opacity: calc(0.8 * var(--fx)); transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(14); } }

@media (max-width: 720px) {
  .hud { padding: 18px 18px 0; }
  .foot { padding: 0 18px 16px; flex-direction: column; align-items: flex-start; }
  #playerBox { align-self: flex-end; }
  #progress { margin: 0 18px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .line, .c, #overlay { transition-duration: 0.01s; }
  .w.shake, .w.breath, #intro .press { animation: none; }
}
