:root {
  --red-900: #7e1718;
  --red-800: #9d1d1f;
  --red-700: #c42c2f;
  --red-100: #fff2ee;
  --gold-700: #b9822b;
  --gold-500: #d9ab59;
  --gold-200: #f1d79b;
  --paper: #fff9ed;
  --paper-soft: #f6ecd7;
  --jade: #1f7b72;
  --ink: #332016;
  --muted: #846c56;
  --line: rgba(166, 111, 38, 0.28);
  --shadow: 0 16px 42px rgba(71, 34, 19, 0.18);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 12%, rgba(217, 171, 89, 0.24), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(31, 123, 114, 0.12), transparent 24%),
    linear-gradient(135deg, #6e1516 0%, #b72b29 42%, #ead3a2 42%, #f9edda 100%);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(31, 123, 114, 0.45);
  outline-offset: 2px;
}

.app {
  position: relative;
  width: min(100vw, 440px);
  min-height: 100vh;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 249, 237, 0.94), rgba(246, 236, 215, 0.98)),
    repeating-linear-gradient(45deg, rgba(185, 130, 43, 0.06) 0 1px, transparent 1px 12px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28), 0 28px 80px rgba(50, 12, 8, 0.36);
  overflow: hidden;
}

.app::before,
.app::after {
  content: "";
  position: fixed;
  left: 50%;
  width: min(100vw, 440px);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 0;
}

.app::before {
  top: 0;
  height: 190px;
  background:
    linear-gradient(180deg, rgba(126, 23, 24, 0.18), transparent),
    radial-gradient(circle at 20% 0, rgba(217, 171, 89, 0.28), transparent 34%),
    radial-gradient(circle at 90% 14%, rgba(31, 123, 114, 0.1), transparent 30%);
}

.app::after {
  bottom: 0;
  height: 120px;
  background: linear-gradient(0deg, rgba(126, 23, 24, 0.12), transparent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 58px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  background: rgba(255, 249, 237, 0.82);
  border-bottom: 1px solid rgba(185, 130, 43, 0.22);
  backdrop-filter: blur(16px);
}

.topbar-title {
  min-width: 0;
  text-align: center;
  line-height: 1.1;
}

.topbar-title strong {
  display: block;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 19px;
  color: var(--red-900);
  letter-spacing: 0;
}

.topbar-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--red-800);
  background: linear-gradient(180deg, #fffdf8, #f7e9cf);
  border: 1px solid rgba(185, 130, 43, 0.34);
  box-shadow: 0 5px 14px rgba(126, 23, 24, 0.12);
}

main {
  position: relative;
  z-index: 1;
}

.screen {
  display: none;
  min-height: calc(100vh - 58px);
  padding: 16px 18px calc(96px + var(--safe-bottom));
}

.screen.is-active {
  display: block;
  animation: screenIn 260ms ease both;
}

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

.start-art {
  position: relative;
  height: min(62vh, 575px);
  min-height: 420px;
  border-radius: 0 0 28px 28px;
  overflow: hidden;
  margin: -16px -18px 0;
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.start-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 48%;
  display: block;
}

.start-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(62, 18, 12, 0.18), transparent 42%, rgba(62, 18, 12, 0.18)),
    linear-gradient(0deg, rgba(255, 249, 237, 0.82), transparent 38%);
}

.start-copy {
  position: absolute;
  left: 26px;
  right: 26px;
  top: 34px;
  z-index: 1;
  text-align: center;
  color: #fff8df;
  text-shadow: 0 2px 14px rgba(74, 18, 12, 0.5);
}

.start-copy p,
.start-copy span {
  display: inline-block;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid rgba(255, 228, 168, 0.7);
  background: rgba(126, 23, 24, 0.42);
  color: #ffe4a8;
  border-radius: 999px;
  font-size: 12px;
}

.start-copy h1 {
  margin: 14px 0 12px;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: 0;
}

.join-panel {
  position: relative;
  z-index: 2;
  margin: -88px 0 0;
  padding: 18px;
  border: 1px solid rgba(185, 130, 43, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(255, 246, 229, 0.96)),
    radial-gradient(circle at 100% 0, rgba(217, 171, 89, 0.18), transparent 34%);
  box-shadow: var(--shadow);
}

