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

:root {
  --green: #33ff33;
  --green-dim: #1a8c1a;
  --amber: #ffbf00;
  --red: #ff3333;
  --bg: #0a0a0a;
  --screen-bg: #0d1a0d;
  --text-shadow: 0 0 8px rgba(51, 255, 51, 0.6);
}

body {
  background: #000;
  color: var(--green);
  font-family: 'VT323', monospace;
  font-size: 20px;
}

/* A: phosphor side-bleed + D: CRT depth vignette — fixed behind all content */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 70% at 0% 50%,  rgba(20, 80, 20, 0.18) 0%, transparent 100%),
    radial-gradient(ellipse 55% 70% at 100% 50%, rgba(20, 80, 20, 0.18) 0%, transparent 100%),
    radial-gradient(ellipse 80% 80% at 50% 40%,  #0a0f0a 0%, #000 100%);
}

/* === CRT SCREEN === */
#screen {
  position: relative;
  width: 700px;
  max-width: 95vw;
  min-height: 500px;
  background: var(--screen-bg);
  border: 3px solid #222;
  border-radius: 20px;
  padding: 40px;
  box-shadow:
    0 0 60px rgba(51, 255, 51, 0.1),
    inset 0 0 60px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

/* === SCANLINES === */
#crt-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 400;
}

/* === VIGNETTE === */
#vignette {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
  z-index: 399;
}

/* === FLICKER === */
@keyframes flicker {
  0% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  96% { opacity: 0.9; }
  97% { opacity: 1; }
}

#screen {
  animation: flicker 4s infinite;
}

/* === TYPOGRAPHY === */
h1, h2 {
  font-family: 'Press Start 2P', cursive;
  text-shadow: var(--text-shadow);
  line-height: 1.6;
}

h1 {
  font-size: 18px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 191, 0, 0.6);
}

h2 {
  font-size: 14px;
  margin-bottom: 20px;
  color: var(--green);
}

p {
  text-shadow: var(--text-shadow);
  margin-bottom: 12px;
}

.subtitle {
  text-align: center;
  color: var(--green-dim);
  font-size: 24px;
  letter-spacing: 2px;
}

.hint {
  color: #446644;
  font-size: 16px;
  text-align: center;
}

/* === SCREEN SECTIONS === */
.screen-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.hidden { display: none !important; }

/* === BUTTONS === */
button {
  font-family: 'Press Start 2P', cursive;
  background: transparent;
  border: 2px solid var(--green);
  color: var(--green);
  padding: 16px 32px;
  font-size: 16px;
  cursor: pointer;
  text-shadow: var(--text-shadow);
  transition: all 0.15s;
  margin-top: 20px;
  touch-action: manipulation;
}

button:hover {
  background: var(--green);
  color: var(--bg);
  text-shadow: none;
  box-shadow: 0 0 20px rgba(51, 255, 51, 0.4);
}

button:active {
  transform: scale(0.95);
}

/* === PULSE ANIMATION === */
@keyframes pulse-border {
  0%, 100% { border-color: var(--green); box-shadow: 0 0 10px rgba(51, 255, 51, 0.2); }
  50% { border-color: var(--amber); box-shadow: 0 0 25px rgba(255, 191, 0, 0.4); }
}

.pulse {
  animation: pulse-border 2s ease-in-out infinite;
  font-size: 20px;
  padding: 20px 40px;
}

/* === CALL ACTIONS ROW === */
#call-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

#call-actions button {
  flex: 1;
  margin-top: 0;
  font-size: 11px;
  padding: 12px 8px;
}

/* === HANG UP === */
#hangup-btn {
  display: block;
  width: 100%;
  border-color: var(--red);
  color: var(--red);
  text-shadow: 0 0 8px rgba(255, 51, 51, 0.6);
  margin-top: 16px;
}

#hangup-btn:hover {
  background: var(--red);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(255, 51, 51, 0.4);
}

#download-btn {
  border-color: var(--green-dim);
  color: var(--green-dim);
  text-shadow: none;
  font-size: 10px;
}

#download-btn:hover {
  background: var(--green-dim);
  color: var(--bg);
  box-shadow: 0 0 16px rgba(26, 140, 26, 0.4);
}

/* === INPUT === */
input[type="password"],
input[type="text"] {
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--green-dim);
  color: var(--green);
  padding: 10px 14px;
  outline: none;
  width: 100%;
  max-width: 400px;
}

input::placeholder {
  color: #335533;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(51, 255, 51, 0.2);
}

.input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 460px;
  margin: 16px 0;
}

.input-row input { flex: 1; }
.input-row button { margin-top: 0; padding: 10px 16px; font-size: 11px; }

/* === CALLING SCREEN === */
#call-status {
  font-family: 'Press Start 2P', cursive;
  font-size: 14px;
  text-align: center;
  margin-bottom: 24px;
  min-height: 40px;
}

