/* ═══════════════════════════════════════════════
   BidTrivia — style.css
   Design: light cream theme, Newsreader serif
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,300;0,6..72,400;0,6..72,500;0,6..72,600;0,6..72,700;1,6..72,400&display=swap');

/* ── Custom Properties ── */
:root {
  --bg:          #FAF6F1;
  --bg-2:        #F3EDE5;
  --bg-3:        #E8DFD4;
  --card-bg:     rgba(255, 255, 255, 0.75);
  --card-border: rgba(0, 0, 0, 0.09);
  --purple:      #4E2A84;
  --purple-mid:  #6B38B8;
  --purple-light:#9B6DDF;
  --purple-glow: rgba(107, 56, 184, 0.18);
  --gold:        #8B6914;
  --gold-light:  #6B5100;
  --correct:     #16A34A;
  --correct-glow:rgba(22, 163, 74, 0.2);
  --wrong:       #DC2626;
  --wrong-glow:  rgba(220, 38, 38, 0.2);
  --text-1:      #1A1A1A;
  --text-2:      #5C5C5C;
  --text-3:      #8C8C8C;
  --r1-color:    #2563EB;
  --r2-color:    #7C3AED;
  --font:        'Inter', system-ui, sans-serif;
  --font-serif:  'Newsreader', Georgia, 'Times New Roman', serif;
  --radius:      14px;
  --radius-sm:   8px;
  --card-w:      160px;
  --card-h:      auto;
  --slot-w:      52px;
  --transition:  0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active { display: flex; }

/* ══════════════════════════════════════
   START SCREEN
══════════════════════════════════════ */
#start-screen {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  overflow: hidden;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(78,42,132,0.08) 0%, transparent 70%),
              var(--bg);
}

/* Star particles */
.stars { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--purple-mid);
  border-radius: 50%;
  opacity: 0;
  animation: twinkle 4s infinite;
}
.star:nth-child(1)  { top:  8%; left: 12%; animation-delay: 0s; }
.star:nth-child(2)  { top: 15%; left: 78%; animation-delay: 0.8s; }
.star:nth-child(3)  { top: 30%; left: 25%; animation-delay: 1.5s; }
.star:nth-child(4)  { top: 45%; left: 88%; animation-delay: 0.3s; }
.star:nth-child(5)  { top: 60%; left: 5%;  animation-delay: 2.1s; }
.star:nth-child(6)  { top: 72%; left: 60%; animation-delay: 1.1s; }
.star:nth-child(7)  { top: 85%; left: 40%; animation-delay: 0.6s; }
.star:nth-child(8)  { top: 20%; left: 50%; animation-delay: 1.8s; }
.star:nth-child(9)  { top: 55%; left: 35%; animation-delay: 2.5s; }

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.5); }
}

.start-content {
  position: relative;
  z-index: 1;
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.start-logo {
  text-align: center;
}
.logo-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 16px rgba(78,42,132,0.3));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.start-logo h1 {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--purple) 30%, var(--purple-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  margin-top: 0.5rem;
  color: var(--text-2);
  font-size: 1rem;
}

/* How to play box */
.how-to-play {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}
.how-to-play h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 1.2rem;
}
.steps { display: flex; flex-direction: column; gap: 1rem; }
.step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--purple-mid);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-text {
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.5;
}
.step-text strong { color: var(--text-1); }

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 2.4rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  color: white;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--purple-glow);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--purple-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 2rem;
  border: 1px solid var(--card-border);
  border-radius: 50px;
  background: var(--card-bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}
.btn-secondary:hover {
  color: var(--text-1);
  border-color: rgba(0,0,0,0.18);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════ */
#game-screen {
  flex-direction: column;
  background: radial-gradient(ellipse 100% 40% at 50% 0%, rgba(78,42,132,0.06) 0%, transparent 60%),
              var(--bg);
}

/* Header */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(250,246,241,0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}
.brand-name { letter-spacing: -0.5px; }

.header-center .progress-text-header {
  font-size: 0.8rem;
  color: var(--text-2);
  text-align: center;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
}

