:root {
  --paper: #f7f1df;
  --ink: #24352f;
  --muted: #66756c;
  --jade: #2f7d69;
  --jade-dark: #265f52;
  --jade-soft: #ddeee6;
  --gold: #c8a35b;
  --red: #da5d54;
  --red-strong: #bf342e;
  --red-soft: #f6ddd8;
  --green: #47966d;
  --green-soft: #d8efe1;
  --panel: rgba(255, 251, 239, 0.84);
  --shadow: 0 18px 42px rgba(35, 48, 44, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Source Han Sans SC", Arial, sans-serif;
  background:
    linear-gradient(rgba(247, 241, 223, 0.9), rgba(247, 241, 223, 0.92)),
    url("./assets/paper-bamboo.svg");
  background-size: cover;
  overflow: hidden;
}

button,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  min-width: 1100px;
  display: grid;
  grid-template-rows: minmax(88px, 10vh) 1fr minmax(108px, 14vh);
  gap: 14px;
  padding: 16px 22px 18px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) auto minmax(470px, 1fr);
  align-items: center;
  gap: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(47, 125, 105, 0.18);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(39, 52, 49, 0.06);
}

.timebar {
  justify-content: flex-end;
}

.music-toggle {
  min-width: 52px;
  padding: 0 14px;
  font-size: 24px;
  line-height: 1;
}

.music-toggle.off {
  color: #7b6950;
  background: rgba(255, 255, 255, 0.78);
}

