@import url('https://fonts.googleapis.com/css2?family=Chivo+Mono:wght@400;600;700&family=Sora:wght@400;600;700;800&display=swap');

/* ═══════════════════════════════════════════════
   SILLAGE 9 — Sci-Fi Terminal Theme
   Ambiance sous-marin / station spatiale
   ═══════════════════════════════════════════════ */

:root {
  --bg-0: #080c14;
  --bg-1: #0d1420;
  --bg-2: #121c2e;
  --panel: rgba(8, 14, 24, 0.92);
  --panel-strong: rgba(6, 10, 18, 0.96);
  --line: rgba(0, 240, 255, 0.18);
  --line-strong: rgba(255, 107, 43, 0.35);

  --ink-0: #e0f4f0;
  --ink-1: #a0e8d8;
  --ink-2: #5a8a80;

  --accent-hot: #ff6b2b;
  --accent-hot-soft: #cc5522;
  --accent-cold: #00f0ff;
  --accent-cold-soft: #00b8c5;

  --ok: #00f0ff;
  --warn: #f2c265;
  --bad: #ff3344;

  --font-ui: 'Sora', sans-serif;
  --font-mono: 'Chivo Mono', monospace;

  --radius-lg: 4px;
  --radius-md: 3px;
  --radius-sm: 2px;

  --glow-cyan: 0 0 8px rgba(0, 240, 255, 0.4), 0 0 20px rgba(0, 240, 255, 0.15);
  --glow-amber: 0 0 8px rgba(255, 107, 43, 0.4), 0 0 20px rgba(255, 107, 43, 0.15);
  --glow-red: 0 0 8px rgba(255, 51, 68, 0.5), 0 0 20px rgba(255, 51, 68, 0.2);
  --text-glow: 0 0 6px rgba(0, 240, 255, 0.5);
}

/* ── SVG noise filter ── */
svg.noise-filter {
  position: absolute;
  width: 0;
  height: 0;
}

/* ── Keyframes ── */
@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98%           { opacity: 0.85; }
  99%           { opacity: 0.92; }
}

@keyframes glitch {
  0%   { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  10%  { clip-path: inset(20% 0 60% 0); transform: translate(-3px, 0); }
  20%  { clip-path: inset(60% 0 10% 0); transform: translate(3px, 0); }
  30%  { clip-path: inset(40% 0 30% 0); transform: translate(-2px, 1px); }
  40%  { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
}

@keyframes pulse-critical {
  0%, 100% { box-shadow: 0 0 4px rgba(255, 51, 68, 0.3); border-color: rgba(255, 51, 68, 0.4); }
  50%      { box-shadow: 0 0 14px rgba(255, 51, 68, 0.6); border-color: rgba(255, 51, 68, 0.7); }
}

@keyframes border-glow {
  0%, 100% { border-color: rgba(0, 240, 255, 0.18); }
  50%      { border-color: rgba(0, 240, 255, 0.35); }
}

@keyframes float-particles {
  0%   { background-position: 0% 0%, 100% 100%, 50% 50%; }
  100% { background-position: 100% 100%, 0% 0%, 0% 100%; }
}

@keyframes typing-dots {
  0%       { content: '▌'; }
  25%      { content: '▌ .'; }
  50%      { content: '▌ . .'; }
  75%      { content: '▌ . . .'; }
  100%     { content: '▌'; }
}

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

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

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

@-webkit-keyframes scanline {
  0%   { -webkit-transform: translateY(-100%); }
  100% { -webkit-transform: translateY(100vh); }
}

@-webkit-keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98%           { opacity: 0.85; }
  99%           { opacity: 0.92; }
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  color: var(--ink-1);
  font-family: var(--font-mono);
  background: var(--bg-0);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ── Atmosphere layer: scanlines + particles + noise ── */
.atmo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 600px 600px at 15% 20%, rgba(0, 240, 255, 0.04), transparent),
    radial-gradient(ellipse 400px 400px at 85% 70%, rgba(0, 240, 255, 0.03), transparent),
    radial-gradient(ellipse 200px 200px at 50% 50%, rgba(0, 240, 255, 0.02), transparent);
  -webkit-animation: float-particles 30s linear infinite;
  animation: float-particles 30s linear infinite;
}

/* Scanlines overlay */
.atmo::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 240, 255, 0.015) 2px,
    rgba(0, 240, 255, 0.015) 4px
  );
  pointer-events: none;
}

/* Moving scanline bar */
.atmo::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(180deg, transparent, rgba(0, 240, 255, 0.08), transparent);
  -webkit-animation: scanline 8s linear infinite;
  animation: scanline 8s linear infinite;
  pointer-events: none;
}

/* ── App shell ── */
.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, 100%);
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  -webkit-animation: border-glow 4s ease-in-out infinite;
  animation: border-glow 4s ease-in-out infinite;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cold);
  letter-spacing: 0.06em;
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: rgba(0, 240, 255, 0.06);
  text-shadow: var(--text-glow);
  -webkit-animation: flicker 4s infinite;
  animation: flicker 4s infinite;
}

