/* =====================================================================
   How Well Do You Know...? — Quiz Engine Styles
   Bold, feminine, earthy red / orange / pink theme.
   ===================================================================== */

:root {
  --primary-red: #B83B26;
  --accent-orange: #D96B27;
  --highlight-pink: #D86B81;
  --bg-earth: #FBF6EF;
  --surface-card: #FFFFFF;
  --text-dark: #2B2121;

  --text-muted: #7a6a63;
  --border-soft: #ecdfd3;
  --shadow-card: 0 18px 45px rgba(43, 33, 33, 0.12);
  --shadow-btn: 0 8px 20px rgba(184, 59, 38, 0.28);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  color: var(--text-dark);
  background:
    radial-gradient(circle at 12% 12%, rgba(216, 107, 129, 0.16), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(217, 107, 39, 0.16), transparent 40%),
    radial-gradient(circle at 50% 120%, rgba(184, 59, 38, 0.12), transparent 55%),
    var(--bg-earth);
  min-height: 100vh;
  padding: 24px 16px 90px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Cards / Screens ───────────────────────────────────────────────── */
.screen {
  display: none;
  animation: cardIn 0.5s var(--ease);
}
.screen.active { display: block; }

.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Typography ────────────────────────────────────────────────────── */
.title {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  line-height: 1.15;
  color: var(--primary-red);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-orange);
  margin-bottom: 18px;
}
.lead {
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hero-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  border: 3px solid var(--highlight-pink);
}

/* ── Name entry form ───────────────────────────────────────────────── */
.name-form { text-align: left; }
.field-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}
.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text-dark);
  background: var(--bg-earth);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.text-input:focus {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 4px rgba(217, 107, 39, 0.15);
}
.error-text {
  color: var(--primary-red);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 10px 2px 0;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  padding: 15px 24px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-block { width: 100%; margin-top: 22px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-orange), var(--primary-red));
  box-shadow: var(--shadow-btn);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(184, 59, 38, 0.34);
  filter: brightness(1.04);
}
.btn-secondary {
  color: #fff;
  background: linear-gradient(135deg, var(--highlight-pink), var(--accent-orange));
  box-shadow: 0 8px 20px rgba(216, 107, 129, 0.3);
}
.btn-secondary:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

/* ── Progress ──────────────────────────────────────────────────────── */
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.progress-label { font-weight: 700; color: var(--primary-red); }
.progress-by { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--highlight-pink), var(--accent-orange), var(--primary-red));
  border-radius: 999px;
  transition: width 0.5s var(--ease);
}

/* ── Question ──────────────────────────────────────────────────────── */
.question-anim { animation: cardIn 0.4s var(--ease); }
.question-anim.swap { animation: qSwap 0.35s var(--ease); }
@keyframes qSwap {
  0%   { opacity: 0; transform: translateX(28px); }
  100% { opacity: 1; transform: translateX(0); }
}

.question-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  border: 3px solid var(--highlight-pink);
  background: var(--bg-earth);
}
.question-text {
  font-size: 1.35rem;
  line-height: 1.35;
  color: var(--text-dark);
  margin-bottom: 22px;
}

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 16px 18px;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--bg-earth);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}
.option:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent-orange);
}
.option .marker {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-card);
  border: 2px solid var(--border-soft);
  font-weight: 800;
  color: var(--accent-orange);
}
.option.selected {
  border-color: var(--accent-orange);
  background: rgba(217, 107, 39, 0.12);
}
.option.selected .marker {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
  color: #fff;
}
.option.correct {
  border-color: #3f9d5a;
  background: rgba(63, 157, 90, 0.14);
}
.option.correct .marker { background: #3f9d5a; border-color: #3f9d5a; color: #fff; }
.option.wrong {
  border-color: var(--primary-red);
  background: rgba(184, 59, 38, 0.12);
}
.option.wrong .marker { background: var(--primary-red); border-color: var(--primary-red); color: #fff; }
.option:disabled { cursor: default; }

.fun-fact {
  margin-top: 16px;
  padding: 12px 16px;
  border-left: 4px solid var(--highlight-pink);
  background: rgba(216, 107, 129, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-muted);
  animation: cardIn 0.3s var(--ease);
}

/* ── Results ───────────────────────────────────────────────────────── */
#screen-results { text-align: center; }
.score-ring {
  width: 170px; height: 170px;
  margin: 8px auto 22px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  background:
    radial-gradient(var(--surface-card) 58%, transparent 59%),
    conic-gradient(var(--accent-orange) var(--ring-pct, 0%), var(--border-soft) 0);
  transition: --ring-pct 0.8s var(--ease);
}
.score-percent {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--primary-red);
  line-height: 1;
}
.score-raw { font-size: 1rem; color: var(--text-muted); font-weight: 600; }

/* ── Hall of Fame ──────────────────────────────────────────────────── */
.hall-of-fame {
  margin-top: 12px;
  text-align: left;
  background: var(--bg-earth);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 16px;
}
.hof-title {
  text-align: center;
  color: var(--accent-orange);
  margin-bottom: 14px;
  font-size: 1.2rem;
}
.hof-rows { display: flex; flex-direction: column; gap: 8px; }
.hof-loading, .hof-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 12px;
  font-size: 0.95rem;
}
.hof-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  animation: cardIn 0.35s var(--ease);
}
.hof-row.is-you {
  border-color: var(--highlight-pink);
  background: rgba(216, 107, 129, 0.12);
  box-shadow: 0 0 0 2px rgba(216, 107, 129, 0.25);
}
.hof-rank { font-weight: 800; font-size: 1.1rem; color: var(--accent-orange); text-align: center; }
.hof-name { font-weight: 700; color: var(--text-dark); }
.hof-name .you-tag {
  font-size: 0.72rem;
  color: var(--highlight-pink);
  font-weight: 700;
  margin-left: 6px;
}
.hof-score { font-weight: 800; color: var(--primary-red); white-space: nowrap; }
.hof-score small { display: block; font-weight: 600; color: var(--text-muted); font-size: 0.72rem; }

