/* ============================================================
   SMIRI DONALDA — Style Sheet
   ============================================================ */

/* ── Google Font ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;900&family=Playfair+Display:wght@700;900&family=Lora:ital,wght@0,400;0,700;1,400&display=swap');

/* ── CSS Custom Properties ───────────────────────────────────── */
:root {
  --font-main: 'Outfit', sans-serif;

  /* Palette */
  --bg-dark: #0b0f19;
  --bg-card: rgba(20, 28, 48, 0.85);
  --bg-chat: rgba(12, 18, 35, 0.92);
  --accent-red: #ff3b3b;
  --accent-gold: #ffc531;
  --accent-green: #2ecc71;
  --accent-blue: #3498db;
  --text-primary: #f0f0f0;
  --text-secondary: #a0aec0;

  /* Stress bar colours (overridden dynamically) */
  --stress-color: var(--accent-green);

  /* Sizes */
  --bar-height: 38px;
  --chat-width: 350px;
  --chat-height: 420px;

  /* z-layers */
  --z-bg: 1;
  --z-news: 10;
  --z-donald: 20;
  --z-ui: 50;
  --z-overlay: 100;

  /* Mobile Keyboard */
  --keyboard-offset: 0px;
  --visual-viewport-height: 100vh;
}

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

html, body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none; /* Disable all browser gestures (zoom, pan, etc.) */
  user-select: none;  /* Disable text selection */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none; /* Prevent rubber-banding on iOS */
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ── Hero Container ──────────────────────────────────────────── */
#game-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(30, 50, 100, 0.35) 0%, transparent 60%),
    #000;
}

/* ── Stress Meter ────────────────────────────────────────────── */
#stress-bar-wrapper {
  position: absolute;
  bottom: var(--keyboard-offset, 0);
  left: 0;
  width: 100%;
  height: calc(var(--bar-height) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: rgba(0, 0, 0, 0.9); /* More opaque when floating */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1100; /* Above everything including chat */
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#stress-bar-wrapper .label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
  animation: label-pulse 2s ease-in-out infinite;
}

@keyframes label-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.98); color: var(--stress-color); }
}

#stress-bar-track {
  flex: 1;
  height: 16px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: visible; /* Changed from hidden to allow sparks/glows to be seen */
  position: relative;
}

#nuclear-icon {
  font-size: 22px;
  animation: nuclear-spin 4s linear infinite;
  filter: drop-shadow(0 0 5px var(--accent-gold));
  text-shadow: 0 0 10px var(--stress-color);
  cursor: help;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes nuclear-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#stress-bar-fill {
  height: 100%;
  width: 20%;
  border-radius: 10px;
  background-color: var(--stress-color);
  position: relative;
  /* Removed overflow: hidden to allow the spark and glow to exceed bounds */
  transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.4s ease;
  box-shadow: 0 0 15px var(--stress-color);
}

/* Moving Zebra Stripes (Inner) */
#stress-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.15) 10px,
    transparent 10px,
    transparent 20px
  );
  background-size: 40px 40px;
  animation: bar-stripes 1s linear infinite;
  mask-image: linear-gradient(to bottom, black, black); /* clips to parent radius */
}

/* Spark at the tip of the bar */
#stress-bar-fill::before {
  content: "⚡";
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  filter: drop-shadow(0 0 8px #fff);
  animation: spark-jump 0.2s ease-in-out infinite alternate;
  z-index: 5;
}

@keyframes spark-jump {
  from { transform: translateY(-50%) scale(1) rotate(0deg); opacity: 0.8; }
  to { transform: translateY(-60%) scale(1.3) rotate(15deg); opacity: 1; }
}

@keyframes bar-stripes {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}

/* Critical State */
#stress-bar-fill.critical {
  animation: bar-blink-red 0.2s infinite alternate;
}

