/* ═══════════════════════════════════════════════════════════════
   style.css — Clap! Concert Timing Game
   Design: Playful & fun · Aged paper bg · Bold ink · Abril Fatface
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:          #F7F3EE;
  --ink:         #1A1A2E;
  --green:       #2ECC71;
  --orange:      #FF7F50;
  --red:         #E74C3C;
  --gold:        #F4C430;
  --purple:      #7B4FBF;
  --blue:        #3B82F6;
  --pink:        #FF6B9D;

  --radius-pill: 60px;
  --shadow-hard: 5px 5px 0px var(--ink);
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow: hidden;
}

/* noise grain */
body::after {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ── Screen shell ────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity .3s ease, transform .3s ease;
}
.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 1 — LANDING
════════════════════════════════════════════════════════════════ */
#screen-landing {
  background: var(--ink);
  gap: 0;
  position: fixed; inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* decorative circles */
.landing-deco { position: absolute; inset: 0; pointer-events: none; }
.deco-circle  { position: absolute; border-radius: 50%; }
.deco-circle--1 { width: 500px; height: 500px; background: var(--gold);   opacity: .10; top: -200px; right: -130px; }
.deco-circle--2 { width: 340px; height: 340px; background: var(--pink);   opacity: .12; bottom: -100px; left: -80px; }
.deco-circle--3 { width: 180px; height: 180px; background: var(--purple); opacity: .15; top: 42%; left: 8%; }

.landing-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .28em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 14px; position: relative; z-index: 1;
}

.landing-title {
  font-family: 'Abril Fatface', serif;
  font-size: clamp(80px, 15vw, 140px);
  line-height: .9;
  color: #fff;
  text-align: center;
  position: relative; z-index: 1;
  margin-bottom: 6px;
}
.landing-title__bang {
  color: var(--gold);
  display: inline-block;
  animation: bangWobble 2.6s ease-in-out infinite;
}
@keyframes bangWobble {
  0%, 100% { transform: rotate(-4deg) scale(1);    }
  50%       { transform: rotate(4deg)  scale(1.08); }
}

.landing-sub {
  font-size: 16px; font-weight: 300; line-height: 1.65;
  color: rgba(255,255,255,.6);
  text-align: center; max-width: 360px;
  margin-top: 22px; margin-bottom: 42px;
  position: relative; z-index: 1;
}

.btn-start {
  background: var(--gold); color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 18px; font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 17px 52px;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: transform .1s, box-shadow .1s;
  position: relative; z-index: 1;
}
.btn-start:hover  { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); }
.btn-start:active { transform: translate(3px,3px);   box-shadow: 2px 2px 0 var(--ink); }

.btn-quick {
  background: transparent; color: rgba(255,255,255,.75);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; font-weight: 600;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: var(--radius-pill);
  padding: 12px 36px;
  cursor: pointer;
  margin-top: 14px;
  transition: color .2s, border-color .2s;
  position: relative; z-index: 1;
}
.btn-quick:hover  { color: #fff; border-color: rgba(255,255,255,.55); }
.btn-quick:active { color: rgba(255,255,255,.5); }

.btn-practice {
  background: transparent; color: rgba(255,255,255,.55);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; font-weight: 500;
  border: 2px solid rgba(255,255,255,.2);
  border-radius: var(--radius-pill);
  padding: 12px 36px;
  cursor: pointer;
  margin-top: 12px;
  transition: color .2s, border-color .2s;
  position: relative; z-index: 1;
}
.btn-practice:hover  { color: #fff; border-color: rgba(255,255,255,.45); }
.btn-practice:active { color: rgba(255,255,255,.4); }

.btn-chopin {
  background: transparent; color: rgba(255,255,255,.45);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 500; font-style: italic;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-pill);
  padding: 10px 28px;
  cursor: pointer;
  margin-top: 10px;
  transition: color .2s, border-color .2s;
  position: relative; z-index: 1;
}
.btn-chopin:hover  { color: #fff; border-color: rgba(255,255,255,.35); }
.btn-chopin:active { color: rgba(255,255,255,.35); }

.btn-mic-test {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-pill);
  padding: 8px 20px;
  margin-top: 24px;
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  position: relative; z-index: 1;
  transition: border-color .2s;
}
.btn-mic-test:hover { border-color: rgba(255,255,255,.3); }
.mic-test-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  transition: background .4s, box-shadow .4s;
}
.mic-test-dot.active {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.mic-test-dot.error {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}
.mic-test-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; color: rgba(255,255,255,.4);
  letter-spacing: .04em;
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 2 — GAME
════════════════════════════════════════════════════════════════ */
#screen-game {
  background: var(--bg);
  justify-content: flex-start;
  padding: 0;
  gap: 0;
}

