:root {
  --bg: #0a0d0a;
  --green: #39ff88;
  --green-soft: rgba(57, 255, 136, 0.6);
  --red: #ff3a3a;
  --mono: 'Share Tech Mono', monospace;
  --pixel: 'VT323', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--green);
  font-family: var(--mono);
  overflow: hidden;
}

body.ai-idle {}
body.has-entered {}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(57, 255, 136, 0.2);
  text-shadow: 0 0 8px var(--green-soft);
  letter-spacing: 1px;
}

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

.countdown {
  border: 1px solid rgba(57,255,136,0.4);
  padding: 2px 6px;
  font-size: 12px;
  letter-spacing: 1px;
}

.audio-toggle {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  padding: 4px 8px;
  cursor: pointer;
  font-family: var(--mono);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  height: calc(100vh - 48px);
  gap: 12px;
  padding: 12px 18px;
}

.side {
  font-size: 12px;
  opacity: 0.7;
  overflow: hidden;
}

.terminal-log {
  height: 100%;
  border: 1px solid rgba(57, 255, 136, 0.2);
  padding: 8px;
  background: rgba(10, 15, 10, 0.6);
}

.center { text-align: center; position: relative; }

.crt-frame {
  position: relative;
  margin: 0 auto;
  width: min(70vw, 760px);
  height: min(50vh, 420px);
  border: 2px solid rgba(57,255,136,0.5);
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(20,40,20,0.9), rgba(5,10,5,0.9));
  box-shadow: 0 0 25px rgba(57,255,136,0.2);
  --eye-left-x: 38%;
  --eye-left-y: 42%;
  --eye-right-x: 62%;
  --eye-right-y: 42%;
  --pupil-radius: 12px;
  --mouth-x: 50%;
  --mouth-y: 78%;
}

.face-layer {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: contrast(1.1) saturate(1.1);
}

.eye-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pupil {
  position: absolute;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 6px rgba(57,255,136,0.5));
}

#pupil-left { left: var(--eye-left-x); top: var(--eye-left-y); }
#pupil-right { left: var(--eye-right-x); top: var(--eye-right-y); }

.eye-glow {
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  opacity: 0.7;
  pointer-events: none;
}

.mouth {
  position: absolute;
  width: 360px;
  height: 180px;
  left: var(--mouth-x);
  top: var(--mouth-y);
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 6px rgba(57,255,136,0.6));
}

body.ai-speaking .mouth {
  animation: mouthWobble 0.12s infinite;
}

@keyframes mouthWobble {
  0% { transform: translate(-50%, -50%) translateY(0px); }
  50% { transform: translate(-50%, -50%) translateY(1px); }
  100% { transform: translate(-50%, -50%) translateY(0px); }
}

body.ai-speaking .face-layer {
  filter: contrast(1.12) saturate(1.15) brightness(1.03);
}

.crt-status {
  position: absolute;
  top: 10px;
  left: 12px;
  font-size: 12px;
  color: var(--green);
  z-index: 2;
}

.crt-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 30%, rgba(57,255,136,0.06) 50%, transparent 70%);
  mix-blend-mode: screen;
  animation: scan 5s linear infinite;
}

.prompt {
  margin: 14px auto 8px;
  width: min(70vw, 760px);
  display: flex;
  gap: 10px;
}

.prompt input,
.chat-input input {
  flex: 1;
  background: #060806;
  border: 1px solid rgba(57,255,136,0.5);
  color: var(--green);
  padding: 10px;
  font-family: var(--mono);
}

.prompt button,
.chat-input button {
  background: rgba(57,255,136,0.15);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--mono);
}

.prophecy {
  margin-top: 8px;
  font-family: var(--pixel);
  font-size: 24px;
  text-shadow: 0 0 8px var(--green-soft);
}

.chat {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 320px;
  background: rgba(5,10,5,0.9);
  border: 1px solid rgba(57,255,136,0.4);
  display: flex;
  flex-direction: column;
  max-height: 45vh;
}

.chat-header {
  padding: 8px;
  border-bottom: 1px solid rgba(57,255,136,0.2);
}

.chat-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.chat-bubble {
  padding: 6px 8px;
  border: 1px solid rgba(57,255,136,0.2);
  background: rgba(10, 20, 10, 0.7);
}

.chat-bubble.user { background: rgba(10,10,10,0.7); }

.enter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.enter-box {
  border: 1px solid var(--green);
  padding: 24px;
  text-align: center;
  background: rgba(10,15,10,0.9);
}

.enter-title { font-size: 20px; margin-bottom: 12px; }

.cursor-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.remote-cursor {
  position: absolute;
  width: 26px;
  height: 26px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 24 24" fill="white" stroke="black" stroke-width="1"><path d="M3 1l7 19 2-7 7-2z"/></svg>') no-repeat center/contain;
}

.cursor-label {
  position: absolute;
  top: 18px;
  left: 18px;
  font-size: 10px;
  background: rgba(0,0,0,0.6);
  padding: 2px 4px;
  border: 1px solid rgba(57,255,136,0.4);
}

.scanlines, .noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.scanlines {
  background: linear-gradient(rgba(255,255,255,0.03) 50%, rgba(0,0,0,0.03) 50%);
  background-size: 100% 2px;
  mix-blend-mode: overlay;
}

.noise {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3"/></filter><rect width="100" height="100" filter="url(#n)" opacity="0.2"/></svg>');
  opacity: 0.08;
  animation: flicker 0.2s infinite;
}

@keyframes scan { 0% { transform: translateY(-20%);} 100% { transform: translateY(20%);} }
@keyframes flicker { 0% { opacity: 0.05;} 50% { opacity: 0.12;} 100% { opacity: 0.07;} }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
  .chat { width: 90vw; right: 5vw; }
}