.lives-display {
  display: flex;
  gap: 2px;
  font-size: 1.2rem;
}
.life { transition: var(--transition); }
.life.lost { filter: grayscale(1) opacity(0.3); transform: scale(0.8); }

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-3);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
}
.stat-label { font-size: 0.75rem; color: var(--text-2); }
.stat-value { font-size: 0.9rem; font-weight: 700; color: var(--text-1); }

/* Main */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem 0 2rem;
  gap: 1.5rem;
}

/* Active Section */
.active-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
}
.section-prompt {
  font-size: 0.9rem;
  color: var(--text-2);
}
.section-prompt strong { color: var(--text-1); }

#active-card-wrap {
  perspective: 800px;
}

/* ── Cards ── */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 60%);
  pointer-events: none;
}

/* Active card */
.card--active {
  width: min(300px, 90vw);
  cursor: grab;
  box-shadow: 0 0 0 1px var(--purple-mid), 0 8px 24px rgba(0,0,0,0.1), 0 0 30px var(--purple-glow);
  animation: pulse-border 2.5s ease-in-out infinite;
}
.card--active:active { cursor: grabbing; transform: scale(1.02) rotate(1deg); }
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 1px var(--purple-mid), 0 8px 24px rgba(0,0,0,0.1), 0 0 20px var(--purple-glow); }
  50% { box-shadow: 0 0 0 1px var(--purple-light), 0 8px 24px rgba(0,0,0,0.1), 0 0 36px var(--purple-glow); }
}

.card-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.badge-r1 { background: rgba(96,165,250,0.2); color: var(--r1-color); border: 1px solid rgba(96,165,250,0.3); }
.badge-r2 { background: rgba(167,139,250,0.2); color: var(--r2-color); border: 1px solid rgba(167,139,250,0.3); }

.card-year-label {
  font-size: 0.72rem;
  color: var(--text-3);
  font-weight: 500;
}
.card-course-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.3;
}

.card-professor {
  font-size: 0.78rem;
  color: var(--text-2);
  font-style: italic;
}
.card-campus {
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.card-term-phase {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 0.15rem;
}
.card-stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}
.card-stat { display: flex; flex-direction: column; gap: 1px; }
.card-stat-label { font-size: 0.65rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.card-stat-value { font-size: 0.9rem; font-weight: 700; color: var(--text-1); }
.cost-hidden .card-stat-label { color: var(--gold); }
.cost-hidden .card-stat-value { color: var(--gold-light); }

.drag-hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-3);
}

