/* =============================================================
   FROGGER - Minecraft Pixel Style Interface
   ============================================================= */

:root {
  /* Minecraft-style dark backgrounds */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3d3d3d;
  --bg-panel: #252525;
  
  /* Minecraft Green Theme */
  --cyan-primary: #5cb85c;
  --cyan-dark: #449d44;
  --cyan-glow: rgba(92, 184, 92, 0.4);
  
  /* Accent color - Minecraft green */
  --accent-primary: #5cb85c;
  --accent-secondary: #7ed57e;
  
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #606060;
  
  --border-color: #4a4a4a;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'VT323', monospace;
  font-size: 18px;
  background: var(--bg-primary);
  color: var(--text-primary);
  image-rendering: pixelated;
}

/* =============================================================
   OVERLAY EFFECTS
   ============================================================= */

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none !important;
  z-index: 9999;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Hide overlays on mobile to improve performance and prevent touch issues */
@media (max-width: 700px) {
  .noise-overlay,
  .scan-line {
    display: none !important;
  }
}

/* Scanline removed */

/* =============================================================
   APP LAYOUT
   ============================================================= */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* =============================================================
   SIDEBAR
   ============================================================= */

.sidebar {
  flex: 0 0 auto;
  width: 100%;
  height: 60px;
  background: rgba(20, 20, 20, 0.98);
  border-bottom: 3px solid var(--cyan-primary);
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.sidebar::after {
  display: none;
}

.sidebar-header {
  padding: 10px 0;
  border-bottom: none;
  display: flex;
  align-items: center;
}

.logo-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.logo-img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  animation: hop 2s ease-in-out infinite;
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.logo-sub {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: var(--cyan-primary);
  letter-spacing: 0.1em;
  text-shadow: 1px 1px 0 #2a5a2a;
}

.status-line {
  display: none;
}

.nav-menu {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 0;
  margin-left: 30px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  margin: 0;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.1s ease;
  position: relative;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--border-color);
}

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

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(92, 184, 92, 0.2);
  border-color: var(--cyan-dark);
  transform: translate(2px, 2px);
}

.nav-item.active {
  color: #1a1a1a;
  background: var(--cyan-primary);
  border-color: var(--cyan-dark);
  box-shadow: 3px 3px 0 var(--cyan-dark);
}

.nav-item:active {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.nav-icon {
  width: 18px;
  height: 18px;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-footer {
  display: none;
}

.connection-status {
  display: none;
}

.pulse {
  width: 6px;
  height: 6px;
  background: #00ff88;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

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

/* =============================================================
   MAIN CONTENT - Split View
   ============================================================= */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  background: var(--bg-primary);
  position: relative;
  min-height: 0;
  /* overflow: hidden - REMOVED, breaks mobile scroll */
}

/* =============================================================
   CHARACTER CONTAINER - Live2D Area
   ============================================================= */

.character-container {
  flex: 0 0 45%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: 
    radial-gradient(ellipse 70% 80% at 50% 50%, rgba(5, 3, 2, 0.85) 0%, rgba(10, 7, 6, 0.4) 60%, rgba(10, 7, 6, 0) 100%),
    url('bg.png') center center / cover no-repeat,
    var(--bg-primary);
  overflow: hidden;
  border-right: 3px solid var(--border-color);
}

#live2d-canvas,
#vrm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  opacity: 0;
  transition: opacity 1.2s ease-out;
  touch-action: none; /* Let OrbitControls handle all touch events */
}

.character-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.character-placeholder.hidden {
  display: none;
}

.placeholder-content {
  text-align: center;
  padding: 40px 50px;
  border: 3px solid var(--cyan-dark);
  border-radius: 0;
  background: rgba(20, 20, 20, 0.95);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.5);
}

.placeholder-icon {
  font-family: 'Press Start 2P', cursive;
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--cyan-primary);
  text-shadow: 3px 3px 0 #2a5a2a;
  letter-spacing: 0.1em;
}