@keyframes bar-blink-red {
  from { filter: brightness(1); box-shadow: 0 0 15px #ff3b3b; }
  to { filter: brightness(1.8); box-shadow: 0 0 40px #ff3b3b, 0 0 80px rgba(255, 59, 59, 0.6); }
}

/* Hit Flash Animation */
#stress-bar-fill.hit {
  animation: bar-hit 0.3s ease-out;
}

@keyframes bar-hit {
  0% { filter: brightness(2); transform: scaleY(1.2); }
  100% { filter: brightness(1); transform: scaleY(1); }
}

#stress-value {
  font-size: 15px;
  font-weight: 900;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* ── Donald Background Layers (full-screen hero) ────────────── */
/* ── Donald Background Container ────────────────────────────── */
#donald-bg-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: var(--z-bg);
  background: #000;
  overflow: hidden;
}

.donald-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 10%;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  animation: bg-breathe 25s ease-in-out infinite alternate;
}

@keyframes bg-breathe {
  from { transform: scale(1) rotate(0deg); }
  to { transform: scale(1.08) rotate(1deg); }
}

.donald-bg.active {
  opacity: 1;
}

#ambient-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5; /* Above background images, below UI */
  mix-blend-mode: plus-lighter; /* Better glow effect for embers */
}

/* Dark vignette overlay on top of background */
#donald-vignette {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-bg) + 1);
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 15%, transparent 85%, rgba(0, 0, 0, 0.7) 100%);
}
/* ── App Title ───────────────────────────────────────────────── */
#app-title {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: var(--z-ui);
  font-family: var(--font-main);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ── Language Switcher ───────────────────────────────────────── */
#lang-switcher {
  position: absolute;
  top: 20px;
  right: 15px; /* Moved to right corner above news feed */
  z-index: var(--z-ui);
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.lang-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.lang-btn.active {
  background: var(--accent-gold);
  color: #000;
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(255, 197, 49, 0.4);
}

/* ── Chatbox ─────────────────────────────────────────────────── */
#chatbox {
  position: absolute;
  top: auto;
  left: 80px;
  bottom: calc(var(--bar-height) + 20px);
  width: var(--chat-width);
  height: 62vh;
  background: rgba(12, 18, 35, 0.88);
  border: 1px solid rgba(255, 59, 59, 0.15);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-ui);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
}

#chatbox.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

#chatbox.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Chat Alert Banner ───────────────────────────────────────── */
#chat-alert {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-ui);
  background: rgba(255, 59, 59, 0.2);
  border: 2px solid var(--accent-red);
  border-radius: 16px;
  padding: 18px 32px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 40px rgba(255, 59, 59, 0.3);
  animation: alert-pulse 1.5s ease-in-out infinite;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#chat-alert.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: none;
}

#chat-alert.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 40px rgba(255, 59, 59, 0.3); }
  50% { box-shadow: 0 0 60px rgba(255, 59, 59, 0.6), 0 0 100px rgba(255, 59, 59, 0.2); }
}

#chat-header {
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-gold);
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#chat-header .title {
  display: flex;
  align-items: center;
  gap: 8px;
}

#chat-header .title::before {
  content: '🛋️';
}

#chat-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 5px;
  transition: color 0.2s, transform 0.2s;
}

#chat-close:hover {
  color: var(--accent-red);
  transform: scale(1.2);
}

/* ── Psychotherapist Icon ───────────────────────────────────── */
#psy-icon {
  position: absolute;
  bottom: calc(var(--bar-height) + 20px);
  left: 15px;
  width: 55px;
  height: 55px;
  background: rgba(12, 18, 35, 0.95);
  border: 2px solid rgba(255, 197, 49, 0.5);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--z-ui);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 25px rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
}

#psy-icon:hover {
  transform: scale(1.1) translateY(-5px);
  border-color: var(--accent-gold);
  box-shadow: 0 12px 35px rgba(255, 197, 49, 0.5);
}

#psy-icon .icon {
  font-size: 28px;
  filter: drop-shadow(0 0 5px rgba(255, 197, 49, 0.3));
}

#psy-icon .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent-gold);
  color: #000;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

#psy-icon.mandatory {
  border-color: var(--accent-red);
  background: rgba(255, 59, 59, 0.1);
  animation: psy-pulse 0.8s infinite alternate;
}

