* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Inter", sans-serif;
  background: #02111e;
  color: #d4f4ff;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: fixed;
  touch-action: none;
}
#canvas-container {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}
#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}
#title-bar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(2, 17, 30, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 32px;
  border-radius: 60px;
  border: 1px solid #3ad8ff55;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 60px #00a6ff22;
  white-space: nowrap;
  transition: all 0.3s ease;
}
#title-bar h1 {
  font-weight: 300;
  font-size: 1.2rem;
  letter-spacing: 6px;
  color: #a6ecff;
  transition: font-size 0.3s ease;
}
#title-bar .sub {
  font-size: 0.7rem;
  opacity: 0.6;
  letter-spacing: 2px;
}
#info-bottom {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(2, 17, 30, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 10px 20px;
  border-radius: 40px;
  border-left: 3px solid #00e5ff;
  pointer-events: none;
  font-size: 0.8rem;
  opacity: 0.7;
  transition: all 0.3s ease;
}

/* --- Lesson Panel --- */
#lesson-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 820px;
  max-height: 88vh;
  background: rgba(2, 17, 30, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid #3ad8ff88;
  border-radius: 28px;
  padding: 32px 36px;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  box-shadow:
    0 20px 80px rgba(0, 0, 0, 0.95),
    0 0 80px #00a6ff33;
  z-index: 50;
  display: none;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  transition: all 0.3s ease;
}
#lesson-panel::-webkit-scrollbar {
  width: 4px;
}
#lesson-panel::-webkit-scrollbar-track {
  background: transparent;
}
#lesson-panel::-webkit-scrollbar-thumb {
  background: #3ad8ff88;
  border-radius: 20px;
}

#lesson-panel .close-btn {
  position: sticky;
  top: 0;
  float: right;
  background: none;
  border: none;
  color: #8ad4ff;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 8px;
  transition: 0.2s;
  pointer-events: auto;
  z-index: 10;
  touch-action: manipulation;
}
#lesson-panel .close-btn:hover {
  color: #fff;
  transform: scale(1.1);
}
#lesson-panel .close-btn:active {
  transform: scale(0.9);
}

#lesson-panel .panel-header {
  margin-bottom: 20px;
  border-bottom: 1px solid #3ad8ff33;
  padding-bottom: 16px;
}
#lesson-panel .panel-header h2 {
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: 2px;
  color: #b2f0ff;
  margin-bottom: 4px;
  transition: font-size 0.3s ease;
}
#lesson-panel .panel-header .meta {
  font-size: 0.85rem;
  opacity: 0.65;
  letter-spacing: 1px;
}
#lesson-panel .content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #d4f4ff;
  word-wrap: break-word;
}
#lesson-panel .content .section {
  margin: 18px 0 12px 0;
  font-weight: 500;
  color: #a6ecff;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  border-left: 3px solid #3ad8ff66;
  padding-left: 14px;
}
#lesson-panel .content .highlight {
  background: rgba(0, 180, 255, 0.12);
  padding: 2px 8px;
  border-radius: 6px;
  color: #b2f0ff;
  font-weight: 500;
}
#lesson-panel .content .key-point {
  display: block;
  padding: 8px 16px;
  margin: 6px 0;
  background: rgba(0, 80, 130, 0.15);
  border-radius: 8px;
  border-left: 2px solid #00e5ff;
}
#lesson-panel .content .reflection {
  margin-top: 24px;
  padding: 18px 22px;
  background: rgba(0, 80, 120, 0.2);
  border-left: 4px solid #00e5ff;
  border-radius: 12px;
  font-style: italic;
  color: #c8f0ff;
}
#lesson-panel .content .reflection strong {
  color: #a6ecff;
  font-style: normal;
}
#lesson-panel .content ul,
#lesson-panel .content ol {
  padding-left: 24px;
  margin: 8px 0;
}
#lesson-panel .content li {
  margin: 4px 0;
}
#lesson-panel .content .diagram-box {
  background: rgba(0, 40, 70, 0.3);
  border: 1px dashed #3ad8ff44;
  border-radius: 12px;
  padding: 14px 18px;
  margin: 16px 0;
  text-align: center;
  font-size: 0.9rem;
  color: #8ad4ff;
}

