:root {
  --bg: #eef3f1;
  --panel: #ffffff;
  --ink: #1d2521;
  --muted: #65736d;
  --line: #d7e1dd;
  --accent: #1f7a63;
  --accent-dark: #155c4a;
  --accent-warm: #b8842e;
  --accent-red: #a6433f;
  --soft-green: #e6f4ee;
  --soft-gold: #fbf3df;
  --warn: #a95d00;
  --bad: #b93232;
  --good: #19734f;
  --shadow: 0 16px 38px rgba(28, 42, 36, 0.10);
  --shadow-soft: 0 8px 20px rgba(28, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f7faf8 0%, var(--bg) 42%, #e9efec 100%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
input {
  font: inherit;
}

.shell,
.admin-shell {
  width: min(1160px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 34px;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.brand-block,
.topline,
.test-header {
  margin-bottom: 18px;
}

.brand-block {
  max-width: 760px;
}

.brand-block p,
.message,
.loading-msg,
.result-message,
.rank-label {
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  font-size: 24px;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 330px;
  padding: 38px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #173f36 0%, #1f725d 54%, #b8842e 100%);
  color: #ffffff;
  box-shadow: 0 22px 46px rgba(24, 57, 47, 0.22);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 auto;
  width: 44%;
  height: 100%;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,0.13) 0 1px, transparent 1px 24px);
  opacity: .55;
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero .eyebrow {
  color: #d7efe8;
}

.hero h1 {
  font-size: clamp(34px, 4.6vw, 58px);
  line-height: 1.08;
}

.hero-sub {
  margin: 18px 0 0;
  max-width: 680px;
  color: rgba(255,255,255,.88);
  font-size: 18px;
  line-height: 1.75;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px;
  padding: 0 13px;
  background: rgba(255,255,255,.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: blur(4px);
}

.rule-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.rule-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow-soft);
}

.rule-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.rule-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 18px 0 10px;
}

.big-btn {
  min-width: 160px;
  min-height: 50px;
}

.home-note,
.muted-line,
.board-meta,
.practice-note,
.score-cap {
  color: var(--muted);
  line-height: 1.65;
}

.home-note {
  min-height: 24px;
  margin: 8px 0 16px;
}

.panel,
.image-card,
.answer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-panel {
  max-width: 460px;
  padding: 20px;
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fbfcfd;
  color: var(--ink);
}

.primary-btn,
.ghost-btn,
.ghost-link {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: .46;
  cursor: not-allowed;
}

.ghost-btn,
.ghost-link {
  color: var(--accent-dark);
  background: #eef8fa;
  border-color: #c8e3e9;
}

.topline,
.test-header,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.test-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.image-card {
  margin: 0;
  min-height: 420px;
  padding: 14px;
  display: grid;
  place-items: center;
}

.image-card img {
  width: 100%;
  max-height: min(72vh, 690px);
  object-fit: contain;
  display: block;
}

.answer-card {
  padding: 14px;
  position: sticky;
  top: 16px;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--ink);
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.option-btn:hover {
  border-color: var(--accent);
}

.option-btn.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.option-btn:disabled {
  opacity: .58;
  cursor: not-allowed;
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 0;
}

.timer-box {
  min-width: 92px;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.timer-box span {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.timer-box.is-warning span {
  color: var(--warn);
}

.timer-box.is-critical span {
  color: var(--bad);
}

.timer-box small {
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5eb;
  margin: 0 0 14px;
}

#timerBar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width .2s linear;
}

.loading-msg {
  min-height: 24px;
  margin: 0 0 12px;
}

.feedback {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  background: #f3f6f8;
  color: var(--muted);
  display: none;
}

.feedback.is-good {
  color: var(--good);
  background: #e9f6ef;
}

.feedback.is-bad {
  color: var(--bad);
  background: #faecec;
}

.result-hero {
  max-width: 620px;
  padding: 28px;
}

.result-panel,
.board-panel,
.standing-panel {
  padding: 18px;
  margin-top: 16px;
}

.board-panel {
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbfa 100%);
}

.panel-head h2,
.result-panel h3 {
  margin: 0;
}

.score-number {
  font-size: 76px;
  font-weight: 900;
  line-height: 1;
  margin: 18px 0 10px;
  color: var(--accent-dark);
}

.tier-badge,
.br-tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 900;
  font-size: 13px;
  border: 1px solid transparent;
}