/* ── Top bar ── */
.top-bar {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 2px solid var(--ink);
  background: var(--bg);
  flex-shrink: 0;
}

.round-badge {
  font-family: 'Abril Fatface', serif;
  font-size: 14px; letter-spacing: .02em;
  background: var(--ink); color: var(--gold);
  padding: 5px 14px; border-radius: 40px;
  white-space: nowrap;
}
/* attacca variant */
.round-badge.attacca { background: var(--purple); color: #fff; }

.clip-title {
  font-size: 13px; font-weight: 500;
  color: rgba(26,26,46,.45);
  text-align: center; flex: 1;
  padding: 0 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mic-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: rgba(26,26,46,.35);
}
.mic-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(26,26,46,.2);
  transition: background .4s, box-shadow .4s;
  cursor: pointer;
}
.mic-dot.active {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

/* ── Video ── */
.video-wrap {
  width: 100%; max-width: 720px;
  margin: 0 auto;
  position: relative;
  flex-shrink: 0;
}
.video-wrap iframe,
#yt-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  display: block;
}

/* countdown overlay */
.countdown-overlay {
  position: absolute; inset: 0;
  background: rgba(26,26,46,.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  transition: opacity .4s ease;
}
.countdown-overlay.gone { opacity: 0; pointer-events: none; }

.countdown-num {
  font-family: 'Abril Fatface', serif;
  font-size: 100px; color: #fff;
  animation: countPop .55s cubic-bezier(.34,1.56,.64,1);
}
@keyframes countPop {
  0%   { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}
.countdown-label {
  font-size: 13px; letter-spacing: .12em;
  text-transform: uppercase; color: rgba(255,255,255,.5);
}

/* ── Game body ── */
.game-body {
  flex: 1; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; padding: 20px 24px 28px;
}

/* instruction label */
.instruction {
  font-size: 12px; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(26,26,46,.0);   /* invisible by default */
  transition: color .2s, transform .2s;
  text-align: center;
}
.instruction.visible {
  color: var(--ink);
  animation: instrBounce .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes instrBounce {
  0%   { transform: scale(.85); }
  100% { transform: scale(1); }
}

/* ── Clap button ── */
.clap-btn-wrap {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 160px; height: 160px;
}

.clap-btn {
  position: relative; z-index: 2;
  width: 130px; height: 130px; border-radius: 50%;
  font-size: 52px; line-height: 1;
  background: var(--gold);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);    box-shadow: var(--shadow-hard); }
  50%       { transform: scale(1.05); box-shadow: 7px 7px 0 var(--ink); }
}

/* when clap window is open */
.clap-btn.listening {
  animation: pulse 1s ease-in-out infinite;
  background: var(--green);
}
@keyframes pulse {
  0%, 100% { transform: scale(1);    box-shadow: 5px 5px 0 var(--ink), 0 0 0 0 rgba(46,204,113,.4); }
  50%       { transform: scale(1.08); box-shadow: 6px 6px 0 var(--ink), 0 0 0 18px rgba(46,204,113,0); }
}

/* ripple ring on clap */
.clap-btn-wrap::before,
.clap-btn-wrap::after {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid var(--gold);
  opacity: 0;
}
.clap-btn-wrap.clapped::before { animation: ripple .6s ease-out forwards; }
.clap-btn-wrap.clapped::after  { animation: ripple .6s .15s ease-out forwards; }
@keyframes ripple {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(2.2); opacity: 0; }
}

.clap-btn:hover  { transform: translate(-2px,-2px) scale(1.03); box-shadow: 7px 7px 0 var(--ink); }
.clap-btn:active { transform: translate(3px,3px)   scale(.97);  box-shadow: 2px 2px 0 var(--ink); }

