/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --accent-rgb: 34, 197, 94;     /* green — updated live by JS */
  --bg: #0a0a0f;
  --card-bg: #12121a;
  --card-border: #1e1e2e;
  --text: #e2e8f0;
  --text-muted: #4a5568;
  --radius: 12px;
  --transition: 0.45s ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color var(--transition);
}

/* ============================================================
   Layout
   ============================================================ */
.page-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  position: relative;
  z-index: 1;
}

/* ============================================================
   Header
   ============================================================ */
header {
  text-align: center;
  margin-bottom: 3rem;
}

header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-shadow: 0 0 50px rgba(var(--accent-rgb), 0.45);
  transition: text-shadow var(--transition);
}

.subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* ============================================================
   Card Deck
   ============================================================ */
.deck-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 4rem;
}

.deck-wrapper {
  position: relative;
  width: 520px;
  max-width: calc(100vw - 2rem);
  overflow: visible;
  padding-bottom: 22px; /* room for ghost cards peeking below */
}

.card {
  background: var(--card-bg);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 20px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transition: border-color var(--transition);
}

.card-active {
  position: relative;
  z-index: 2;
}

.card-ghost-1,
.card-ghost-2 {
  position: absolute;
  inset: 0;
}

.card-ghost-2 {
  transform: rotate(-5deg) translateY(14px) scale(0.96);
  z-index: 0;
  opacity: 0.45;
}

.card-ghost-1 {
  transform: rotate(-2.5deg) translateY(7px) scale(0.98);
  z-index: 1;
  opacity: 0.65;
}

@keyframes flyAway {
  0%   { transform: translateX(0) rotate(0deg); opacity: 1; }
  20%  { transform: translateX(8%) rotate(6deg); opacity: 1; }
  100% { transform: translateX(150%) rotate(28deg); opacity: 0; }
}

@keyframes enterCard {
  from { transform: translateX(-110%) rotate(-12deg); opacity: 0; }
  to   { transform: translateX(0) rotate(0deg); opacity: 1; }
}

.card.flying {
  animation: flyAway 0.5s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

.card.entering {
  animation: enterCard 0.38s cubic-bezier(0, 0, 0.2, 1) forwards;
}

/* ============================================================
   Card Content
   ============================================================ */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.card-progress {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.22rem 0.6rem;
  border-radius: 20px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.3;
}

/* ============================================================
   Answer Buttons
   ============================================================ */
.card-answers {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.answer-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: 0.825rem;
  line-height: 1.45;
  transition: background 0.13s, border-color 0.13s, transform 0.1s;
  width: 100%;
}

.answer-btn:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.09);
  border-color: rgba(var(--accent-rgb), 0.35);
  transform: translateX(3px);
}

.answer-btn:disabled { cursor: default; }

.answer-btn.selected {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgb(var(--accent-rgb));
}

.answer-label {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 0.08rem;
}