.placeholder-content p {
  font-family: 'VT323', monospace;
  font-size: 1.4rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.placeholder-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

.character-effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.glow-effect {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  height: 40%;
  background: radial-gradient(ellipse at center bottom, var(--cyan-glow) 0%, transparent 70%);
  opacity: 0.3;
}

.character-name-tag {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 3px solid var(--cyan-primary);
  padding: 8px 20px;
  border-radius: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
}

.character-name-tag .name {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.9rem;
  color: var(--cyan-primary);
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #000;
}

.character-name-tag .status {
  font-size: 0.7rem;
  color: #00ff88;
  text-shadow: 1px 1px 0 #000;
}

/* =============================================================
   CHAT WINDOW
   ============================================================= */

.chat-window {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  display: flex;
  flex-direction: column;
  background: rgba(20, 20, 20, 0.95);
  position: relative;
}

.chat-window::before {
  display: none;
}

.chat-header {
  flex: 0 0 auto; /* Don't grow or shrink */
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.5);
  border-bottom: 3px solid var(--border-color);
}

.header-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-dark), transparent);
}

.header-text {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.65rem;
  color: var(--cyan-primary);
  letter-spacing: 0.2em;
  text-shadow: 1px 1px 0 #000;
}

.messages-container {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  -webkit-overflow-scrolling: touch;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 0;
}

.messages-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 0;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
}

.messages-container {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.message {
  animation: messageIn 0.3s ease-out;
}

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

.msg-sender {
  display: block;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}

.message.frogger .msg-sender { color: var(--cyan-primary); }
.message.user .msg-sender { color: #E8956A; }

.msg-text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-primary);
  padding-left: 12px;
  border-left: 2px solid var(--border-color);
}

.message.frogger .msg-text { border-left-color: rgba(0, 212, 255, 0.3); }
.message.user .msg-text { border-left-color: rgba(255, 107, 157, 0.3); }

.msg-text .action {
  color: var(--text-muted);
  font-style: italic;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding-left: 12px;
}

.typing-indicator span {
  width: 5px;
  height: 5px;
  background: var(--cyan-primary);
  border-radius: 50%;
  animation: typingDot 1.4s ease-in-out infinite;
}

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

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

.input-container {
  padding: 15px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

#chatForm {
  display: flex;
  gap: 10px;
}

#messageInput {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  padding: 12px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

#messageInput::placeholder {
  color: var(--text-muted);
}

#messageInput:focus {
  border-color: var(--cyan-primary);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.1);
}

#sendBtn {
  width: 45px;
  height: 45px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--cyan-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#sendBtn svg {
  width: 18px;
  height: 18px;
}

#sendBtn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--cyan-primary);
}

#sendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */

@media (max-width: 1100px) {
  .character-container {
    width: 40%;
    min-width: 300px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 60px;
  }
  
  .logo-sub, .nav-label, .status-text {
    display: none;
  }
  
  .logo-container {
    justify-content: center;
  }
  
  .logo-img {
    width: 28px;
    height: 28px;
  }
  
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  
  .character-container {
    width: 35%;
    min-width: 250px;
  }
}

/* Mobile styles consolidated at end of file */

/* =============================================================
   ANIMATIONS
   ============================================================= */

.app-container {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Expression change animation */
.character-container.expression-change #live2d-canvas {
  animation: expressionPulse 0.3s ease-out;
}

@keyframes expressionPulse {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
  100% { filter: brightness(1); }
}

/* =============================================================
   JOURNAL PANEL
   ============================================================= */

.panel-section {
  display: none;
  flex: 1;
  min-height: 0;
}

.panel-section.active {
  display: flex;
  flex-direction: column;
}

.journal-panel,
.settings-panel {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  display: none;
  flex-direction: column;
  background: rgba(20, 20, 20, 0.95);
}

.journal-panel.active,
.settings-panel.active {
  display: flex;
}

.journal-intro {
  flex: 0 0 auto; /* Don't grow or shrink */
  padding: 15px 20px;
  text-align: center;
  border-bottom: 3px solid var(--border-color);
  background: rgba(92, 184, 92, 0.05);
}

