:root {
  --page-width: 794px;
  --page-height: 1123px;
  --ink: #4f4a47;
  --ink-soft: #6c6763;
  --paper: #ffffff;
  --screen-bg: #eee9df;
  --accent: #ffb32f;
  --accent-strong: #ff6f0a;
  --accent-soft: #f6e0b6;
  --panel-bg: #fffdfa;
  --line: #ece7dd;
  --shadow: rgba(61, 53, 47, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.92) 0, rgba(255, 255, 255, 0) 44%),
    linear-gradient(180deg, #f7f3ea 0%, #ece7dd 100%);
}

.preview-shell {
  padding: 0 12px 24px;
}

.page-stage {
  position: relative;
  margin: 0 auto;
}

.page {
  position: relative;
  width: var(--page-width);
  height: auto;
  padding: 34px 52px 26px;
  background: var(--paper);
  box-shadow: 0 32px 60px rgba(61, 53, 47, 0.15);
  transform-origin: top left;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 18px;
}

.print-page-header {
  display: none;
}

.worksheet-flow-page {
  display: contents;
}

.topbar--print {
  display: none;
}

.topbar__field {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.topbar__field--wide {
  flex: 1.15;
}

.topbar__label {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.topbar__rule {
  height: 6px;
  flex: 1;
  min-width: 90px;
  background:
    url("assets/line-dark.png") repeat-x center top,
    url("assets/line-light.png") repeat-x center bottom;
}

.topbar__stamp {
  width: 76px;
  height: 90px;
  border: 3px solid var(--ink-soft);
  flex: none;
}

.hero-panel {
  position: relative;
  width: 682px;
  height: auto;
  margin: 0 auto 14px;
}

.hero-panel__frame {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.hero-panel__content {
  position: relative;
  z-index: 1;
  padding: 48px 32px 24px;
}

.hero-panel__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.hero-panel__icon {
  width: 31px;
  height: 36px;
}

.hero-panel__title h1 {
  margin: 0;
  font-size: 27px;
  font-weight: 800;
  letter-spacing: 1px;
}

.hero-panel__divider {
  height: 3px;
  background: var(--ink-soft);
  opacity: 0.9;
}

.hero-panel__meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.hero-panel__grade {
  min-width: 88px;
  font-size: 16px;
  font-weight: 700;
}

.preview-track {
  display: grid;
  grid-template-columns: repeat(14, 34px);
  gap: 4px;
}

.preview-track__slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid #efebe3;
  background: #ffffff;
}

.preview-track__slot img {
  width: 24px;
  height: 24px;
}

.preview-track__slot--crown {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.preview-track__slot--solid {
  background: linear-gradient(180deg, #ffbe3f 0%, #ffaf1f 100%);
  border-color: #f7d17f;
}

.hero-panel__legend {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 18px;
}

.hero-panel__count {
  min-width: 78px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.hero-panel__count strong {
  display: inline-block;
  margin-top: 2px;
  font-size: 16px;
}

.legend-list {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  min-width: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.legend-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 2px solid #efebe3;
  background: #ffffff;
}

.legend-item__icon img {
  width: 21px;
  height: 21px;
}

.legend-item__icon--crown {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.legend-item__icon--solid {
  border-color: #f7d17f;
  background: linear-gradient(180deg, #ffc147 0%, #ffb122 100%);
}

.legend-item__icon--half {
  background:
    linear-gradient(180deg, #ffffff 0 50%, #ffb122 50% 100%);
}

.legend-item__icon--bar {
  background:
    linear-gradient(180deg, #ffffff 0 68%, #ffb122 68% 100%);
}

.legend-item__icon--empty {
  background: #ffffff;
}

.worksheet-flow {
  display: flow-root;
  position: relative;
  width: 668px;
  margin: 0 auto;
  padding: 8px 0 0;
  background:
    linear-gradient(rgba(108, 103, 99, 0.65), rgba(108, 103, 99, 0.65))
      left 3px bottom / calc(100% - 6px) 2px no-repeat;
}

.worksheet-flow::before,
.worksheet-flow::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 0;
  width: 2px;
  background: var(--ink-soft);
  opacity: 0.65;
}

.worksheet-flow::before {
  left: 3px;
}

.worksheet-flow::after {
  right: 3px;
}

.stage-card {
  position: relative;
  width: 640px;
  margin: 0 auto 20px;
  padding-top: 38px;
}

.stage-card:last-of-type {
  margin-bottom: 16px;
}

.stage-card--featured {
  padding-top: 50px;
}

.stage-card__tab {
  position: absolute;
  top: 0;
  left: 18px;
  display: flex;
  align-items: stretch;
  isolation: isolate;
  overflow: visible;
  width: 520px;
  height: 66px;
  padding: 6px 24px 6px 50px;
  border-radius: 16px;
  background: transparent;
  box-shadow: 10px 10px 0 rgba(79, 74, 71, 0.2);
  z-index: 2;
}

.stage-card__tab::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--panel-bg);
  box-shadow: inset 0 0 0 1px rgba(79, 74, 71, 0.86);
  z-index: -2;
}

.stage-card__tab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    url("assets/line-light.png") repeat-x left 18px top 0 / 36px 1px,
    url("assets/line-light.png") repeat-x left 18px bottom 0 / 36px 1px;
  pointer-events: none;
  z-index: -1;
}

.stage-card--featured .stage-card__tab {
  height: 66px;
}

.stage-card__accent {
  display: none;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 44px;
  pointer-events: none;
  z-index: 3;
}

.stage-card__tab-content {
  flex: 1;
  min-width: 0;
}

.stage-card__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.stage-card__title-row h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.stage-card__subtitle {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 1.1;
  font-weight: 700;
  color: rgba(79, 74, 71, 0.9);
}

.stage-card__shadow {
  display: none;
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 46px;
  pointer-events: none;
  z-index: 3;
}

.mini-progress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-progress__bars {
  display: inline-flex;
  gap: 4px;
}

.mini-progress__bar {
  display: inline-block;
  width: 20px;
  height: 10px;
}

.mini-progress__bar--strong {
  background: var(--accent-strong);
}

.mini-progress__bar--warm {
  background: var(--accent);
}

.mini-progress__bar--soft {
  background: var(--accent-soft);
}

.stage-card__body {
  position: relative;
  min-height: 176px;
  padding: 48px 38px 26px;
  border: 2px solid var(--ink);
  border-radius: 26px;
  background: #ffffff;
}

.stage-card__body::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(79, 74, 71, 0.72);
  border-radius: 18px;
}

.stage-card__notch {
  position: absolute;
  width: 15px;
  height: 14px;
  background: #ffffff;
}

.stage-card__notch--top {
  top: 14px;
  right: 16px;
  border-top: 1px solid rgba(79, 74, 71, 0.72);
  border-right: 1px solid rgba(79, 74, 71, 0.72);
}

.stage-card__notch--bottom {
  left: 16px;
  bottom: 14px;
  border-left: 1px solid rgba(79, 74, 71, 0.72);
  border-bottom: 1px solid rgba(79, 74, 71, 0.72);
}

.worksheet-grid {
  position: relative;
  z-index: 1;
}

.worksheet-grid__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px;
  padding: 18px 4px 14px;
  border-bottom: 2px solid rgba(79, 74, 71, 0.55);
}

.worksheet-grid__row:first-child {
  padding-top: 10px;
}

.worksheet-grid__item {
  display: block;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.bonus-card {
  position: relative;
  width: 640px;
  min-height: 144px;
  margin: 30px auto 0;
  padding: 24px 28px 18px;
  border: 2px solid var(--ink);
  border-radius: 22px;
  background: #ffffff;
}

.bonus-card__content {
  width: 500px;
}

.bonus-card__lead {
  display: flex;
  align-items: center;
  gap: 18px;
}

.bonus-card__lead strong {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.bonus-card__diamond {
  width: 20px;
  height: 20px;
  background: #ffd54b;
  transform: rotate(45deg);
  flex: none;
}

.bonus-card__dash {
  margin-top: 28px;
  width: 350px;
  height: 3px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(79, 74, 71, 0.85) 0 10px,
      transparent 10px 22px
    );
}

.bonus-card__astronaut {
  position: absolute;
  right: 22px;
  bottom: -22px;
  width: 100px;
  height: auto;
}

@media print {
  @page {
    size: A4;
    margin: 34px 52px 26px;
  }

  body {
    background: #ffffff;
  }

  .preview-shell {
    padding: 0;
  }

  .page-stage {
    width: auto !important;
    height: auto !important;
    margin: 0;
  }

  .page {
    width: auto;
    padding: 0;
    box-shadow: none;
    transform: none !important;
  }

  .print-header .topbar,
  .print-page-header .topbar {
    margin: 0 0 18px;
  }

  .print-header {
    display: none;
  }

  .print-page-header {
    display: block;
  }

  .worksheet-flow {
    width: auto;
    margin: 0;
    padding: 0;
    background: none;
  }

  .worksheet-flow::before,
  .worksheet-flow::after {
    display: none;
  }

  .worksheet-flow-page {
    display: flow-root;
    position: relative;
    width: 668px;
    margin: 0 auto;
    padding: 8px 0 0;
    break-inside: avoid-page;
    page-break-inside: avoid;
    background:
      linear-gradient(rgba(108, 103, 99, 0.65), rgba(108, 103, 99, 0.65))
        left 3px bottom / calc(100% - 6px) 2px no-repeat;
  }

  .worksheet-flow-page::before,
  .worksheet-flow-page::after {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 0;
    width: 2px;
    background: var(--ink-soft);
    opacity: 0.65;
  }

  .worksheet-flow-page::before {
    left: 3px;
  }

  .worksheet-flow-page::after {
    right: 3px;
  }

  .topbar,
  .hero-panel,
  .worksheet-flow-page,
  .stage-card,
  .bonus-card {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  .print-break-before {
    break-before: page;
    page-break-before: always;
  }
}
