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

body {
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #FFF8E7 url(/bg.jpg) no-repeat center center fixed;
  background-size: contain;
  color: #4A4030;
  min-height: 100vh;
  line-height: 1.7;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #FFE066;
  border-bottom: 4px solid #FFC93C;
  box-shadow: 0 4px 12px rgba(255, 193, 60, 0.3);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #5A4A20;
  font-weight: bold;
  font-size: 1.3rem;
}

.logo-icon { font-size: 1.6rem; }

.nav { display: flex; gap: 8px; }

.nav-link {
  text-decoration: none;
  color: #6B5B30;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: bold;
  transition: 0.2s;
}

.nav-link:hover { background: rgba(255,255,255,0.5); }

.nav-link.active {
  background: #fff;
  color: #E8960C;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.post-form-card {
  background: #fff;
  border: 3px solid #FFE066;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 6px 20px rgba(255, 193, 60, 0.25);
}

.post-form-card h2 {
  color: #E8960C;
  font-size: 1.25rem;
}

.subtitle {
  color: #A89870;
  font-size: 0.85rem;
  margin: 6px 0 14px;
}

textarea {
  width: 100%;
  min-height: 110px;
  background: #FFFDF5;
  border: 2px solid #FFE9A8;
  border-radius: 14px;
  color: #4A4030;
  padding: 14px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

textarea:focus {
  border-color: #FFC93C;
  box-shadow: 0 0 0 4px rgba(255, 201, 60, 0.2);
}

textarea::placeholder { color: #C4B690; }

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

#charCount { color: #A89870; font-size: 0.8rem; }

.btn-primary {
  background: linear-gradient(135deg, #FFD93C, #FFB830);
  color: #5A4A20;
  border: none;
  padding: 11px 26px;
  border-radius: 25px;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 184, 48, 0.4);
  transition: 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 184, 48, 0.5);
}

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.section-title {
  color: #E8960C;
  margin-bottom: 16px;
  font-size: 1.15rem;
}

.post-card {
  background: #fff;
  border: 2px solid #FFE9A8;
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
  animation: fadeIn 0.4s ease;
}

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

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

.post-anon {
  color: #E8960C;
  font-size: 0.8rem;
  font-weight: bold;
  background: #FFF3D1;
  padding: 4px 12px;
  border-radius: 16px;
  border: 1px solid #FFE066;
}

.post-time { color: #B5A888; font-size: 0.75rem; }

.post-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}

.ai-reply {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px dashed #FFE9A8;
}

.ai-reply-name {
  color: #4EA8DE;
  font-size: 0.85rem;
  font-weight: bold;
  margin-bottom: 6px;
}

.ai-reply-content {
  color: #5A6B7C;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: #F0F8FF;
  padding: 12px 14px;
  border-radius: 14px;
  border-left: 4px solid #4EA8DE;
}

.ai-loading {
  color: #A89870;
  font-size: 0.85rem;
  margin-top: 10px;
}

.loading { text-align: center; color: #B5A888; padding: 20px; }

.chat-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  justify-content: center;
}

.chat-container {
  width: 100%;
  max-width: 650px;
  height: calc(100vh - 130px);
  min-height: 500px;
  background: #fff;
  border: 3px solid #FFE066;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(255, 193, 60, 0.3);
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #FFE066;
  border-bottom: 3px solid #FFC93C;
}

.chat-avatar {
  width: 46px;
  height: 46px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-info { flex: 1; }

.chat-name {
  font-weight: bold;
  color: #5A4A20;
  font-size: 1.1rem;
}

.chat-status {
  font-size: 0.8rem;
  color: #6B5B30;
}

.clear-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 10px;
}

.clear-btn:hover { background: rgba(255,255,255,0.5); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #FFFDF5;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 80%;
  animation: fadeIn 0.3s ease;
}

.message.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.ai {
  align-self: flex-start;
}

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #FFE066;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.msg-bubble {
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.message.ai .msg-bubble {
  background: #F0F8FF;
  border: 1px solid #CDE4F5;
  border-bottom-left-radius: 6px;
  color: #4A5568;
}

.message.me .msg-bubble {
  background: #FFD93C;
  border-bottom-right-radius: 6px;
  color: #5A4A20;
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px;
  border-top: 2px solid #FFE9A8;
  background: #fff;
}

.chat-input {
  flex: 1;
  border: 2px solid #FFE9A8;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  background: #FFFDF5;
  color: #4A4030;
}

.chat-input:focus {
  border-color: #FFC93C;
  box-shadow: 0 0 0 3px rgba(255, 201, 60, 0.2);
}

.send-btn {
  padding: 10px 20px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .main { padding: 16px 10px 40px; }
  .post-form-card { padding: 16px; }
  .post-card { padding: 14px; }
  .logo-text { display: none; }
  .chat-container {
    height: calc(100vh - 120px);
    min-height: 400px;
    border-radius: 14px;
  }
  .message { max-width: 90%; }
}
body.page-chat {
  background: #FFF8E7 url(/bg_chat.jpg) no-repeat center center fixed;
  background-size: contain;
}
body.page-gossip {
  background: #FFF8E7 url(/bg_gossip.jpg) no-repeat center center fixed;
  background-size: contain;
}
body.page-battle {
  background: #FFF8E7 url(/bg_battle.jpg) no-repeat center center fixed;
  background-size: contain;
}
.battle-main { max-width: 720px; margin: 0 auto; padding: 20px 16px; }
.battle-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.battle-top h2 { color: #E8960C; }
.battle-card { background: rgba(255,255,255,0.9); border: 2px solid #FFE9A8; border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.battle-card-head { display: flex; justify-content: space-between; font-weight: bold; color: #5A4A20; }
.battle-card-body { margin: 6px 0; font-size: 0.9rem; }
.battle-card-foot { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; }
.battle-msg { padding: 6px 0; font-size: 0.9rem; border-bottom: 1px dashed #FFE9A8; }
.judge-result { background: #FFF3D1; border: 1px solid #FFE066; border-radius: 10px; padding: 10px; margin: 10px 0; }
.battle-input { display: flex; gap: 8px; margin: 10px 0; }
.battle-input textarea { flex: 1; min-height: 50px; }
