/* 全局重置与基础样式 */
:root {
  --primary-accent: #00ffc3;
  --secondary-accent: #ff007f;
  --tertiary-accent: #ff9900;
  --background-color: #000000;
  --surface-color: rgba(20, 20, 22, 0.8);
  --text-color: #e0e0e0;
  --text-color-dim: #9e9e9e;
  --text-color-warn: #f7d379;
  --border-color: rgba(255, 255, 255, 0.1);
  --footer-height: 60px; /* 默认页脚高度 */
  --intro-text-color: #00ffc3;
  --glow-color-main: #00ffc3; /* 主房间点亮颜色 */
  --glow-color-a: #ff007f; /* A房间点亮颜色 */
  --glow-color-custom: #ff9900; /* 自定义房间点亮颜色 */

  /* 用户等级颜色 */
  --level-site-owner-color: #cc99ff; /* 站长 */
  --level-admin-color: #98fb98; /* 管理员 (草绿色) */
  --level-chamoku: #dd1111; /* 茶墨 */
  --level-mod-color: #87ceeb; /* 受信用户 (亮蓝色) */
  --level-room-owner-color: #2e8b57; /* 房主 (深绿色) */
  --level-other-user-color: #82b1ff; /* 其他人 */
  --level-self-color: #ffffff; /* 自己 */
}

@font-face {
  font-family: "Default_sans";
  src: url("https://isos-natsu.byterain.co/mirror/JNMYT.woff"); /* Change it please very soon bcz it loads very slowly */
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  font-size: 16px;
}

body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden; /* 防止body滚动 */
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: "Default_sans", "Segoe UI", "Roboto", "Helvetica Neue",
    sans-serif;
  font-size: 16px;
  display: flex;
  flex-direction: column;
}

/* 页面切换与动画 */
#landing-page,
#chat-wrapper {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition: opacity 0.5s, visibility 0.5s;
}

.hidden {
  opacity: 0;
  visibility: hidden;
}

/* 主页样式 */
#landing-page {
  /* display: flex;*/
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  padding: 2rem;
  overflow-y: auto;
}

#landing-header {
  text-align: center;
  margin-bottom: 2rem;
}
#landing-header h1 {
  font-size: 3rem;
  margin: 0;
  font-weight: 600;
}
#login-status {
  margin-top: 1rem;
  color: var(--text-color-dim);
}
#logout-button {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-color-dim);
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: 8px;
  cursor: pointer;
}

#room-selection {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}
.room-card {
  width: 250px;
  height: 350px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  padding: 1rem;
}
.room-card::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  filter: blur(60px);
  transition: all 0.5s ease;
}
.room-card:hover {
  transform: translateY(-10px) scale(1.03);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.room-card:hover::before {
  width: 220px;
  height: 220px;
  filter: blur(90px);
}
#main-room-card::before {
  background: var(--primary-accent);
}
#main-room-card {
  color: var(--primary-accent);
}
#a-room-card::before {
  background: var(--secondary-accent);
}
#a-room-card {
  color: var(--secondary-accent);
}
#custom-room-card::before {
  background: var(--tertiary-accent);
}
#custom-room-card {
  color: var(--tertiary-accent);
}

/* Here is BKLight */
/* .room-card h3 {
        font-size: 2rem;
        margin: 0;
        z-index: 1;
      } */
/* .room-card p, */
.room-card input,
.room-card button {
  z-index: 1;
}
/* .room-card p {
        color: var(--text-color-dim);
      } */
.room-card h3,
.room-card p,
.room-card span {
  transition: color 0.5s ease-out;
}
/* 坏掉的字符样式 */
.broken-char {
  animation: flicker-char 1.5s infinite alternate ease-in-out;
}
/* Glitch 效果 - 针对单个字符 */
@keyframes flicker-char {
  0%,
  100% {
    opacity: 0.2;
  }
  5% {
    opacity: 1;
  }
  10%,
  30% {
    opacity: 0.2;
  }
  45% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}
/* 针对每个卡片悬停时特定颜色的发光 */
#main-room-card:hover h3,
#main-room-card:hover p,
#main-room-card:hover span {
  text-shadow: 0 0 8px var(--glow-color-main), 0 0 15px var(--glow-color-main);
}
#a-room-card:hover h3,
#a-room-card:hover p,
#a-room-card:hover span {
  text-shadow: 0 0 8px var(--glow-color-a), 0 0 15px var(--glow-color-a);
}
#custom-room-card:hover h3,
#custom-room-card:hover p,
#custom-room-card:hover span {
  text-shadow: 0 0 8px var(--glow-color-custom),
    0 0 15px var(--glow-color-custom);
}
/* 鼠标悬停在“坏掉的字符”上时，它会更剧烈地闪烁 */
.room-card:hover .broken-char {
  animation: flicker-char-hover 0.5s infinite alternate ease-in-out; /* 悬停时加快闪烁速度 */
  /* 使用悬停时整体卡片的发光颜色 */
}
/* 鼠标悬停时坏掉字符的闪烁动画 */
@keyframes flicker-char-hover {
  0%,
  100% {
    opacity: 0.2;
  }
  5% {
    opacity: 1;
  }
  10%,
  30% {
    opacity: 0.2;
  }
  45% {
    opacity: 1;
  }
  50% {
    opacity: 0.2;
  }
}