.timer-select {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.timer-select select {
  min-width: 128px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(47, 125, 105, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}

.seg,
.icon-btn,
.review-toggle,
.modal-actions button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid rgba(47, 125, 105, 0.16);
  background: rgba(255, 255, 255, 0.7);
  transition: transform 150ms ease, background 150ms ease, color 150ms ease;
}

.seg {
  min-width: 92px;
}

.seg:hover,
.icon-btn:hover,
.review-toggle:hover,
.modal-actions button:hover {
  background: var(--jade-soft);
}

.seg.active,
.icon-btn.primary,
.review-toggle,
.modal-actions button {
  background: var(--jade);
  color: #fffdf2;
}

.icon-btn.paused {
  background: #b88123;
  color: #fffdf2;
}

.brand {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 20px;
  justify-self: center;
}

h1 {
  margin: 0;
  white-space: nowrap;
  font-family: "SimSun", "Source Han Serif SC", serif;
  font-size: 42px;
  color: #1f564a;
  letter-spacing: 0;
}

.timer {
  min-width: 128px;
  padding: 8px 16px;
  border-radius: 8px;
  color: #fffdf2;
  background: var(--jade-dark);
  font-size: 34px;
  font-weight: 900;
  text-align: center;
  box-shadow: var(--shadow);
}

.timer.warning {
  background: var(--red-strong);
}

.arena {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.arena.single {
  grid-template-columns: minmax(720px, 0.76fr);
  justify-content: center;
}

.arena.single .player-board[data-player="1"] {
  display: none;
}

.player-board {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(160px, 26%);
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(47, 125, 105, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.player-board.idle {
  opacity: 0.96;
}

.player-board.alerting .poem-card {
  animation: dangerPulse 1.1s ease-in-out infinite;
  border-color: rgba(191, 52, 46, 0.82);
  box-shadow: inset 0 0 0 2px rgba(191, 52, 46, 0.36);
}

.player-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.player-headline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 40px;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fffdf2;
  background: var(--jade);
  font-weight: 800;
}

.player-badge.second {
  background: #6f7048;
}

.status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.status.good {
  color: var(--green);
}

.status.bad {
  color: var(--red-strong);
}

.question-timer {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(47, 125, 105, 0.18);
  border-radius: 999px;
  background: rgba(221, 238, 230, 0.86);
  color: #1f564a;
  font-size: 15px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.question-timer.warning {
  color: #fffdf2;
  background: rgba(191, 52, 46, 0.88);
  border-color: rgba(191, 52, 46, 0.92);
  animation: subtleBlink 0.9s ease-in-out infinite;
}

.player-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.select-wrap {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.select-wrap select {
  min-width: 136px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(47, 125, 105, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  outline: none;
}

.feedback-burst {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 76px;
  display: none;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.feedback-burst.show {
  display: flex;
}

.feedback-burst span {
  min-width: 180px;
  padding: 10px 18px;
  border-radius: 999px;
  text-align: center;
  color: #fffdf2;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 16px 36px rgba(33, 44, 40, 0.22);
  animation: burstIn 480ms ease forwards;
}

.feedback-burst.good span {
  background: linear-gradient(135deg, #3d8a63, #5fb37e);
}

.feedback-burst.bad span {
  background: linear-gradient(135deg, #c14137, #ea796a);
}

.poem-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  padding: 28px 24px 24px;
  border: 1px solid rgba(199, 164, 93, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(247, 241, 223, 0.66)),
    repeating-linear-gradient(0deg, rgba(47, 125, 105, 0.04), rgba(47, 125, 105, 0.04) 1px, transparent 1px, transparent 38px);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.poem-meta {
  min-height: 28px;
  color: var(--muted);
  font-size: 18px;
  text-align: center;
}

.poem-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  text-align: center;
  font-size: 38px;
  line-height: 1.78;
  font-weight: 900;
}

.poem-text {
  display: inline-block;
}

.slot {
  min-width: 124px;
  min-height: 68px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 16px;
  border: 2px dashed rgba(47, 125, 105, 0.62);
  border-radius: 8px;
  color: #1f564a;
  background: linear-gradient(180deg, rgba(230, 244, 237, 0.94), rgba(214, 237, 225, 0.92));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42), 0 8px 18px rgba(47, 125, 105, 0.08);
}

.slot.filled {
  border-style: solid;
  border-color: rgba(71, 150, 109, 0.78);
  background: var(--green-soft);
}

.slot.wrong {
  border-color: var(--red);
  background: var(--red-soft);
  animation: wrongShake 280ms ease;
}

.choices {
  display: flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  flex-wrap: wrap;
  gap: 13px;
  padding: 10px;
}

.choice {
  min-width: 104px;
  min-height: 62px;
  padding: 0 20px;
  border: 1px solid rgba(47, 125, 105, 0.28);
  border-radius: 8px;
  background: #fffdfa;
  color: #1f3a34;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(39, 52, 49, 0.1);
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.choice:hover {
  background: var(--jade-soft);
  transform: translateY(-2px);
}

.choice.selected {
  background: #f1e5bd;
  border-color: rgba(200, 163, 91, 0.52);
}

.choice.used,
.choice.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.scorebar {
  display: grid;
  grid-template-columns: 1fr minmax(190px, 280px) 1fr;
  align-items: center;
  gap: 18px;
}

.score-panel {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-content: center;
  gap: 10px 18px;
  padding: 16px 20px;
  border: 1px solid rgba(47, 125, 105, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(39, 52, 49, 0.08);
}

.score-panel.hidden {
  visibility: hidden;
}

.score-panel strong {
  font-size: 20px;
}

.answer-count {
  margin-left: 12px;
  color: var(--muted);
  font-weight: 800;
}

.score {
  color: #1f564a;
  font-size: 32px;
  font-weight: 900;
}

.bar {
  grid-column: 1 / -1;
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(47, 125, 105, 0.14);
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--gold));
  transition: width 180ms ease;
}

.round-note {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border-radius: 8px;
  color: #fffdf2;
  background: var(--jade-dark);
  font-weight: 800;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 40, 37, 0.38);
  z-index: 20;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(980px, 92vw);
  max-height: 90vh;
  overflow: auto;
  padding: 28px;
  border: 2px solid rgba(200, 164, 93, 0.66);
  border-radius: 8px;
  background: #fff9ea;
  box-shadow: 0 30px 70px rgba(22, 31, 28, 0.28);
  position: relative;
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(47, 125, 105, 0.1);
  font-size: 28px;
}

.modal h2 {
  margin: 0 0 14px;
  text-align: center;
  font-family: "SimSun", "Source Han Serif SC", serif;
  font-size: 36px;
  color: #1f564a;
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.rule-block,
.result-card,
.review-item {
  padding: 18px;
  border: 1px solid rgba(47, 125, 105, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.rule-block h3,
.result-card h3 {
  margin: 0 0 10px;
  color: #1f564a;
  font-size: 22px;
}

.rule-block p {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.6;
}

.winner {
  margin-bottom: 18px;
  text-align: center;
  color: #7a693c;
  font-size: 28px;
  font-weight: 900;
}

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

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(47, 125, 105, 0.09);
  font-size: 19px;
}

.review-toggle,
.modal-actions button {
  min-height: 56px;
  margin-top: 18px;
  padding: 0 24px;
  font-size: 20px;
  font-weight: 900;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.review-item strong {
  color: #1f564a;
  font-size: 20px;
}

.review-item div {
  margin-top: 6px;
  font-size: 18px;
}

@keyframes burstIn {
  0% {
    transform: translateY(-8px) scale(0.88);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 0.96;
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes dangerPulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 2px rgba(191, 52, 46, 0.24), 0 0 0 rgba(191, 52, 46, 0);
  }
  50% {
    box-shadow: inset 0 0 0 2px rgba(191, 52, 46, 0.44), 0 0 18px rgba(191, 52, 46, 0.18);
  }
}

@keyframes subtleBlink {
  0%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }
  50% {
    opacity: 0.74;
    transform: translateY(-1px);
  }
}

@media (max-width: 1220px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-width: 0;
    min-height: 100vh;
    height: auto;
  }

  .topbar,
  .arena,
  .scorebar,
  .rules-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .arena.single {
    grid-template-columns: 1fr;
  }

  .brand,
  .toolbar,
  .timebar {
    justify-content: center;
  }
}