/* ── Attacca state ── */
.attacca-label {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}
.attacca-emoji { font-size: 64px; animation: breathe 3s ease-in-out infinite; }
.attacca-text  {
  font-size: 14px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--purple);
}

.key-hint-game {
  font-size: 12px; color: rgba(26,26,46,.3);
  letter-spacing: .04em;
}
@media (hover: none) and (pointer: coarse) {
  .key-hint-game { display: none; }
}
kbd {
  font-family: 'DM Sans', monospace;
  background: rgba(26,26,46,.08);
  border: 1px solid rgba(26,26,46,.2);
  border-radius: 4px; padding: 1px 6px;
  font-size: 11px;
}

/* ════════════════════════════════════════════════════════════════
   SCREEN 3 — FEEDBACK
════════════════════════════════════════════════════════════════ */
#screen-feedback {
  padding: 0;
}

.feedback-bg {
  position: absolute; inset: 0;
  opacity: .18;
  transition: background .3s;
}
.feedback-bg.bg-green  { background: var(--green); }
.feedback-bg.bg-orange { background: var(--orange); }
.feedback-bg.bg-red    { background: var(--red); }

.feedback-card {
  position: relative; z-index: 1;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 40px 44px 36px;
  max-width: 420px; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
  text-align: center;
}

.feedback-emoji {
  font-size: 72px;
  animation: emojiPop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes emojiPop {
  0%   { transform: scale(0) rotate(-20deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.feedback-delta {
  font-family: 'Abril Fatface', serif;
  font-size: 52px; line-height: 1;
}
.feedback-delta.green  { color: var(--green); }
.feedback-delta.orange { color: var(--orange); }
.feedback-delta.red    { color: var(--red); }

.feedback-msg {
  font-size: 20px; font-weight: 700; line-height: 1.3;
  margin-top: 4px;
}

.feedback-note {
  font-size: 13px; font-weight: 300; line-height: 1.6;
  color: rgba(26,26,46,.55);
  border-top: 1px solid rgba(26,26,46,.1);
  padding-top: 12px; margin-top: 4px;
}

.btn-next {
  margin-top: 8px;
  background: var(--ink); color: var(--gold);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px; font-weight: 700;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 13px 36px;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(26,26,46,.25);
  transition: transform .1s, box-shadow .1s;
}
.btn-next:hover  { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 rgba(26,26,46,.25); }
.btn-next:active { transform: translate(2px,2px);   box-shadow: 2px 2px 0 rgba(26,26,46,.25); }

/* ════════════════════════════════════════════════════════════════
   SCREEN 4 — END
════════════════════════════════════════════════════════════════ */
#screen-end { background: var(--bg); }

.end-card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 10px 10px 0 var(--ink);
  padding: 44px 52px 40px;
  max-width: 460px; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
}

.end-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: rgba(26,26,46,.4);
}

.end-score {
  font-family: 'Abril Fatface', serif;
  font-size: 80px; line-height: 1; color: var(--ink);
}

.end-verdict {
  font-size: 22px; font-weight: 700;
  text-align: center; line-height: 1.3;
  margin-bottom: 6px;
}

/* recap list */
.end-recap {
  width: 100%; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
  border-top: 2px solid rgba(26,26,46,.08);
  padding-top: 16px; margin-top: 6px;
}
.end-recap li {
  display: flex; align-items: center;
  justify-content: space-between;
  font-size: 13px; font-weight: 500;
  padding: 6px 0;
  border-bottom: 1px solid rgba(26,26,46,.06);
}
.recap-composer { flex: 1; color: rgba(26,26,46,.7); }
.recap-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin: 0 12px; flex-shrink: 0;
}
.recap-dot--green  { background: var(--green); }
.recap-dot--orange { background: var(--orange); }
.recap-dot--red    { background: var(--red); }
.recap-delta { font-weight: 700; font-size: 14px; min-width: 48px; text-align: right; }
.recap-delta.green  { color: var(--green); }
.recap-delta.orange { color: var(--orange); }
.recap-delta.red    { color: var(--red); }

.btn-again { margin-top: 20px; }

/* ── Utility ── */
.hidden { display: none !important; }