/* --- RESPONSIVE BREAKPOINTS --- */
@media (max-width: 768px) {
  #title-bar {
    top: 12px;
    padding: 6px 16px;
    white-space: normal;
    max-width: 90%;
  }
  #title-bar h1 {
    font-size: 0.9rem;
    letter-spacing: 3px;
  }
  #title-bar .sub {
    font-size: 0.6rem;
  }
  #info-bottom {
    bottom: 16px;
    left: 16px;
    padding: 6px 14px;
    font-size: 0.7rem;
    border-left-width: 2px;
  }
  #lesson-panel {
    padding: 20px 16px;
    width: 95%;
    max-height: 92vh;
    border-radius: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  #lesson-panel .panel-header h2 {
    font-size: 1.4rem;
    letter-spacing: 1px;
  }
  #lesson-panel .panel-header .meta {
    font-size: 0.75rem;
  }
  #lesson-panel .content {
    font-size: 0.88rem;
    line-height: 1.7;
  }
  #lesson-panel .content .section {
    font-size: 0.95rem;
    padding-left: 10px;
    margin: 14px 0 10px 0;
  }
  #lesson-panel .content .key-point {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
  #lesson-panel .content .reflection {
    padding: 14px 16px;
    font-size: 0.85rem;
  }
  #lesson-panel .content .diagram-box {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
  #lesson-panel .close-btn {
    font-size: 1.5rem;
    padding: 0 4px;
  }
  #lesson-panel .content ul,
  #lesson-panel .content ol {
    padding-left: 18px;
  }
}

@media (max-width: 480px) {
  #title-bar {
    top: 8px;
    padding: 4px 12px;
    border-radius: 40px;
  }
  #title-bar h1 {
    font-size: 0.75rem;
    letter-spacing: 2px;
  }
  #title-bar .sub {
    font-size: 0.5rem;
    letter-spacing: 1px;
  }
  #info-bottom {
    display: none;
  }
  #lesson-panel {
    padding: 16px 12px;
    width: 98%;
    max-height: 94vh;
    border-radius: 16px;
  }
  #lesson-panel .panel-header {
    margin-bottom: 14px;
    padding-bottom: 10px;
  }
  #lesson-panel .panel-header h2 {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
  }
  #lesson-panel .panel-header .meta {
    font-size: 0.65rem;
  }
  #lesson-panel .content {
    font-size: 0.82rem;
    line-height: 1.6;
  }
  #lesson-panel .content .section {
    font-size: 0.88rem;
    padding-left: 8px;
    margin: 12px 0 8px 0;
    border-left-width: 2px;
  }
  #lesson-panel .content .key-point {
    padding: 5px 10px;
    font-size: 0.8rem;
    border-left-width: 2px;
  }
  #lesson-panel .content .reflection {
    padding: 12px 14px;
    font-size: 0.8rem;
    border-left-width: 3px;
    margin-top: 16px;
  }
  #lesson-panel .content .diagram-box {
    padding: 8px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
    margin: 10px 0;
  }
  #lesson-panel .content ul,
  #lesson-panel .content ol {
    padding-left: 14px;
  }
  #lesson-panel .content li {
    margin: 3px 0;
  }
  #lesson-panel .close-btn {
    font-size: 1.3rem;
    padding: 0 2px;
  }
}

@media (max-height: 700px) {
  #lesson-panel {
    max-height: 90vh;
    padding: 16px 20px;
  }
  #lesson-panel .panel-header h2 {
    font-size: 1.3rem;
  }
  #lesson-panel .content {
    font-size: 0.85rem;
    line-height: 1.6;
  }
}

@media (max-height: 500px) {
  #lesson-panel {
    max-height: 92vh;
    padding: 12px 14px;
    border-radius: 14px;
  }
  #lesson-panel .panel-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  #lesson-panel .panel-header h2 {
    font-size: 1rem;
  }
  #lesson-panel .content .section {
    margin: 10px 0 6px 0;
    font-size: 0.82rem;
  }
  #lesson-panel .content .key-point {
    padding: 4px 8px;
    margin: 4px 0;
    font-size: 0.78rem;
  }
  #lesson-panel .content .reflection {
    padding: 10px 12px;
    font-size: 0.78rem;
    margin-top: 12px;
  }
}

/* Touch device optimizations */
@media (hover: none) {
  #lesson-panel .close-btn:hover {
    transform: none;
  }
  #lesson-panel .close-btn:active {
    transform: scale(0.9);
  }
}

@media (max-width: 768px) {
  #copyright {
    bottom: 16px;
    right: 16px;
    padding: 4px 12px;
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  #copyright {
    bottom: 12px;
    right: 12px;
    padding: 3px 10px;
    font-size: 0.5rem;
    opacity: 0.7;
  }
}