@keyframes psy-pulse {
  from { 
    transform: scale(1); 
    box-shadow: 0 0 15px rgba(255, 59, 59, 0.4);
    border-color: rgba(255, 59, 59, 0.5);
  }
  to { 
    transform: scale(1.2) translateY(-5px); 
    box-shadow: 0 0 40px rgba(255, 59, 59, 0.8), 0 0 60px rgba(255, 59, 59, 0.4);
    border-color: var(--accent-red);
  }
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Scrollbar */
#chat-messages::-webkit-scrollbar {
  width: 5px;
}
#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  animation: msg-in 0.3s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: rgba(52, 152, 219, 0.25);
  border: 1px solid rgba(52, 152, 219, 0.35);
  color: #dbeafe;
}

.msg.donald {
  align-self: flex-start;
  background: rgba(255, 197, 49, 0.15);
  border: 1px solid rgba(255, 197, 49, 0.25);
  color: #fef3c7;
}

.msg.system {
  align-self: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  font-size: 12px;
}

#chat-input-wrapper {
  display: flex;
  padding: 10px;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--accent-blue);
}

#chat-input::placeholder {
  color: var(--text-secondary);
}

#chat-send {
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  color: #fff;
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

#chat-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.4);
}

#chat-send:active {
  transform: scale(0.97);
}



/* ── Countdown Overlay ───────────────────────────────────────── */
#countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#countdown-overlay.active {
  display: flex;
  pointer-events: auto;
}

#countdown-overlay .countdown-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,0,0,0.2) 0%, rgba(0,0,0,0.9) 100%);
  opacity: 0;
  animation: countdown-backdrop-in 0.5s forwards;
}

@keyframes countdown-backdrop-in {
  to { opacity: 1; }
}

#countdown-text {
  position: relative;
  z-index: 2;
  font-size: clamp(100px, 20vw, 250px);
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  font-family: var(--font-main);
  text-shadow: 
    0 0 20px rgba(255, 0, 0, 0.8),
    0 0 40px rgba(255, 59, 59, 0.6),
    0 0 80px rgba(255, 59, 59, 0.4);
  transform: scale(0);
  opacity: 0;
}

.countdown-anim {
  animation: countdown-pulse 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes countdown-pulse {
  0% { transform: scale(0.2); opacity: 0; filter: blur(10px); }
  30% { transform: scale(1.2); opacity: 1; filter: blur(0px); }
  50% { transform: scale(1); opacity: 1; filter: blur(0px); }
  80% { transform: scale(1); opacity: 1; filter: blur(0px); }
  100% { transform: scale(1.5); opacity: 0; filter: blur(20px); }
}

.countdown-boom {
  animation: countdown-boom-anim 1s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
  color: #ff3b3b !important;
  text-shadow: 
    0 0 50px #ff3b3b,
    0 0 100px #ff0000,
    0 0 150px #ffaa00 !important;
}

@keyframes countdown-boom-anim {
  0% { transform: scale(0.5); opacity: 0; }
  20% { transform: scale(1.5); opacity: 1; }
  100% { transform: scale(3); opacity: 0; filter: blur(30px); }
}

/* ── Endgame Overlay ─────────────────────────────────────────── */
#endgame-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}

#endgame-overlay.active {
  display: flex;
}

#endgame-overlay .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}

#endgame-overlay .content {
  position: relative;
  z-index: 2;
  text-align: center;
  animation: overlay-in 0.6s ease;
}

@keyframes overlay-in {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

#endgame-overlay .content h1 {
  font-size: clamp(28px, 5vw, 60px);
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 14px;
}

#endgame-overlay .content p {
  font-size: clamp(14px, 2vw, 20px);
  color: var(--text-secondary);
}

#endgame-overlay .content h1.game-over {
  color: var(--accent-red);
  text-shadow: 0 0 40px rgba(255, 59, 59, 0.6);
}

#endgame-overlay .content h1.victory {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#restart-btn {
  padding: 14px 36px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-gold), #ff8c00);
  color: #000;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 2;
}

#restart-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(255, 197, 49, 0.5);
}

/* ── Explosion Canvas ────────────────────────────────────────── */
#explosion-canvas {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) - 1);
  pointer-events: none;
}