#queue-display {
  font-size: 22px;
  text-align: center;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 191, 0, 0.5);
  min-height: 30px;
  margin-bottom: 16px;
}

#fun-fact {
  font-size: 18px;
  color: var(--green-dim);
  text-align: center;
  max-width: 500px;
  min-height: 50px;
}

/* === CONNECTED SCREEN === */
#connected-screen {
  justify-content: flex-start;
  align-items: stretch;
}

#counselor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1a331a;
  margin-bottom: 12px;
}

#counselor-portrait {
  width: 56px;
  height: 56px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--green-dim);
  filter: saturate(0.6) brightness(0.9);
  box-shadow: 0 0 8px rgba(51, 255, 51, 0.2);
}

#counselor-info {
  flex: 1;
  min-width: 0;
}

#counselor-name {
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  color: var(--amber);
  display: block;
  margin-bottom: 4px;
}

#counselor-title {
  font-size: 16px;
  color: var(--green-dim);
}

#conversation-log {
  flex: 1;
  overflow-y: auto;
  max-height: 280px;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dim) transparent;
}

.msg {
  margin-bottom: 10px;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg .label {
  font-family: 'Press Start 2P', cursive;
  font-size: 9px;
  margin-bottom: 2px;
}

.msg.counselor .label { color: var(--amber); }
.msg.caller .label { color: var(--green); }
.msg.counselor .text { color: #bbffbb; }
.msg.caller .text { color: var(--green-dim); }
.msg.system-msg { color: #446644; font-style: italic; text-align: center; font-size: 16px; }

/* === VOICE STATUS === */
#voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 18px;
}

#voice-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-dim);
  transition: background 0.3s;
}

#voice-indicator.listening { background: var(--green); box-shadow: 0 0 10px var(--green); }
#voice-indicator.processing { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
#voice-indicator.speaking { background: #ff6600; box-shadow: 0 0 10px #ff6600; }

#voice-label { color: var(--green-dim); }

/* === TEXT INPUT FALLBACK === */
#text-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

#text-input-row.hidden { display: none; }
#text-input-row input { flex: 1; }
#text-input-row button { margin-top: 0; padding: 8px 12px; font-size: 10px; }

/* === MIC BUTTON === */
.mic-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--green-dim);
  border-radius: 50%;
  background: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.mic-btn.hidden { display: none; }
.mic-btn:not(:disabled):hover { border-color: var(--green); box-shadow: 0 0 8px var(--green); }
.mic-btn.active { border-color: var(--green); animation: mic-pulse 1.2s ease-in-out infinite; }
.mic-btn:disabled { opacity: 0.3; cursor: not-allowed; }

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 6px var(--green); }
  50% { box-shadow: 0 0 16px var(--green), 0 0 28px var(--green); }
}

/* === SCREEN FLASH === */
@keyframes screen-flash {
  0% { background: white; }
  100% { background: var(--screen-bg); }
}

.flash {
  animation: screen-flash 0.3s ease-out;
}

/* === STATIC EFFECT === */
@keyframes static-noise {
  0%, 100% { opacity: 0; }
  50% { opacity: 0.08; }
}

.static-active::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><filter id="n"><feTurbulence baseFrequency="0.9"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.4"/></svg>');
  animation: static-noise 0.15s steps(5) infinite;
  pointer-events: none;
  z-index: 10;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 3px; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — CRT overlay / call screen
═══════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  #screen {
    padding: 20px 16px;
    border-radius: 12px;
    min-height: auto;
  }

  h1 {
    font-size: 14px;
  }

  /* Conversation log: more vertical space on small screens */
  #conversation-log {
    max-height: 45vh;
  }

  /* Main pulse button */
  .pulse {
    font-size: 14px;
    padding: 16px 20px;
  }

  /* Counselor header */
  #counselor-portrait {
    width: 44px;
    height: 44px;
  }

  #counselor-name {
    font-size: 10px;
  }

  #counselor-title {
    font-size: 14px;
  }

  /* Message text */
  .msg .label {
    font-size: 8px;
  }

  /* Call action buttons */
  #call-actions {
    flex-direction: row; /* keep side by side but smaller */
    gap: 8px;
  }

  #call-actions button {
    font-size: 8px;
    padding: 10px 6px;
    letter-spacing: 0;
  }

  /* Voice status */
  #voice-status {
    font-size: 15px;
    padding: 6px 0;
  }

  /* Text input row */
  #text-input-row input {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  #text-input-row button {
    font-size: 9px;
    padding: 8px 10px;
  }

  /* Queue/calling screen */
  #call-status {
    font-size: 11px;
  }

  #queue-display {
    font-size: 18px;
  }

  #fun-fact {
    font-size: 15px;
  }
}
