/* === Basic Style Reset === */
html, body {
  /* Changed from hidden to auto to enable scrolling */
  overflow: hidden;
  margin: 0;
  padding: 0;
  /* Default: white background for page */
  background: #FFFFFF;
}

body {
  font-family: 'Montserrat', Arial, sans-serif;
  /* Default: white background for page */
  background: #FFFFFF;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Background SVG === */


/* === Top Bar === */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #18225a;
  height: 56px;
  padding: 0 32px;
  color: white;
  position: relative;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  position: absolute; 
  left: 32px;
  top: 50%;
  transform: translateY(-50%);
}

.top-bar-right {
  display: flex;
  align-items: center;
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
}

.top-logo {
  height: 32px;
  margin-right: 12px;
}

.secondary-logo {
  height: 28px;
}

.top-bar-title {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
}

/* Language toggle in top bar */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  margin-right: 4px;
  font-family: 'Montserrat', Arial, sans-serif;
}

.lang-option {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Montserrat', Arial, sans-serif;
}

.lang-option.active {
  color: #ffffff;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .4s;
  border-radius: 22px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #648bf2;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* === Instruction Popup === */
.mic-instruction-popup {
  position: absolute;
  top: 100px;
  right: 40px;
  background-color: white;
  border-radius: 12px;
  padding: 16px 20px;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  font-family: 'Montserrat', Arial, sans-serif;
  z-index: 100;
  border: 1px solid rgba(194, 212, 242, 0.5);
}

.popup-content {
  font-size: 16px;
  line-height: 1.5;
  color: #18225a;
  font-weight: 500;
}

.popup-content h3 {
  font-size: 1rem;
  line-height: 1.5;
  color: #18225a;
  font-weight: 500;
}

.popup-content p {
  font-size: .9rem;
  padding-top: 0px;
  line-height: 1.5;
  color: #18225a;
  font-weight: 500;
}

.popup-content ul {
  margin: 0;
  font-size: .9rem;
  padding-left: 20px;
}

.popup-content li {
  font-size: .9rem;
  margin-bottom: 8px;
}

.popup-divider {
  margin: 15px 0;
  border: 0;
  height: 1px;
  background-color: rgba(194, 212, 242, 0.8);
}

.popup-highlight {
  font-weight: 700;
  color: #8024E3;
}

.close-popup-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.close-popup-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* === Main Content === */
.main-content {
  top:25px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  /* Distribute space to push buttons toward footer */
  justify-content: space-between;
}

/* === AVATAR - CRITICAL CSS === */
#content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto;
  z-index: 2;
  /* Added flex-grow to push buttons down */
  flex-grow: 1;
}

/* IMPORTANT: VIDEO WRAPPER STYLING */
#video-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  width: 100vh;
  height: 100vh;
  overflow: hidden;
  border-radius: 20px;
}


#video-wrapper canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Hide old video elements */
#idle-video-element, 
#pre-response-video-element, 
#stream-video-element {
  display: none;
}

/* === Buttons Layout === */
.button-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  /* Moved to auto margins to push near footer */
  margin-top: auto;
  margin-bottom: 20px;
}

.help-container {
  position: absolute;
  top: 80px;
  right: 60px;
  z-index: 10;
}

.action-btn {
  border: none;
  background: white;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.action-btn:disabled{
  cursor: default;
  background-color: rgba(0,0,0,0.2);
}
.action-btn:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(128, 36, 227, 0.2);
}

.small-btn {
  width: 56px;
  height: 56px;
  background: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.large-btn {
  width: 80px;
  height: 80px;
  background: #8024E3;
  box-shadow: 0 4px 12px rgba(128, 36, 227, 0.3);
}

.large-btn .icon {
  filter: brightness(10);
}

/* Microphone Button States */
.small-btn.mic-off {
  width: 80px;
  height: 80px;
  background: white !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.small-btn.mic-off .icon {
  filter: none !important; /* Remove the brightness filter when mic is off */
}

.question-mark {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 28px;
  font-weight: bold;
  color: #8024E3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* === New Session Button === */
.new-session-wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  gap: 10px;
  margin-bottom: 10px;
}

.new-session-btn {
  background: white;
  color: #8024e3;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 12px 28px;
  border-radius: 30px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  max-width: 180px; 
}

.new-session-btn:hover {
  background: #8024e3;
  color: #fff;
  box-shadow: 0 8px 16px rgba(128, 36, 227, 0.3);
}

/* === Vote Button === */

.vote-wrapper {
  display: flex;
  justify-content: left;
  align-items: center;
  margin-top: 0px;
  margin-bottom: 0;
  width: 100%;
}

.vote-btn {
  background: white;
  color: #8024e3;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  font-size: 1.13rem;
  padding: 4px 36px;
  border-radius: 32px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.13);
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vote-btn p {
  margin: 0;
  font-size: 1.13rem;
  font-weight: 700;
}

.vote-btn-link {
  background: white;
  color: #8024e3;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  font-size: 1.13rem;
  padding: 12px 36px;
  border-radius: 32px;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.13);
  transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
  cursor: pointer;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  outline: none;
  letter-spacing: 0.01em;
}
.vote-btn-link:hover, .vote-btn-link:focus {
  background: #8024e3;
  color: #fff;
  box-shadow: 0 8px 16px rgba(128, 36, 227, 0.3);
  text-decoration: none;
}


.vote-btn:hover {
  background: #8024e3;
  color: #fff;
  box-shadow: 0 8px 16px rgba(128, 36, 227, 0.3);
}

/* === Footer === */
.footer {
  background: #18225a;
  color: #fff;
  padding: 36px 32px 16px 32px;
  position: relative;
  z-index: 2;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto 24px auto;
}

.footer-left {
  max-width: 60%;
}

.footer-logos {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.footer-logo {
  height: 32px;
  margin-right: 12px;
}

.footer-desc {
  font-size: 1rem;
  margin-bottom: 16px;
  color: #dde9fa;
  line-height: 1.5;
}

.footer-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
}

.footer-links {
  display: flex;
  align-items: center;
  font-size: 1rem;
  color: #fff;
}

.footer-links a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: #b5aaff;
}

