/* pulse/public/styles.css
 *
 * Pulse keeps its own dark, colourful arcade look (like Snake's green or
 * Brickbreaker's cyan) on top of the shared chrome: --accent here is hot
 * magenta, and the six "spectrum" colours are the site's candlelight
 * palette (same values as lightlol.com's tokens), which is what the pads,
 * orbs and background are painted with.
 */
:root {
  --bg:            #0a0618;
  --surface-1:     #150f2e;
  --surface-2:     #1c1440;
  --border:        #30245f;
  --border-strong: #46368a;
  --text:          #F4F1FF;
  --text-mid:      #cfc8ee;
  --text-muted:    #9d95c9;
  --accent:        #ff4fd8;
  --accent-hover:  #ff78e2;
  --on-accent:     #2a0522;
  --danger:        #ff6b6b;

  /* spectrum: pad 1..6, and the three instrument bands */
  --s1: #FF6A5C; --s2: #FF9A3C; --s3: #FFDA3D; --s4: #8EE05A; --s5: #3ED6C2; --s6: #8AA2FF;
  --band-low:  #ff4fd8;
  --band-mid:  #3ED6C2;
  --band-high: #FFDA3D;

  --font-display: 'Fredoka', sans-serif;
  --font-body:    'Nunito', sans-serif;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
/* safe-area.css pads <body>; this page positions its layers against the
   viewport itself (using the --safe-* values above), so cancel that padding. */
body { padding: 0 !important; }

#bg, #fx { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#bg { z-index: 0; }
#fx { z-index: 6; pointer-events: none; }

.screen { position: fixed; inset: 0; }

/* ── Menu / listening / results cards (same shape as every game's join card) ── */
.auth-page {
  z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--safe-top) + 5rem) 1rem calc(var(--safe-bottom) + 2rem);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.auth-card {
  width: 100%; max-width: 440px;
  background: rgba(21, 15, 46, 0.86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
.game-title {
  text-align: center; margin: 0 0 0.4rem;
  font-family: var(--font-display); font-size: 2.6rem; letter-spacing: 6px; font-weight: 700;
  background: linear-gradient(90deg, var(--s1), var(--s2), var(--s3), var(--s4), var(--s5), var(--s6), var(--accent));
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: titleSlide 7s linear infinite;
}
@keyframes titleSlide { to { background-position: 200% 0; } }
.screen-title { text-align: center; font-family: var(--font-display); margin: 0 0 0.6rem; font-size: 1.6rem; }
.tagline { margin: 0 0 1.1rem; color: var(--text-mid); font-size: 0.9rem; text-align: center; line-height: 1.45; }
.howto-row { text-align: center; margin: 0 0 1.25rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-field { display: flex; flex-direction: column; gap: 0.5rem; }
.picker-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mid); }

button {
  margin: 0; background: var(--accent); color: var(--on-accent); border: none; border-radius: 999px;
  padding: 0.85rem; font-family: var(--font-body); font-size: 1rem; font-weight: 800; cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
}
button:hover  { filter: brightness(1.1); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: default; transform: none; filter: none; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--s5); outline-offset: 2px; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.link-btn {
  background: none; color: var(--text-mid); text-decoration: underline; text-underline-offset: 3px;
  font-weight: 700; font-size: 0.9rem; padding: 0.4rem; text-align: center;
}
a.link-btn { display: block; }
.link-btn:hover { color: var(--text); filter: none; }

.hint { color: var(--text-mid); font-size: 13px; text-align: center; margin: 0; line-height: 1.45; }
.hint.small { font-size: 12px; color: var(--text-muted); }
.join-notes { display: flex; flex-direction: column; gap: 0.5rem; }
.signin-note a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.error-msg { color: var(--danger); font-size: 13px; margin: 0; text-align: center; line-height: 1.4; }
.error-msg:empty { display: none; }
.back-home-link.profile-link { right: calc(1rem + 44px); }

/* ── Mode cards ── */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; text-align: center;
  background: var(--surface-2); color: var(--text); border: 2px solid var(--border); border-radius: 14px; padding: 0.9rem 0.6rem 0.8rem;
  font-weight: 500;
}
.mode-card:hover { filter: none; border-color: var(--border-strong); }
.mode-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 79, 216, 0.18), 0 0 24px -6px var(--accent); }
.mode-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; }
.mode-blurb { font-size: 0.74rem; line-height: 1.35; color: var(--text-mid); }
.mode-best { font-size: 0.72rem; color: var(--s3); font-weight: 800; min-height: 1em; }
.mode-art { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 38px; }
.mode-art i { display: block; border-radius: 50%; width: 14px; height: 14px; background: var(--c, var(--s5)); box-shadow: 0 0 10px var(--c, var(--s5)); }
.mode-art--wave i:nth-child(1) { --c: var(--s1); margin-bottom: 2px; animation: bob 1.6s ease-in-out infinite; }
.mode-art--wave i:nth-child(2) { --c: var(--s2); margin-bottom: 10px; animation: bob 1.6s ease-in-out -0.3s infinite; }
.mode-art--wave i:nth-child(3) { --c: var(--s3); margin-bottom: 16px; animation: bob 1.6s ease-in-out -0.6s infinite; }
.mode-art--wave i:nth-child(4) { --c: var(--s5); margin-bottom: 10px; animation: bob 1.6s ease-in-out -0.9s infinite; }
.mode-art--wave i:nth-child(5) { --c: var(--s6); margin-bottom: 2px; animation: bob 1.6s ease-in-out -1.2s infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.mode-art--pop { align-items: center; }
.mode-art--pop i:nth-child(1) { --c: var(--band-low); width: 24px; height: 24px; animation: popArt 1.8s ease-in-out infinite; }
.mode-art--pop i:nth-child(2) { --c: var(--band-mid); width: 18px; height: 18px; animation: popArt 1.8s ease-in-out -0.6s infinite; }
.mode-art--pop i:nth-child(3) { --c: var(--band-high); width: 12px; height: 12px; animation: popArt 1.8s ease-in-out -1.2s infinite; }
@keyframes popArt { 0%, 100% { transform: scale(0.8); opacity: 0.7; } 40% { transform: scale(1.18); opacity: 1; } }

/* ── Listening ── */
.meter { display: flex; align-items: flex-end; justify-content: center; gap: 5px; height: 64px; margin: 0.5rem 0 1rem; }
.meter i { display: block; width: 14px; height: 6px; border-radius: 5px; background: var(--c); opacity: 0.35; transition: height 0.06s linear, opacity 0.12s; }
.meter i:nth-child(1) { --c: var(--s1); } .meter i:nth-child(2) { --c: var(--s1); } .meter i:nth-child(3) { --c: var(--s2); }
.meter i:nth-child(4) { --c: var(--s2); } .meter i:nth-child(5) { --c: var(--s3); } .meter i:nth-child(6) { --c: var(--s3); }
.meter i:nth-child(7) { --c: var(--s4); } .meter i:nth-child(8) { --c: var(--s4); } .meter i:nth-child(9) { --c: var(--s5); }
.meter i:nth-child(10) { --c: var(--s5); } .meter i:nth-child(11) { --c: var(--s6); } .meter i:nth-child(12) { --c: var(--s6); }
#screen-listen .hint { margin-bottom: 1rem; }
#listen-text.ok { color: var(--s4); font-weight: 800; }

/* ── Results ── */
.result-mode { text-align: center; margin: 0; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; }
.result-score { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; margin: 0.25rem 0 1rem; }
#result-score { font-family: var(--font-display); font-weight: 700; font-size: 3.4rem; line-height: 1; color: var(--s3); text-shadow: 0 0 28px rgba(255, 218, 61, 0.35); font-variant-numeric: tabular-nums; }
.result-newbest { color: var(--on-accent); background: var(--accent); font-weight: 800; font-size: 0.75rem; padding: 0.2rem 0.7rem; border-radius: 999px; animation: popIn 0.4s ease-out; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.6rem; margin: 0 0 1rem; }
.result-grid > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0.55rem 0.3rem; text-align: center; }
.result-grid dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.result-grid dd { margin: 0.1rem 0 0; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
#result-save { margin-bottom: 1rem; min-height: 1.3em; }
#result-save.good { color: var(--s4); }
#result-save.bad { color: var(--danger); }
#result-save a { color: inherit; text-decoration: underline; }

/* ── Play: HUD ── */
#screen-play { z-index: 5; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#hud {
  position: absolute; z-index: 7; left: 0; right: 0; top: 0; pointer-events: none;
  padding: calc(var(--safe-top) + 0.9rem) calc(var(--safe-right) + 4rem) 0 calc(var(--safe-left) + 1rem);
  display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0.2rem 0.75rem;
}
.hud-score { display: flex; flex-direction: column; line-height: 1; }
.hud-label { font-size: 0.65rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); font-weight: 800; }
#hud-score { font-family: var(--font-display); font-weight: 700; font-size: 2.1rem; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgba(255, 79, 216, 0.45); }
.hud-mid { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.mult { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; color: var(--text-mid); transition: color 0.2s, transform 0.2s; }
.mult.m2 { color: var(--s5); } .mult.m3 { color: var(--s3); } .mult.m4 { color: var(--accent); text-shadow: 0 0 14px var(--accent); }
.mult.bump { transform: scale(1.35); }
.combo { font-size: 0.8rem; font-weight: 800; color: var(--text-mid); min-height: 1em; }
.hud-bpm { position: absolute; left: calc(var(--safe-left) + 1rem); top: calc(var(--safe-top) + 5rem); font-size: 0.7rem; font-weight: 800; color: var(--text-muted); letter-spacing: 0.08em; }
.timebar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 0.55rem; }
.timebar i { display: block; height: 100%; width: 100%; transform-origin: left center; transform: scaleX(1); background: linear-gradient(90deg, var(--s5), var(--s3), var(--accent)); }