.tier-badge {
  min-height: 36px;
  padding: 0 14px;
  font-size: 15px;
}

.t0 { color: #586169; background: #eef1f2; border-color: #d6dcdf; }
.t1 { color: #566f25; background: #edf6dd; border-color: #d5e9af; }
.t2 { color: #17624f; background: #e4f4ee; border-color: #bee1d3; }
.t3 { color: #1d6580; background: #e5f4fa; border-color: #b9ddeb; }
.t4 { color: #7a5416; background: #fbf0d8; border-color: #ecd49c; }
.t5 { color: #8a3f20; background: #fae7dc; border-color: #ebc0aa; }
.t6 { color: #823b62; background: #f7e5ef; border-color: #e8bcd4; }

.board-list {
  display: grid;
  gap: 8px;
}

.board-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 64px;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  box-shadow: 0 5px 14px rgba(28, 42, 36, .05);
}

.board-row.is-you {
  border-color: #d1a85d;
  background: linear-gradient(90deg, var(--soft-gold), #ffffff 58%);
}

.br-rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #edf2ef;
  color: var(--muted);
  font-weight: 900;
}

.br-rank.top1 {
  color: #ffffff;
  background: #b8842e;
}

.br-rank.top2 {
  color: #ffffff;
  background: #687c8a;
}

.br-rank.top3 {
  color: #ffffff;
  background: #9a6841;
}

.br-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.br-score {
  justify-self: end;
  min-width: 48px;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 950;
  text-align: right;
}

.dist-wrap {
  margin-top: 18px;
}

.dist-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-weight: 900;
}

.dist-chart {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  align-items: end;
  gap: 5px;
  height: 88px;
  padding: 10px 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8f6;
}

.dist-bar {
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: #9fc5b6;
}

.dist-bar.is-you {
  background: var(--accent-warm);
}

.dist-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.standing-title,
.standing-line,
.standing-sub {
  margin: 0;
}

.standing-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.standing-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 18px;
}

.standing-line strong {
  font-size: 28px;
  color: var(--accent-dark);
}

.standing-sub {
  margin-top: 4px;
  color: var(--muted);
}

.share-wrap {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, #f5f8f6 0%, #eef4f1 100%);
}

.share-wrap::before {
  content: "生成后在此预览";
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.share-wrap.has-preview::before {
  content: none;
}

.share-wrap img {
  display: block;
  width: min(100%, 420px);
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(28, 42, 36, .16);
}

.share-wrap img[hidden],
.share-wrap img:not([src]) {
  display: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card strong {
  display: block;
  font-size: 28px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.admin-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fbfcfd;
  cursor: pointer;
}

.table-actions,
.detail-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.danger-btn,
.danger-mini-btn {
  border-color: #e6b4b1;
  background: #fff1f0;
  color: var(--accent-red);
}

.danger-btn:hover,
.danger-mini-btn:hover {
  border-color: var(--accent-red);
  background: #fde4e2;
}

.danger-btn {
  min-height: 44px;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

.detail-box {
  display: grid;
  gap: 10px;
}

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.detail-item .detail-actions {
  margin-top: 12px;
}

.code-output {
  min-height: 70px;
  padding: 12px;
  border-radius: 6px;
  background: #111b24;
  color: #e9f2f8;
  white-space: pre-wrap;
}

.message.is-error {
  color: var(--bad);
}

.message.is-ok {
  color: var(--good);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 28, 24, .42);
}

.modal-card {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(18, 28, 24, .24);
}

.modal-card h3 {
  margin: 0 0 10px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 900px) {
  .test-layout,
  .stat-grid,
  .rule-cards {
    grid-template-columns: 1fr;
  }

  .answer-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell,
  .admin-shell {
    width: min(100vw - 18px, 1160px);
    padding: 16px 0;
  }

  h1 {
    font-size: 24px;
  }

  .hero {
    min-height: 0;
    padding: 24px 18px;
  }

  .hero h1 {
    font-size: 34px;
  }

  .hero-sub {
    font-size: 15px;
  }

  h2 {
    font-size: 21px;
  }

  .topline,
  .test-header,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .image-card {
    min-height: 260px;
  }

  .action-row {
    grid-template-columns: 1fr;
  }

  .board-row {
    grid-template-columns: 36px minmax(0, 1fr) 52px;
  }

  .board-row .br-tier {
    grid-column: 2 / 3;
    justify-self: start;
  }

  .br-score {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .dist-chart {
    height: 72px;
  }
}