/* ── Confetti Canvas ─────────────────────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-overlay) - 1);
  pointer-events: none;
}

/* ── Instructions badge ──────────────────────────────────────── */
#instructions {
  position: absolute;
  bottom: calc(var(--bar-height) + 12px);
  right: 230px;
  z-index: var(--z-ui);
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 18px;
  max-width: 280px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#instructions strong {
  color: var(--accent-gold);
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

/* ── News Feed (Right Side Strip) ────────────────────────────── */
#news-feed-wrapper {
  position: absolute;
  top: 75px;
  right: 5px;
  bottom: calc(var(--bar-height) + 10px);
  width: 210px;
  z-index: var(--z-ui);  /* Above donald bg layers */
  overflow: hidden;
  /* Removed pointer-events: none to ensure scrolling works reliably */
  /* Fade edges for stacking illusion */
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black 8%,
    black 92%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black 8%,
    black 92%,
    transparent 100%
  );
}

#news-feed-container {
  height: 100%;
  overflow-y: auto;
  padding: 40px 10px 40px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: none;
  pointer-events: auto;  /* Re-enable clicks inside */
}

#news-feed-container::-webkit-scrollbar {
  display: none;
}

/* ── News Card ──────────────────────────────────────────────── */
.news-card {
  width: 100%;
  height: 135px;       /* Increased for newspaper details */
  flex-shrink: 0;
  cursor: pointer;
  perspective: 900px;
  /* Transform is set by JS for scroll effect, don't add CSS transitions
     that fight with it — transitions are on .card-inner only */
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.news-card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 2px; /* Newspaper edges are usually sharp or slightly rounded */
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid #d3d0c9;
  background: rgba(253, 250, 243, 0.87); /* Newspaper paper color (87% opacity on desktop) */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

/* ── Card Front ─────────────────────────────────────────────── */
.card-front {
  background-color: rgba(253, 250, 243, 0.87);
  background-image: 
    radial-gradient(#e6e1d6 1px, transparent 0),
    radial-gradient(#e6e1d6 1px, transparent 0);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  border-top: 3px double #1a1a1a;
  border-bottom: 3px double #1a1a1a;
}

.card-front h3 {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  color: #1a1a1a;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: -0.2px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  border-bottom: 1px solid #333;
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.newspaper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 6.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #666;
  border-bottom: 1px solid #ccc;
  padding-bottom: 3px;
  margin-bottom: 8px;
  font-family: var(--font-main);
}

.newspaper-footer {
  font-size: 6px;
  font-weight: 400;
  color: #888;
  text-align: right;
  margin-top: 5px;
  border-top: 1px dotted #ccc;
  padding-top: 3px;
  font-style: italic;
}

.card-front .badge {
  font-family: var(--font-main);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid currentColor;
  border-radius: 0;
  width: fit-content;
}

.newspaper-header span:first-child {
  font-weight: 900;
  color: #1a1a1a;
}

/* ── Card Back ──────────────────────────────────────────────── */
.card-back {
  background: rgba(253, 250, 243, 0.87);
  transform: rotateY(180deg);
  border-top: 3px double #1a1a1a;
  border-bottom: 3px double #1a1a1a;
}

.card-back p {
  font-family: 'Lora', serif;
  font-size: 10px;
  line-height: 1.35;
  color: #222;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  font-style: italic;
}

/* ── Type-specific accents ──────────────────────────────────── */
/* ── Newspaper Accents ──────────────────────────────────── */
.news-card.real .card-front {
  border-top-color: #000;
}
.news-card.real .card-front .badge {
  color: #cc0000;
}

.news-card.satire .card-front {
  border-top-color: #000;
}
.news-card.satire .card-front .badge {
  color: #996600;
}

/* ── Responsive tweaks ───────────────────────────────────────── */
@media (max-width: 900px) {
  #instructions {
    display: none;
  }

  .donald-bg {
    background-position: center 10%;
  }
  
  /* Chat Icon - Top Left */
  #psy-icon {
    top: 20px;
    left: 15px;
    bottom: auto;
  }

  /* Language Switcher - Top Right */
  #lang-switcher {
    top: 20px;
    right: 15px;
  }

  /* App Title - Centered between Chat and Lang Switcher */
  #app-title {
    top: 32px;
    left: 75px;
    right: 145px;
    transform: none;
    font-size: clamp(11px, 3.5vw, 16px);
    letter-spacing: 1px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Chatbox */
  #chatbox {
    width: calc(100vw - 20px);
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(var(--keyboard-offset, 0px) + var(--bar-height) + 10px);
    height: auto;
    max-height: calc(var(--visual-viewport-height, 100vh) - 100px);
    --chat-width: calc(100vw - 20px);
    z-index: 1000;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  }

  #chat-messages {
    max-height: 40vh;
  }

  #news-feed-wrapper {
    display: block; 
    top: auto;
    bottom: calc(var(--keyboard-offset, 0px) + var(--bar-height) + env(safe-area-inset-bottom, 0));
    left: 0;
    right: auto;
    width: 100vw;
    height: 165px; /* Slightly taller to accommodate scroll shadow */
    mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);
    pointer-events: auto;
    z-index: 900; /* Just below the stress bar but above background */
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #news-feed-container {
    flex-direction: row;
    overflow-y: hidden;
    overflow-x: auto;
    padding: 10px 20px;
    gap: 15px;
    align-items: center;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    pointer-events: auto;
  }

  /* Dodatni prazni prostor na kraju da zadnja kartica ne bude odrezana maskom */
  #news-feed-container::after {
    content: "";
    flex: 0 0 20px;
    height: 10px;
  }

  .news-card {
    width: 220px;
    height: 135px;
    flex: 0 0 auto; /* Ensures card doesn't shrink and breaks flex layout */
  }

  /* Override opacity for mobile (45% instead of 87%) */
  .card-front, .card-back {
    background: rgba(253, 250, 243, 0.45);
  }
  .card-front {
    background-color: rgba(253, 250, 243, 0.45);
  }
  .card-back {
    background: rgba(253, 250, 243, 0.45);
  }
}