.answer-btn[data-score="4"] .answer-label { background: rgba(239,68,68,0.18);  color: #f87171; }
.answer-btn[data-score="3"] .answer-label { background: rgba(245,158,11,0.18); color: #fbbf24; }
.answer-btn[data-score="2"] .answer-label { background: rgba(234,179,8,0.18);  color: #facc15; }
.answer-btn[data-score="1"] .answer-label { background: rgba(132,204,22,0.18); color: #a3e635; }
.answer-btn[data-score="0"] .answer-label { background: rgba(34,197,94,0.18);  color: #4ade80; }

.answer-key {
  margin-left: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.63rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  align-self: center;
}

/* ============================================================
   Deck Controls
   ============================================================ */
.deck-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 520px;
  max-width: calc(100vw - 2rem);
}

.back-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.back-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(var(--accent-rgb), 0.5);
}

.back-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Result Section
   ============================================================ */
.result-section {
  max-width: 640px;
  margin: 0 auto;
  display: none;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

.result-section.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ============================================================
   Flame Canvas — fixed full-width bar at viewport bottom
   ============================================================ */
.flame-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.flame-wrapper.visible {
  opacity: 1;
  transform: translateY(0);
}

#flame-canvas {
  display: block;
  width: 100%;
}

/* ============================================================
   Result Card
   ============================================================ */
.result-card {
  background: var(--card-bg);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: var(--radius);
  padding: 2.25rem 2.5rem 2rem;
  text-align: center;
  box-shadow:
    0 0 50px rgba(var(--accent-rgb), 0.1),
    0 12px 40px rgba(0, 0, 0, 0.55);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.risk-display {
  margin-bottom: 1.2rem;
}

.risk-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.risk-percent {
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
  color: rgb(var(--accent-rgb));
  text-shadow: 0 0 40px rgba(var(--accent-rgb), 0.55);
  transition: color var(--transition), text-shadow var(--transition);
}

.pct-sign {
  font-size: 2.75rem;
  font-weight: 700;
  vertical-align: super;
}

/* ============================================================
   Risk Bar
   ============================================================ */
.risk-bar-track {
  background: #1a1a28;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 1.6rem;
}

.risk-bar-fill {
  height: 100%;
  border-radius: 5px;
  width: 0%;
  background: rgb(var(--accent-rgb));
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.65);
  transition: width 0.5s ease, background var(--transition), box-shadow var(--transition);
}

/* ============================================================
   Verdict & Tip
   ============================================================ */
.verdict {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.65rem;
  transition: color var(--transition);
}

.tip {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  min-height: 1.3em;
  margin-bottom: 1.75rem;
}

/* ============================================================
   Share Button
   ============================================================ */
.share-btn {
  background: transparent;
  border: 1px solid rgba(var(--accent-rgb), 0.38);
  color: rgb(var(--accent-rgb));
  padding: 0.6rem 1.6rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.share-btn:hover {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgb(var(--accent-rgb));
}

.share-feedback {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.55rem;
  min-height: 1.2em;
}

.restart-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  padding: 0.6rem 1.6rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.restart-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   Confirm Modal
   ============================================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  backdrop-filter: blur(4px);
}

.confirm-overlay.hidden {
  display: none;
}

.confirm-box {
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 2rem 2.25rem;
  max-width: 360px;
  width: calc(100vw - 2rem);
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.confirm-msg {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.confirm-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  padding: 0.55rem 1.4rem;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.confirm-cancel:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
}

.confirm-ok {
  background: #ef4444;
  border: none;
  color: #fff;
  padding: 0.55rem 1.4rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.confirm-ok:hover {
  opacity: 0.85;
}

.report-btn {
  display: block;
  width: 100%;
  background: rgb(var(--accent-rgb));
  border: none;
  color: #0a0a0f;
  padding: 0.75rem 1.75rem;
  border-radius: 8px;
  font-size: 0.925rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: opacity 0.2s, background var(--transition);
  letter-spacing: 0.01em;
}

.report-btn:hover {
  opacity: 0.85;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .result-card {
    padding: 1.5rem 1.25rem;
  }

  .risk-percent {
    font-size: 4.5rem;
  }
}

@media (max-width: 480px) {
  .questions-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Report Modal Overlay
   ============================================================ */
.report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
  opacity: 1;
  transition: opacity 0.25s ease;
}

.report-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ============================================================
   Paper
   ============================================================ */
.report-paper {
  background: #fdf8f0;
  color: #1a1a1a;
  width: min(700px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 3px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    3px 3px 0 #e0d8cc,
    6px 6px 0 #d4cdc0;
  position: relative;
  padding: 3rem 3.5rem 2.5rem;
  font-family: Georgia, 'Times New Roman', serif;
}

/* Watermark */
.report-paper::before {
  content: 'CONFIDENTIAL';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 4.5rem;
  font-weight: 900;
  color: rgba(180, 30, 30, 0.06);
  letter-spacing: 0.08em;
  pointer-events: none;
  white-space: nowrap;
  user-select: none;
}

.report-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: transparent;
  border: 1px solid #c8bfb0;
  color: #666;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.report-close:hover {
  background: #ede8e0;
  color: #111;
}

/* ============================================================
   Report Header
   ============================================================ */
.report-header {
  text-align: center;
  border-bottom: 2px solid #c8bfb0;
  padding-bottom: 1.25rem;
  margin-bottom: 1rem;
}

.report-company {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: #999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  margin-bottom: 0.4rem;
}

.report-title {
  font-size: 1.45rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #111;
}

.report-subtitle {
  font-size: 0.72rem;
  color: #999;
  font-style: italic;
  margin-top: 0.2rem;
}

/* ============================================================
   Meta Row
   ============================================================ */
.report-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #777;
  margin: 0.75rem 0 1.5rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   Score Box
   ============================================================ */
.report-score-box {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #f5f0e8;
  border: 1px solid #d8d0c4;
  border-radius: 4px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.75rem;
}

.report-score-number {
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.report-score-pct {
  font-size: 1.5rem;
  font-weight: 700;
}

.report-score-right { flex: 1; }

.report-score-label {
  font-size: 0.75rem;
  color: #777;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  margin-bottom: 0.4rem;
}

.report-bar-track {
  height: 7px;
  background: #ddd8d0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.report-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.report-classification {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   Section Titles
   ============================================================ */
.report-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #999;
  border-bottom: 1px solid #d8d0c4;
  padding-bottom: 0.3rem;
  margin: 1.75rem 0 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ============================================================
   Report Items
   ============================================================ */
.report-item {
  margin-bottom: 1.25rem;
}

.report-item--caution {
  opacity: 0.82;
}

.report-item-title {
  font-size: 0.975rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.report-severity {
  font-size: 0.72rem;
  font-weight: 400;
  color: #888;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.report-item-weakness {
  font-size: 0.83rem;
  color: #555;
  font-style: italic;
  line-height: 1.55;
  margin-bottom: 0.4rem;
}

.report-item-action {
  font-size: 0.83rem;
  color: #222;
  line-height: 1.6;
  padding-left: 0.9rem;
  border-left: 3px solid #c8bfb0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.report-empty {
  font-size: 0.83rem;
  color: #aaa;
  font-style: italic;
}

.report-safe-list {
  font-size: 0.83rem;
  color: #444;
  line-height: 1.8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.report-conclusion {
  font-size: 0.875rem;
  color: #333;
  line-height: 1.75;
}

/* ============================================================
   Signature Footer
   ============================================================ */
.report-footer {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #c8bfb0;
}

.report-sig-block { flex: 1; }

.report-signature-line {
  border-bottom: 1px solid #888;
  margin-top: 2rem;
  margin-bottom: 0.3rem;
}

.report-signature-label {
  font-size: 0.65rem;
  color: #aaa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.report-disclaimer {
  font-size: 0.7rem;
  color: #bbb;
  text-align: center;
  margin-top: 1.5rem;
  font-style: italic;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
}

/* ============================================================
   Print Button
   ============================================================ */
.report-print-btn {
  display: block;
  margin: 1.5rem auto 0;
  background: transparent;
  border: 1px solid #c8bfb0;
  color: #666;
  padding: 0.5rem 1.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  transition: background 0.15s;
}

.report-print-btn:hover {
  background: #ede8e0;
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  body > *:not(.report-overlay) { display: none !important; }

  .report-overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    backdrop-filter: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .report-paper {
    box-shadow: none !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    padding: 2rem !important;
  }

  .report-close,
  .report-print-btn { display: none !important; }
}

@media (max-width: 600px) {
  .report-paper {
    padding: 2rem 1.5rem;
  }

  .report-footer {
    flex-direction: column;
    gap: 1rem;
  }

  .report-meta {
    flex-direction: column;
    gap: 0.25rem;
  }
}