#custom-room-input,
#custom-room-join-button {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 0.75rem;
  border-radius: 8px;
  margin-top: 1rem;
  text-align: center;
  width: 85%;
}
#custom-room-join-button {
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}
#custom-room-join-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* 登录模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
}
.modal-overlay.visible {
  display: flex;
}
.modal-content {
  background: #1c1c1e;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}
.modal-content h3 {
  margin-top: 0;
}
.modal-content input {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #2c2c2e;
  color: #fff;
}
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}
.modal-buttons button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#login-button {
  background: var(--primary-accent);
  color: #000;
  font-weight: bold;
}
#close-login-modal {
  background: #3c3c3e;
  color: #fff;
}

/* 聊天界面 */
#chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  user-select: none; /* 禁止选中 */
}

/* 顶部栏 */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #121212;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
#top-bar .room-title {
  font-weight: bold;
}
#top-bar .buttons {
  display: flex;
  gap: 0.5rem;
}
#top-bar button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 1em;
  color: var(--text-color-dim);
  z-index: 105;
}
#top-bar button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* 消息区域 */
.container {
  flex-grow: 1; /* 占据剩余空间 */
  overflow-y: auto; /* 允许内容滚动 */
  -webkit-overflow-scrolling: touch; /* iOS 滚动优化 */
  scroll-behavior: smooth;
  height: 100%;
}
#messages {
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.message {
  display: flex;
}
.message .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
}
.message .content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 44px);
}
.message .nick-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.message .trip {
  font-size: 0.75rem;
  color: #9e9e9e;
}
.message .nick a {
  font-size: 1rem;
  text-decoration: none;
  font-weight: bold;
  color: var(--level-other-user-color);
}
.message .timestamp {
  font-size: 0.75rem;
  color: var(--text-color-dim);
  font-weight: normal;
}

.message.me .nick a {
  color: var(--level-self-color);
}
.message.level-site-owner .nick a {
  color: var(--level-site-owner-color);
}
.message.level-chamoku .nick a {
  color: var(--level-chamoku);
}
.message.level-admin .nick a {
  color: var(--level-admin-color);
}
.message.level-mod .nick a {
  color: var(--level-mod-color);
}
.message.level-room-owner .nick a {
  color: var(--level-room-owner-color);
}

.message .text {
  margin-top: 4px;
  line-height: 1.6;
  word-wrap: break-word;
  font-size: 1rem;
}
a {
  color: #64b5f6;
}
.message .text img {
  max-width: 70%;
  border-radius: 8px;
  margin-top: 4px;
}

/* 系统消息 */
.info,
.warn {
  font-style: italic;
  color: var(--text-color-dim);
  margin: 0 auto;
  text-align: center;
  padding: 0.5rem 0;
  width: 100%;
}
.warn {
  color: var(--text-color-warn);
}
.info .text,
.warn .text {
  margin: 0;
}
.join-info {
  font-size: 0.8rem;
  color: #aaa;
}

/* 消息入场动画 */
@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.new-message {
  animation: slideIn 0.3s ease-out;
}

/* 聊天输入框 */
#footer {
  flex-shrink: 0;
  background-color: #121212;
  border-top: 1px solid var(--border-color);
  z-index: 100;
}
#footer .container {
  display: flex;
  align-items: flex-end;
  padding: 0.7em;
  gap: 1em;
}
#chatform {
  flex-grow: 1;
  position: relative;
}
#chatinput {
  width: 100%;
  max-height: 150px;
  background: transparent;
  border: none;
  color: #fff;
  resize: none;
  font-family: inherit;
  outline: none;
}
#footer button {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  transition: background-color 0.2s;
  align-self: flex-end;
  margin-bottom: 4px;
}
#footer button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}
#footer button svg {
  width: 30px;
  fill: #fff;
}
#markdown-hint {
  position: absolute;
  bottom: 100%;
  left: 10px;
  margin-bottom: 4px;
  background: rgba(40, 40, 40, 0.9);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-color-dim);
  display: none;
}

/* 侧边栏 */
#sidebar {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100%;
  background: #1c1c1e;
  padding: 1em;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 104;
  overflow-y: auto;
  border-left: 1px solid var(--border-color);
}
#sidebar.open {
  right: 0;
}
#sidebar-content h3,
#sidebar-content h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
#sidebar-content p {
  margin: 0.5rem 0;
}
#users li {
  list-style-type: none;
  margin-bottom: 5px;
}
#users a {
  color: var(--text-color);
  text-decoration: none;
}

