@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=DM+Mono:wght@300;400&display=swap');

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

:root {
  --bg:      #0a0800;
  --s1:      #110e03;
  --s2:      #161200;
  --border:  rgba(200,150,12,0.12);
  --gold:    #c8960c;
  --gold2:   #f0c040;
  --cream:   #e8dfc0;
  --dim:     #4a4020;

  /* Section colors */
  --str:     #e05050;   /* strings */
  --ww:      #4090e0;   /* woodwind */
  --br:      #e08820;   /* brass */
  --perc:    #a060e0;   /* percussion */
  --tutti:   #40c070;   /* tutti */

  --serif:   'Playfair Display', serif;
  --mono:    'DM Mono', monospace;
}

/* ── BASE ─────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    180deg, transparent, transparent 28px,
    rgba(200,150,12,0.025) 29px
  );
  pointer-events: none; z-index: 0;
}

.wrap {
  position: relative; z-index: 1;
  width: min(960px, 100%);
  display: flex; flex-direction: column; gap: 10px;
}

/* ── HEADER ──────────────────────────────────────── */
header {
  text-align: center;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--serif);
  font-size: 24px; font-weight: 900;
  color: var(--gold2);
  text-shadow: 0 0 30px rgba(240,192,64,0.3);
  letter-spacing: 0.04em;
}

.logo-sub {
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.22em; text-transform: uppercase;
  margin-top: 3px;
}

.hstatus {
  display: flex; align-items: center;
  justify-content: center; gap: 8px;
  margin-top: 7px;
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.1em;
}

.sdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--dim); transition: all 0.3s;
}
.sdot.live { background: var(--tutti); box-shadow: 0 0 8px var(--tutti); }

/* ── OBRA SELECTOR ───────────────────────────────── */
.obra-section {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}

.obra-title {
  font-family: var(--serif);
  font-size: 11px; color: var(--gold);
  letter-spacing: 0.15em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.obra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

.obra-card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; flex-direction: column; gap: 2px;
}

.obra-card:hover {
  border-color: rgba(200,150,12,0.4);
  background: rgba(200,150,12,0.05);
}

.obra-card.selected {
  border-color: var(--gold);
  background: rgba(200,150,12,0.1);
  box-shadow: 0 0 12px rgba(200,150,12,0.15);
}

.obra-composer {
  font-size: 8px; color: var(--dim);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.obra-name {
  font-family: var(--serif);
  font-size: 11px; color: var(--cream);
  line-height: 1.3;
}

.obra-detail {
  font-size: 8px; color: var(--dim);
  font-style: italic;
}

.obra-card.selected .obra-name { color: var(--gold2); }

.obra-active-display {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px;
  background: rgba(200,150,12,0.06);
  border: 1px solid rgba(200,150,12,0.2);
  border-radius: 3px;
}

.obra-active-composer {
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.obra-active-name {
  font-family: var(--serif);
  font-size: 14px; color: var(--gold2);
}

.obra-active-mvt {
  font-size: 9px; color: var(--dim);
  font-style: italic; margin-left: auto;
}

/* ── STAGE (camera) ──────────────────────────────── */
.stage {
  position: relative;
  width: 100%; aspect-ratio: 16/9;
  border-radius: 5px; overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

#video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0.35;
}

#canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  transform: scaleX(-1);
}

#beat-flash {
  position: absolute; inset: 0;
  background: rgba(240,192,64,0);
  pointer-events: none;
  transition: background 0.05s;
}

.stage-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  font-size: 11px; color: var(--dim);
  letter-spacing: 0.12em;
  pointer-events: none;
}
.stage-overlay.hidden { display: none; }

.pulse-ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--gold);
  animation: ring 1.5s ease-out infinite;
}
@keyframes ring {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.7); opacity: 0; }
}

.zone-label {
  position: absolute;
  font-size: 8px; letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none; opacity: 0.28;
}
.zone-label.tl { top: 9px; left: 10px;  color: var(--cream); }
.zone-label.tr { top: 9px; right: 10px; color: var(--gold);  }

/* ── START BUTTON ────────────────────────────────── */
#start-btn {
  display: block; margin: 0 auto;
  font-family: var(--serif);
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold2); background: transparent;
  border: 1px solid var(--gold);
  border-radius: 3px; padding: 11px 40px;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(200,150,12,0.08) inset;
  transition: all 0.2s;
}
#start-btn:hover {
  background: rgba(200,150,12,0.09);
  box-shadow: 0 0 30px rgba(200,150,12,0.18) inset;
}
#start-btn:disabled { opacity: 0.2; cursor: not-allowed; }

/* ── SCORE BAR ───────────────────────────────────── */
.score-bar {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 14px;
  display: flex; align-items: center; gap: 10px;
  overflow: hidden;
}

.score-label {
  font-size: 9px; color: var(--dim);
  letter-spacing: 0.1em; white-space: nowrap;
}

.beat-dots {
  display: flex; gap: 5px; align-items: center; flex: 1;
}

.beat-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dim);
  transition: background 0.05s, transform 0.05s, box-shadow 0.05s;
}
.beat-dot.big { width: 12px; height: 12px; }
.beat-dot.on  { transform: scale(1.5); }

