:root {
  color-scheme: light;
  --canvas: #f3e9e3;
  --paper-top: #fff9f3;
  --paper-bottom: #fbf2e9;
  --stub-top: #f8e3e1;
  --stub-bottom: #f1d8db;
  --ink: #2c1f24;
  --muted: #73585d;
  --rose: #91465a;
  --rose-strong: #793447;
  --champagne: #b89171;
  --rule: #e1c9bd;
  --texture: url("assets/paper.png");
  --face: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --figures: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  background: var(--canvas) var(--texture);
  color: var(--ink);
  font-family: var(--face);
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
h1, h2, p { margin: 0; }
button { font: inherit; }
button:focus-visible {
  outline: 2px solid var(--rose-strong);
  outline-offset: 4px;
}

.waiting-shell {
  width: min(100%, 490px);
  margin-block: clamp(26px, 6vh, 64px);
  padding-inline: clamp(14px, 4.8vw, 24px);
}
.ticket {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 21px;
  box-shadow: 0 24px 58px -36px #55323c70, 0 5px 18px #55323c0a;
}
.ticket-main {
  padding: 25px clamp(19px, 5.8vw, 31px) 26px;
  background: var(--texture), linear-gradient(155deg, var(--paper-top), var(--paper-bottom));
}
.ticket-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.ticket-header::after {
  position: absolute;
  inset: auto auto -1px 0;
  width: 44px;
  height: 1px;
  content: "";
  background: var(--champagne);
}
.portrait {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: clamp(46px, 15vw, 62px);
  aspect-ratio: 1;
  padding: 3px;
  border: 1.5px solid var(--champagne);
  border-radius: 50%;
  background: #fff4e9;
}
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 50%;
}
.event-identity { min-width: 0; }
.event-identity img {
  display: block;
  width: clamp(105px, 36vw, 155px);
  max-width: 100%;
  height: auto;
}
.event-identity p {
  margin-top: 3px;
  color: var(--rose);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .14em;
}
.tail {
  display: block;
  flex: 0 0 auto;
  width: clamp(45px, 15.5vw, 68px);
  height: auto;
  margin-inline-start: auto;
  align-self: start;
  margin-top: 4px;
}
.calling { padding-top: 21px; }
.calling-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.label-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid #e2c5b9;
  border-radius: 999px;
  background: #fbeee9;
  color: var(--rose);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
}
.label-pill::before {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  content: "";
  background: var(--champagne);
}
.queue-clock {
  display: flex;
  align-items: baseline;
  gap: 5px 7px;
  color: var(--muted);
  font-size: 12px;
}
.queue-clock time {
  color: var(--ink);
  font: 650 17px/1 var(--figures);
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.call-value { margin: 5px 0 12px; }
.call-number {
  display: flex;
  align-items: baseline;
  gap: clamp(10px, 3vw, 19px);
  white-space: nowrap;
}
.call-number strong {
  font: 700 clamp(82px, 27.3vw, 126px)/1 var(--figures);
  font-variant-numeric: tabular-nums;
  letter-spacing: .045em;
}
.call-number span {
  font-size: clamp(17px, 4.8vw, 23px);
  font-weight: 700;
}
.call-number.number-changed strong { animation: call-highlight .5s ease-out; }
@keyframes call-highlight {
  0% { color: var(--rose); }
  100% { color: var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  .call-number.number-changed strong { animation: none; }
}
.call-empty {
  display: grid;
  align-items: center;
  min-height: clamp(88px, 27vw, 128px);
  color: var(--muted);
  font-size: clamp(21px, 6vw, 26px);
  font-weight: 650;
}
.queue-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: #eadbd3;
}
.queue-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress);
  border-radius: inherit;
  background: var(--rose);
}
.queue-pin {
  position: absolute;
  top: 50%;
  left: clamp(6px, var(--progress), calc(100% - 6px));
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  border: 1.5px solid var(--paper-top);
  border-radius: 50%;
  background: var(--champagne);
}
.progress-caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.progress-caption strong {
  color: var(--rose);
  font-family: var(--figures);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
}
.my-ticket {
  margin-top: 14px;
  padding: 7px 13px 12px;
  border: 1px solid var(--rule);
  border-radius: 11px;
  background: linear-gradient(145deg, #fcf1e9, #fbf0eb);
}
.mine-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.mine-head strong {
  margin-inline-start: 6px;
  color: var(--ink);
  font: 650 16px var(--figures);
  font-variant-numeric: tabular-nums;
}
.mine-head button {
  min-height: 34px;
  min-width: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--rose-strong);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}
