:root {
  --gold: #f6c453;
  --gold-deep: #e8a33d;
  --lantern-red: #e84a3a;
  --ink: #fdf3d7;
  --night-1: #0b1e4b;
  --night-2: #1b1240;
  --night-3: #2a1440;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(246, 196, 83, 0.35);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 78% 18%, rgba(255, 236, 170, 0.18), transparent 32%),
    linear-gradient(160deg, var(--night-1) 0%, var(--night-2) 45%, var(--night-3) 100%);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 22px 34px, #fff, transparent),
    radial-gradient(1px 1px at 88px 122px, #ffe9b0, transparent),
    radial-gradient(1.2px 1.2px at 145px 70px, #fff, transparent),
    radial-gradient(1px 1px at 190px 150px, #fff, transparent),
    radial-gradient(1.4px 1.4px at 250px 40px, #ffe9b0, transparent),
    radial-gradient(1px 1px at 60px 190px, #fff, transparent);
  background-repeat: repeat;
  background-size: 300px 300px;
  animation: twinkle 5s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.moon {
  position: fixed;
  top: 42px;
  right: 48px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 34%, rgba(255, 255, 255, 0.9), transparent 42%),
    radial-gradient(circle at 60% 62%, rgba(255, 244, 205, 0.9), rgba(255, 236, 170, 0.6));
  box-shadow:
    0 0 60px 20px rgba(255, 238, 180, 0.25),
    0 0 140px 50px rgba(255, 238, 180, 0.12);
  z-index: 0;
  animation: moon-float 8s ease-in-out infinite;
}

@keyframes moon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.cloud {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  filter: blur(16px);
}

.cloud-1 {
  width: 360px; height: 90px;
  left: -180px; top: 30%;
  animation: drift 38s linear infinite;
}

.cloud-2 {
  width: 420px; height: 100px;
  left: -220px; top: 58%;
  animation: drift 52s linear infinite 12s;
}

@keyframes drift {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 440px)); }
}

.lantern {
  position: fixed;
  top: -8px;
  z-index: 0;
  width: 46px;
  height: 58px;
  border-radius: 50% / 52%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 220, 150, 0.95), transparent 40%),
    linear-gradient(180deg, #f27a4a, var(--lantern-red) 60%, #b92f24);
  box-shadow: 0 0 26px 8px rgba(240, 100, 70, 0.35);
  transform-origin: top center;
}

.lantern::before {
  content: "";
  position: absolute;
  top: -18px; left: 50%;
  width: 2px; height: 18px;
  transform: translateX(-50%);
  background: rgba(255, 236, 170, 0.8);
}

.lantern::after {
  content: "";
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 20px; height: 7px;
  border-radius: 3px;
  background: var(--gold-deep);
}

.lantern-1 { left: 10%; animation: sway 3.4s ease-in-out infinite; }
.lantern-2 { left: 27%; animation: sway 4.1s ease-in-out infinite 0.5s; }
.lantern-3 { left: 44%; animation: sway 3.7s ease-in-out infinite 1s; }

@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
  background: rgba(8, 18, 44, 0.45);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(246, 196, 83, 0.25);
}

.brand {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 1px;
}

.site-header nav { display: flex; gap: 18px; }