/* ── MP3 Player widget (PuzzleMaster injection) ────────────────────── */
.mp3-player {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 900;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
  overflow: hidden;
  min-width: 210px;
  user-select: none;
}
.mp3-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--highlight-pink), var(--primary-red));
}
.mp3-emoji { transition: transform 0.3s var(--ease); }
.mp3-emoji.spin { animation: mp3pulse 0.8s ease infinite alternate; }
@keyframes mp3pulse { from { transform: scale(1) rotate(0); } to { transform: scale(1.25) rotate(12deg); } }
.mp3-label { flex: 1; font-size: 0.95rem; }
.mp3-chevron { font-size: 0.8rem; }
.mp3-panel { padding: 12px 14px; }
.mp3-track {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mp3-controls { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.mp3-controls button {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-orange), var(--primary-red));
  transition: transform 0.15s var(--ease);
}
.mp3-controls button:hover { transform: scale(1.12); }
#mp3-volume { width: 100%; accent-color: var(--accent-orange); cursor: pointer; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card { padding: 26px 20px; }
  .question-text { font-size: 1.18rem; }
  .mp3-player { min-width: 0; right: 12px; bottom: 12px; }
  .mp3-label { display: none; }
  .hof-row { grid-template-columns: 38px 1fr auto; gap: 8px; }
}

/* ── Persistent portal nav link (fixed top-left) ──────────────── */
.portal-nav-link {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 901;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border-soft);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(43, 33, 33, 0.10);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.portal-nav-link:hover {
  color: var(--primary-red);
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--highlight-pink);
}

/* ── E-Card intro + floating photo board ───────────────────────────── */
#screen-ecard.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.photo-board {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.polaroid {
  position: absolute;
  width: 210px;
  background: var(--surface-card);
  padding: 12px 12px 8px;
  border-radius: 6px;
  box-shadow: 0 14px 30px rgba(43, 33, 33, 0.22);
  transform: rotate(var(--rot, 0deg));
  animation-name: drift;
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
}
.polaroid-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(217, 107, 39, 0.25), rgba(216, 107, 129, 0.28));
}
.polaroid-photo::after {
  content: "";
}
.polaroid-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.polaroid figcaption {
  margin-top: 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: "Segoe Script", "Comic Sans MS", cursive;
}

/* Scatter positions + individual rotation/drift tuning */
.pos-1 { top: 6%;  left: 4%;   --rot: -7deg;  animation-duration: 7s;   animation-delay: 0s;   }
.pos-2 { top: 9%;  right: 5%;  --rot: 6deg;   animation-duration: 8.5s; animation-delay: 0.6s; }
.pos-3 { top: 38%; left: 3%;   --rot: 5deg;   animation-duration: 9s;   animation-delay: 1.1s; }
.pos-4 { top: 42%; right: 3%;  --rot: -6deg;  animation-duration: 7.8s; animation-delay: 0.3s; }
.pos-5 { bottom: 7%; left: 9%; --rot: 8deg;   animation-duration: 8s;   animation-delay: 1.4s; }
.pos-6 { bottom: 6%; right: 10%; --rot: -8deg; animation-duration: 9.5s; animation-delay: 0.9s; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(var(--rot, 0deg)); }
  50%      { transform: translate(6px, -14px) rotate(calc(var(--rot, 0deg) + 2deg)); }
}