.separator {
  width: 1px;
  height: 16px;
  background-color: #b5aaff;
  margin: 0 15px;
}

.footer-copyright {
  font-size: 0.92rem;
  color: #b5aaff;
  text-align: center;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid rgba(181, 170, 255, 0.2);
}

.footer-ai-warning {
  color: #dde9fa;
  font-size: 0.98rem;
  line-height: 1.4;
  margin-top: 16px;
  text-align: right;
  max-width: 280px;
  word-break: break-word;
}

/* === Character Container (Required but hidden from view) === */
.character-container {
  position: fixed;
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 450px;
  z-index: -1;
}

#character-body,
#mouth-shape {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#mouth-shape {
  z-index: 2;
}

#character-body {
  z-index: 1;
}

/* === Connection Status Colors === */
.peerConnectionState-new {
  color: cornflowerblue;
}
.peerConnectionState-connecting {
  color: orange;
}
.peerConnectionState-connected {
  color: green;
}
.peerConnectionState-disconnected,
.peerConnectionState-closed,
.peerConnectionState-failed {
  color: red;
}

.iceConnectionState-new {
  color: cornflowerblue;
}
.iceConnectionState-checking {
  color: orange;
}
.iceConnectionState-connected,
.iceConnectionState-completed {
  color: green;
}
.iceConnectionState-disconnected,
.iceConnectionState-closed,
.iceConnectionState-failed {
  color: red;
}

.iceGatheringState-new {
  color: cornflowerblue;
}
.iceGatheringState-gathering {
  color: orange;
}
.iceGatheringState-complete {
  color: black;
}

.signalingState-stable {
  color: green;
}
.signalingState-have-local-offer,
.signalingState-have-remote-offer,
.signalingState-have-local-pranswer,
.signalingState-have-remote-pranswer {
  color: cornflowerblue;
}
.signalingState-closed {
  color: red;
}

.streamingState-streaming {
  color: green;
}

.streamingState-empty {
  color: grey;
}

.streamEvent-started {
  color: green;
}

.streamEvent-done {
  color: orange;
}

.streamEvent-ready {
  color: green;
}

.streamEvent-error {
  color: red;
}

.streamEvent-dont-care {
  color: gray;
}

/* === High Score Display === */
.high-score-container {
  position: absolute;
  top: 0px;
  left: 40px;
  background: rgba(26, 34, 87, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 15px 20px;
  color: white;
  font-family: 'Montserrat', Arial, sans-serif;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2), 0 0 10px rgba(100, 139, 242, 0.15);
  z-index: 10;
  text-align: center;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.18);
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* === Vote Display === */
.vote-container p {
  margin: 0 0 8px 0;
  font-size: .9rem;
  line-height: 1.5;
  font-weight: 400;
}


.vote-container h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}

@media (max-width: 600px) {
  .vote-container {
    left: 0;
    top: 12px;
    right: 0;
    margin: 0 auto;
    padding: 18px 8px 16px 8px;
    max-width: 98vw;
    border-radius: 14px;
    gap: 8px;
  }
  .vote-logo-wrapper img {
    height: 72px;
    max-width: 160px;
  }
  .vote-btn, .vote-btn-link {
    padding: 4px 18px;
    font-size: 1rem;
    border-radius: 24px;
  }
  .vote-container p {
    font-size: 0.9rem;
    font-weight: 400;
  }

  .vote-container h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 8px 0;
  }
}

.vote-container {
  position: absolute;
  top: 0px;
  left: 40px;
  background: rgba(26, 34, 87, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 28px 32px 24px 32px;
  color: white;
  font-family: 'Montserrat', Arial, sans-serif;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.22), 0 0 10px rgba(100, 139, 242, 0.18);
  z-index: 10;
  text-align: center;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.18);
  max-width: 200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.vote-logo-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}
.vote-logo-wrapper img {
  height: 96px;
  width: auto;
  max-width: 240px;
  display: block;
} 


.score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 5px 0;
}

.spark-icon {
  margin: 0 8px;
  filter: drop-shadow(0 0 8px rgba(100, 139, 242, 0.8));
  animation: sparkle-float 3s ease-in-out infinite;
}

