:root{
  --bg: #100D13;
  --surface: #1B1620;
  --surface-2: #241D2B;
  --line: #352C3E;
  --text: #F3ECE4;
  --muted: #9C93A6;
  --gold: #D8A24A;
  --gold-soft: rgba(216,162,74,0.14);
  --steel: #6C8EAD;
  --miss: #B5533C;
  --radius: 14px;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background: radial-gradient(120% 140% at 50% -10%, #201A29 0%, var(--bg) 55%);
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height:100vh;
}

.hidden{ display:none !important; }

.app-shell{
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.app-header{ margin-bottom: 36px; }
.brand{ display:flex; align-items:baseline; gap:10px; }
.brand-mark{ color: var(--gold); font-size: 14px; }
.brand-name{ font-family:'Fraunces', serif; font-weight:600; font-size: 22px; letter-spacing: 0.02em; }
.brand-sub{ color: var(--muted); font-size: 13px; }

.title-serif{
  font-family:'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  margin: 0 0 12px;
}
.lede{ color: var(--muted); font-size: 15.5px; line-height:1.55; max-width: 46ch; margin: 0 0 28px; }
.muted{ color: var(--muted); }

/* SETUP */
.setup-grid{
  display:grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 48px;
}
@media (max-width: 760px){
  .setup-grid{ grid-template-columns: 1fr; }
}

.playlist-list{ display:flex; flex-direction:column; gap: 8px; margin-bottom: 28px; }

.playlist-card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 16px;
  transition: border-color .15s ease, background .15s ease;
}
.playlist-card.selected{ border-color: var(--gold); background: var(--gold-soft); }
.playlist-card.disabled{ opacity: .4; }

.playlist-row{ display:flex; align-items:center; gap:12px; cursor:pointer; }
.playlist-row input[type="checkbox"]{
  appearance:none; width:19px; height:19px; border-radius:5px;
  border: 1.5px solid var(--line); background: var(--surface-2);
  display:grid; place-items:center; flex-shrink:0; cursor:pointer;
}
.playlist-row input[type="checkbox"]:checked{ border-color: var(--gold); background: var(--gold); }
.playlist-row input[type="checkbox"]:checked::after{ content:"✓"; font-size:13px; color:#100D13; font-weight:700; }

.playlist-name{ font-weight:600; font-size:15px; }
.playlist-count{ color: var(--muted); font-size: 12.5px; margin-left:auto; font-family:'IBM Plex Mono', monospace; }

.histogram-wrap{ margin-top: 8px; }
.decade-histogram{
  display:flex; width:100%; height: 20px; border-radius: 5px; overflow:hidden;
}
.histogram-segment{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  min-width: 0; overflow:hidden; white-space:nowrap;
  color:#fff; text-shadow: 0 1px 1px rgba(0,0,0,.35);
  line-height: 1;
}
.histogram-decade{ font-size: 7.5px; font-weight:700; letter-spacing:.02em; }
.histogram-pct{ font-size: 7px; opacity:.85; margin-top:1px; }

.weight-row{ margin-top: 12px; padding-left: 31px; display:flex; align-items:center; gap: 12px; }
.weight-label{
  font-size: 11.5px; text-transform:uppercase; letter-spacing:.05em; color: var(--muted);
  flex-shrink:0;
}
.weight-row input[type="range"]{
  flex:1; accent-color: var(--gold); height: 4px;
}
.weight-value{
  font-family:'IBM Plex Mono', monospace; font-size: 14px; color: var(--gold); font-weight:600;
  min-width: 20px; text-align:right;
}

.field-block{ margin-bottom: 26px; }
.field-label{ display:block; font-size: 13px; color: var(--muted); margin-bottom: 8px; text-transform:uppercase; letter-spacing: .05em; }
.num-input{
  width: 110px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-size: 18px; padding: 10px 12px;
  font-family:'IBM Plex Mono', monospace;
}
.field-hint{ color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.btn-primary{
  background: var(--gold); color: #1B1305; border:none; border-radius: 999px;
  padding: 14px 28px; font-size: 15px; font-weight: 600; cursor:pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn-primary:hover:not(:disabled){ transform: translateY(-1px); }
.btn-primary:disabled{ opacity: .35; cursor:not-allowed; }

.btn-secondary{
  background: transparent; color: var(--text); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 13px 26px; font-size: 15px; font-weight: 600; cursor:pointer;
}
.btn-secondary:hover{ border-color: var(--gold); color: var(--gold); }

.btn-ghost{
  display:block; margin: 30px auto 0; background:none; border:none;
  color: var(--muted); font-size: 13px; cursor:pointer; text-decoration: underline;
}

.error-msg{ color: var(--miss); font-size: 13.5px; margin-top: 14px; min-height: 1em; }

.setup-aside{
  border-left: 1px solid var(--line);
  padding-left: 32px;
}
.aside-title{ font-size: 13px; text-transform:uppercase; letter-spacing:.05em; color: var(--muted); margin-bottom: 18px; }
.aside-steps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap: 18px; }
.aside-steps li{ font-size: 14px; line-height:1.5; color: #C9C1D2; display:flex; gap: 12px; }
.step-num{ font-family:'IBM Plex Mono', monospace; color: var(--gold); font-size: 12px; flex-shrink:0; padding-top:2px; }

.playback-mode{ display:flex; flex-direction:column; gap: 10px; }
.mode-option{
  display:flex; gap: 10px; align-items:flex-start; cursor:pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px;
}
.mode-option:has(input:checked){ border-color: var(--gold); background: var(--gold-soft); }
.mode-option input[type="radio"]{ margin-top: 3px; accent-color: var(--gold); flex-shrink:0; }
.mode-option strong{ font-size: 14px; }
.mode-option p{ margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height:1.45; }

.premium-connect-box{ margin-top: 12px; padding-left: 2px; }
.btn-small{ padding: 9px 18px; font-size: 13px; }
#premium-status{ margin-top: 8px; }
#premium-status.connected{ color: #7FBF8F; }
#premium-status.error{ color: var(--miss); }

.starting-years-list{
  display:flex; flex-direction:column; gap: 10px; margin-top: 24px; text-align:left;
}
.starting-year-card{
  display:flex; align-items:center; justify-content:space-between;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px;
}
.starting-year-card .player-name{ font-weight:600; font-size: 14.5px; }
.starting-year-card .player-year{
  font-family:'IBM Plex Mono', monospace; font-size: 22px; color: var(--gold); font-weight:600;
}

/* GAME */
.game-wrap{ max-width: 480px; margin: 0 auto; text-align:center; position:relative; padding-top: 40px; }

.btn-close-x{
  position:absolute; top: 0; right: 0; z-index: 20;
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; border: 1.5px solid var(--line);
  color: var(--miss); font-size: 15px; line-height:1; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: background .12s ease, border-color .12s ease;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  touch-action: manipulation; padding: 0; margin: 0;
}
.btn-close-x:hover{ background: rgba(181,83,60,0.12); border-color: var(--miss); }

.btn-settings-x{
  left: 0; right: auto; color: var(--muted);
}
.btn-settings-x:hover{ background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.btn-settings-x.active{ border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }

.incremental-panel{
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 44px 0 24px; text-align:left;
  display:flex; flex-wrap:wrap; align-items:flex-end; gap: 14px;
}
.incremental-field{ display:flex; flex-direction:column; gap: 6px; }
.incremental-field label{
  font-size: 11px; text-transform:uppercase; letter-spacing:.05em; color: var(--muted);
}
.incremental-field .num-input{ width: 84px; font-size: 15px; padding: 8px 10px; }
.incremental-panel .field-hint{ flex-basis:100%; margin: 4px 0 0; }

.session-playlists-line{
  font-size: 12.5px; color: var(--muted); margin: 32px 0 0; text-align:center;
}
.session-playlists-line strong{ color: var(--text); font-weight:600; }


.disc-stage{ position: relative; margin-bottom: 36px; }

.disc-cover{
  width: 260px; height: 260px; margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2A222F 0%, #0B090D 70%);
  border: 1px solid var(--line);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  position:relative;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6), inset 0 0 0 8px #17121C, inset 0 0 0 9px #35303c;
  animation: spin 7s linear infinite;
  animation-play-state: paused;
}
.disc-cover.spinning{ animation-play-state: running; }

.disc-rings{
  position:absolute; inset: 34px;
  border-radius:50%;
  background: repeating-radial-gradient(circle, transparent 0 6px, rgba(255,255,255,0.025) 6px 7px);
}

@keyframes spin{ to{ transform: rotate(360deg); } }

.btn-play{
  width: 70px; height:70px; border-radius:50%; border:none;
  background: var(--gold); color:#1B1305;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; z-index:2; box-shadow: 0 8px 24px -4px rgba(216,162,74,0.5);
  transition: transform .12s ease;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  touch-action: manipulation; padding: 0; margin: 0;
}
.btn-play:hover{ transform: scale(1.05); }
.btn-play svg{ margin-left: 3px; }

.disc-hint{
  position:absolute; bottom: 28px; color: var(--muted); font-size: 12px;
  text-transform:uppercase; letter-spacing:.08em; margin:0;
}

.embed-holder{ position: absolute; opacity:0; pointer-events:none; height:0; overflow:hidden; }

.reveal-panel{
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display:flex; align-items:center; gap:20px; text-align:left;
}
.reveal-year{
  font-family:'IBM Plex Mono', monospace; font-size: 40px; font-weight:600;
  color: var(--gold); flex-shrink:0; min-width: 96px;
}
.reveal-name{ font-family:'Fraunces', serif; font-weight:600; font-size:19px; }
.reveal-artist{ color: var(--muted); font-size: 14.5px; margin-top:2px; }
.reveal-note{ color: var(--steel); font-size: 12.5px; margin-top: 6px; }

.game-actions{ display:flex; gap: 14px; justify-content:center; margin-top: 4px; }

.end-wrap{ text-align:center; max-width: 420px; margin: 60px auto 0; }
.end-wrap .lede{ margin-left:auto; margin-right:auto; }

.session-history{ margin-top: 44px; text-align:left; }
.session-history-title{
  font-size: 12px; text-transform:uppercase; letter-spacing:.06em; color: var(--muted);
  margin: 0 0 12px;
}
.session-history-list{
  display:flex; flex-direction:column; gap: 8px;
}
.session-history-list .muted.small{ font-size: 13px; margin:0; }
.history-item{
  display:flex; align-items:center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px;
}
.history-year{
  font-family:'IBM Plex Mono', monospace; font-size: 15px; color: var(--gold); font-weight:600;
  min-width: 42px; flex-shrink:0;
}
.history-info{ display:flex; flex-direction:column; min-width:0; }
.history-name{ font-size: 13.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.history-artist{ font-size: 12px; color: var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* MODAL */
.modal-overlay{
  position: fixed; inset: 0; background: rgba(8,6,10,0.72);
  display:flex; align-items:center; justify-content:center;
  padding: 20px; z-index: 100;
}
.modal-box{
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; max-width: 380px; width:100%;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6);
}
.modal-title{ font-family:'Fraunces', serif; font-weight:600; font-size: 20px; margin: 0 0 10px; }
.modal-text{ color: var(--muted); font-size: 14px; line-height:1.5; margin: 0 0 22px; }
.modal-actions{ display:flex; gap: 12px; justify-content:flex-end; }
.btn-danger{
  background: var(--miss); color: #FBEDE8; border:none; border-radius: 999px;
  padding: 12px 22px; font-size: 14.5px; font-weight:600; cursor:pointer;
}
.btn-danger:hover{ opacity:.9; }

.report-link{
  background:none; border:none; color: var(--muted); font-size: 12px;
  text-decoration: underline; cursor:pointer; margin-top: 10px; padding:0;
}
.report-link:hover{ color: var(--steel); }

.history-report-btn{
  background:none; border:none; color: var(--muted); font-size: 16px;
  cursor:pointer; padding: 4px 6px; flex-shrink:0; line-height:1;
}
.history-report-btn:hover{ color: var(--miss); }

.report-textarea{
  width:100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 10px 12px;
  font-family:'Inter', sans-serif; font-size: 14px; resize:vertical;
  margin-bottom: 14px;
}

.year-adjust-row{ display:flex; align-items:center; justify-content:center; gap: 10px; margin-bottom: 14px; }
.year-adjust-input{
  flex: 0 0 33%; width: 33%; min-width: 0; text-align:center;
  appearance: textfield; -moz-appearance: textfield;
}
.year-adjust-input::-webkit-outer-spin-button,
.year-adjust-input::-webkit-inner-spin-button{
  -webkit-appearance: none; margin: 0;
}
.year-adjust-btn{
  width: 38px; height: 38px; flex-shrink:0; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-size: 18px; line-height:1; cursor:pointer;
  appearance:none; -webkit-appearance:none; touch-action:manipulation;
}
.year-adjust-btn:hover{ border-color: var(--gold); color: var(--gold); }
