/* ==========================================================================
   PerioNews — Mobile-First Dark Mode PWA Styles
   Zero dependencies, high contrast, iOS safe-area aware
   ========================================================================== */

:root {
  --bg-base: #0b0f17;
  --bg-elevated: #131a27;
  --bg-card: #172031;
  --bg-card-top: #1d283d;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --green: #10b981;
  --green-bright: #34d399;
  --green-bg: rgba(16, 185, 129, 0.16);
  --green-border: rgba(52, 211, 153, 0.55);

  --red: #ef4444;
  --red-bright: #fb7185;
  --red-bg: rgba(239, 68, 68, 0.16);
  --red-border: rgba(251, 113, 133, 0.55);

  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.16);

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;

  --shadow-card: 0 22px 45px -16px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.07);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(30, 58, 138, 0.28), transparent 46%),
    radial-gradient(circle at 86% 100%, rgba(153, 27, 27, 0.22), transparent 48%),
    var(--bg-base);
}

.hidden {
  display: none !important;
}

/* App Shell */
.app-shell {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  position: relative;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  flex-shrink: 0;
  padding-bottom: 10px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-name span {
  color: var(--red-bright);
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.stat-value {
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-streak.is-hot {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.45);
}

.stat-streak.is-hot .stat-value {
  color: #fde68a;
}

.stat-pill.bump {
  animation: statBump 0.35s ease;
}

@keyframes statBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--red-bright), var(--amber), var(--green-bright));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ==========================================================================
   Game Main & Card Deck
   ========================================================================== */
.game-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.deck-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deck-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  color: var(--text-secondary);
  padding: 24px;
}

.deck-status .error-box {
  background: var(--bg-card);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 340px;
}

.deck-status .error-box h2 {
  font-size: 1.05rem;
  color: var(--red-bright);
  margin-bottom: 8px;
}

.deck-status .error-box p {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.deck-status .error-box code {
  display: inline-block;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: #93c5fd;
  user-select: text;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--green-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.card-deck {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 560px;
}

/* Individual Full-Bleed Photo News Card */
.news-card {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: #0d131f;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  touch-action: none;
  will-change: transform;
  cursor: grab;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.news-card.is-dragging {
  cursor: grabbing;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.news-card.is-next {
  transform: scale(0.95) translateY(12px);
  opacity: 0.72;
  pointer-events: none;
}

.news-card.is-back {
  transform: scale(0.9) translateY(24px);
  opacity: 0.35;
  pointer-events: none;
}

.news-card.is-leaving {
  transition: transform 0.36s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s ease;
  pointer-events: none;
}

/* Full-bleed journalist photo background */
.card-bg-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
  pointer-events: none;
  transform: scale(1.01);
}

/* Dual-zone dark gradient scrim for crisp text over photo while keeping face clear */
.card-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(6, 9, 15, 0.90) 0%,
      rgba(6, 9, 15, 0.56) 20%,
      rgba(6, 9, 15, 0.06) 38%,
      rgba(6, 9, 15, 0.12) 52%,
      rgba(6, 9, 15, 0.74) 70%,
      rgba(6, 9, 15, 0.96) 100%
    );
}

/* Dynamic Swipe Stamps */
.swipe-stamp {
  position: absolute;
  top: 118px;
  z-index: 10;
  padding: 8px 18px;
  border-radius: 12px;
  border: 3.5px solid currentColor;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.stamp-believe {
  left: 18px;
  color: var(--green-bright);
  background: rgba(6, 78, 59, 0.78);
  transform: rotate(-14deg);
}

.stamp-fake {
  right: 18px;
  color: var(--red-bright);
  background: rgba(127, 29, 29, 0.82);
  transform: rotate(14deg);
}

/* Foreground Card Overlay */
.card-overlay {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px 20px 16px;
}

/* Top Zone: Big Journalist Name */
.card-top-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.journalist-name-xl {
  font-size: clamp(1.9rem, 7.8vw, 2.45rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: #ffffff;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.75);
}

.journalist-media-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: rgba(11, 15, 23, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.01em;
}

.media-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red-bright);
}

/* Bottom Zone: Channel Badge + News Headline over Photo */
.card-bottom-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.breaking-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 7px;
  background: rgba(239, 68, 68, 0.88);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.news-headline {
  font-size: clamp(1.16rem, 4.7vw, 1.42rem);
  font-weight: 800;
  line-height: 1.32;
  color: #ffffff;
  letter-spacing: -0.015em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

.card-footer-hint {
  margin-top: 4px;
  padding-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.hint-left {
  color: #fda4af;
}

.hint-center {
  opacity: 0.7;
}

.hint-right {
  color: #6ee7b7;
}

/* ==========================================================================
   Action Buttons
   ========================================================================== */
.action-bar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 2px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 60px;
  border-radius: 18px;
  border: 1.5px solid transparent;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-fake {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: #fecdd3;
  box-shadow: 0 10px 24px -10px rgba(239, 68, 68, 0.5);
}

.btn-fake:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.25);
}

.btn-believe {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: #a7f3d0;
  box-shadow: 0 10px 24px -10px rgba(16, 185, 129, 0.5);
}

.btn-believe:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.25);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Truth Reveal Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  background: rgba(4, 7, 13, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}