.ecard-center {
  position: relative;
  z-index: 2;
  max-width: 500px;
  width: 100%;
  text-align: center;
  padding: 40px 34px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  animation: cardIn 0.6s var(--ease);
}
/* ── Bouncing hero photo (ecard intro) ─────────────────────────── */
.ecard-hero-wrap {
  display: inline-block;
  margin: 0 auto 22px;
  animation: heroBounce 2.2s ease-in-out infinite;
}
@keyframes heroBounce {
  0%, 100% { transform: translateY(0);     }
  50%       { transform: translateY(-26px); }
}
.ecard-hero-photo {
  width: 210px;
  height: 210px;
  border-radius: var(--radius-lg);
  object-fit: cover;
  object-position: center top;
  border: 5px solid var(--highlight-pink);
  box-shadow:
    0 18px 40px rgba(184, 59, 38, 0.25),
    0 0 0 10px rgba(216, 107, 129, 0.12);
  transition: opacity 0.35s ease;
  display: block;
}
.ecard-greeting {
  font-size: clamp(2.8rem, 12vw, 4.2rem);
  line-height: 1.05;
  color: var(--primary-red);
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}
.ecard-sub {
  font-size: clamp(1.25rem, 5vw, 1.5rem);
  font-weight: 700;
  color: var(--accent-orange);
  margin-bottom: 16px;
}
.ecard-message {
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 26px;
}
.ecard-btn { width: 100%; }

.ecard-extra-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  width: 100%;
}
.ecard-extra-btn {
  width: 100%;
  text-align: center;
  text-decoration: none;
}
.btn-ghost {
  color: rgba(43, 33, 33, 0.85);
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(6px);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.92);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
  transform: translateY(-2px);
}

.hof-standalone-title { text-align: center; }

/* ── Score comment section (results screen) ──────────────────── */
.score-comment-section {
  text-align: left;
  margin: 8px 0 18px;
}
.score-comment-optional {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}
.score-comment-input {
  resize: vertical;
  min-height: 68px;
  font-family: inherit;
  line-height: 1.5;
  margin-top: 8px;
  display: block;
  width: 100%;
}
.hof-comment {
  display: block;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.35;
}

/* ── Inline Guestbook (screen-guestbook) ────────────────────── */
.gb-sign-wrap {
  background: var(--bg-earth);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.gb-sign-heading {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary-red);
  margin-bottom: 16px;
}
.gb-sign-once {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}
.gb-sign-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  line-height: 1.5;
  display: block;
  width: 100%;
  margin-top: 8px;
}
.char-count {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.gb-sign-success-msg {
  padding: 12px 16px;
  background: rgba(63, 157, 90, 0.10);
  border: 2px solid #3f9d5a;
  border-radius: var(--radius-md);
  color: #2a6b3e;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 12px;
  animation: cardIn 0.3s var(--ease);
}
.gb-signed-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(63, 157, 90, 0.08);
  border: 2px solid #3f9d5a;
  border-radius: var(--radius-md);
  font-size: 0.97rem;
  color: var(--text-dark);
  line-height: 1.45;
  margin-bottom: 8px;
}
.gb-signed-notice > span { font-size: 1.4rem; flex-shrink: 0; }

.gb-entries {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gb-entry {
  display: flex;
  gap: 14px;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 14px rgba(43, 33, 33, 0.06);
  animation: cardIn 0.35s var(--ease);
}
.gb-entry-avatar {
  flex-shrink: 0;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border-soft);
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  background: var(--bg-earth);
}
.gb-entry-avatar img { width: 100%; height: 100%; object-fit: cover; }
.gb-entry-body   { flex: 1; min-width: 0; }
.gb-entry-name   { font-weight: 800; color: var(--primary-red); font-size: 0.92rem; margin-bottom: 4px; }
.gb-entry-msg    { font-size: 0.93rem; color: var(--text-dark); line-height: 1.5; word-break: break-word; }
.gb-entry-date   { font-size: 0.76rem; color: var(--text-muted); margin-top: 5px; }
.gb-empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 22px 0;
}

/* ── Music-hint on ecard screen ───────────────────────────── */
.music-hint {
  font-size: 0.78rem;
  color: rgba(43, 33, 33, 0.42);
  margin-top: 10px;
  font-style: italic;
  transition: opacity 0.7s ease;
}
.music-hint.is-hidden { opacity: 0; pointer-events: none; }

@media (max-width: 620px) {
  .polaroid { width: 150px; padding: 9px 9px 6px; }
  .polaroid figcaption { font-size: 0.82rem; }
  .pos-1 { top: 1%;  left: -3%;  }
  .pos-2 { top: 2%;  right: -3%; }
  .pos-3 { top: 32%; left: -6%;  }
  .pos-4 { top: 35%; right: -6%; }
  .pos-5 { bottom: 1%; left: -2%; }
  .pos-6 { bottom: 0%; right: -2%; }
  .ecard-center { padding: 30px 22px; background: rgba(255, 255, 255, 0.86); }
}