.tempo-display {
  font-size: 10px; color: var(--gold);
  white-space: nowrap; letter-spacing: 0.05em;
}

/* ── SECTIONS ────────────────────────────────────── */
.sections-label {
  font-size: 8px; color: var(--dim);
  letter-spacing: 0.18em; text-transform: uppercase;
}

.sections {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.section {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 8px;
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  transition: all 0.1s;
}

.section.active {
  border-color: currentColor;
}

@keyframes sec-in  { 0% { transform: scale(0.94); opacity: 0.5; } 100% { transform: scale(1); opacity: 1; } }
@keyframes sec-out { 0% { opacity: 1; } 100% { opacity: 0.4; } }
.section.entering { animation: sec-in  0.3s ease-out; }
.section.leaving  { animation: sec-out 0.2s ease-in;  }

.sec-icon     { font-size: 24px; line-height: 1; }
.sec-name     { font-family: var(--serif); font-size: 11px; font-weight: 700; text-align: center; }
.sec-finger   { font-size: 8px; color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; }
.sec-instr    { font-size: 7px; color: var(--dim); text-align: center; line-height: 1.5; margin-top: 2px; }

.sec-bar      { width: 100%; height: 2px; background: rgba(255,255,255,0.05); border-radius: 1px; }
.sec-bar-fill { height: 100%; border-radius: 1px; transition: width 0.06s; width: 0%; }

/* Per-section color theming */
.sec-str  { color: var(--str);  }
.sec-str.active  { background: rgba(224,80,80,0.08);  box-shadow: 0 0 16px rgba(224,80,80,0.15);  }
.sec-str  .sec-bar-fill { background: var(--str);  box-shadow: 0 0 5px var(--str);  }

.sec-ww   { color: var(--ww);   }
.sec-ww.active   { background: rgba(64,144,224,0.08); box-shadow: 0 0 16px rgba(64,144,224,0.15); }
.sec-ww   .sec-bar-fill { background: var(--ww);   box-shadow: 0 0 5px var(--ww);   }

.sec-br   { color: var(--br);   }
.sec-br.active   { background: rgba(224,136,32,0.08); box-shadow: 0 0 16px rgba(224,136,32,0.15); }
.sec-br   .sec-bar-fill { background: var(--br);   box-shadow: 0 0 5px var(--br);   }

.sec-perc { color: var(--perc); }
.sec-perc.active { background: rgba(160,96,224,0.08); box-shadow: 0 0 16px rgba(160,96,224,0.15); }
.sec-perc .sec-bar-fill { background: var(--perc); box-shadow: 0 0 5px var(--perc); }

.sec-tutti{ color: var(--tutti);}
.sec-tutti.active{ background: rgba(64,192,112,0.08); box-shadow: 0 0 16px rgba(64,192,112,0.15);}
.sec-tutti .sec-bar-fill { background: var(--tutti); box-shadow: 0 0 5px var(--tutti); }

/* ── METERS ──────────────────────────────────────── */
.meters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.meter {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 11px;
  display: flex; flex-direction: column; gap: 3px;
}

.meter-label {
  font-size: 7px; color: var(--dim);
  letter-spacing: 0.15em; text-transform: uppercase;
}

.meter-value {
  font-family: var(--serif);
  font-size: 22px; color: var(--cream); line-height: 1;
}
.meter-value.gold {
  color: var(--gold2);
  text-shadow: 0 0 10px rgba(240,192,64,0.25);
}

.bar { height: 2px; background: rgba(255,255,255,0.04); border-radius: 1px; margin-top: 4px; }
.bar-fill { height: 100%; border-radius: 1px; transition: width 0.06s; }
.bar-gold   { background: var(--gold2); box-shadow: 0 0 5px var(--gold2); }
.bar-tutti  { background: var(--tutti); box-shadow: 0 0 5px var(--tutti); }

/* ── BOTTOM PANELS ───────────────────────────────── */
.bottom-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.panel {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
}

.panel-title {
  font-size: 8px; color: var(--dim);
  letter-spacing: 0.18em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

/* Sections legend in bottom panel */
.sec-legend { display: flex; flex-direction: column; gap: 5px; }

.sec-legend-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: all 0.1s;
}
.sec-legend-row.active {
  background: rgba(200,150,12,0.07);
  border-color: rgba(200,150,12,0.25);
}

.sec-legend-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim); flex-shrink: 0;
  transition: all 0.1s;
}
.sec-legend-row.active .sec-legend-dot {
  box-shadow: 0 0 7px currentColor;
}

.sec-legend-finger {
  font-size: 9px; color: var(--dim);
  min-width: 52px; letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sec-legend-name {
  font-family: var(--serif);
  font-size: 11px; color: var(--cream);
  flex: 1;
}
.sec-legend-instr {
  font-size: 8px; color: var(--dim);
  text-align: right; line-height: 1.3;
}

/* Hints */
.hints { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hint-col { display: flex; flex-direction: column; gap: 4px; }
.hint-title {
  font-size: 7px; letter-spacing: 0.15em;
  text-transform: uppercase; margin-bottom: 3px;
}
.hint-row { display: flex; gap: 6px; font-size: 8px; color: var(--dim); }
.hint-row b { color: var(--cream); font-weight: 400; min-width: 54px; }
