/* ===== 单词闪电战 — 暗夜闪电竞技风 ===== */

/* --- 基础重置 & 字体 --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Quicksand", "Nunito", sans-serif;
  background: #1A1A2E;
  color: #F0F0FF;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  padding: 20px 16px 100px;
  position: relative;
}

/* --- 顶部标题栏 --- */
.header {
  text-align: center;
  padding: 24px 0 16px;
}

.logo {
  font-size: 28px;
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 0 40px rgba(255, 215, 0, 0.2);
  letter-spacing: 2px;
}

.subtitle {
  font-size: 14px;
  color: rgba(240, 240, 255, 0.6);
  margin-top: 4px;
}

/* --- 通用区块 --- */
.section {
  margin-top: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: #F0F0FF;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

/* --- 主题选择卡片 --- */
.topic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.topic-card {
  background: rgba(26, 26, 46, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 215, 0, 0.15);
  border-radius: 16px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.3s, box-shadow 0.3s;
}

.topic-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  border-radius: 50%;
  border: 2px solid transparent;
  animation: currentFlow 3s linear infinite;
}

.topic-card:nth-child(1)::before { animation-delay: 0s; }
.topic-card:nth-child(2)::before { animation-delay: 0.5s; }
.topic-card:nth-child(3)::before { animation-delay: 1s; }
.topic-card:nth-child(4)::before { animation-delay: 1.5s; }

@keyframes currentFlow {
  0% { border-color: rgba(255, 215, 0, 0); box-shadow: inset 0 0 0 rgba(255, 215, 0, 0); }
  50% { border-color: rgba(255, 215, 0, 0.3); box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.1); }
  100% { border-color: rgba(255, 215, 0, 0); box-shadow: inset 0 0 0 rgba(255, 215, 0, 0); }
}

.topic-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 215, 0, 0.4);
}

.topic-card:active {
  transform: scale(0.97);
}

.topic-card.selected {
  border-color: #FFD700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), inset 0 0 20px rgba(255, 215, 0, 0.05);
  transform: translateY(-3px);
}

.topic-card.selected::before {
  animation-duration: 1.5s;
}

.topic-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.topic-name {
  font-size: 16px;
  font-weight: 700;
  color: #F0F0FF;
}

.topic-count {
  font-size: 12px;
  color: rgba(240, 240, 255, 0.5);
  margin-top: 4px;
}

/* --- 对战区 --- */
.battle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.battle-topic {
  font-size: 14px;
  color: #FFD700;
  font-weight: 700;
  background: rgba(255, 215, 0, 0.1);
  padding: 4px 12px;
  border-radius: 20px;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(240, 240, 255, 0.6);
  text-transform: uppercase;
}

.score-num {
  font-size: 28px;
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.opponent-score .score-num {
  color: #FF3366;
  text-shadow: 0 0 10px rgba(255, 51, 102, 0.4);
}

.score-divider {
  font-size: 24px;
  color: rgba(240, 240, 255, 0.3);
  margin-top: 8px;
}

/* --- 题目卡片 --- */
.question-card {
  background: #F0F0FF;
  border: 2px solid rgba(26, 26, 46, 0.2);
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
  transition: box-shadow 0.3s;
}

.question-card.flash-correct {
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.2);
}

.question-card.flash-wrong {
  box-shadow: 0 0 30px rgba(255, 51, 102, 0.6), 0 0 60px rgba(255, 51, 102, 0.2);
}

.question-word {
  font-size: 36px;
  font-weight: 800;
  color: #1A1A2E;
  margin-bottom: 20px;
}

.answer-area {
  display: flex;
  gap: 10px;
}

.answer-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid rgba(26, 26, 46, 0.2);
  border-radius: 14px;
  background: #fff;
  color: #1A1A2E;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.answer-input:focus {
  border-color: #FFD700;
}

/* --- 抢答按钮 --- */
.btn-grab {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 800;
  color: #1A1A2E;
  background: #FFD700;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  font-family: inherit;
}

.btn-grab:hover:not(:disabled) {
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.5);
}

.btn-grab:active:not(:disabled) {
  transform: scale(0.95);
  box-shadow: 0 0 36px rgba(255, 215, 0, 0.7);
}

.btn-grab:disabled {
  background: #555;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
}