#field { position: absolute; inset: 0; z-index: 4; }
#pads, #notes { position: absolute; inset: 0; }
#notes { pointer-events: none; }
#notes > .note { pointer-events: auto; }

/* Wave pads */
.pad {
  position: absolute; left: 0; top: 0; padding: 0; margin: 0; border-radius: 50%;
  width: var(--d); height: var(--d);
  transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%));
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), transparent 42%), radial-gradient(circle, var(--c) 0%, var(--cd) 100%);
  border: 3px solid var(--cl);
  box-shadow: 0 0 18px -2px var(--c), inset 0 -6px 14px rgba(0,0,0,0.3);
  touch-action: none;
  transition: box-shadow 0.12s, filter 0.12s;
}
.pad:hover { filter: none; }
.pad:active { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(0.94); }
.pad.cue { box-shadow: 0 0 30px 2px var(--c), inset 0 -6px 14px rgba(0,0,0,0.3); }
.pad.hit { animation: padHit 0.28s ease-out; }
@keyframes padHit {
  0% { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(1.22); filter: brightness(1.6); }
  100% { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(1); filter: none; }
}

/* Pop notes */
.note {
  position: absolute; left: 0; top: 0; padding: 0; margin: 0; border-radius: 50%;
  width: var(--d); height: var(--d);
  transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%));
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.6), transparent 40%), radial-gradient(circle, var(--c) 0%, var(--cd) 100%);
  border: 3px solid var(--cl);
  box-shadow: 0 0 26px 0 var(--c);
  touch-action: none;
  animation: notePop 0.16s cubic-bezier(.2,1.6,.4,1) both;
}
.note:hover { filter: none; }
.note .ring {
  position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--c); pointer-events: none;
  animation: ringClose var(--life) linear both;
}
.note.gone { animation: noteGone 0.2s ease-in both; pointer-events: none; }
.note.caught { animation: noteCaught 0.22s ease-out both; pointer-events: none; }
@keyframes notePop {
  from { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(0.1); opacity: 0; }
  to   { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(1); opacity: 1; }
}
@keyframes ringClose { from { transform: scale(2.3); opacity: 0.2; } 12% { opacity: 0.9; } to { transform: scale(1); opacity: 0.9; } }
@keyframes noteGone { to { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(0.6); opacity: 0; filter: grayscale(1); } }
@keyframes noteCaught { to { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)) scale(1.7); opacity: 0; } }
#field.paused .ring { animation-play-state: paused; }

