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

:root {
  --bg:        #1c1a2e;
  --bg2:       #252340;
  --paper:     #f8f0dc;
  --paper-dark:#e0cfa0;
  --red:       #c0624a;
  --red-dark:  #9a4a38;
  --gold:      #e8c060;
  --tan:       #9890c0;
  --text-light:#f8f0dc;
  --text-dark: #1c1a2e;
  --nav-h:     64px;
  --font-type: 'Special Elite', serif;
  --font-head: 'Oswald', sans-serif;
  --font-mono: 'Courier Prime', monospace;
}

body {
  font-family: var(--font-type);
  background: var(--bg);
  color: var(--text-light);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}
.hidden { display: none !important; }

/* ── Screens ── */
.screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #2a1f08 0%, #1c1a2e 100%);
}
.login-box {
  background: var(--paper); color: var(--text-dark);
  padding: 2.5rem 2rem; max-width: 400px; width: 92%;
  position: relative;
  box-shadow: 0 0 0 1px var(--paper-dark), 0 20px 60px rgba(0,0,0,0.8);
  transform: rotate(-0.5deg);
}
.login-box::before {
  content: ''; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  width: 60px; height: 14px; background: rgba(180,160,100,0.55);
}
.stamp {
  position: absolute; top: 1rem; right: 1rem;
  border: 3px solid var(--red); color: var(--red);
  font-family: var(--font-head); font-size: 0.7rem; font-weight: 700;
  padding: 0.2rem 0.5rem; transform: rotate(12deg);
  opacity: 0.8; letter-spacing: 2px;
}
.case-header { text-align: center; border-bottom: 2px solid var(--tan); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.case-number { font-family: var(--font-mono); font-size: 0.75rem; color: var(--tan); letter-spacing: 3px; }
.case-header h1, .name-title {
  font-family: var(--font-head); font-size: 3rem; font-weight: 700;
  letter-spacing: 8px; color: var(--text-dark); line-height: 1;
}
.name-title { font-size: 2rem; letter-spacing: 4px; text-align: center; margin: 0.8rem 0 1.2rem; }
.case-sub { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 2px; color: var(--tan); margin-top: 0.3rem; }
.login-label { font-family: var(--font-mono); font-size: 0.7rem; color: var(--tan); letter-spacing: 1px; margin-bottom: 0.7rem; text-align: center; }
.login-box input[type=password], .login-box input[type=text] {
  width: 100%; padding: 0.8rem 1rem;
  background: rgba(0,0,0,0.05); border: 1px solid var(--tan); border-bottom: 2px solid var(--tan);
  font-family: var(--font-mono); font-size: 1.1rem; letter-spacing: 6px; text-align: center;
  color: var(--text-dark); margin-bottom: 1rem; outline: none;
}
.login-box input[type=text] { letter-spacing: 2px; }
.login-box input:focus { border-color: var(--red); }
.login-box button {
  width: 100%; padding: 0.9rem;
  background: var(--red); color: white; border: none;
  font-family: var(--font-head); font-size: 1rem; font-weight: 700; letter-spacing: 3px;
  cursor: pointer;
}
.login-box button:active { background: var(--red-dark); }
.error { font-family: var(--font-mono); font-size: 0.8rem; color: var(--red); text-align: center; margin-top: 0.8rem; }

/* ── Header ── */
header {
  background: var(--bg2);
  border-bottom: 2px solid var(--gold);
  padding: 1rem 1rem 0.8rem;
  text-align: center;
}
.classified-bar {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 2px;
  color: var(--red); border-top: 1px solid var(--red); border-bottom: 1px solid var(--red);
  padding: 0.2rem; margin-bottom: 0.8rem;
}
.title-block { margin-bottom: 0.6rem; }
.case-badge {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 3px;
  color: var(--gold); border: 1px solid var(--gold); display: inline-block;
  padding: 0.15rem 0.7rem; margin-bottom: 0.3rem;
}
header h1 {
  font-family: var(--font-head); font-size: clamp(2.2rem, 8vw, 4.5rem);
  font-weight: 700; letter-spacing: 10px; color: var(--paper);
  text-shadow: 0 0 20px rgba(212,160,23,0.3), 2px 2px 0 rgba(0,0,0,0.5);
  line-height: 1;
}
.subtitle { font-family: var(--font-mono); font-size: 0.65rem; color: var(--gold); letter-spacing: 3px; }

/* Countdown */
.countdown {
  font-family: var(--font-mono); font-size: 0.75rem; color: var(--tan);
  letter-spacing: 2px; margin-top: 0.5rem; min-height: 1.2em;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #1c1a2e;
  border-top: 2px solid var(--gold);
  display: flex;
  z-index: 100;
  safe-area-inset-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: transparent; border: none; color: var(--tan);
  cursor: pointer; gap: 0.15rem; padding: 0.4rem 0;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:active { background: rgba(255,255,255,0.05); }
.nav-btn.active { color: var(--gold); border-top: 2px solid var(--gold); }
.nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-label { font-family: var(--font-head); font-size: 0.6rem; letter-spacing: 1px; }

/* ── Main Content ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }
main {
  flex: 1;
  padding-bottom: calc(var(--nav-h) + 1rem);
  overflow-y: auto;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-inner { max-width: 700px; margin: 0 auto; padding: 1.2rem 1rem; }



/* ── Upload ── */
.upload-zone {
  border: 2px dashed #4a3f25; padding: 2rem;
  text-align: center; cursor: pointer; margin-bottom: 1rem;
  background: rgba(240,230,200,0.02);
  transition: all 0.2s; position: relative;
}
.upload-zone:active, .upload-zone.dragover { border-color: var(--gold); background: rgba(212,160,23,0.05); }
.cam-icon { font-size: 2.5rem; margin-bottom: 0.4rem; }
.upload-inner p { font-family: var(--font-head); letter-spacing: 3px; color: var(--paper); font-size: 0.9rem; }
.upload-inner small { font-family: var(--font-mono); font-size: 0.7rem; color: var(--tan); }
.upload-form {
  background: rgba(240,230,200,0.04); border: 1px solid #3a3020;
  padding: 1.2rem; margin-bottom: 1rem;
}

.preview-strip { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.preview-strip img { width: 72px; height: 72px; object-fit: cover; border: 3px solid var(--paper); transform: rotate(-2deg); box-shadow: 2px 2px 6px rgba(0,0,0,0.5); }

/* ── Photo Board ── */
.photo-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.2rem; }
.polaroid {
  background: var(--paper); padding: 0.5rem 0.5rem 1.8rem;
  box-shadow: 3px 3px 10px rgba(0,0,0,0.6);
  position: relative; cursor: pointer; transition: transform 0.2s;
}
.polaroid:nth-child(odd)  { transform: rotate(-2deg); }
.polaroid:nth-child(even) { transform: rotate(1.5deg); }
.polaroid:active { transform: rotate(0deg) scale(1.05); z-index: 10; }
.polaroid::before { content: ''; position: absolute; top: -7px; left: 50%; transform: translateX(-50%); width: 36px; height: 13px; background: rgba(212,160,23,0.5); }
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.polaroid .caption { font-family: var(--font-type); font-size: 0.65rem; color: #555; text-align: center; margin-top: 0.3rem; }
.phase-label { font-family: var(--font-head); font-size: 0.55rem; letter-spacing: 2px; color: var(--tan); text-align: center; }

/* ── Comments ── */
.comment-form { background: rgba(240,230,200,0.04); border: 1px solid #3a3020; padding: 1.2rem; margin-bottom: 1.2rem; }
.comment-form textarea, .letter-box textarea {
  width: 100%; padding: 0.7rem 1rem;
  background: rgba(0,0,0,0.3); border: 1px solid #4a3f25; border-bottom: 2px solid #4a3f25;
  color: var(--paper); font-family: var(--font-type); font-size: 0.95rem;
  margin-bottom: 0.8rem; outline: none; resize: vertical; min-height: 90px;
}
.comment-form textarea:focus, .letter-box textarea:focus { border-color: var(--gold); }
.char-row { display: flex; align-items: center; justify-content: space-between; font-family: var(--font-mono); font-size: 0.7rem; color: var(--tan); }
.comments-board { display: flex; flex-direction: column; gap: 0.8rem; }
.comment-card {
  background: var(--paper); color: var(--text-dark);
  padding: 1rem 1rem 1rem 1.2rem;
  border-left: 4px solid var(--red);
  box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
  transform: rotate(-0.3deg); position: relative;
}
.comment-card:nth-child(even) { transform: rotate(0.2deg); }
.comment-card::before { content: ''; position: absolute; top: -5px; right: 15px; width: 28px; height: 11px; background: rgba(212,160,23,0.45); }
.comment-card .name { font-family: var(--font-head); letter-spacing: 2px; color: var(--red-dark); font-size: 0.85rem; }
.comment-card .msg { font-family: var(--font-type); margin-top: 0.4rem; line-height: 1.5; font-size: 0.9rem; }
.comment-card .time { font-family: var(--font-mono); font-size: 0.65rem; color: var(--tan); margin-top: 0.4rem; }

/* ── Music ── */
.music-box { background: rgba(240,230,200,0.04); border: 1px solid #3a3020; padding: 1.2rem; margin-bottom: 1.2rem; }
.search-row { display: flex; gap: 0.5rem; }
.search-row input {
  flex: 1; padding: 0.7rem 1rem;
  background: rgba(0,0,0,0.3); border: 1px solid #4a3f25; border-bottom: 2px solid #4a3f25;
  color: var(--paper); font-family: var(--font-mono); font-size: 0.9rem; outline: none;
}
.search-row input:focus { border-color: var(--gold); }
.search-result { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem; margin-bottom: 0.3rem; background: rgba(0,0,0,0.3); border-left: 3px solid #4a3f25; }
.search-result img { width: 42px; height: 42px; object-fit: cover; flex-shrink: 0; }
.search-result .info { flex: 1; min-width: 0; }
.search-result .track { font-family: var(--font-head); font-size: 0.85rem; letter-spacing: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result .artist { font-family: var(--font-mono); font-size: 0.7rem; color: var(--tan); }
.setlist-box { border: 1px solid #4a3f25; }
.setlist-header { background: #1c1a2e; padding: 0.6rem 1rem; font-family: var(--font-head); letter-spacing: 4px; font-size: 0.8rem; color: var(--gold); text-align: center; border-bottom: 1px solid #4a3f25; }
.setlist-item { display: flex; align-items: center; gap: 0.8rem; padding: 0.6rem 1rem; border-bottom: 1px dashed #2a2010; font-family: var(--font-mono); font-size: 0.8rem; }
.setlist-item:last-child { border-bottom: none; }
.track-num { color: var(--gold); font-weight: 700; min-width: 1.8rem; }
.track-info { flex: 1; min-width: 0; }
.track-info .track-name { color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-info .track-artist { color: var(--tan); font-size: 0.7rem; }
.track-requester { color: #4a3f25; font-size: 0.65rem; flex-shrink: 0; }

/* ── Quiz ── */
.quiz-header { margin-bottom: 1.2rem; }
.quiz-sub { font-family: var(--font-mono); font-size: 0.75rem; color: var(--tan); margin-top: 0.4rem; }
.quiz-card {
  background: var(--paper); color: var(--text-dark);
  padding: 1.2rem; margin-bottom: 1rem;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.4);
  transform: rotate(-0.2deg);
}
.quiz-card:nth-child(even) { transform: rotate(0.3deg); }
.quiz-q-num { font-family: var(--font-mono); font-size: 0.65rem; color: var(--tan); margin-bottom: 0.4rem; }
.quiz-q-text { font-family: var(--font-head); font-size: 1rem; letter-spacing: 1px; color: var(--text-dark); margin-bottom: 0.8rem; }
.quiz-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.quiz-answer {
  padding: 0.6rem 0.8rem; background: rgba(0,0,0,0.06);
  border: 1px solid var(--tan); font-family: var(--font-type); font-size: 0.85rem;
  cursor: pointer; text-align: left; color: var(--text-dark);
  transition: all 0.15s; -webkit-tap-highlight-color: transparent;
}
.quiz-answer:active { background: rgba(192,57,43,0.1); }
.quiz-answer.correct { background: #d4edda; border-color: #28a745; color: #155724; }
.quiz-answer.wrong   { background: #f8d7da; border-color: var(--red); color: var(--red-dark); }
.quiz-answer.disabled { cursor: default; opacity: 0.7; }
.quiz-done { font-family: var(--font-mono); font-size: 0.75rem; color: var(--tan); text-align: center; padding: 0.5rem; }
.quiz-score { text-align: center; padding: 1.5rem; background: rgba(240,230,200,0.04); border: 1px solid var(--gold); margin-bottom: 1rem; }
.quiz-score .score-num { font-family: var(--font-head); font-size: 3rem; color: var(--gold); }
.quiz-score .score-label { font-family: var(--font-mono); font-size: 0.8rem; color: var(--tan); }
.leaderboard { margin-top: 1rem; border: 1px solid #4a3f25; }
.lb-item { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 1rem; border-bottom: 1px dashed #2a2010; font-family: var(--font-mono); font-size: 0.85rem; }
.lb-item:last-child { border-bottom: none; }
.lb-rank { color: var(--gold); font-weight: 700; min-width: 1.5rem; }
.lb-name { flex: 1; color: var(--paper); }
.lb-score { color: var(--gold); }
.lb-item.me .lb-name { color: var(--gold); }

/* ── Letter ── */
.letter-box { background: rgba(240,230,200,0.04); border: 1px solid #3a3020; padding: 1.2rem; }
.letter-sub { font-family: var(--font-mono); font-size: 0.75rem; color: var(--tan); margin-bottom: 1rem; line-height: 1.5; }
.letter-box textarea { min-height: 200px; }
.letter-saved { font-family: var(--font-mono); font-size: 0.8rem; color: #5cb85c; margin-top: 0.8rem; text-align: center; border: 1px solid #5cb85c; padding: 0.5rem; }

/* ── Shared Inputs ── */
.form-label { font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 2px; color: var(--gold); margin-bottom: 0.8rem; }
.btn-primary {
  background: var(--red); color: white; border: none;
  padding: 0.65rem 1.2rem; font-family: var(--font-head); font-size: 0.85rem;
  font-weight: 700; letter-spacing: 2px; cursor: pointer;
}
.btn-primary:active { background: var(--red-dark); }
.btn-secondary {
  background: transparent; color: var(--tan);
  border: 1px solid #4a3f25; padding: 0.65rem 1.2rem;
  font-family: var(--font-head); font-size: 0.85rem; letter-spacing: 2px; cursor: pointer;
}
.btn-row { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 0.8rem); left: 50%; transform: translateX(-50%);
  background: var(--paper); color: var(--text-dark);
  font-family: var(--font-mono); font-size: 0.8rem;
  padding: 0.7rem 1.2rem; border-left: 4px solid var(--red);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.4);
  z-index: 200; white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

@media (min-width: 600px) {
  .photo-board { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .quiz-answers { grid-template-columns: 1fr 1fr; }
}

/* Spotify */
.spotify-embed { margin-bottom: 0; }
.btn-spotify {
  display: block; width: 100%; padding: 0.8rem 1rem;
  background: #1DB954; color: white; text-decoration: none;
  font-family: var(--font-head); font-size: 0.85rem; letter-spacing: 2px;
  text-align: center; font-weight: 700;
}
.btn-spotify:hover { background: #1aa34a; }
