@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

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

body {
  font-family: 'Share Tech Mono', monospace;
  background: #020408;
  color: #00e5ff;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Space background canvas */
#space-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* CRT scanline overlay */
.scanline {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  position: relative;
  z-index: 1;
}

/* Header */
header {
  border-bottom: 1px solid #00e5ff33;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

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

.status-dot {
  width: 10px;
  height: 10px;
  background: #00ff88;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ff88;
  animation: pulse 2s ease-in-out infinite;
}

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

h1 {
  font-size: 28px;
  letter-spacing: 8px;
  text-shadow: 0 0 20px #00e5ff88;
}

.subtitle {
  font-size: 11px;
  color: #00e5ff88;
  letter-spacing: 2px;
}

.ship-stats {
  display: flex;
  gap: 24px;
  margin-top: 8px;
  font-size: 11px;
  color: #00ff8899;
  letter-spacing: 1px;
}

/* Chat area */
.chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: #00e5ff33 transparent;
}

.chat::-webkit-scrollbar {
  width: 4px;
}

.chat::-webkit-scrollbar-thumb {
  background: #00e5ff44;
  border-radius: 2px;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 4px;
  line-height: 1.6;
  animation: fadeIn 0.3s ease;
}

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

.message .label {
  display: block;
  font-size: 10px;
  letter-spacing: 3px;
  margin-bottom: 6px;
  opacity: 0.6;
}

.message p {
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.alpha {
  align-self: flex-start;
  background: rgba(0, 229, 255, 0.06);
  border-left: 2px solid #00e5ff55;
  backdrop-filter: blur(12px);
}

.message.alpha .label {
  color: #00e5ff;
}

.message.commander {
  align-self: flex-end;
  background: rgba(255, 153, 0, 0.06);
  border-right: 2px solid #ff990055;
  color: #ff9900;
  backdrop-filter: blur(12px);
}

.message.commander .label {
  color: #ff9900;
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  padding: 12px 16px;
  color: #00e5ff66;
  font-size: 13px;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Input */
.input-area {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #00e5ff22;
}

#user-input {
  flex: 1;
  background: rgba(13, 18, 32, 0.8);
  border: 1px solid #00e5ff33;
  color: #ff9900;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
}

#user-input::placeholder {
  color: #ff990044;
}

#user-input:focus {
  border-color: #00e5ff88;
}

#send-btn {
  background: #00e5ff15;
  border: 1px solid #00e5ff44;
  color: #00e5ff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 12px 24px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

#send-btn:hover {
  background: #00e5ff25;
  border-color: #00e5ff88;
  box-shadow: 0 0 12px #00e5ff22;
}

#send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Focus states for accessibility */
#user-input:focus-visible {
  border-color: #00e5ff;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
  outline: none;
}

#send-btn:focus-visible {
  outline: 2px solid #00e5ff;
  outline-offset: 2px;
}

/* Retry button */
.retry-btn {
  display: inline-block;
  margin-top: 8px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: #00e5ff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 6px 14px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}

.retry-btn:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: rgba(0, 229, 255, 0.5);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.retry-btn:focus-visible {
  outline: 2px solid #00e5ff;
  outline-offset: 2px;
}

/* ─── Mobile Responsive: 600px ─── */
@media (max-width: 600px) {
  body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  .container {
    padding: 10px;
    height: 100vh;
    height: 100dvh;
  }

  h1 {
    font-size: 20px;
    letter-spacing: 5px;
  }

  .subtitle {
    font-size: 9px;
    letter-spacing: 1px;
  }

  .header-bar {
    gap: 8px;
    flex-wrap: wrap;
  }

  .ship-stats {
    gap: 10px;
    font-size: 9px;
    flex-wrap: wrap;
  }

  header {
    padding-bottom: 8px;
    margin-bottom: 8px;
  }

  .chat {
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
    gap: 10px;
  }

  .message {
    max-width: 92%;
    padding: 10px 12px;
  }

  .message p {
    font-size: 13px;
    line-height: 1.5;
  }

  .message .label {
    font-size: 9px;
  }

  .input-area {
    padding-top: 8px;
    gap: 6px;
    position: sticky;
    bottom: 0;
    background: rgba(2, 4, 8, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #user-input {
    font-size: 16px; /* prevent iOS zoom on focus */
    padding: 10px 12px;
    min-height: 44px;
  }

  #send-btn {
    font-size: 11px;
    padding: 10px 14px;
    min-width: 44px;
    min-height: 44px;
    letter-spacing: 1px;
  }

  .scanline {
    background: repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.08) 0px,
      rgba(0, 0, 0, 0.08) 1px,
      transparent 1px,
      transparent 4px
    );
  }

  .typing-indicator {
    font-size: 11px;
    padding: 8px 12px;
  }
}

/* ─── Mobile Responsive: 400px (small phones) ─── */
@media (max-width: 400px) {
  .container {
    padding: 6px;
  }

  h1 {
    font-size: 16px;
    letter-spacing: 4px;
  }

  .subtitle {
    font-size: 8px;
    display: none;
  }

  .ship-stats {
    font-size: 8px;
    gap: 8px;
  }

  .message {
    max-width: 96%;
    padding: 8px 10px;
  }

  .message p {
    font-size: 12px;
  }

  #user-input {
    padding: 8px 10px;
  }

  #send-btn {
    font-size: 10px;
    padding: 8px 10px;
    min-width: 44px;
    min-height: 44px;
  }
}