@media (min-height: 680px) {
  .modal-overlay {
    align-items: center;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 416px;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: #131b2b;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.78);
  animation: sheetPop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sheetPop {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}

.modal-banner.is-correct {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.28), rgba(5, 150, 105, 0.12));
  border-bottom: 1px solid rgba(52, 211, 153, 0.3);
}

.modal-banner.is-wrong {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.28), rgba(185, 28, 28, 0.12));
  border-bottom: 1px solid rgba(251, 113, 133, 0.3);
}

.modal-status-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 900;
}

.is-correct .modal-status-icon {
  background: var(--green);
  color: #052e16;
}

.is-wrong .modal-status-icon {
  background: var(--red);
  color: #fff1f2;
}

.modal-result-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
}

.modal-points-delta {
  font-size: 0.86rem;
  font-weight: 700;
  margin-top: 3px;
}

.is-correct .modal-points-delta {
  color: var(--green-bright);
}

.is-wrong .modal-points-delta {
  color: var(--red-bright);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.verdict-pill {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.verdict-pill.is-truth {
  background: var(--green-bg);
  color: var(--green-bright);
  border: 1px solid var(--green-border);
}

.verdict-pill.is-lie {
  background: var(--red-bg);
  color: var(--red-bright);
  border: 1px solid var(--red-border);
}

.modal-journalist {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.modal-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
}

.modal-journalist-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.modal-journalist-meta strong {
  font-size: 0.94rem;
  color: var(--text-primary);
}

.modal-journalist-meta span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-explanation {
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.modal-source {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 13px;
  border-radius: 13px;
  background: rgba(16, 185, 129, 0.11);
  border: 1px solid rgba(52, 211, 153, 0.36);
}

.source-header {
  display: flex;
  align-items: center;
}

.source-badge {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green-bright);
}

.source-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.35;
}

.source-link:hover {
  text-decoration: underline;
}

.source-link.is-static {
  pointer-events: none;
}

.source-link.is-static .source-ext {
  display: none;
}

.source-ext {
  flex-shrink: 0;
  font-size: 0.95rem;
  color: var(--green-bright);
}

.recap-source-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #60a5fa;
  text-decoration: none;
}

.recap-source-link:hover {
  text-decoration: underline;
}

.modal-footer {
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border-subtle);
}

.primary-btn {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #dbeafe 100%);
  color: #0b0f17;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.97);
}

.primary-btn:hover {
  filter: brightness(1.04);
}

/* ==========================================================================
   End-of-Deck Summary Screen
   ========================================================================== */
.end-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: 6px;
}

.end-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(175deg, var(--bg-card-top) 0%, var(--bg-card) 55%, #101725 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 22px 20px 18px;
  box-shadow: var(--shadow-card);
  text-align: center;
  animation: sheetPop 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.end-badge {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}

.end-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--red-bright);
  margin-bottom: 4px;
}

.end-rank {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.end-subtitle {
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.end-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.18rem;
  font-weight: 900;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.recap-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  text-align: left;
  margin-bottom: 14px;
}

.recap-title {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.recap-list {
  list-style: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.recap-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  line-height: 1.35;
}

.recap-dot {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 900;
  margin-top: 1px;
}

.recap-dot.ok {
  background: var(--green-bg);
  color: var(--green-bright);
  border: 1px solid var(--green-border);
}

.recap-dot.fail {
  background: var(--red-bg);
  color: var(--red-bright);
  border: 1px solid var(--red-border);
}

.recap-item-copy {
  min-width: 0;
}

.recap-item-copy strong {
  display: block;
  color: var(--text-primary);
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.recap-item-copy span {
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Compact screen adjustments (iPhone SE / small viewports) */
@media (max-height: 670px) {
  .card-overlay {
    padding: 15px 16px 12px;
  }

  .journalist-name-xl {
    font-size: 1.7rem;
  }

  .swipe-stamp {
    top: 94px;
    font-size: 1.25rem;
  }

  .news-headline {
    font-size: 1.08rem;
    line-height: 1.28;
  }

  .action-btn {
    height: 52px;
  }
}