/* 图片放大器 */
#lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 300;
}
#lightbox.visible {
  display: flex;
}
#lightbox-image {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

/* 涟漪动画 */
@keyframes ripple-effect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}
.ripple-send {
  position: fixed;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-effect 0.6s linear;
  background-color: rgba(0, 255, 195, 0.7);
  width: 100px;
  height: 100px;
  z-index: 999;
  pointer-events: none;
}
@keyframes page-transition-enter {
  from {
    transform: scale(var(--scale));
    border-radius: 16px;
  }
  to {
    transform: scale(1);
    border-radius: 0;
  }
}
.ripple-enter {
  position: fixed;
  background: #000;
  animation: page-transition-enter 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform-origin: top left;
  --scale: calc(var(--width) / 100vw);
  top: var(--top);
  left: var(--left);
  width: 100vw;
  height: 100vh;
  z-index: 199;
}

.intro-text {
  position: absolute;
  font-weight: bold;
  white-space: nowrap;
  user-select: none;
  /* Prevent text selection */
  transition: transform 0.1s linear, opacity 0.5s linear;
  /* Smooth movement and fade */
}

.intro-text-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  /* Below main content */
  pointer-events: none;
  /* Don't interfere with mouse events */
}
/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.2;
  } /* 设定一个较淡的可见度 */
}

/* 淡出动画 */
@keyframes fadeOut {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 0;
  }
}

/* Glitch 效果 */
@keyframes glitch {
  0% {
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
      -0.05em 0 0 rgba(0, 255, 0, 0.75);
    transform: translateX(-0.02em);
  }
  25% {
    text-shadow: 0 0.05em 0 rgba(0, 0, 255, 0.75),
      0 -0.05em 0 rgba(255, 0, 255, 0.75);
    transform: translateX(0.02em);
  }
  50% {
    text-shadow: -0.05em 0 0 rgba(0, 255, 0, 0.75),
      0.05em 0 0 rgba(255, 0, 0, 0.75);
    transform: translateX(-0.02em);
  }
  75% {
    text-shadow: 0 -0.05em 0 rgba(255, 0, 255, 0.75),
      0 0.05em 0 rgba(0, 0, 255, 0.75);
    transform: translateX(0.02em);
  }
  100% {
    text-shadow: none;
    transform: translateX(0);
  }
}

.intro-text.glitch-active {
  animation: glitch 0.5s infinite linear alternate,
    /* glitch 动画 */ fadeIn 1s ease-in-out forwards; /* 淡入动画 */
}
.intro-text.fade-out {
  animation: fadeOut 1s ease-in-out forwards;
}

::-webkit-scrollbar-track {
  background-color: transparent;
  border-radius: 2em;
}

::-webkit-scrollbar {
  width: 0.3rem;
  height: 8px;
}

::-webkit-scrollbar-corner {
  background-color: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: #64b5f6;
  background-image: -webkit-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.4) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0.4) 75%,
    transparent 75%,
    transparent
  );
  border-radius: 2em;
}

.context-menu {
  position: fixed;
  background: var(--background-color);
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 0;
  z-index: 9999;
  display: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-family: inherit;
  font-size: 14px;
  min-width: 80px;
}
.menu-item {
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover {
  background-color: #b2b2b2;
}
/* 添加箭头指示 */
.context-menu::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 12px;
  border-width: 0 5px 5px 5px;
  border-style: solid;
  border-color: transparent transparent #fff transparent;
}
.context-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 11px;
  border-width: 0 6px 6px 6px;
  border-style: solid;
  border-color: transparent transparent #ccc transparent;
}

#meme-popup {
  display: none;
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--background-color);
  border: 1px solid rgb(204, 204, 204);
  border-radius: 8px;
  box-shadow: rgba(0, 0, 0, 0.15) 0px 2px 8px;
  padding: 0px;
  z-index: 9999;
  max-width: 90vw;
  height: 50vh;
  width: 67vw;
  overflow: hidden;
}

#meme-list-wrapper {
  overflow-y: auto;
  height: 90%;
}

.meme-list-active {
  display: flex !important;
}

.meme-list {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}

#meme-tabs {
  display: flex;
  border-top: 1px solid #eee;
  flex-direction: row;
  overflow-y: hidden;
  overflow-x: auto;
}

.meme-tab {
  color: #eee;
  border: none;
  background: none;
  padding: 0.514rem;
  margin: 0;
  font: inherit;
  cursor: pointer;
  min-width: 80px;
  font-size: 0.8rem;
}

.meme-tab-active {
  background: #eee;
  color: #000;
}

.meme-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 4rem;
}

.meme-item img {
  width: 3.1rem;
  height: 3.1rem;
  object-fit: contain;
  cursor: pointer;
}

.meme-item span {
  font-size: 0.8rem;
  color: rgb(102, 102, 102);
  margin-top: 0.1rem;
}