.join-panel label {
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.join-panel label span {
  color: var(--red-900);
  font-weight: 700;
  font-size: 14px;
}

.join-panel input,
.join-panel select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #fffaf0;
  border: 1px solid rgba(185, 130, 43, 0.34);
  border-radius: 8px;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  color: #fff9e6;
  background:
    linear-gradient(180deg, #d84538, #9d1d1f),
    var(--red-800);
  border: 1px solid rgba(255, 218, 139, 0.6);
  box-shadow: 0 10px 20px rgba(126, 23, 24, 0.28);
}

.secondary-btn {
  color: var(--red-900);
  background: #fffaf0;
  border: 1px solid rgba(185, 130, 43, 0.44);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.quick-actions button {
  min-height: 40px;
  color: var(--jade);
  background: rgba(31, 123, 114, 0.08);
  border: 1px solid rgba(31, 123, 114, 0.2);
  border-radius: 8px;
  font-weight: 700;
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 6px 0 12px;
}

.hud-kicker {
  display: inline-block;
  color: var(--jade);
  font-size: 12px;
  font-weight: 800;
}

.hud h2,
.section-head h2 {
  margin: 4px 0 0;
  color: var(--red-900);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 30px;
  letter-spacing: 0;
}

.timer {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  color: var(--red-800);
  font-size: 16px;
}

.timer svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer circle {
  fill: none;
  stroke-width: 4;
  stroke: rgba(185, 130, 43, 0.22);
}

#timer-ring {
  stroke: var(--red-700);
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 280ms linear;
}

.timer b {
  position: relative;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.score-strip span {
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid rgba(185, 130, 43, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.score-strip b {
  display: block;
  color: var(--red-900);
  font-size: 16px;
}

.question-card {
  overflow: hidden;
  border: 1px solid rgba(196, 44, 47, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.9);
  box-shadow: var(--shadow);
}

.question-art {
  position: relative;
  aspect-ratio: 1.22;
  max-height: 305px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 16%, rgba(217, 171, 89, 0.34), transparent 32%),
    linear-gradient(135deg, #fff4dd, #e7f0ec);
}

.question-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 32%;
  opacity: 0.88;
  filter: saturate(1.04);
}

.question-art.is-textual img {
  opacity: 0.18;
  filter: saturate(0.8) blur(1px);
}

.question-art.is-textual::after {
  content: attr(data-seal);
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(185, 130, 43, 0.34);
  border-radius: 50%;
  color: rgba(126, 23, 24, 0.9);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 64px;
  background: rgba(255, 249, 237, 0.6);
}

.question-type {
  position: absolute;
  top: 12px;
  left: 12px;
  min-width: 58px;
  padding: 5px 10px;
  border-radius: 999px;
  color: #fff8df;
  background: rgba(126, 23, 24, 0.88);
  border: 1px solid rgba(255, 228, 168, 0.7);
  font-size: 12px;
  text-align: center;
}

.question-copy {
  padding: 16px;
}

.question-copy p {
  min-height: 19px;
  margin: 0 0 8px;
  color: var(--jade);
  font-size: 13px;
  font-weight: 800;
}

.question-copy h3 {
  min-height: 62px;
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.55;
}

.options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.option-btn {
  min-height: 54px;
  padding: 12px 14px;
  border: 1px solid rgba(185, 130, 43, 0.34);
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf8, #f8ecd2);
  box-shadow: 0 8px 18px rgba(84, 47, 18, 0.1);
  font-size: 17px;
  font-weight: 800;
  text-align: left;
}

.option-btn::first-letter {
  color: var(--red-800);
}

.option-btn.is-correct {
  color: #fff;
  background: linear-gradient(180deg, #229181, #176960);
}

.option-btn.is-wrong {
  color: #fff;
  background: linear-gradient(180deg, #d74638, #9d1d1f);
}

.feedback {
  min-height: 24px;
  margin: 12px 2px 0;
  color: var(--red-900);
  font-weight: 800;
  text-align: center;
}

.section-head {
  margin: 8px 0 16px;
}

.section-head span {
  display: inline-block;
  color: var(--jade);
  font-size: 13px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(185, 130, 43, 0.16);
  border: 1px solid rgba(185, 130, 43, 0.22);
}

.segmented button {
  min-height: 38px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.is-active {
  color: #fff8df;
  background: var(--red-800);
  box-shadow: 0 8px 18px rgba(126, 23, 24, 0.2);
}

.poster-ribbon {
  display: grid;
  grid-template-columns: 82px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 9px;
  border: 1px solid rgba(185, 130, 43, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(126, 23, 24, 0.1), rgba(255, 253, 247, 0.9)),
    #fffaf0;
}

.poster-ribbon img {
  width: 82px;
  height: 104px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(185, 130, 43, 0.28);
}

.poster-ribbon b {
  display: block;
  color: var(--red-900);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 24px;
  letter-spacing: 0;
}

.poster-ribbon span {
  display: inline-block;
  margin-top: 7px;
  padding: 5px 10px;
  color: #fff8df;
  background: var(--jade);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.community-bars {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(185, 130, 43, 0.17);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--gold-500), var(--red-700));
}

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

.rank-item {
  display: grid;
  grid-template-columns: 42px 1fr 56px;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid rgba(185, 130, 43, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.84);
}

.rank-index {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff8df;
  background: var(--red-800);
  font-weight: 900;
}

.rank-name {
  min-width: 0;
}

.rank-name b {
  display: block;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-name span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.rank-score {
  color: var(--jade);
  font-weight: 900;
  text-align: right;
}

.sticky-action {
  margin-top: 16px;
}

.wide-art {
  overflow: hidden;
  border: 1px solid rgba(185, 130, 43, 0.34);
  border-radius: 8px;
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.wide-art img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.stage-grid,
.prize-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.stage-item,
.prize-item {
  padding: 14px;
  border: 1px solid rgba(185, 130, 43, 0.28);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.86);
}

.stage-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
}

.stage-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #fff8df;
  background: linear-gradient(180deg, var(--gold-500), var(--red-800));
  font-weight: 900;
}

.stage-item h3,
.prize-item h3 {
  margin: 0 0 4px;
  color: var(--red-900);
  font-size: 17px;
}

.stage-item p,
.prize-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.prize-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.prize-value {
  min-width: 66px;
  padding: 7px 8px;
  color: #fff8df;
  background: var(--jade);
  border-radius: 999px;
  font-weight: 900;
  text-align: center;
}

.result-panel {
  margin: 28px 0 0;
  padding: 24px 18px 18px;
  border: 1px solid rgba(185, 130, 43, 0.42);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0, rgba(217, 171, 89, 0.28), transparent 38%),
    linear-gradient(180deg, #fffdf7, #f7ead0);
  box-shadow: var(--shadow);
  text-align: center;
}

.seal {
  display: inline-block;
  padding: 4px 12px;
  color: var(--red-800);
  border: 2px solid currentColor;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 900;
}

.result-panel h2 {
  margin: 16px 0 8px;
  color: var(--red-900);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 32px;
  letter-spacing: 0;
}

.result-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.result-score {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin: 18px auto;
  color: #fff8df;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.36), transparent 28%),
    linear-gradient(180deg, var(--gold-500), var(--red-800));
  box-shadow: 0 14px 28px rgba(126, 23, 24, 0.25);
}

.result-score b {
  font-size: 42px;
  line-height: 1;
}

.result-score span {
  font-size: 13px;
}

.reward-ticket {
  min-height: 68px;
  padding: 13px;
  border: 1px dashed rgba(126, 23, 24, 0.36);
  border-radius: 8px;
  background: #fff7e5;
  color: var(--red-900);
  font-weight: 800;
  line-height: 1.6;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100vw, 440px);
  padding: 8px 10px calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(255, 249, 237, 0.9);
  border-top: 1px solid rgba(185, 130, 43, 0.24);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-height: 52px;
  color: var(--muted);
  background: transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0 auto 3px;
  border-radius: 50%;
  background: rgba(185, 130, 43, 0.15);
  color: var(--red-900);
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: 15px;
}

.bottom-nav button.is-active {
  color: var(--red-900);
  background: rgba(196, 44, 47, 0.08);
}

.bottom-nav button.is-active span {
  color: #fff8df;
  background: var(--red-800);
}

@media (min-width: 720px) {
  body {
    padding: 24px 0;
  }

  .app {
    min-height: calc(100vh - 48px);
    border-radius: 28px;
  }

  .bottom-nav {
    bottom: 24px;
    border-radius: 0 0 28px 28px;
  }

  .topbar {
    border-radius: 28px 28px 0 0;
  }
}

@media (max-height: 720px) {
  .start-art {
    min-height: 360px;
    height: 54vh;
  }

  .start-copy h1 {
    font-size: 38px;
  }

  .question-art {
    max-height: 235px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