.float {
  position: absolute; left: 0; top: 0; z-index: 8; pointer-events: none; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--c, #fff); text-shadow: 0 0 10px var(--c, #fff), 0 2px 4px rgba(0,0,0,0.6);
  transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%));
  animation: floatUp 0.7s ease-out forwards;
}
@keyframes floatUp {
  from { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%)); opacity: 1; }
  to   { transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50% - 46px)); opacity: 0; }
}

.play-hint {
  position: absolute; left: 0; right: 0; z-index: 7; text-align: center; pointer-events: none;
  bottom: calc(var(--safe-bottom) + 1rem); margin: 0; padding: 0 1rem;
  font-size: 0.85rem; font-weight: 800; color: var(--s3); text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  opacity: 0; transition: opacity 0.25s;
}
.play-hint.show { opacity: 1; }

.countdown {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-family: var(--font-display); font-weight: 700; font-size: 9rem; color: #fff; text-shadow: 0 0 40px var(--accent), 0 0 80px var(--s5);
}
.countdown span { animation: countPop 0.9s ease-out both; }
@keyframes countPop { from { transform: scale(2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } to { transform: scale(0.85); opacity: 0; } }
@keyframes popIn { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

body[data-phase="play"] .back-home-link:not(.profile-link),
body[data-phase="play"] .profile-link { display: none !important; }
body[data-phase="listen"] .profile-link { display: none !important; }

/* ── Overlay + confirm dialog ── */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(5, 3, 14, 0.8); padding: 1rem; }
.overlay-card { background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 16px; padding: 1.5rem; max-width: 340px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 0.9rem; }
.overlay-card p { margin: 0; line-height: 1.45; }
.dialog-overlay { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(5, 3, 14, 0.75); }
.dialog-overlay.open { display: flex; }
.dialog-box { background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: 14px; padding: 24px; width: 88%; max-width: 340px; text-align: center; }
.dialog-message { margin: 0 0 16px; color: var(--text); font-size: 15px; line-height: 1.4; }
.dialog-actions { display: flex; gap: 10px; justify-content: center; }
.dialog-btn { padding: 10px 20px; }
.dialog-btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }

@media (max-height: 640px) { .countdown { font-size: 6rem; } }
@media (prefers-reduced-motion: reduce) {
  .game-title, .mode-art i, .settings-nut, .settings-nut-tip { animation: none !important; }
  .note { animation-duration: 0.01s; }
  .float { animation-duration: 0.4s; }
}

/* Narrow phones (iPhone SE / mini width): keep the two corner pills from touching. */
@media (max-width: 380px) {
  .back-home-link { font-size: 0.8rem; padding: 0.5rem 0.8rem; }
  .game-title { font-size: 2.2rem; letter-spacing: 4px; }
}