.site-header nav a {
  color: rgba(253, 243, 215, 0.85);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.site-header nav a:hover {
  background: rgba(246, 196, 83, 0.2);
  color: var(--gold);
}

.content {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.hero { text-align: center; margin: 8px 0 28px; }
.hero h1 {
  font-size: 40px;
  margin: 0 0 10px;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(246, 196, 83, 0.35);
}
.hero p { margin: 0; color: rgba(253, 243, 215, 0.85); }

.flash-list { margin-bottom: 18px; display: grid; gap: 10px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 500; }
.flash-success { background: rgba(64, 145, 76, 0.35); border: 1px solid rgba(120, 210, 130, 0.5); }
.flash-error { background: rgba(170, 55, 45, 0.35); border: 1px solid rgba(240, 120, 100, 0.5); }

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 480px;
  margin: 0 auto 24px;
}

.search-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(246, 196, 83, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 15px;
}

.search-form input[type="text"]:focus { outline: none; border-color: var(--gold); }

.search-form .clear-search {
  color: rgba(253, 243, 215, 0.75);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  padding: 6px 4px;
}

.search-form .clear-search:hover { color: var(--gold); }

.empty-hint {
  text-align: center;
  color: rgba(253, 243, 215, 0.75);
  padding: 30px 0;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(253, 243, 215, 0.2);
  text-decoration: none;
  font-size: 14px;
}

.page-btn:hover { background: rgba(246, 196, 83, 0.18); color: var(--gold); }

.page-btn.current {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #3a1d0a;
  font-weight: 700;
  border-color: transparent;
}

.page-btn.disabled {
  opacity: 0.35;
  cursor: default;
}

.page-ellipsis {
  color: rgba(253, 243, 215, 0.5);
  padding: 0 4px;
}

.riddle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.riddle-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, border-color 0.2s;
}

.riddle-card:hover { transform: translateY(-3px); border-color: var(--gold); }

.riddle-head { display: flex; justify-content: space-between; align-items: center; }

.badge {
  font-size: 12px;
  color: #fff7e0;
  background: linear-gradient(135deg, #d95b43, #9e2f26);
  padding: 3px 10px;
  border-radius: 999px;
}

.riddle-no { font-size: 12px; color: rgba(253, 243, 215, 0.6); }

.question { margin: 0; font-size: 18px; line-height: 1.5; }

.guess-form { display: flex; gap: 8px; }

.guess-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(246, 196, 83, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 15px;
}

.guess-input:focus { outline: none; border-color: var(--gold); }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #3a1d0a;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  padding: 10px 14px;
  transition: filter 0.2s, transform 0.1s;
}

button:hover { filter: brightness(1.08); }
button:active { transform: scale(0.97); }

.guess-result { min-height: 20px; font-size: 14px; }
.guess-result.correct { color: #9fe6a8; }
.guess-result.wrong { color: #ffb0a0; }

.riddle-actions { display: flex; gap: 8px; }

.riddle-actions button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(253, 243, 215, 0.25);
  padding: 8px 12px;
}

.riddle-actions button:hover {
  background: rgba(246, 196, 83, 0.18);
  color: var(--gold);
}

.hint { margin: 0; font-size: 13px; color: rgba(253, 243, 215, 0.75); }
.hidden { display: none; }

.riddle-form {
  display: grid;
  gap: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 24px;
  backdrop-filter: blur(10px);
}

.riddle-form label { display: grid; gap: 8px; font-weight: 600; }

.riddle-form input,
.riddle-form textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(246, 196, 83, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
}

.riddle-form input:focus,
.riddle-form textarea:focus { outline: none; border-color: var(--gold); }

.required { color: #ff9b85; }

.riddle-form button[type="submit"] { width: 100%; padding: 13px; font-size: 16px; }

@media (max-width: 560px) {
  .moon { width: 100px; height: 100px; right: 18px; top: 70px; }
  .hero h1 { font-size: 30px; }
  .site-header { flex-direction: column; gap: 10px; }
}

.game-start,
.game-finish {
  text-align: center;
  padding: 36px 20px;
}

.game-start p,
.game-finish p {
  margin: 0 0 18px;
  color: rgba(253, 243, 215, 0.85);
  font-size: 16px;
}

.game-start button,
.game-finish button {
  font-size: 16px;
  padding: 12px 26px;
}

.game-finish h2 {
  color: var(--gold);
  margin: 0 0 10px;
  font-size: 30px;
}

.game-board {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.game-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: rgba(253, 243, 215, 0.75);
}

.flashcard {
  perspective: 1200px;
  height: 300px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px;
  border-radius: 20px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
}

.flashcard-front {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, rgba(246, 196, 83, 0.22), rgba(232, 74, 58, 0.22));
  border: 1px solid var(--gold);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.card-question {
  margin: 0;
  font-size: 24px;
  line-height: 1.5;
  color: var(--ink);
}

.card-hint {
  margin: 0;
  font-size: 14px;
  color: rgba(253, 243, 215, 0.8);
}

.card-answer-label {
  margin: 0;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--gold);
}

.card-answer {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  color: #fff7e0;
}

.game-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(253, 243, 215, 0.25);
}