.brand-wrap h1 {
  font-family: var(--font-ui);
  font-size: clamp(17px, 2.1vw, 22px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--ink-0);
  text-shadow: var(--text-glow);
}

.zone-label {
  margin-top: 4px;
  color: var(--accent-cold);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-shadow: var(--text-glow);
  -webkit-animation: flicker 6s infinite;
  animation: flicker 6s infinite;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Signal indicator ── */
.signal-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 240, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 10px;
  font-family: var(--font-mono);
}

.bars {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.bar {
  width: 4px;
  border-radius: 1px;
  background: #1a2a38;
  transition: background 220ms ease, box-shadow 220ms ease;
}

.bar:nth-child(1) { height: 4px; }
.bar:nth-child(2) { height: 7px; }
.bar:nth-child(3) { height: 11px; }
.bar:nth-child(4) { height: 15px; }

.bar.active.good { background: var(--accent-cold); box-shadow: 0 0 4px rgba(0, 240, 255, 0.5); }
.bar.active.mid  { background: var(--warn); box-shadow: 0 0 4px rgba(242, 194, 101, 0.5); }
.bar.active.bad  { background: var(--bad); box-shadow: 0 0 4px rgba(255, 51, 68, 0.5); }

#signal-text {
  min-width: 40px;
  color: var(--ink-1);
  text-align: right;
  font-size: 11px;
  text-shadow: var(--text-glow);
}

/* ── Layout ── */
.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.9fr);
  gap: 8px;
}

/* ── Comm panel ── */
.comm-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 6px;
}

/* ── Shared panel styles ── */
.feed,
.choices,
.wait-panel,
.hud-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--panel);
}

/* ── Feed ── */
.feed {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  position: relative;
}

.feed::-webkit-scrollbar {
  width: 6px;
}

.feed::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.25);
}

.feed::-webkit-scrollbar-track {
  background: transparent;
}

.log {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── Messages ── */
.msg {
  opacity: 0;
  transform: translateY(7px);
  -webkit-animation: reveal 0.28s ease forwards;
  animation: reveal 0.28s ease forwards;
}

.msg .bubble {
  border-radius: 3px;
  padding: 10px 12px;
  line-height: 1.58;
  font-family: var(--font-mono);
}

.msg.incoming {
  align-self: flex-start;
  max-width: 92%;
}

.msg.incoming .bubble {
  background: rgba(0, 240, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.15);
  font-size: 14px;
  color: var(--ink-1);
  -webkit-animation: glitch 0.4s ease forwards;
  animation: glitch 0.4s ease forwards;
}

.msg.incoming.interference .bubble {
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
  color: var(--accent-cold);
  text-shadow: var(--text-glow);
  border-style: dashed;
}

.msg.outgoing {
  align-self: flex-end;
  max-width: 84%;
}

.msg.outgoing .bubble {
  background: rgba(255, 107, 43, 0.08);
  border: 1px solid rgba(255, 107, 43, 0.3);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #ffb088;
}

.msg.system {
  align-self: center;
}

.msg.system .bubble {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-cold);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  background: rgba(0, 240, 255, 0.03);
  text-shadow: var(--text-glow);
  -webkit-animation: flicker 5s infinite;
  animation: flicker 5s infinite;
}

/* ── Typing indicator ── */
.typing {
  align-self: flex-start;
  font-family: var(--font-mono);
  color: var(--accent-cold);
  font-size: 11px;
  padding: 5px 4px;
  text-shadow: var(--text-glow);
}

.typing::after {
  content: ' ▌';
  -webkit-animation: cursor-blink 1s step-end infinite;
  animation: cursor-blink 1s step-end infinite;
}

/* ── Wait panel ── */
.wait-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.wait-panel p {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-shadow: var(--text-glow);
}

.wait-panel strong {
  font-size: 20px;
  line-height: 1;
  color: var(--accent-cold);
  text-shadow: var(--text-glow);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(0, 240, 255, 0.15);
  border-top-color: var(--accent-cold);
  -webkit-animation: spin 1s linear infinite;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
}

/* ── Choices ── */
.choices {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px;
}

.choice {
  text-align: left;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 240, 255, 0.2);
  background: rgba(0, 240, 255, 0.03);
  color: var(--ink-0);
  padding: 10px 12px;
  font-family: var(--font-mono);
  transition: transform 0.14s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.choice:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 107, 43, 0.6);
  box-shadow: var(--glow-amber);
  background: rgba(255, 107, 43, 0.06);
}

.choice-title {
  font-size: 13px;
  line-height: 1.35;
  display: block;
}

.choice-meta {
  margin-top: 6px;
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.choice.locked {
  border-color: rgba(255, 51, 68, 0.4);
}

.choice[disabled] {
  opacity: 0.45;
  cursor: default;
}

.choice.selected {
  border-color: var(--accent-hot);
  box-shadow: var(--glow-amber);
}

/* ── HUD panel ── */
.hud-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
}

.hud-card {
  padding: 10px;
  background: var(--panel-strong);
  -webkit-animation: border-glow 5s ease-in-out infinite;
  animation: border-glow 5s ease-in-out infinite;
}

.card-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title-row h2 {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-0);
  text-shadow: var(--text-glow);
}

