/* ═══════════════════════════════════════════════════════════════════════════
   SIGNAL PERDU — Styles
   Underground bioluminescent aesthetic
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

:root {
  --bg-deep: #0a0c10;
  --bg-surface: #0f1219;
  --bg-card: #141821;
  --bg-card-hover: #1a1f2e;
  
  --glow-cyan: #00e5cc;
  --glow-blue: #0088ff;
  --glow-purple: #7c3aed;
  --glow-green: #22d366;
  --glow-amber: #f0a030;
  --glow-red: #ff3b5c;
  
  --text-primary: #e8ecf4;
  --text-secondary: #8892a4;
  --text-dim: #4a5468;
  --text-aya: #00e5cc;
  
  --signal-good: #22d366;
  --signal-medium: #f0a030;
  --signal-bad: #ff3b5c;
  
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-serif: 'Crimson Pro', Georgia, serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-mono);
  background: var(--bg-deep);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

/* ── Background effects ──────────────────────────────────────────────────── */

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(0, 229, 204, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 136, 255, 0.02) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(124, 58, 237, 0.02) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Noise texture overlay */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* ── Header / Signal bar ─────────────────────────────────────────────────── */

.header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(180deg, rgba(15,18,25,0.98) 0%, rgba(15,18,25,0.85) 100%);
  border-bottom: 1px solid rgba(0, 229, 204, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.signal-icon {
  position: relative;
  width: 20px;
  height: 16px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.signal-bar {
  width: 3px;
  background: var(--signal-good);
  border-radius: 1px;
  transition: height 0.5s, background 0.5s;
}
.signal-bar:nth-child(1) { height: 4px; }
.signal-bar:nth-child(2) { height: 7px; }
.signal-bar:nth-child(3) { height: 10px; }
.signal-bar:nth-child(4) { height: 14px; }

.signal-bar.inactive {
  background: var(--text-dim);
}

.signal-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.header-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-reset {
  background: none;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}
.btn-reset:hover {
  border-color: var(--glow-red);
  color: var(--glow-red);
}

/* ── Chat area ───────────────────────────────────────────────────────────── */

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  z-index: 5;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
  width: 4px;
}
.chat-container::-webkit-scrollbar-track {
  background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 204, 0.15);
  border-radius: 2px;
}