.ghost-btn:hover {
  background: rgba(246, 196, 83, 0.18);
  color: var(--gold);
}

@media (max-width: 560px) {
  .flashcard { height: 260px; }
  .card-question { font-size: 20px; }
  .card-answer { font-size: 24px; }
}

.challenge-start,
.challenge-finish,
.challenge-fail {
  text-align: center;
  padding: 36px 20px;
}

.challenge-start p,
.challenge-finish p,
.challenge-fail p {
  margin: 0 0 18px;
  color: rgba(253, 243, 215, 0.85);
  font-size: 16px;
}

.challenge-start button,
.challenge-finish button,
.challenge-fail button {
  font-size: 16px;
  padding: 12px 26px;
}

.challenge-finish h2 {
  color: var(--gold);
  margin: 0 0 10px;
  font-size: 30px;
}

.challenge-fail h2 {
  color: var(--lantern-red);
  margin: 0 0 10px;
  font-size: 30px;
}

.challenge-fail button {
  background: linear-gradient(135deg, #f27a4a, var(--lantern-red));
  color: #fff7e0;
}

.leaderboard {
  max-width: 480px;
  margin: 0 auto 28px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px 22px;
  backdrop-filter: blur(10px);
}

.leaderboard h2 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--gold);
  text-align: center;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.leaderboard-item:nth-child(1) { border: 1px solid rgba(246, 196, 83, 0.6); }
.leaderboard-item:nth-child(2) { border: 1px solid rgba(220, 220, 220, 0.4); }
.leaderboard-item:nth-child(3) { border: 1px solid rgba(205, 140, 90, 0.5); }

.leaderboard-rank {
  flex: 0 0 56px;
  font-size: 13px;
  color: rgba(253, 243, 215, 0.7);
}

.leaderboard-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.leaderboard-score {
  flex: 0 0 auto;
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
}

.leaderboard-empty {
  text-align: center;
  color: rgba(253, 243, 215, 0.6);
  padding: 10px 0;
  list-style: none;
}

.contest-name {
  max-width: 480px;
  margin: 0 auto 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px 22px;
  backdrop-filter: blur(10px);
}

.contest-name label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: rgba(253, 243, 215, 0.85);
}

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

.contest-name-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(246, 196, 83, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 15px;
}

.contest-name-row input[type="text"]:focus { outline: none; border-color: var(--gold); }

.contest-name-error {
  margin: 10px 0 0;
  font-size: 13px;
  color: #ffb0a0;
}

.challenge-board {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.challenge-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: rgba(253, 243, 215, 0.75);
}

.streak {
  font-weight: 700;
  color: var(--gold);
}

.timer-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(246, 196, 83, 0.25);
}

.timer-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--lantern-red));
}

.timer-text {
  text-align: center;
  font-size: 14px;
  color: rgba(253, 243, 215, 0.8);
}

.challenge-question {
  margin: 0;
  font-size: 22px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
  min-height: 66px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.option-btn {
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  padding: 16px 14px;
  font-size: 16px;
  border-radius: 14px;
  text-align: center;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.option-btn:disabled { cursor: default; }

.option-btn.correct {
  background: rgba(64, 145, 76, 0.4);
  border-color: rgba(120, 210, 130, 0.7);
  color: #eafff0;
}

.option-btn.wrong {
  background: rgba(170, 55, 45, 0.4);
  border-color: rgba(240, 120, 100, 0.7);
  color: #fff0ee;
}

.challenge-feedback {
  min-height: 24px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
}

.challenge-feedback.correct { color: #9fe6a8; }
.challenge-feedback.wrong { color: #ffb0a0; }

@media (max-width: 560px) {
  .options-grid { grid-template-columns: 1fr; }
  .challenge-question { font-size: 19px; }
}