/* --- 提示文字 --- */
.battle-hint {
  margin-top: 10px;
  font-size: 13px;
  color: #FF3366;
  font-weight: 600;
  min-height: 20px;
}

/* --- 战果列表 --- */
.result-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(26, 26, 46, 0.6);
  border-radius: 12px;
  padding: 12px 14px;
  animation: slideIn 0.3s ease-out;
}

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

.result-stripe {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.result-stripe.win {
  background: #FFD700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.result-stripe.lose {
  background: #555;
}

.result-info {
  flex: 1;
  min-width: 0;
}

.result-word {
  font-size: 13px;
  color: rgba(240, 240, 255, 0.5);
}

.result-answer {
  font-size: 15px;
  font-weight: 700;
  color: #F0F0FF;
}

.result-answer .correct-word {
  color: #FFD700;
}

.result-answer .correct-word::after {
  content: ' ⚡';
  font-size: 12px;
}

.result-status {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.result-status.win {
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
}

.result-status.lose {
  background: rgba(255, 51, 102, 0.15);
  color: #FF3366;
}

/* --- 对战操作按钮 --- */
.battle-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: center;
}

.btn-next, .btn-finish {
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-next {
  background: #FFD700;
  color: #1A1A2E;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
}

.btn-next:hover {
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.5);
}

.btn-next:active {
  transform: scale(0.95);
}

.btn-finish {
  background: rgba(255, 51, 102, 0.15);
  color: #FF3366;
  border: 2px solid rgba(255, 51, 102, 0.3);
}

.btn-finish:hover {
  background: rgba(255, 51, 102, 0.25);
}

.btn-finish:active {
  transform: scale(0.95);
}

/* --- 底部 --- */
.footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 16px 20px;
  background: linear-gradient(transparent, #1A1A2E 40%);
  display: flex;
  justify-content: center;
  gap: 8px;
}

.btn-history, .btn-leaderboard {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: rgba(240, 240, 255, 0.7);
  background: rgba(26, 26, 46, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}

.btn-history:hover, .btn-leaderboard:hover {
  border-color: rgba(255, 215, 0, 0.5);
  color: #FFD700;
}

/* --- 历史弹层 --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.history-panel {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

.history-title {
  font-size: 20px;
  font-weight: 800;
  color: #FFD700;
}

.btn-close-history {
  width: 36px;
  height: 36px;
  font-size: 18px;
  background: rgba(255, 215, 0, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #FFD700;
  transition: transform 0.15s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-history:active {
  transform: scale(0.85);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-empty {
  text-align: center;
  color: rgba(240, 240, 255, 0.4);
  font-size: 14px;
  padding: 40px 0;
}

.history-group {
  margin-bottom: 16px;
}

.history-group-header {
  font-size: 12px;
  color: rgba(240, 240, 255, 0.4);
  margin-bottom: 6px;
  padding-left: 4px;
}

.history-group .result-item {
  background: rgba(26, 26, 46, 0.4);
}

/* --- 登录弹层 --- */
.btn-login {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  color: #F0F0FF;
  background: rgba(26, 26, 46, 0.8);
  border: 1px solid rgba(240, 240, 255, 0.2);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
  margin-right: 8px;
}

.btn-login:hover {
  border-color: rgba(240, 240, 255, 0.5);
  color: #FFD700;
}

.btn-login.logged-in {
  color: #FFD700;
  border-color: rgba(255, 215, 0, 0.4);
}

.login-panel {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

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

.login-title {
  font-size: 20px;
  font-weight: 800;
  color: #FFD700;
}

.btn-close-login {
  width: 36px;
  height: 36px;
  font-size: 18px;
  background: rgba(255, 215, 0, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #FFD700;
  transition: transform 0.15s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-login:active {
  transform: scale(0.85);
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.5);
}

.login-desc {
  font-size: 13px;
  color: rgba(240, 240, 255, 0.5);
  margin-bottom: 10px;
}

.login-row {
  display: flex;
  gap: 10px;
}

.login-name-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid rgba(255, 215, 0, 0.2);
  border-radius: 14px;
  background: rgba(26, 26, 46, 0.6);
  color: #F0F0FF;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.login-name-input:focus {
  border-color: #FFD700;
}

.login-name-input::placeholder {
  color: rgba(240, 240, 255, 0.3);
}

.btn-login-go {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  color: #1A1A2E;
  background: #FFD700;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  white-space: nowrap;
}

.btn-login-go:hover:not(:disabled) {
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.5);
}

.btn-login-go:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-login-go:disabled {
  background: #555;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-logout {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #FF3366;
  background: rgba(255, 51, 102, 0.1);
  border: 1px solid rgba(255, 51, 102, 0.25);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s;
}

.btn-logout:hover {
  background: rgba(255, 51, 102, 0.2);
  border-color: rgba(255, 51, 102, 0.5);
}

.btn-logout:active {
  transform: scale(0.95);
}

.login-hint {
  margin-top: 8px;
  font-size: 13px;
  color: #FF3366;
  font-weight: 600;
  min-height: 20px;
}

.login-divider {
  height: 1px;
  background: rgba(255, 215, 0, 0.1);
  margin: 16px 0;
}

.account-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-chip {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(240, 240, 255, 0.8);
  background: rgba(26, 26, 46, 0.6);
  border: 2px solid rgba(255, 215, 0, 0.15);
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.account-chip:hover {
  border-color: rgba(255, 215, 0, 0.4);
}

.account-chip.current {
  border-color: #FFD700;
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

/* ===== 排行榜弹层 ===== */
.leaderboard-panel {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

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

.leaderboard-title {
  font-size: 20px;
  font-weight: 800;
  color: #FFD700;
}

.btn-close-leaderboard {
  width: 36px;
  height: 36px;
  font-size: 18px;
  background: rgba(255, 215, 0, 0.1);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #FFD700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-empty {
  text-align: center;
  color: rgba(240, 240, 255, 0.4);
  font-size: 14px;
  padding: 40px 0;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(26, 26, 46, 0.4);
  border-radius: 12px;
  transition: background 0.2s;
}

.lb-row.lb-me {
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.25);
}

.lb-rank {
  font-size: 18px;
  font-weight: 800;
  width: 32px;
  text-align: center;
  color: rgba(240, 240, 255, 0.6);
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: #F0F0FF;
}

.lb-me .lb-name {
  color: #FFD700;
}

.lb-score {
  font-size: 16px;
  font-weight: 800;
  color: #FFD700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.lb-topic {
  font-size: 11px;
  color: rgba(240, 240, 255, 0.4);
  flex-shrink: 0;
}

/* ===== AI 小老师按钮 ===== */
.btn-ai-teacher {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #FFD700;
  background: rgba(255, 215, 0, 0.1);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn-ai-teacher:hover {
  border-color: rgba(255, 215, 0, 0.6);
  background: rgba(255, 215, 0, 0.18);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

/* ===== 聊天消息区 ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 100px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 50vh;
}

.chat-bubble {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: slideIn 0.25s ease-out;
}

.bubble-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble-teacher {
  align-self: flex-start;
}

.bubble-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(26, 26, 46, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.bubble-user .bubble-avatar {
  background: rgba(255, 215, 0, 0.15);
}

.bubble-teacher .bubble-avatar {
  background: rgba(100, 180, 255, 0.15);
}

.bubble-text {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  color: #F0F0FF;
  word-break: break-word;
}

.bubble-user .bubble-text {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-bottom-right-radius: 6px;
}

.bubble-teacher .bubble-text {
  background: rgba(100, 180, 255, 0.12);
  border: 1px solid rgba(100, 180, 255, 0.18);
  border-bottom-left-radius: 6px;
}

/* ===== 聊天输入栏 ===== */
.chat-input-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 10px 16px 20px;
  background: linear-gradient(transparent, #1A1A2E 35%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  border: 2px solid rgba(255, 215, 0, 0.2);
  border-radius: 24px;
  background: rgba(26, 26, 46, 0.8);
  color: #F0F0FF;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #FFD700;
}

.chat-input::placeholder {
  color: rgba(240, 240, 255, 0.3);
}

.chat-send-btn {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  color: #1A1A2E;
  background: #FFD700;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.3);
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  white-space: nowrap;
}

.chat-send-btn:hover:not(:disabled) {
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.5);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  background: #555;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
}

/* ===== 回首页按钮 ===== */
.chat-back {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}

.btn-back-home {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #FFD700;
  background: rgba(26, 26, 46, 0.8);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.btn-back-home:hover {
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.1);
}
