:root {
  color-scheme: light;
  --paper: #f7f4eb;
  --panel: #fbf9f1;
  --ink: #071e26;
  --navy: #183746;
  --green: #0c392f;
  --gold: #be8b41;
  --gold-light: #f6d89e;
  --line: #e8dfcc;
  --ornaments: url('./v3-ornaments.png?v=3.1');
  font-family: "Noto Serif SC", "Songti SC", "SimSun", "Times New Roman", serif;
  color: var(--ink);
  background: #eae5da;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  max-width: 540px;
  min-width: 300px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: default; opacity: .68; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid #9b6b25;
  outline-offset: 2px;
}
a { color: inherit; text-decoration: none; }
p, h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.topbar {
  background: linear-gradient(120deg, #fffdf8, #f5f2e9);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  gap: 6px;
}
.brand {
  font: 700 clamp(25px, 6.6vw, 39px)/1 Georgia, "Times New Roman", serif;
  letter-spacing: -.055em;
  color: #0a342d;
}
.header-actions, .wallet-pill, .language, .text-button, .icon-heading, .balance-row {
  display: flex;
  align-items: center;
}
.header-actions { gap: 5px; }
.wallet-pill, .language {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 27px;
  background: #fcfaf4;
  box-shadow: 0 1px 2px #82683b14;
  white-space: nowrap;
}
.wallet, .copy-button, .icon-button, .refresh-button {
  background: transparent;
  border: 0;
}
.wallet {
  padding: 4px 7px;
  min-width: 0;
  max-width: 104px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(10px, 2.7vw, 13px);
}
.copy-button {
  min-width: 20px;
  padding: 4px 5px 4px 0;
  display: grid;
  place-items: center;
}
.copy-icon {
  position: relative;
  display: block;
  width: 8px;
  height: 10px;
  border: 1.25px solid currentColor;
  border-radius: 1.5px;
  background: #fcfaf4;
}
.copy-icon::before {
  content: "";
  position: absolute;
  inset: 1px 1px -3px -3px;
  border-left: 1.25px solid;
  border-bottom: 1.25px solid;
  border-radius: 1.5px;
}
.language {
  gap: 6px;
  padding: 4px 8px;
  font-size: clamp(11px, 2.75vw, 13px);
}
.chevron {
  display: inline-block;
  width: 6px;
  height: 6px;
  flex: none;
  border: solid currentColor;
  border-width: 1px 1px 0 0;
  transform: rotate(45deg);
}
.chevron.down { transform: translateY(-1px) rotate(135deg); }
.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  font-size: 21px;
}
.hamburger {
  width: 18px;
  height: 1.5px;
  background: var(--ink);
  box-shadow: 0 -5.5px var(--ink), 0 5.5px var(--ink);
}