/* ── Timeline Card (placed) ── */
.card--placed {
  width: var(--card-w);
  flex-shrink: 0;
  cursor: default;
  animation: card-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes card-pop {
  0% { transform: scale(0.7) translateY(-10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.card--placed .card-course-name { font-size: 0.82rem; }
.card--placed .card-stat-value  { font-size: 0.8rem; }
.card--placed .card-stat-label  { font-size: 0.58rem; }
.card--placed .card-term-phase  { font-size: 0.65rem; }
.card--placed .card-professor   { font-size: 0.65rem; }
.card--placed .card-campus      { font-size: 0.58rem; }
.card--placed .card-badge { font-size: 0.62rem; padding: 0.15rem 0.45rem; }
.cost-reveal {
  margin-top: 0.25rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: rgba(78,42,132,0.06);
  border: 1px solid rgba(78,42,132,0.12);
  text-align: center;
}
.cost-reveal-label { font-size: 0.58rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.cost-reveal-value { font-size: 1.1rem; font-weight: 800; color: var(--purple); }

/* correct/wrong highlights */
.card--correct {
  box-shadow: 0 0 0 2px var(--correct), 0 0 24px var(--correct-glow);
  animation: card-correct-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes card-correct-pop {
  0% { transform: scale(0.7) translateY(-20px); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.card--wrong {
  box-shadow: 0 0 0 2px var(--wrong), 0 0 24px var(--wrong-glow);
}

/* ── Timeline ── */
.timeline-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.timeline-axis-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  font-size: 0.72rem;
  color: var(--text-3);
}
.axis-title { color: var(--text-2); font-weight: 600; }

.timeline-scroll-wrap {
  overflow-x: auto;
  overflow-y: visible;
  padding: 0.5rem 1.5rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}
.timeline-scroll-wrap::-webkit-scrollbar { height: 4px; }
.timeline-scroll-wrap::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 2px; }

.timeline {
  display: flex;
  align-items: stretch;
  min-width: max-content;
  position: relative;
  gap: 0;
  padding-bottom: 0.5rem;
}
/* Horizontal line */
.timeline::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,0.12) 5%, rgba(0,0,0,0.12) 95%, transparent);
}

/* ── Drop Slots ── */
.slot {
  flex-shrink: 0;
  width: var(--slot-w);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  border-radius: 8px;
}
.slot-inner {
  width: 3px;
  height: 60px;
  background: var(--bg-3);
  border-radius: 2px;
  transition: var(--transition);
  position: relative;
}
.slot-inner::after {
  content: '▼';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--text-3);
  opacity: 0;
  transition: var(--transition);
}
.slot:hover .slot-inner,
.slot.drag-over .slot-inner {
  width: 4px;
  height: 80px;
  background: var(--purple-light);
  box-shadow: 0 0 16px var(--purple-glow);
}
.slot:hover .slot-inner::after,
.slot.drag-over .slot-inner::after {
  opacity: 1;
  color: var(--purple-light);
}
.slot.drag-over {
  background: rgba(107, 56, 184, 0.1);
  border-radius: 8px;
}

/* ── Shake animation ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px) rotate(-1deg); }
  30% { transform: translateX(8px) rotate(1deg); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}
.shake { animation: shake 0.5s ease; }

/* ── Flash ── */
@keyframes flash-wrong {
  0%, 100% { background: var(--card-bg); }
  40% { background: rgba(220,38,38,0.12); }
}
@keyframes flash-correct {
  0%, 100% { background: var(--card-bg); }
  40% { background: rgba(22,163,74,0.12); }
}

/* ══════════════════════════════════════
   GAME OVER SCREEN
══════════════════════════════════════ */
#gameover-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(78,42,132,0.08) 0%, transparent 70%),
              var(--bg);
}
.gameover-content {
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.gameover-emoji {
  font-size: 4rem;
  animation: float 3s ease-in-out infinite;
}
.gameover-title { font-size: 2rem; font-weight: 800; }
.gameover-sub { color: var(--text-2); text-align: center; }

/* Score ring */
.final-score-ring {
  position: relative;
  width: 160px; height: 160px;
}
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-3); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--purple-light);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 8px var(--purple-glow));
}
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-number { font-size: 2.8rem; font-weight: 800; line-height: 1; }
.ring-label { font-size: 0.75rem; color: var(--text-2); margin-top: 0.25rem; }

.gameover-stats {
  display: flex;
  gap: 2rem;
}
.go-stat { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.go-stat-val { font-size: 1.8rem; font-weight: 800; color: var(--text-1); }
.go-stat-label { font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }

.gameover-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  backdrop-filter: blur(12px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
.toast.correct {
  background: rgba(22,163,74,0.1);
  border: 1px solid var(--correct);
  color: #15803D;
}
.toast.wrong {
  background: rgba(220,38,38,0.1);
  border: 1px solid var(--wrong);
  color: #B91C1C;
}
.toast.info {
  background: rgba(78,42,132,0.1);
  border: 1px solid var(--purple-light);
  color: var(--text-1);
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 600px) {
  .game-header { padding: 0.6rem 1rem; gap: 0.5rem; }
  .brand-name { display: none; }
  :root { --card-w: 140px; --slot-w: 40px; }
  .card--active { width: min(260px, 85vw); }
  .header-right { gap: 0.4rem; }
  .stat-pill { padding: 0.25rem 0.5rem; }
  .timeline-scroll-wrap { padding: 0.5rem 1rem 1.5rem; }
}

@media (max-width: 360px) {
  :root { --card-w: 120px; --slot-w: 32px; }
}