.left-spark {
  animation-delay: 0.5s;
}

.right-spark {
  animation-delay: 1s;
}

.spark-icon svg {
  width: 20px;
  height: 20px;
}

@keyframes sparkle-float {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

.high-score-label {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
  color: #ffffff;
}

.score-celebration {
  position: absolute;
  top: -25px;
  left: 0;
  right: 0;
  font-size: 14px;
  font-weight: 700;
  color: #648bf2;
  text-shadow: 0 0 10px rgba(100, 139, 242, 0.8);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.score-celebration.show {
  opacity: 1;
  transform: translateY(0);
  animation: celebrate 1.5s ease-out;
}

@keyframes celebrate {
  0% { transform: translateY(10px); opacity: 0; }
  10% { transform: translateY(-5px); opacity: 1; }
  20% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
  40% { transform: translateY(0); }
  60% { transform: scale(1.1); }
  80% { transform: scale(1); }
  100% { transform: translateY(0); opacity: 0; }
}

.high-score-value {
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 5px;
  position: relative;
  letter-spacing: 1px;
}

/* Animation for when score updates */
@keyframes scoreUpdate {
  0% { transform: scale(1); }
  20% { transform: scale(1.3); }
  40% { transform: scale(1.1); }
  60% { transform: scale(1.2); }
  80% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.score-updated {
  animation: scoreUpdate 0.8s ease;
}

/* Responsive adjustments */
@media (max-width: 700px) {
  .main-content {
    padding: 20px 0 20px;
  }
  
  #video-wrapper {
    height: 350px;
    width: 350px;
  }
  
  .button-row {
    gap: 16px;
  }
  
  .large-btn {
    width: 72px;
    height: 72px;
  }
  
  .small-btn {
    width: 48px;
    height: 48px;
  }
  
  .large-btn .icon {
    width: 32px;
    height: 32px;
  }
  
  .small-btn .icon,
  .question-mark {
    width: 22px;
    height: 22px;
    font-size: 22px;
  }
  
  .help-container {
    right: 24px;
    bottom: 120px;
  }
  
  .footer-content {
    flex-direction: column;
    align-items: center;
  }
  
  .footer-left {
    max-width: 100%;
    text-align: center;
  }
  
  .footer-right {
    align-items: center;
    margin-top: 20px;
  }
  
  .mic-instruction-popup {
    top: 80px;
    right: 20px;
    max-width: 280px;
  }
  
  .voice-only-section {
    width: 90%;
    margin: 10px auto;
  }
  
  .voice-only-section textarea {
    font-size: 0.9rem;
    min-height: 70px;
    padding: 10px 12px;
  }
  
  .voice-only-btn {
    padding: 10px 24px !important;
    font-size: 0.9rem !important;
  }
}

/* --- Additions for new top-bar-title-nav and nav-link styles --- */
.top-bar-title-nav {
  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  text-align: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 55%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.top-bar-title-nav .nav-link {
  font-weight: 700;
  font-size: 0.98rem;
  margin-left: 18px;
  color: #fff;
  text-decoration: none;
  transition: color 0.2s;
}

.top-bar-title-nav .nav-link:hover {
  color: #b5aaff;
}

/* Invisible but required content wrapper */
.content-wrapper {
  position: absolute;
  height: 1px;
  width: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* === Voice Only Section === */
.voice-only-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 15px auto;
  max-width: 600px;
}

.voice-only-section textarea {
  width: 100% !important;
  border: 2px solid #c2d4f2;
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 1rem;
  background: white;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.voice-only-section textarea:focus {
  outline: none;
  border-color: #9c27b0;
  box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.1);
}

.voice-only-section textarea::placeholder {
  color: #999;
  font-style: italic;
}

.voice-only-btn {
  padding: 12px 32px !important;
  border-radius: 30px !important;
  background: #9c27b0 !important;
  color: white !important;
  font-family: 'Montserrat', Arial, sans-serif !important;
  font-weight: 600 !important;
  font-size: 1rem !important;
  border: none !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 4px 12px rgba(156, 39, 176, 0.3) !important;
  width: auto !important;
  height: auto !important;
}

.voice-only-btn:hover {
  background: #7b1fa2 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 16px rgba(156, 39, 176, 0.4) !important;
}

.voice-only-btn:active {
  transform: translateY(0) !important;
}

.peerConnectionState-new {
  color: cornflowerblue;
}

.send-word {
  background: #FFFFFF;
  color: #18225A;
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: 2rem;
  font-weight: 500;
  border-top-left-radius: 45px;
  border-bottom-right-radius: 45px;
  border-top-right-radius: 8px;
  border-bottom-left-radius: 8px;
  padding: 32px 36px;
  width: 473px;
  max-width: 95vw;
  text-align: center;
  margin: 24px auto;
  box-sizing: border-box;
  box-shadow: 0 2px 12px rgba(68,120,199,0.08);
  letter-spacing: 0.01em;
  position: absolute;
  top: 0px;
  right: 10px;
}
.send-word b, .send-word strong {
  font-weight: 700;
}