.quiet-eta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
  margin-top: 3px;
}
.eta-label { color: var(--muted); font-size: 13px; }
.eta-time {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--rose-strong);
}
.eta-time time {
  font: 700 29px/.97 var(--figures);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.eta-time span { color: var(--muted); font-size: 12px; }
.eta-state { margin-top: 4px; color: var(--rose-strong); font-size: 18px; font-weight: 700; }
.eta-hint, .sync-label { color: var(--muted); font-size: 12px; line-height: 1.55; }
.eta-hint { margin-top: 3px; }
.sync-label { margin-top: 9px; color: var(--rose-strong); }
.ticket-form { display: flex; gap: 7px; margin-top: 9px; }
.ticket-form input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: #fffdf9;
  color: var(--ink);
  font: 400 16px var(--face);
}
.ticket-form button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--rose);
  border-radius: 7px;
  background: var(--rose);
  color: var(--paper-top);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.queue-note {
  margin-top: 11px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.ticket-seam {
  position: relative;
  z-index: 1;
  border-top: 1px dashed #bf9699;
}
.ticket-seam::before, .ticket-seam::after {
  position: absolute;
  top: -10px;
  width: 19px;
  height: 19px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--canvas) var(--texture);
  content: "";
}
.ticket-seam::before { left: -10px; }
.ticket-seam::after { right: -10px; }
.ticket-group {
  padding: 23px clamp(19px, 5.8vw, 31px) 25px;
  background: var(--texture), linear-gradient(145deg, var(--stub-top), var(--stub-bottom));
}
.group-heading {
  display: flex;
  align-items: center;
  gap: 13px;
}
.group-mark {
  display: grid;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid #d7acae;
  border-radius: 13px;
  box-shadow: inset 0 0 0 2px #fff9f3, inset 0 0 0 3px #e9cbca;
  background: #fff9f3;
  color: var(--rose);
}
.group-mark svg { width: 33px; height: 33px; }
.group-heading h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .03em;
}
.group-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.group-button, .group-unavailable {
  position: relative;
  width: 100%;
  min-height: 47px;
  margin-top: 16px;
  padding: 10px 36px;
  border: 1px solid transparent;
  border-radius: 9px;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}
.group-button {
  background: var(--rose);
  color: #fff9f3;
  font-weight: 650;
  letter-spacing: .035em;
  cursor: pointer;
  transition: background-color .16s ease;
}
@media (hover: hover) {
  .group-button:hover { background: var(--rose-strong); }
  .dialog-close:hover { background: #fbeee9; }
}
.group-button:active { background: var(--rose-strong); }
.group-button svg {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 19px;
  height: 19px;
  transform: translateY(-50%);
}
.group-unavailable {
  border-color: #d7acae;
  background: #fff9f362;
  color: var(--muted);
}

.group-dialog {
  width: min(calc(100% - 36px), 362px);
  max-height: calc(100% - 36px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 18px;
  background: var(--texture), linear-gradient(var(--paper-top), var(--paper-bottom));
  color: var(--ink);
  box-shadow: 0 24px 64px #38202935;
}
.group-dialog::backdrop { background: #30212665; }
.dialog-inner { padding: 15px 22px 22px; }
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.dialog-header h2 {
  font-size: 20px;
  letter-spacing: .025em;
}
.dialog-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--paper-top);
  color: var(--rose);
  cursor: pointer;
}
.dialog-close svg { width: 21px; height: 21px; }
.qr-frame {
  display: grid;
  place-items: center;
  width: min(100%, 254px);
  aspect-ratio: 1;
  margin-inline: auto;
  padding: 10px;
  border: 1px solid #d7acae;
  border-radius: 14px;
  background: #fffdf9;
  box-shadow: inset 0 0 0 3px #fffdf9, inset 0 0 0 4px #eed6d4;
}
.qr-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.qr-placeholder {
  display: grid;
  justify-items: center;
  gap: 11px;
  padding: 10px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.qr-placeholder svg { width: 38px; height: 38px; color: #ac6978; }
.qr-help {
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 390px) {
  .waiting-shell { margin-block: 31px; }
  .ticket-header { padding-bottom: 17px; }
  .ticket-main { padding-bottom: 21px; }
  .ticket-group { padding-block: 19px 20px; }
}

@media (min-width: 750px) {
  body { align-content: center; }
  .waiting-shell { width: min(100%, 984px); }
  .ticket { grid-template-columns: minmax(0, 1fr) auto minmax(244px, 32%); }
  .ticket-main { padding: 34px clamp(27px, 4vw, 45px) 33px; }
  .ticket-header { gap: 16px; padding-bottom: 22px; }
  .portrait { width: 70px; padding: 4px; }
  .event-identity img { width: 162px; }
  .event-identity p { margin-top: 4px; font-size: 14px; }
  .tail { width: 83px; margin-top: 5px; }
  .calling { padding-top: 24px; }
  .label-pill { padding: 5px 12px; font-size: 14px; }
  .preview-label { font-size: 12px; }
  .call-value { margin-top: 3px; }
  .call-number strong { font-size: clamp(112px, 15vw, 174px); }
  .call-number span { font-size: 25px; }
  .call-empty { min-height: clamp(112px, 15vw, 174px); font-size: 28px; }
  .progress-caption { font-size: 14px; }
  .progress-caption strong { font-size: 18px; }
  .queue-note { font-size: 14px; }
  .ticket-seam {
    border-top: 0;
    border-left: 1px dashed #bf9699;
  }
  .ticket-seam::before, .ticket-seam::after { left: -10px; right: auto; }
  .ticket-seam::after { top: auto; bottom: -10px; }
  .ticket-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px clamp(19px, 2.8vw, 37px);
    text-align: center;
  }
  .group-heading { flex-direction: column; gap: 14px; }
  .group-mark { width: 71px; height: 71px; border-radius: 16px; }
  .group-mark svg { width: 45px; height: 45px; }
  .group-heading h2 { font-size: 24px; }
  .group-heading p { margin-top: 6px; font-size: 14px; }
  .group-button, .group-unavailable { margin-top: 23px; max-width: 234px; }
}

@media (prefers-reduced-motion: reduce) {
  .group-button { transition: none; }
}