.shell { padding: 0 8px max(10px, env(safe-area-inset-bottom)); }
.hero {
  margin: 0 -8px 5px;
  aspect-ratio: 780 / 219;
  background: #d9d6c6 url('./terrace.webp') center/cover no-repeat;
}
.card, .stats {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 11% 110%, #eae1cb40, transparent 50%),
    radial-gradient(ellipse at 92% -15%, #fffdf8 0, transparent 65%),
    var(--panel);
}
.card + .card, .stats + .card { margin-top: 6px; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: 62px;
  align-items: center;
  padding: 8px 0;
  text-align: center;
}
.stats > div + div { border-left: 1px solid #e6d9c2; }
.stats p {
  font-size: clamp(11px, 3vw, 15px);
  color: var(--navy);
  white-space: nowrap;
}
.stats strong {
  color: var(--ink);
  font: 700 clamp(19px, 6.5vw, 32px)/1.1 "Times New Roman", Georgia, serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
}
.stats span { color: var(--navy); font-size: 11px; }

.round-card {
  display: flex;
  align-items: center;
  gap: clamp(8px, 3.6vw, 23px);
  min-height: 62px;
  padding: 7px 11px 7px 12px;
  isolation: isolate;
  overflow: hidden;
}
.round-card::after {
  content: "";
  z-index: -1;
  position: absolute;
  inset: 0 0 0 46%;
  background:
    linear-gradient(90deg, var(--panel), #f8f4e572 43%, #f6eed829),
    url('./round-marble-columns.webp') 95% 50% / auto 170% no-repeat;
  filter: saturate(.62);
  opacity: .99;
}
.round-heading { flex: 1; min-width: 0; }
.round-heading h2 {
  font-size: clamp(20px, 5.9vw, 29px);
  line-height: 1.12;
  font-weight: 700;
  white-space: nowrap;
}
.round-heading p {
  color: var(--navy);
  font-size: clamp(12px, 3.6vw, 16px);
  margin-top: 2px;
}
.round-heading small {
  display: block;
  margin-top: 3px;
  color: #76501d;
  font: 11px/1.2 system-ui, sans-serif;
}
.text-button {
  gap: 6px;
  justify-content: flex-end;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: #123447;
  font-size: clamp(10px, 2.9vw, 13px);
  white-space: nowrap;
  flex: none;
}
.text-button:hover { color: #805419; }

.ornament {
  display: inline-block;
  flex: none;
  background-image: var(--ornaments);
  background-size: 126px 59px;
  background-repeat: no-repeat;
  mix-blend-mode: multiply;
}
.wreath { width: 46px; height: 43px; background-position: 0 0; }
.rule-icon { width: 22px; height: 23px; background-position: -78px 0; }
.chain-icon { width: 23px; height: 23px; background-position: -102px 0; }
.block-icon { width: 12px; height: 13px; background-position: 0 -45px; }
.target-icon { width: 12px; height: 14px; background-position: -14px -45px; }
.shield-icon { width: 12px; height: 13px; background-position: -28px -45px; }
.lock-icon { width: 12px; height: 13px; background-position: -42px -45px; }

.participation, .join-area { padding: 8px 14px 10px; }
.section-heading {
  display: flex;
  min-height: 23px;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}
.section-heading h2 {
  font-size: clamp(15px, 4.2vw, 21px);
  line-height: 1.3;
  white-space: nowrap;
}
#seat-count {
  color: #2b5064;
  font: 400 clamp(12px, 3.4vw, 16px)/1 "Times New Roman", serif;
}
.seat-heading { margin-bottom: 7px; }
.seat-section { position: relative; }
.seat-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
.seat {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: clamp(53px, 15.6vw, 71px);
  border: 1px dashed #c4bdad;
  background: #fcfaf4;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  color: #224251;
  font-size: 11px;
  line-height: 1;
}
.seat.occupied {
  border-style: solid;
  border-color: #e9dfca;
  background: linear-gradient(146deg, #f8f5eb, #f0ecdf);
  font: 700 clamp(11px, 3vw, 15px)/1 "Times New Roman", serif;
  color: #0a171c;
}
.seat.mine { border-color: #b78b47; box-shadow: inset 0 0 0 1px #c19b5b45; }
.seat.winner { outline: 2px solid var(--gold); outline-offset: -2px; }
.seat-icon {
  display: grid;
  grid-template-areas: "icon";
  width: 28px;
  height: 28px;
}
.seat-plus, .seat .avatar {
  grid-area: icon;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #526675;
  font: 400 27px/1 system-ui, sans-serif;
}
.seat .avatar { visibility: hidden; }
.occupied .seat-plus { visibility: hidden; }
.occupied .avatar {
  visibility: visible;
  border-radius: 50%;
  background: var(--ornaments) no-repeat -48px 0 / 126px 59px;
}
.seat-flash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .seat-grid[data-fill="empty"] {
    --seat-sweep: .52;
    --seat-edge: .6;
    --seat-pulse: 1.10;
  }
  .seat-grid[data-fill="partial"] {
    --seat-sweep: .25;
    --seat-edge: .32;
    --seat-pulse: 1.05;
  }
  .seat-grid[data-fill="near"] {
    --seat-sweep: .64;
    --seat-edge: .74;
    --seat-pulse: 1.10;
  }
  .seat-grid[data-fill="last"] {
    --seat-sweep: .78;
    --seat-edge: .9;
    --seat-pulse: 1.13;
  }
  .seat-grid[data-fill]:not([data-fill="static"]) .seat:not(.occupied)::before,
  .seat-grid[data-fill]:not([data-fill="static"]) .seat:not(.occupied)::after,
  .seat.joining::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
  }
  .seat-grid[data-fill]:not([data-fill="static"]) .seat:not(.occupied)::before {
    background: linear-gradient(108deg, transparent 28%, #e0b66444 45%, #f8dc9d9e 52%, transparent 70%);
    animation: seat-sweep 6.4s var(--seat-phase) ease-in-out infinite;
  }
  .seat-grid[data-fill]:not([data-fill="static"]) .seat:not(.occupied)::after {
    box-shadow: inset 0 0 0 1px #d3a454a6, inset 0 0 8px #e0b96844;
    animation: seat-edge 6.4s var(--seat-phase) ease-in-out infinite;
  }
  .seat-grid[data-fill]:not([data-fill="static"]) .seat:not(.occupied) .seat-plus {
    animation: seat-breathe 3.8s var(--seat-phase) ease-in-out infinite;
  }
  .seat.joining::after {
    box-shadow: inset 0 0 0 1px #cea04c, inset 0 0 9px #e1b65c70;
    animation: seat-join-edge .86s ease-out both;
  }
  .seat.joining .seat-plus {
    visibility: visible;
    animation: seat-hide-plus .86s ease-out both;
  }
  .seat.joining .avatar { animation: seat-reveal-avatar .86s ease-out both; }
  .seat.joining .seat-label { animation: seat-reveal-label .86s ease-out both; }
  .seat-grid.round-activated .seat-flash {
    box-shadow: inset 0 0 0 1px #d7ac61, inset 0 0 12px #e2bd735e;
    background: #f4cf7e26;
    animation: seat-full-glow .96s ease-in-out both;
  }
  @keyframes seat-sweep {
    0%, 8% { transform: translateX(-100%); opacity: 0; }
    24%, 41% { opacity: var(--seat-sweep); }
    58%, 100% { transform: translateX(100%); opacity: 0; }
  }
  @keyframes seat-edge {
    0%, 8%, 66%, 100% { opacity: 0; }
    35% { opacity: var(--seat-edge); }
  }
  @keyframes seat-breathe {
    0%, 100% { transform: scale(1); opacity: .8; }
    50% { transform: scale(var(--seat-pulse)); opacity: 1; }
  }
  @keyframes seat-join-edge {
    0%, 100% { opacity: 0; }
    17%, 34% { opacity: 1; }
  }
  @keyframes seat-hide-plus {
    0%, 18% { opacity: 1; }
    44%, 100% { opacity: 0; }
  }
  @keyframes seat-reveal-avatar {
    0%, 37% { opacity: 0; transform: scale(.92); }
    79%, 100% { opacity: 1; transform: scale(1); }
  }
  @keyframes seat-reveal-label {
    0%, 62% { opacity: 0; transform: translateY(2px); }
    100% { opacity: 1; transform: translateY(0); }
  }
  @keyframes seat-full-glow {
    0%, 100% { opacity: 0; }
    8%, 32% { opacity: .85; }
  }
}

.seat-section.is-waiting .seat-grid { row-gap: 45px; }
.waiting {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 1px solid #b5884270;
  display: grid;
  place-items: center;
  background: linear-gradient(90deg, #f8f1e217, #f8f1e237 50%, #f8f1e217);
  pointer-events: none;
}
.waiting-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid #d2ad67;
  border-radius: 9px;
  background: #12382fed;
  color: #fff8e7;
  box-shadow: 0 3px 11px #142f2b30;
  max-width: 95%;
}
.waiting strong, .waiting small { display: block; }
.waiting strong { font-size: 12px; }
.waiting small { margin-top: 2px; font-size: 10px; color: #f2d9a1; }
.orbit {
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid #f3ce8051;
  border-top-color: #f3ce80;
  animation: orbit 1.1s linear infinite;
  flex: none;
}
@keyframes orbit { to { transform: rotate(360deg); } }

.balance-row { gap: 4px; font-size: 11px; color: #173a4c; white-space: nowrap; }
.balance-row strong {
  font: 700 clamp(14px, 3.8vw, 20px)/1 "Times New Roman", Georgia, serif;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.refresh-button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 23px;
  padding: 1px;
}
.refresh-icon {
  width: 11px;
  height: 11px;
  position: relative;
  border: 1.4px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
.refresh-icon::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 0;
  width: 4px;
  height: 4px;
  border: solid currentColor;
  border-width: 1.4px 1.4px 0 0;
}
.tier-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 7px -3px 6px;
}
.tier-group button {
  min-height: 37px;
  border: 1px solid #e8deca;
  border-radius: 6px;
  background: linear-gradient(140deg, #f9f6eb, #f1eddf);
  font: 700 clamp(15px, 4.3vw, 22px)/1 "Times New Roman", Georgia, serif;
  color: var(--ink);
}
.tier-group button[aria-pressed="true"] {
  border: 1.5px solid #d7ac62;
  color: #fff8ed;
  background: linear-gradient(138deg, #164437, #082b24);
  box-shadow: 0 1px 3px #2c271e40;
}
.primary {
  width: 100%;
  min-height: 39px;
  border: 1.5px solid #cf9f58;
  border-radius: 999px;
  background: linear-gradient(135deg, #174237, #082b24 72%);
  color: var(--gold-light);
  font-weight: 700;
  padding: 5px 15px;
}
.primary:hover { background: linear-gradient(135deg, #225443, #0b372b); }
.join-button {
  min-height: 42px;
  margin-inline: -5px;
  width: calc(100% + 10px);
  position: relative;
  font-size: clamp(15px, 4.45vw, 22px);
  box-shadow: 0 2px 5px #152a2338;
  padding-inline: 34px;
}
.join-arrow {
  position: absolute;
  right: 10%;
  top: 50%;
  width: 21px;
  height: 21px;
  transform: translateY(-50%);
  border-radius: 50%;
  border: 1px solid var(--gold-light);
  display: grid;
  place-items: center;
}
.join-arrow::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid var(--gold-light);
  border-width: 1.5px 1.5px 0 0;
  transform: translateX(-1px) rotate(45deg);
}
.transaction {
  font: 11px/1.5 system-ui, sans-serif;
  color: #704a19;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.transaction:empty { display: none; }

.rules, .chain { padding: 7px 12px 8px; }
.icon-heading { gap: 8px; }
.rule-list {
  margin: 2px 0 0 12px;
  padding-left: 22px;
  border-left: 1px solid #b17c37;
  color: var(--navy);
  font-size: clamp(11px, 2.95vw, 15px);
  line-height: 1.55;
}
.rule-list li { padding-left: 2px; }
.table-wrap { margin-top: 4px; }
table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: clamp(10px, 2.8vw, 14px);
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
th {
  font-weight: 400;
  color: #244555;
}
th, td {
  padding: 3px 1px;
  height: 20px;
  border-bottom: 1px solid #e8e0d265;
  border-right: 1px solid #e8e0d290;
}
th:last-child, td:last-child { border-right: 0; }
th:first-child { width: 15%; }
th:nth-child(2), th:nth-child(3) { width: 31%; }
th:last-child { width: 23%; }
th .ornament, td .ornament { vertical-align: middle; margin-right: 4px; }
td button {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: #0c2d3b;
}
.pill {
  display: inline-block;
  min-width: 45px;
  background: #ecd5a7;
  border-radius: 99px;
  color: #352713;
  padding: 2px 6px;
  font-size: clamp(9px, 2.65vw, 13px);
  line-height: 1.2;
}
.pill.drawn { background: #d8e2d7; color: #264b3d; }
.pill.recovery { background: #f0e1cd; color: #67451f; }

.live-line {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  min-height: 19px;
  color: #635f51;
  font: 10px/1.2 system-ui, sans-serif;
}
.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b78845;
}
.live-dot[data-live="true"] { background: #2d7a57; }

dialog {
  width: min(91vw, 420px);
  max-height: 84dvh;
  border: 1px solid #dcb87c;
  border-radius: 14px;
  padding: 15px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 14px 46px #152f2a42;
}
dialog::backdrop { background: #14221d75; }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.dialog-head h2 { color: #0c342b; font-size: 21px; }
.dialog-actions { margin-top: 10px; display: flex; gap: 6px; }
.dialog-actions:empty { display: none; }
.dialog-actions button { flex: 1; }
.dialog-body { font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.dialog-body p + p { margin-top: 7px; }
.dialog-body input, .dialog-body select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}
.dialog-body label { display: block; margin-top: 9px; }
.dialog-list { padding: 0; list-style: none; margin: 0; }
.dialog-list li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.dialog-list button {
  width: 100%;
  text-align: left;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--green);
}
.detail-seats { padding-left: 20px; columns: 2; }
.rules-details { border-bottom: 1px solid var(--line); padding: 7px 0; }
.rules-details summary { cursor: pointer; color: var(--green); }

@media (min-width: 520px) {
  body { box-shadow: 0 5px 35px #3426141f; }
  .top-inner { min-height: 54px; padding-inline: 17px; }
  .shell { padding-inline: 12px; }
  .hero { margin-inline: -12px; }
  .card + .card, .stats + .card { margin-top: 8px; }
  .stats { min-height: 77px; }
  .round-card { min-height: 75px; }
  .participation, .join-area { padding: 10px 16px 13px; }
  .seat-grid { gap: 7px; }
  .tier-group button { min-height: 43px; }
  .join-button { min-height: 47px; }
  th, td { height: 24px; }
}

@media (max-width: 349px) {
  .top-inner { padding-inline: 8px; }
  .header-actions { gap: 3px; }
  .language { padding-inline: 6px; }
  .icon-button { width: 26px; }
  .round-card { gap: 7px; }
  .participation, .join-area { padding-inline: 10px; }
  th .ornament, td .ornament { margin-right: 2px; }
  .join-arrow { right: 6%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