/* ── Stress Card (Left Side) ────────────────────────────────── */
#stress-card {
  position: fixed !important; 
  top: 120px !important;
  left: 30px !important;
  width: 300px !important;
  background: rgba(15, 23, 42, 0.85) !important; /* Slightly more opaque */
  backdrop-filter: blur(25px) !important;
  -webkit-backdrop-filter: blur(25px) !important;
  border: 2px solid rgba(255, 255, 255, 0.2) !important; /* Brighter border */
  border-radius: 24px !important;
  padding: 30px 20px !important;
  z-index: 10000 !important; 
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6) !important;
  visibility: visible !important;
  opacity: 1 !important;
}

#stress-card .card-header {
  margin-bottom: 20px;
}

#stress-card .badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#stress-emoji-container {
  width: 100px;
  height: 100px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#stress-emoji-svg {
  width: 90px;
  height: 90px;
  display: block;
}

#stress-emoji-svg .face {
  fill: #2ecc71;
  transition: fill 0.5s ease;
}

#stress-emoji-svg .eyes circle {
  fill: #000;
  transition: all 0.5s ease;
}

#stress-emoji-svg .mouth {
  fill: none;
  stroke: #000;
  stroke-width: 4;
  stroke-linecap: round;
  transition: d 0.5s ease, stroke 0.5s ease;
}

/* Card Stress Value */
#card-stress-value {
  font-size: 42px;
  font-weight: 900;
  color: #2ecc71;
  margin-bottom: 12px;
  transition: color 0.5s ease;
  font-family: var(--font-main);
}

/* Card Bar */
.card-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}

#card-bar-fill {
  height: 100%;
  width: 20%;
  background: #2ecc71;
  border-radius: 10px;
  transition: width 0.4s ease, background 0.4s ease;
}

#stress-status-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
  color: #fff;
}

#stress-status-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Specific States */
#stress-card.moderate {
  border-color: rgba(241, 196, 15, 0.3);
}

#stress-card.critical {
  border-color: rgba(255, 59, 59, 0.4);
}

/* Card is now always visible or hidden via JS if needed */