.messages-wrapper {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Message bubbles ─────────────────────────────────────────────────────── */

.message {
  opacity: 0;
  transform: translateY(10px);
  animation: messageIn 0.4s ease forwards;
  padding: 2px 0;
}

.message-aya {
  align-self: flex-start;
}

.message-aya .bubble {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.message-aya .bubble.static {
  color: var(--glow-cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.message-system {
  align-self: center;
  text-align: center;
}

.message-system .bubble {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--glow-cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
  padding: 8px 16px;
  border: 1px solid rgba(0, 229, 204, 0.15);
  border-radius: 20px;
  background: rgba(0, 229, 204, 0.03);
}

.message-player {
  align-self: flex-end;
}

.message-player .bubble {
  background: rgba(0, 136, 255, 0.12);
  border: 1px solid rgba(0, 136, 255, 0.2);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  max-width: 85%;
  line-height: 1.5;
}

/* ── Typing indicator ────────────────────────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  opacity: 0;
  animation: messageIn 0.3s ease forwards;
}

.typing-indicator .label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--glow-cyan);
  opacity: 0.4;
  animation: typingPulse 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Choices ─────────────────────────────────────────────────────────────── */

.choices-container {
  position: relative;
  z-index: 10;
  padding: 16px 20px 28px;
  background: linear-gradient(0deg, rgba(10,12,16,0.98) 0%, rgba(10,12,16,0.9) 70%, transparent 100%);
}

.choices-wrapper {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  background: rgba(0, 229, 204, 0.04);
  border: 1px solid rgba(0, 229, 204, 0.15);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  padding: 14px 18px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.choice-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(0, 229, 204, 0.08) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
}

.choice-btn:hover {
  border-color: var(--glow-cyan);
  background: rgba(0, 229, 204, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 229, 204, 0.1);
}

.choice-btn:hover::before {
  opacity: 1;
}

.choice-btn:active {
  transform: translateY(0);
}

.choice-btn.selected {
  border-color: var(--glow-blue);
  background: rgba(0, 136, 255, 0.12);
  opacity: 0.6;
  pointer-events: none;
}

/* ── Waiting screen ──────────────────────────────────────────────────────── */

.waiting-container {
  text-align: center;
  padding: 30px 20px;
}

.waiting-animation {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.waiting-ring {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 50%;
  animation: waitingRotate 3s linear infinite;
}

.waiting-ring:nth-child(1) {
  top: 0; left: 0; right: 0; bottom: 0;
  border-top-color: var(--glow-cyan);
}
.waiting-ring:nth-child(2) {
  top: 8px; left: 8px; right: 8px; bottom: 8px;
  border-right-color: var(--glow-blue);
  animation-direction: reverse;
  animation-duration: 2s;
}
.waiting-ring:nth-child(3) {
  top: 16px; left: 16px; right: 16px; bottom: 16px;
  border-bottom-color: var(--glow-purple);
  animation-duration: 4s;
}

.waiting-text {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.waiting-subtext {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

.waiting-timer {
  font-size: 22px;
  font-weight: 300;
  color: var(--glow-cyan);
  margin: 12px 0;
  font-variant-numeric: tabular-nums;
}

/* ── Ending screen ───────────────────────────────────────────────────────── */

.ending-card {
  text-align: center;
  padding: 40px 20px;
  margin: 20px 0;
  border: 1px solid rgba(0, 229, 204, 0.15);
  border-radius: 16px;
  background: rgba(0, 229, 204, 0.03);
  animation: endingGlow 3s ease-in-out infinite alternate;
}

.ending-card h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 300;
  color: var(--glow-cyan);
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.ending-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.ending-card .btn-restart {
  background: rgba(0, 229, 204, 0.1);
  border: 1px solid var(--glow-cyan);
  color: var(--glow-cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.ending-card .btn-restart:hover {
  background: rgba(0, 229, 204, 0.2);
  box-shadow: 0 0 30px rgba(0, 229, 204, 0.15);
}

.ending-card.death {
  border-color: rgba(255, 59, 92, 0.2);
  background: rgba(255, 59, 92, 0.03);
}
.ending-card.death h2 { color: var(--glow-red); }
.ending-card.death .btn-restart {
  border-color: var(--glow-red);
  color: var(--glow-red);
  background: rgba(255, 59, 92, 0.1);
}

.ending-card.cliffhanger {
  border-color: rgba(124, 58, 237, 0.25);
  background: rgba(124, 58, 237, 0.04);
  animation: cliffhangerGlow 3s ease-in-out infinite alternate;
}
.ending-card.cliffhanger h2 { color: var(--glow-purple); }
.ending-card.cliffhanger .btn-restart {
  border-color: var(--glow-cyan);
  color: var(--glow-cyan);
  background: rgba(0, 229, 204, 0.1);
}
.coming-soon {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--glow-purple);
  opacity: 0.7;
  margin-bottom: 20px;
  animation: blink 3s step-end infinite;
}

/* ── Splash / Start screen ───────────────────────────────────────────────── */

.splash-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  transition: opacity 0.8s, visibility 0.8s;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-title {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 300;
  color: var(--glow-cyan);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow: 0 0 40px rgba(0, 229, 204, 0.3);
  animation: titlePulse 4s ease-in-out infinite alternate;
}

.splash-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: 50px;
}

.splash-start {
  background: none;
  border: 1px solid rgba(0, 229, 204, 0.3);
  color: var(--glow-cyan);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 14px 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.4s;
  position: relative;
  overflow: hidden;
}

.splash-start:hover {
  background: rgba(0, 229, 204, 0.08);
  border-color: var(--glow-cyan);
  box-shadow: 0 0 40px rgba(0, 229, 204, 0.15);
  transform: translateY(-2px);
}

.splash-signal {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 40px;
  animation: blink 2s step-end infinite;
}

/* ── Glitch effect on low signal ─────────────────────────────────────────── */

.glitch-text {
  position: relative;
}

.glitch-text.active::before,
.glitch-text.active::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  overflow: hidden;
}

.glitch-text.active::before {
  color: var(--glow-cyan);
  clip-path: inset(0 0 60% 0);
  animation: glitch1 2s infinite linear;
}

.glitch-text.active::after {
  color: var(--glow-red);
  clip-path: inset(40% 0 0 0);
  animation: glitch2 2s infinite linear;
}

/* ── Notification permission banner ──────────────────────────────────────── */

.notif-banner {
  padding: 12px 20px;
  background: rgba(240, 160, 48, 0.08);
  border-bottom: 1px solid rgba(240, 160, 48, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--glow-amber);
  z-index: 10;
  position: relative;
}

.notif-banner button {
  background: rgba(240, 160, 48, 0.15);
  border: 1px solid rgba(240, 160, 48, 0.3);
  color: var(--glow-amber);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s;
}

.notif-banner button:hover {
  background: rgba(240, 160, 48, 0.25);
}

.notif-banner.hidden {
  display: none;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes messageIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

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

@keyframes titlePulse {
  from { text-shadow: 0 0 40px rgba(0, 229, 204, 0.2); }
  to { text-shadow: 0 0 60px rgba(0, 229, 204, 0.4), 0 0 120px rgba(0, 229, 204, 0.1); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes endingGlow {
  from { box-shadow: 0 0 30px rgba(0, 229, 204, 0.05); }
  to { box-shadow: 0 0 60px rgba(0, 229, 204, 0.1); }
}

@keyframes cliffhangerGlow {
  from { box-shadow: 0 0 30px rgba(124, 58, 237, 0.05); }
  to { box-shadow: 0 0 60px rgba(124, 58, 237, 0.15), 0 0 120px rgba(124, 58, 237, 0.05); }
}

@keyframes glitch1 {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(1px, -1px); }
  60% { transform: translate(-1px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

@keyframes glitch2 {
  0% { transform: translate(0); }
  20% { transform: translate(2px, -1px); }
  40% { transform: translate(-1px, 1px); }
  60% { transform: translate(1px, -2px); }
  80% { transform: translate(-2px, 1px); }
  100% { transform: translate(0); }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .splash-title { font-size: 28px; }
  .chat-container { padding: 12px; }
  .choices-container { padding: 12px 12px 24px; }
  .message-aya .bubble { font-size: 15px; }
}

@media (min-width: 768px) {
  .header { padding: 14px 32px; }
  .chat-container { padding: 24px 32px; }
}

/* ── Scanline effect (subtle) ────────────────────────────────────────────── */
.scanlines {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 2;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.015) 2px,
    rgba(0, 0, 0, 0.015) 4px
  );
}