.journal-warning {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.65rem;
  color: var(--cyan-primary);
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: 1px 1px 0 #2a5a2a;
}

.journal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 6px;
}

.journal-sub {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  color: #666;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.generate-entry-btn {
  background: linear-gradient(135deg, rgba(217, 119, 87, 0.2), rgba(232, 149, 106, 0.2));
  border: 1px solid rgba(217, 119, 87, 0.4);
  color: #E8956A;
  padding: 10px 20px;
  font-family: 'Press Start 2P', cursive;
  font-size: 0.75rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 0;
}

.generate-entry-btn:hover {
  background: linear-gradient(135deg, rgba(217, 119, 87, 0.3), rgba(232, 149, 106, 0.3));
  border-color: rgba(217, 119, 87, 0.7);
  box-shadow: 0 0 20px rgba(255, 0, 100, 0.3);
  transform: translateY(-2px);
}

.generate-entry-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  margin-right: 8px;
}

.journal-entries {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  overflow-y: auto;
  padding: 15px;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for journal */
.journal-entries::-webkit-scrollbar {
  width: 6px;
}

.journal-entries::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 0;
}

.journal-entries::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 0;
}

.journal-entries::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* Firefox scrollbar support */
.journal-entries {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.loading-journal {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
  font-style: italic;
}

.journal-entry {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--border-color);
  border-left: 4px solid;
  margin-bottom: 12px;
  padding: 12px 15px;
  border-radius: 0;
  transition: all 0.1s ease;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.journal-entry:hover {
  background: rgba(92, 184, 92, 0.1);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3);
}

