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

:root {
  --bg: #0a0a0f;
  --bg-subtle: #12121a;
  --text: #c8c8d0;
  --text-dim: #5a5a6e;
  --accent: #8b0000;
  --accent-glow: #ff1a1a;
  --border: #1a1a2e;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Navigation === */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1.5rem 2rem;
  z-index: 100;
  background: linear-gradient(to bottom, var(--bg), transparent);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 101;
}

.nav-toggle span {
  display: block;
  width: 25px;
  height: 2px;
  background: var(--text);
  transition: all 0.3s ease;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 2rem;
  justify-content: flex-end;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  text-shadow: 0 0 8px rgba(200, 200, 208, 0.3);
}

.nav-user {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

#nav-username {
  color: var(--text);
}

.nav-logout {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.nav-close-item {
  display: none;
}

/* Mobile nav */
@media (max-width: 600px) {
  .nav-toggle {
    display: flex;
    position: relative;
    z-index: 102;
  }

  .nav-links {
    position: fixed;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100vh;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-subtle);
    border-right: 1px solid var(--border);
    transition: left 0.3s ease;
    padding-top: 2rem;
  }

  .nav-links.open {
    left: 0;
  }

  .nav-close-item {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
  }

  .nav-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
  }
}

/* === Hero / Landing === */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
}

.glitch-wrapper {
  position: relative;
}

.title {
  font-size: clamp(3rem, 10vw, 7rem);
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--text);
  position: relative;
  animation: fadeInUp 1.5s ease forwards;
}

/* Glitch effect */
.glitch {
  position: relative;
}

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

.glitch::before {
  color: var(--accent-glow);
  animation: glitch-1 4s infinite linear;
}

.glitch::after {
  color: #0ff;
  animation: glitch-2 4s infinite linear;
}

@keyframes glitch-1 {
  0%, 90%, 100% { opacity: 0; transform: none; }
  91% { opacity: 0.8; transform: translate(-2px, -1px); clip-path: inset(20% 0 60% 0); }
  93% { opacity: 0; }
  95% { opacity: 0.6; transform: translate(2px, 1px); clip-path: inset(50% 0 20% 0); }
  97% { opacity: 0; }
}

@keyframes glitch-2 {
  0%, 88%, 100% { opacity: 0; transform: none; }
  89% { opacity: 0.6; transform: translate(2px, 1px); clip-path: inset(40% 0 30% 0); }
  91% { opacity: 0; }
  94% { opacity: 0.5; transform: translate(-1px, 2px); clip-path: inset(10% 0 70% 0); }
  96% { opacity: 0; }
}

.tagline {
  margin-top: 1.5rem;
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  opacity: 0;
  animation: fadeIn 2s ease 1s forwards;
}

.pulse-line {
  margin-top: 3rem;
  width: 200px;
  height: 1px;
  background: var(--accent);
  opacity: 0;
  animation: fadeIn 2s ease 1.5s forwards, pulse 3s ease-in-out 2s infinite;
}

.hero-btn {
  margin-top: 3.5rem;
  padding: 1rem 2rem;
  font-size: 1rem;
  letter-spacing: 3px;
  opacity: 0;
  animation: fadeIn 2s ease 2s forwards;
  text-decoration: none;
  display: inline-block;
}

/* === Sections === */
.section {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
}

.section-title {
  font-size: 1.5rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.hidden {
  display: none;
}

/* === Locked Content === */
.locked-content {
  text-align: center;
  border: 1px solid var(--border);
  padding: 3rem;
  border-radius: 2px;
  background: var(--bg-subtle);
}

.locked-message {
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 0.5rem;
}

.locked-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* === Story Options === */
.story-options {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 100%;
  max-width: 400px;
}

.story-btn {
  padding: 1.2rem 1.5rem;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: none;
  text-align: left;
  white-space: normal;
  line-height: 1.4;
}

.story-btn:hover {
  border-color: var(--accent-glow);
  text-shadow: 0 0 6px rgba(255, 26, 26, 0.3);
}

/* === Chat Interface === */
.chat-container {
  width: 100%;
  max-width: 500px;
  height: 70vh;
  overflow-y: auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-message {
  display: flex;
  animation: fadeInUp 0.3s ease forwards;
}

.chat-sarah {
  justify-content: flex-start;
}

.chat-player {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 75%;
  padding: 0.8rem 1.2rem;
  border-radius: 2px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-sarah .chat-bubble {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
}

.chat-player .chat-bubble {
  background: rgba(139, 0, 0, 0.15);
  border: 1px solid var(--accent);
  color: var(--text);
}

/* Typing indicator */
.typing-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 1rem 1.4rem;
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  background: var(--text-dim);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Chat options */
.chat-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.5rem 0;
  align-self: flex-end;
  width: 100%;
  max-width: 80%;
  margin-left: auto;
}

.chat-option-btn {
  padding: 0.8rem 1.2rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  animation: fadeInUp 0.3s ease forwards;
  line-height: 1.4;
}

.chat-option-btn:hover {
  border-color: var(--accent);
  background: rgba(139, 0, 0, 0.1);
  box-shadow: 0 0 10px rgba(139, 0, 0, 0.2);
}

/* === Visual Novel Interface === */
.novel-scene {
  width: 100%;
  max-width: 600px;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1.5rem;
}

.novel-dialogue-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.5rem 2rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.novel-speaker {
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: bold;
}

.speaker-sarah {
  color: var(--accent);
}

.speaker-player {
  color: #4a9eff;
}

.novel-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  min-height: 1.5em;
}

.novel-typing {
  color: var(--text-dim);
  animation: flicker 1s infinite;
}

.novel-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.novel-option-btn {
  padding: 1rem 1.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
  line-height: 1.4;
}

.novel-option-btn:hover {
  border-color: #4a9eff;
  background: rgba(74, 158, 255, 0.05);
  box-shadow: 0 0 10px rgba(74, 158, 255, 0.15);
}

/* Chapter end */
.chapter-end {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
  animation: fadeIn 2s ease forwards;
}

.chapter-end-content {
  text-align: center;
}

.chapter-end-label {
  font-size: 0.8rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.chapter-end-title {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 1.5rem;
}

/* === Narrative (written story) === */
.narrative-content {
  max-width: 600px;
  text-align: center;
}

/* === About === */
.about-content {
  max-width: 500px;
  text-align: center;
  line-height: 2;
}

.about-content p {
  margin-bottom: 0.5rem;
}

.flicker {
  animation: flicker 5s infinite;
}

@keyframes flicker {
  0%, 95%, 100% { opacity: 1; }
  96% { opacity: 0.2; }
  97% { opacity: 0.8; }
  98% { opacity: 0.1; }
  99% { opacity: 0.7; }
}

/* === Login Form === */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

.input-group input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-group input::placeholder {
  color: var(--text-dim);
}

.btn {
  padding: 0.8rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  background: var(--accent);
  box-shadow: 0 0 15px rgba(139, 0, 0, 0.4);
}

.form-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.form-footer a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.3s ease;
}

.form-footer a:hover {
  border-color: var(--accent);
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.2); }
}

/* === Guest Login === */
.guest-divider {
  color: var(--text-dim);
  font-size: 0.8rem;
  letter-spacing: 2px;
  margin: 1.5rem 0;
  text-align: center;
}

.guest-btn {
  width: 100%;
  max-width: 320px;
}

.guest-name-prompt {
  margin-top: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  max-width: 320px;
}

.guest-name-prompt.visible {
  display: flex;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