.muted {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}

/* ── Meters / Gauges ── */
.meters {
  display: grid;
  gap: 7px;
}

.meter {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 240, 255, 0.12);
  padding: 7px 8px;
  background: rgba(0, 240, 255, 0.02);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.meter-head span {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--ink-1);
}

.meter-head strong {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-0);
  text-shadow: var(--text-glow);
}

.meter-track {
  width: 100%;
  height: 8px;
  border-radius: 1px;
  background: rgba(0, 240, 255, 0.06);
  overflow: hidden;
}

.meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.26s ease, background 0.26s ease;
}

.meter.tone-good .meter-fill {
  background: linear-gradient(90deg, #006a72, #00f0ff);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}

.meter.tone-mid .meter-fill {
  background: linear-gradient(90deg, #8a7020, #f2c265);
  box-shadow: 0 0 6px rgba(242, 194, 101, 0.4);
}

.meter.tone-bad .meter-fill {
  background: linear-gradient(90deg, #881122, #ff3344);
  box-shadow: 0 0 6px rgba(255, 51, 68, 0.4);
}

/* Pulse critical: jauges > 70% */
.meter.tone-bad {
  -webkit-animation: pulse-critical 1.5s ease-in-out infinite;
  animation: pulse-critical 1.5s ease-in-out infinite;
}

/* ── Inventory ── */
.inventory-list {
  list-style: none;
  display: grid;
  gap: 5px;
}

.inv-item,
.inv-empty {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 240, 255, 0.1);
  background: rgba(0, 240, 255, 0.02);
  padding: 7px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
}

.inv-item span {
  font-size: 12px;
  color: var(--ink-1);
}

.inv-item strong {
  min-width: 28px;
  text-align: right;
  font-family: var(--font-mono);
  color: var(--accent-cold);
  font-size: 12px;
  text-shadow: var(--text-glow);
}

.inv-empty {
  font-size: 11px;
  color: var(--ink-2);
}

/* ── Quick actions ── */
.quick-actions {
  display: grid;
  gap: 6px;
}

.survival-action {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 240, 255, 0.2);
  background: rgba(0, 240, 255, 0.04);
  color: var(--ink-0);
  font-size: 11px;
  font-family: var(--font-mono);
  text-align: left;
  padding: 8px 10px;
  letter-spacing: 0.04em;
  transition: border-color 0.2s ease, transform 0.14s ease, box-shadow 0.2s ease;
}

.survival-action:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: var(--glow-cyan);
}

.survival-action[disabled] {
  opacity: 0.35;
  cursor: default;
}

/* ── End card ── */
.end-card {
  margin-top: 6px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 107, 43, 0.3);
  background: rgba(255, 107, 43, 0.06);
  padding: 12px;
}

.end-card h3 {
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink-0);
  text-shadow: 0 0 6px rgba(255, 107, 43, 0.4);
}

.end-card p {
  margin-top: 5px;
  color: var(--ink-1);
  font-size: 12px;
  font-family: var(--font-mono);
}

.end-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.cta,
.ghost {
  border-radius: 3px;
  padding: 9px 14px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: box-shadow 0.2s ease, transform 0.14s ease;
}

.cta {
  color: #080c14;
  border: 1px solid var(--accent-hot);
  background: linear-gradient(180deg, #ff8844, #ff6b2b);
  font-weight: 700;
  box-shadow: var(--glow-amber);
}

.cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 12px rgba(255, 107, 43, 0.5), 0 0 30px rgba(255, 107, 43, 0.2);
}

.ghost {
  color: var(--ink-1);
  border: 1px solid var(--line);
  background: rgba(0, 240, 255, 0.04);
}

.ghost:hover {
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: var(--glow-cyan);
}

.ghost.mini {
  margin-top: 6px;
  width: fit-content;
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

/* ── Intro overlay ── */
.intro {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(8, 12, 20, 0.92);
  padding: 16px;
}

.intro-card {
  width: min(540px, 100%);
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: var(--panel-strong);
  padding: 20px;
  box-shadow: var(--glow-cyan);
}

.intro-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-cold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: var(--text-glow);
  -webkit-animation: flicker 3s infinite;
  animation: flicker 3s infinite;
}

.intro-card h2 {
  margin-top: 8px;
  font-family: var(--font-ui);
  font-size: clamp(22px, 4.7vw, 30px);
  color: var(--ink-0);
  text-shadow: var(--text-glow);
}

.intro-card p {
  margin-top: 10px;
  color: var(--ink-1);
  line-height: 1.65;
  font-size: 13px;
  font-family: var(--font-mono);
}

.intro-card .cta {
  margin-top: 16px;
}

/* ── Responsive: tablet ── */
@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .comm-panel,
  .hud-panel {
    min-height: auto;
  }

  .feed {
    min-height: min(52dvh, 500px);
  }

  .hud-panel {
    grid-template-rows: repeat(3, auto);
  }
}

/* ── Responsive: mobile ── */
@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-right {
    width: 100%;
    justify-content: space-between;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .feed {
    padding: 10px;
  }

  .msg.incoming .bubble {
    font-size: 13px;
  }
}
