* {
  box-sizing: border-box;
}

:root {
  --ink: #141411;
  --muted: #615f56;
  --paper: #f8f0dc;
  --paper-deep: #eadfc7;
  --line: #20201b;
  --shelf: #7f6b54;
  --accent: #d43746;
  --green: #1f755f;
  --blue: #285a7d;
  --gold: #d7a735;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(20, 20, 17, .035) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(#f5efe4 0%, #e4d9c6 58%, #cfc1aa 100%);
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page {
  min-height: 100vh;
}

.market {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(328px, 440px) minmax(0, 1fr);
}

.receipt-panel {
  position: relative;
  z-index: 2;
  margin: 28px 0 28px 28px;
  padding: 28px 28px 34px;
  min-height: calc(100vh - 56px);
  background:
    linear-gradient(rgba(255, 255, 255, .28), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(0deg, rgba(20, 20, 17, .045) 0 1px, transparent 1px 13px),
    var(--paper);
  border: 2px solid var(--line);
  box-shadow: 12px 14px 0 rgba(20, 20, 17, .16);
}

.receipt-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.4) 48%, transparent 52%);
  mix-blend-mode: soft-light;
}

.perforation {
  height: 16px;
  margin: -18px -18px 20px;
  background: radial-gradient(circle at 8px 8px, transparent 0 5px, var(--paper) 5px 9px) 0 0 / 18px 16px;
}

.kicker,
.meta,
.receipt-note {
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 9ch;
  margin: 12px 0 10px;
  font-size: clamp(42px, 5.2vw, 64px);
  line-height: .9;
}

h2 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
}

.meta {
  color: var(--muted);
}

.divider {
  margin: 20px 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: "Courier New", monospace;
  color: var(--muted);
}

.active-ticket {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 14px;
  align-items: end;
  padding: 18px 0;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}

.active-ticket p {
  min-width: 0;
  font-size: 24px;
  line-height: 1.08;
  font-weight: 900;
}

.active-ticket strong {
  color: var(--accent);
  font-size: 40px;
  line-height: 1;
}

.active-ticket span {
  grid-column: 1 / -1;
  font-family: "Courier New", monospace;
  color: var(--muted);
}

.receipt-table {
  width: 100%;
  margin: 22px 0;
  border-collapse: collapse;
  font-family: "Courier New", monospace;
  font-size: 13px;
}

.receipt-table td {
  padding: 9px 6px;
  border-bottom: 1px dashed rgba(20, 20, 17, .45);
  vertical-align: top;
}

.receipt-table td:last-child {
  text-align: right;
  font-weight: 900;
}

.receipt-note {
  position: absolute;
  right: 28px;
  bottom: 28px;
  left: 28px;
  padding-top: 14px;
  border-top: 2px solid var(--line);
  text-align: center;
}

.stage-wrap {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  overflow: hidden;
}

.stage-label {
  position: absolute;
  z-index: 1;
  top: 26px;
  right: 28px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  color: #fff8e8;
  background: rgba(20, 20, 17, .84);
  border: 1px solid rgba(255, 248, 232, .4);
  border-radius: 6px;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.stage-label strong {
  color: #ffd96a;
}

#marketCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.shelf-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 18px;
  padding: 34px 28px 46px;
  border-top: 3px solid var(--line);
}

.product-card,
.photo-card,
.cart {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 6px;
  box-shadow: 6px 7px 0 rgba(20, 20, 17, .16);
}

.product-card {
  min-height: 250px;
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
}

.product-card:hover,
.product-card.is-active {
  transform: translateY(-4px);
  background: #fff7e6;
  box-shadow: 7px 10px 0 rgba(20, 20, 17, .2);
}

.product-card h3 {
  font-size: 19px;
  line-height: 1.15;
}

.price-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: "Courier New", monospace;
  font-weight: 900;
}

.price-line strong {
  color: var(--accent);
  font-size: 24px;
}

.barcode {
  height: 48px;
  background: repeating-linear-gradient(90deg, #111 0 2px, transparent 2px 5px, #111 5px 8px, transparent 8px 13px);
  border: 1px solid rgba(20, 20, 17, .25);
}

.add-button,
.checkout {
  min-height: 42px;
  color: #fffdf3;
  background: var(--green);
  border: 2px solid var(--line);
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease;
}

.add-button:hover,
.checkout:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.comparison,
.cart-section {
  padding: 40px 28px;
  border-top: 3px solid var(--line);
}

.section-head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 18px;
}

.photo-card {
  overflow: hidden;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d8cfbd;
}

.photo-card p {
  padding: 12px 14px 16px;
  font-size: 14px;
  font-weight: 800;
}

.cart-section {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 360px);
  gap: 20px;
  align-items: start;
  padding-bottom: 70px;
}

.cart-section .section-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.cart {
  min-height: 170px;
  padding: 18px;
  font-family: "Courier New", monospace;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed rgba(20, 20, 17, .45);
}

.cart-total {
  margin-top: 18px;
  color: var(--accent);
  text-align: right;
  font-size: 22px;
  font-weight: 900;
}

.checkout {
  width: 100%;
  min-height: 62px;
  background: var(--accent);
}

@media (max-width: 1040px) {
  .market,
  .cart-section {
    grid-template-columns: 1fr;
  }

  .receipt-panel {
    margin: 18px;
    min-height: auto;
    padding-bottom: 86px;
  }

  .stage-wrap {
    position: relative;
    height: 68vh;
  }

  .shelf-list,
  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  h1 {
    max-width: 100%;
    font-size: 38px;
  }

  .shelf-list,
  .photo-grid {
    grid-template-columns: 1fr;
  }

  .receipt-panel,
  .comparison,
  .cart-section,
  .shelf-list {
    margin-left: 0;
    padding-right: 18px;
    padding-left: 18px;
  }

  .active-ticket {
    grid-template-columns: 1fr;
  }

  .active-ticket strong {
    font-size: 34px;
  }
}