/* New mood colors */
.journal-entry.mood-happy { border-left-color: #fbbf24; }
.journal-entry.mood-sad { border-left-color: #6366f1; }
.journal-entry.mood-tired { border-left-color: #9ca3af; }
.journal-entry.mood-excited { border-left-color: #f59e0b; }
.journal-entry.mood-bored { border-left-color: #6b7280; }
.journal-entry.mood-hungry { border-left-color: #f97316; }
.journal-entry.mood-cozy { border-left-color: #a78bfa; }
.journal-entry.mood-annoyed { border-left-color: #ef4444; }
.journal-entry.mood-lovestruck { border-left-color: #ec4899; }
.journal-entry.mood-silly { border-left-color: #34d399; }
.journal-entry.mood-anxious { border-left-color: #f43f5e; }
.journal-entry.mood-peaceful { border-left-color: #14b8a6; }
.journal-entry.mood-lazy { border-left-color: #8b5cf6; }
.journal-entry.mood-determined { border-left-color: #3b82f6; }
.journal-entry.mood-neutral { border-left-color: #64748b; }
/* Legacy moods */
.journal-entry.mood-curious { border-left-color: #8b5cf6; }
.journal-entry.mood-playful { border-left-color: #ec4899; }
.journal-entry.mood-thoughtful { border-left-color: #6366f1; }
.journal-entry.mood-calm { border-left-color: #14b8a6; }
.journal-entry.mood-restless { border-left-color: #ef4444; }
.journal-entry.mood-hopeful { border-left-color: #22c55e; }
.journal-entry.mood-nostalgic { border-left-color: #a855f7; }
.journal-entry.mood-amused { border-left-color: #f472b6; }
.journal-entry.mood-haunted { border-left-color: #8b5cf6; }
.journal-entry.mood-confused { border-left-color: #f59e0b; }
.journal-entry.mood-desperate { border-left-color: #ef4444; }
.journal-entry.mood-disturbed { border-left-color: #ec4899; }
.journal-entry.mood-lonely { border-left-color: #6366f1; }
.journal-entry.mood-cryptic { border-left-color: #14b8a6; }
.journal-entry.mood-fearful { border-left-color: #f43f5e; }
.journal-entry.mood-sleepy { border-left-color: #9ca3af; }
.journal-entry.mood-content { border-left-color: #22c55e; }
.journal-entry.mood-adventurous { border-left-color: #f59e0b; }
.journal-entry.mood-scared { border-left-color: #ef4444; }

.entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.entry-date {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: var(--accent-primary);
  letter-spacing: 1px;
}

.entry-mood {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 2px 8px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.05);
}

.entry-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  font-style: italic;
}

.entry-content::before {
  content: '"';
  color: var(--accent-primary);
  font-size: 1.2rem;
}

.entry-content::after {
  content: '"';
  color: var(--accent-primary);
  font-size: 1.2rem;
}

/* New entry animation */
.journal-entry.new-entry {
  animation: newEntryGlow 1s ease-out;
}

@keyframes newEntryGlow {
  0% {
    box-shadow: 0 0 30px rgba(255, 0, 100, 0.5);
    background: rgba(255, 0, 100, 0.1);
  }
  100% {
    box-shadow: none;
    background: rgba(0, 0, 0, 0.3);
  }
}

/* Journal Pagination */
.journal-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 20px;
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
}

.pagination-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-info {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.75rem;
  color: var(--accent-primary);
  letter-spacing: 1px;
}

/* Settings Panel */
.settings-content {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
}

/* =============================================================
   TECH PANEL
   ============================================================= */

.tech-panel {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  display: none;
  flex-direction: column;
  background: rgba(20, 20, 20, 0.95);
}

.tech-panel.active {
  display: flex;
}

.tech-content {
  flex: 1;
  min-height: 0; /* CRITICAL for flex scroll */
  overflow-y: auto;
  padding: 25px;
  -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for tech panel */
.tech-content::-webkit-scrollbar {
  width: 6px;
}

.tech-content::-webkit-scrollbar-track {
  background: var(--bg-primary);
  border-radius: 0;
}

.tech-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--cyan-primary), var(--cyan-dark));
  border-radius: 0;
}

.tech-content::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-primary);
}

.tech-content {
  scrollbar-width: thin;
  scrollbar-color: var(--cyan-dark) var(--bg-primary);
}

.tech-section {
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--border-color);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.tech-section:last-of-type {
  margin-bottom: 10px;
}

.tech-title {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.7rem;
  color: var(--cyan-primary);
  letter-spacing: 1px;
  margin-bottom: 10px;
  text-shadow: 1px 1px 0 #2a5a2a;
}

.tech-section p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.tech-highlight {
  color: var(--cyan-primary);
  font-weight: 600;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tech-tag {
  background: var(--cyan-primary);
  border: 2px solid var(--cyan-dark);
  color: #1a1a1a;
  padding: 6px 10px;
  font-size: 0.55rem;
  font-family: 'Press Start 2P', cursive;
  letter-spacing: 0.5px;
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--cyan-dark);
  transition: all 0.1s ease;
}

.tech-tag:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--cyan-dark);
}

.tech-footer {
  margin-top: 20px;
  padding: 15px;
  background: rgba(92, 184, 92, 0.1);
  border: 2px solid var(--cyan-dark);
  text-align: center;
}

.tech-footer p {
  font-size: 0.8rem;
  color: var(--cyan-primary);
  font-style: normal;
}

/* =============================================================
   HAMBURGER MENU (Mobile)
   ============================================================= */

.hamburger-btn {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  cursor: pointer;
  padding: 10px;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--cyan-primary);
  transition: all 0.3s ease;
  border-radius: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  opacity: 1;
}

/* =============================================================
   LOADING PROGRESS BAR
   ============================================================= */

.loading-progress {
  width: 180px;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 0;
  overflow: hidden;
  margin: 20px auto;
  border: 2px solid var(--cyan-dark);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--cyan-primary);
  border-radius: 0;
  transition: width 0.3s ease;
}

/* =============================================================
   SOUND CONTROLS
   ============================================================= */

.sound-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 0 15px;
}

.sound-control-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sound-icon {
  font-size: 0.8rem;
  color: var(--cyan-primary);
}

.sound-label {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.5rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.sound-buttons {
  display: flex;
  gap: 5px;
}

.sound-btn {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
}

.sound-btn svg {
  width: 16px;
  height: 16px;
}

.sound-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--cyan-primary);
  color: var(--cyan-primary);
}

.sound-btn.active {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--cyan-primary);
  color: var(--cyan-primary);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.volume-control {
  display: none;
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 0;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--cyan-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--cyan-glow);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--cyan-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px var(--cyan-glow);
}

/* =============================================================
   TTS CONTROLS
   ============================================================= */

.tts-controls {
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-left: 1px solid var(--border-color);
}

.tts-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.tts-toggle input {
  display: none;
}

.tts-slider {
  width: 40px;
  height: 22px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  position: relative;
  transition: all 0.3s ease;
}

.tts-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.tts-toggle input:checked + .tts-slider {
  background: rgba(0, 212, 255, 0.2);
  border-color: var(--cyan-primary);
}

.tts-toggle input:checked + .tts-slider::after {
  left: 21px;
  background: var(--cyan-primary);
  box-shadow: 0 0 8px var(--cyan-glow);
}

.tts-label {
  font-family: 'Press Start 2P', cursive;
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* =============================================================
   SCROLL TO BOTTOM BUTTON
   ============================================================= */

.scroll-bottom-btn {
  position: absolute;
  bottom: 80px;
  right: 20px;
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--cyan-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  z-index: 10;
}

.scroll-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-bottom-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--cyan-primary);
}

.scroll-bottom-btn svg {
  width: 18px;
  height: 18px;
}

/* =============================================================
   MOBILE RESPONSIVE - Enhanced
   ============================================================= */

@media (max-width: 900px) {
  .hamburger-btn {
    display: flex;
  }
  
  .mobile-overlay {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100%;
    width: 240px;
    z-index: 100;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  
  .sidebar.open {
    left: 0;
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .character-container {
    width: 100%;
    min-width: auto;
  }
  
  .logo-sub, .nav-label, .status-text {
    display: block;
  }
  
  .logo-container {
    justify-content: flex-start;
  }
  
  .logo-img {
    width: 36px;
    height: 36px;
  }
  
  .nav-item {
    justify-content: flex-start;
    padding: 12px 20px;
  }
}

/* =============================================================
   MOBILE STYLES (max-width: 700px)
   Using calc() and fixed heights - most reliable approach
   ============================================================= */

@media (max-width: 700px) {
  /* Hide sidebar on mobile */
  .sidebar {
    display: none;
  }
  
  .sidebar.open {
    display: flex;
  }
  
  /* Main content takes full width */
  .main-content {
    width: 100%;
    height: 100vh;
    display: block;
    position: relative;
  }
  
  /* 3D Model - fixed 200px at top */
  .character-container {
    width: 100%;
    height: 200px;
    min-width: 0;
    position: relative;
  }
  
  #vrm-canvas {
    touch-action: none;
  }
  
  /* Hide all panels by default */
  .panel-section {
    display: none;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
  
  /* Active panel - use flex for proper layout */
  .panel-section.active {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
  }
  
  /* ============ CHAT PANEL ============ */
  .chat-window .chat-header {
    flex: 0 0 50px;
  }
  
  .chat-window .messages-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }
  
  .chat-window .input-container {
    flex: 0 0 72px;
    padding: 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
  }
  
  #chatForm {
    display: flex;
    gap: 10px;
    align-items: center;
    height: 100%;
  }
  
  #messageInput {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    height: 48px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
  }
  
  #sendBtn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: var(--cyan-primary);
    border: none;
  }
  
  /* ============ JOURNAL PANEL ============ */
  .journal-panel .chat-header {
    flex: 0 0 50px;
  }
  
  .journal-panel .journal-intro {
    flex: 0 0 auto;
    max-height: 100px;
    overflow: hidden;
    padding: 10px 15px;
  }
  
  .journal-panel .journal-entries {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }
  
  .journal-entry {
    padding: 12px;
    margin-bottom: 12px;
  }
  
  .journal-pagination {
    display: none;
  }
  
  /* ============ TECH PANEL ============ */
  .tech-panel .chat-header {
    flex: 0 0 50px;
  }
  
  .tech-panel .tech-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
  }
  
  .tech-section {
    margin-bottom: 18px;
    padding-bottom: 15px;
  }
  
  .tech-title {
    font-size: 0.75rem;
    margin-bottom: 10px;
  }
  
  .tech-section p {
    font-size: 0.8rem;
    line-height: 1.6;
  }
  
  .tech-stack {
    gap: 6px;
    flex-wrap: wrap;
  }
  
  .tech-tag {
    padding: 6px 10px;
    font-size: 0.6rem;
  }
  
  /* Character name tag */
  .character-name-tag {
    bottom: 10px;
    padding: 6px 12px;
  }
  
  .character-name-tag .name {
    font-size: 0.85rem;
  }
  
  .character-name-tag .status {
    font-size: 0.65rem;
  }
  
  /* Entry styling */
  .entry-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .entry-date {
    font-size: 0.65rem;
  }
  
  .entry-mood {
    font-size: 0.6rem;
  }
  
  .entry-content {
    font-size: 0.85rem;
  }
}

/* Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
  .character-container {
    height: 180px;
    flex: 0 0 180px;
  }
  
  .placeholder-icon {
    font-size: 2.5rem;
  }
  
  .placeholder-content p {
    font-size: 1rem;
  }
  
  .chat-header {
    padding: 10px 12px;
  }
  
  .header-text {
    font-size: 0.6rem;
    letter-spacing: 0.2em;
  }
  
  .header-line {
    display: none;
  }
  
  .msg-sender {
    font-size: 0.65rem;
  }
  
  .msg-text {
    font-size: 0.85rem;
    padding-left: 8px;
    line-height: 1.5;
  }
  
  .journal-intro {
    padding: 12px;
  }
  
  .journal-warning {
    font-size: 0.65rem;
    letter-spacing: 2px;
  }
  
  .journal-desc {
    font-size: 0.75rem;
    line-height: 1.5;
  }
  
  .journal-sub {
    display: none;
  }
  
  .journal-entries {
    padding: 10px;
  }
  
  .journal-entry {
    padding: 10px;
    margin-bottom: 10px;
  }
  
  .entry-content {
    font-size: 0.8rem;
  }
  
  .tech-content {
    padding: 12px;
  }
  
  .tech-section {
    margin-bottom: 15px;
    padding-bottom: 12px;
  }
  
  .tech-title {
    font-size: 0.7rem;
  }
  
  .tech-section p {
    font-size: 0.75rem;
  }
  
  .tech-tag {
    padding: 4px 6px;
    font-size: 0.55rem;
  }
  
  .sound-controls,
  .tts-controls {
    padding: 10px 12px;
  }
  
  .sound-btn {
    width: 32px;
    height: 32px;
  }
}

/* Extra Small (max-width: 360px) */
@media (max-width: 360px) {
  .character-container {
    height: 150px;
    flex: 0 0 150px;
  }
  
  .character-name-tag {
    display: none;
  }
  
  .tech-tag {
    padding: 3px 5px;
    font-size: 0.5rem;
  }
  
  .journal-warning {
    display: none;
  }
}

/* =============================================================
   TOUCH DEVICE OVERRIDES
   ============================================================= */

@media (hover: none) and (pointer: coarse) {
  #messageInput,
  #sendBtn,
  .nav-item,
  .sound-btn,
  .pagination-btn {
    min-height: 44px;
  }
  
  .nav-item:active,
  .sound-btn:active,
  #sendBtn:active,
  .pagination-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
  }
  
  .nav-item:hover,
  .sound-btn:hover,
  .journal-entry:hover {
    background: transparent;
    transform: none;
  }
}

/* =============================================================
   iOS SAFARI SPECIFIC FIXES
   ============================================================= */

@supports (-webkit-touch-callout: none) {
  /* iOS Safari only */
  .messages-container,
  .journal-entries,
  .tech-content {
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
  }
}
