/* 酒Game大排檔：迎新營組旗。夜晚墨色底，四隻組色對應四個花色 */
:root {
  --ink: #141210;
  --ink-2: #1e1b18;
  --ink-3: #2b2723;
  --line: #3a342e;
  --paper: #f3eee3;
  --muted: #b3aa9e;
  --red: #d92b25;
  --yellow: #ffc400;
  --blue: #2f5bea;
  --green: #19b35f;
  --display: "Chiron Hei HK", "PingFang HK", "Noto Sans HK", sans-serif;
  --body: "PingFang HK", "Noto Sans HK", "Microsoft JhengHei", system-ui, sans-serif;
  --t-body: 17px;
  --t-display: clamp(46px, 14vw, 76px);
  --cw: min(54vw, 230px, 31svh);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain-soft: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

/* 組色：每個花色一隻 */
[data-suit="h"] { --bg: var(--red); --fg: #fff; }
[data-suit="d"] { --bg: var(--yellow); --fg: var(--ink); }
[data-suit="s"] { --bg: var(--blue); --fg: #fff; }
[data-suit="c"] { --bg: var(--green); --fg: var(--ink); }
[data-suit="j"] { --bg: var(--paper); --fg: var(--ink); }
[data-suit="none"] { --bg: var(--ink-2); --fg: var(--paper); }

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100svh;
  background: var(--ink);
  color: var(--paper);
  font: 400 var(--t-body)/1.6 var(--body);
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--yellow); color: var(--ink); }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
a { color: inherit; text-underline-offset: 0.2em; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---------- 頂部 ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}

.logo {
  font: 900 var(--t-body)/1 var(--display);
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.logo span {
  display: inline-block;
  margin-left: 4px;
  padding: 5px 7px 4px;
  background: var(--red);
  color: #fff;
  transform: rotate(-3deg);
}

.tools { display: flex; gap: 2px; }

.icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--paper);
  text-decoration: none;
}

.icon svg { width: 24px; height: 24px; }
.icon:hover { background: var(--ink-3); }

.text-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: 900 var(--t-body)/1 var(--display);
  letter-spacing: 0.08em;
  text-decoration: none;
}

/* ---------- 牌堆進度：每抽一張留低一格組色 ---------- */
.rail {
  display: grid;
  grid-template-columns: repeat(var(--n, 52), 1fr);
  gap: 2px;
  width: calc(100% - 32px);
  max-width: 528px;
  height: 8px;
  margin: 0 auto;
}

.rail i { background: var(--ink-3); border-radius: 1px; }
.rail i[data-suit] { background: var(--bg); }
.rail[hidden] { display: none; }

/* ---------- 輪到邊個 ---------- */
.turn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin: 0;
  color: var(--muted);
}

.turn b { color: var(--paper); font-weight: 800; }
.turn .left { font-variant-numeric: tabular-nums; }

.link-btn {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--paper);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

/* ---------- 枱面 ---------- */
.table {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  padding: 4px 0 28px;
}

.deck {
  position: relative;
  width: calc(var(--cw) * 0.6);
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 0;
  background: none;
  transition: transform 0.2s var(--ease);
}

.deck:active { transform: scale(0.96); }

.deck .layer, .deck .back {
  position: absolute;
  inset: 0;
  border-radius: 7% / 5%;
}

.deck .layer {
  background: #b5241f;
  box-shadow: 0 6px 14px rgb(0 0 0 / 0.45);
}

.deck .layer:nth-child(1) { transform: translate(6px, -6px) rotate(3deg); }
.deck .layer:nth-child(2) { transform: translate(3px, -3px) rotate(1.5deg); }

.card {
  position: relative;
  width: var(--cw);
  aspect-ratio: 5 / 7;
  perspective: 1200px;
  cursor: pointer;
}

.inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease);
}

.card.up .inner { transform: rotateY(180deg); }

/* ---------- 牌 ---------- */
.face {
  position: absolute;
  inset: 0;
  border-radius: 7% / 5%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  container-type: size;
  box-shadow: 0 18px 36px rgb(0 0 0 / 0.55), 0 2px 4px rgb(0 0 0 / 0.4);
}

.back {
  background: var(--grain-soft), var(--red);
  background-blend-mode: multiply;
}

.back::before {
  content: "";
  position: absolute;
  inset: 6%;
  border: 2px solid rgb(255 255 255 / 0.9);
  border-radius: 4% / 3%;
}

.back::after {
  content: "酒";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font: 900 52cqw/1 var(--display);
  transform: rotate(-6deg);
}

.front {
  transform: rotateY(180deg);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 900;
}

.front.red { color: var(--red); }

/* 牌面用組色（黃、綠加深咗，喺米白牌面上先夠對比） */
.front[data-suit="h"] { --suit: var(--red); }
.front[data-suit="d"] { --suit: #a87200; }
.front[data-suit="s"] { --suit: var(--blue); }
.front[data-suit="c"] { --suit: #0f8a49; }
.front[data-suit="j"] { --suit: var(--ink); }
.front[data-suit] { color: var(--suit); }
.mini .front { transform: none; }

.front svg { fill: currentColor; }

.corner {
  position: absolute;
  top: 6%;
  left: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3cqw;
  font-size: 17cqw;
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.corner svg { width: 11cqw; height: 11cqw; }

.corner.br {
  top: auto;
  left: auto;
  bottom: 6%;
  right: 7%;
  transform: rotate(180deg);
}

.pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.pip svg { width: 46cqw; height: 46cqw; }

.pip b {
  font-size: 58cqw;
  line-height: 1;
  letter-spacing: -0.04em;
}

.joker .corner {
  writing-mode: vertical-rl;
  font-size: 10cqw;
  letter-spacing: 0.1em;
}

.front.joker::before { border-color: var(--ink); }
.joker .pip svg { width: 58cqw; height: 58cqw; }

/* 牌面規則名：直排大字，J/Q/K 用圓圈字 */
.front::before {
  content: "";
  position: absolute;
  inset: 4.5% 6%;
  border: 2px solid currentColor;
  border-radius: 4% / 3%;
  opacity: 0.3;
}

.pip.has-say { inset: 13% 18%; }

.say {
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  font-size: min(30cqw, calc(64cqh / var(--n)));
  line-height: 1.02;
  letter-spacing: 0.04em;
  transform: rotate(-3deg);
}

.say > span { display: inline-block; }
.say .tcy { text-combine-upright: all; }
.say.circles { flex-direction: row; gap: 3cqh; }

.say.circles > span {
  display: grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  font-size: min(17cqw, calc(40cqh / var(--n)));
  border-radius: 50%;
  background: var(--suit, currentColor);
  color: var(--paper);
}
.card.fresh .say > span { animation: stamp 0.42s var(--ease) both; animation-delay: calc(0.45s + var(--i) * 0.14s); }

/* 名牌貼紙：邊個抽中 */
.sticker {
  position: absolute;
  left: 50%;
  bottom: -14px;
  z-index: 2;
  max-width: 90%;
  padding: 4px 12px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--fg);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 14px rgb(0 0 0 / 0.45);
  transform: translateX(-50%) rotate(-4deg);
  opacity: 0;
  transition: opacity 0.2s, transform 0.4s var(--ease);
}

.sticker.on { opacity: 1; transform: translateX(-50%) rotate(-4deg) scale(1); }
.sticker:empty { display: none; }

/* ---------- 組色規則區：叫口號 ---------- */
.field {
  position: relative;
  background: var(--bg);
  color: var(--fg);
  isolation: isolate;
}

.field::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--grain);
  opacity: 0.14;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.field-in {
  max-width: 560px;
  margin: 0 auto;
  padding: 26px 16px 30px;
}

.chant {
  margin: 0;
  font: 900 var(--t-display)/1.02 var(--display);
  font-size: max(40px, min(96px, calc((min(100vw, 560px) - 40px) / var(--n, 4))));
  letter-spacing: -0.02em;
  text-wrap: balance;
  transform: rotate(-2deg);
  transform-origin: left center;
}

.chant span { display: inline-block; }

.lead {
  margin: 0;
  font: 900 clamp(24px, 6.6vw, 32px)/1.3 var(--display);
  text-wrap: balance;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.short {
  margin: 10px 0 0;
  max-width: 34em;
  text-wrap: pretty;
}

.target {
  display: inline-block;
  margin: 14px 0 0;
  padding: 6px 12px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 800;
}

.field details { margin-top: 14px; }

.field summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.field summary::-webkit-details-marker { display: none; }

.field summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.25s var(--ease);
}

.field details[open] summary::after { transform: translateY(2px) rotate(-135deg); }

.how { margin: 4px 0 0; padding-left: 1.4em; }
.how li { margin: 6px 0; padding-left: 2px; }
.how li::marker { font-weight: 800; }

.ex { margin: 10px 0 0; }
.ex b { font-weight: 800; }

.law-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.law-form input { flex: 1; }

.law-form button {
  flex: none;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font-weight: 800;
}

input[type="text"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  caret-color: var(--yellow);
}

input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="text"]:focus, textarea:focus { outline: none; border-color: var(--yellow); }

/* 叫口號：組色由左邊展開，字逐粒蓋印 */
.field.unfurl { animation: unfurl 0.5s var(--ease); }
.field.unfurl .chant span { animation: stamp 0.42s var(--ease) both; animation-delay: calc(0.35s + var(--i) * 0.14s); }
.field.unfurl .lead, .field.unfurl .short, .field.unfurl .target { animation: rise 0.4s var(--ease) both; animation-delay: calc(0.45s + var(--n, 4) * 0.14s); }

@keyframes unfurl {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes stamp {
  from { opacity: 0; transform: scale(1.7) rotate(-8deg); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 場上狀態 ---------- */
.status:not(:empty) { padding: 22px 0 6px; }

.status h2 {
  margin: 0 0 10px;
  font: 800 var(--t-body)/1.4 var(--body);
}

.status h2 small { color: var(--muted); font-weight: 400; font-size: 1em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--ink-3);
  font-weight: 800;
}

.chip small { color: var(--muted); font-weight: 400; font-size: 1em; }
.chip.use { background: var(--paper); color: var(--ink); }
.chip.use small { color: #5c554c; }
.chip.use:hover { background: #fff; }

.laws { margin: 12px 0 0; padding: 0; list-style: none; }

.laws li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0 4px 14px;
  border-bottom: 1px solid var(--line);
}

.x {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
}

.x svg { width: 18px; height: 18px; }
.x:hover { background: var(--ink-3); color: var(--paper); }

/* ---------- 抽牌掣 ---------- */
.bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(rgb(20 18 16 / 0), var(--ink) 40%);
}

.draw {
  display: block;
  width: 100%;
  max-width: 528px;
  min-height: 64px;
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: 900 var(--t-body)/1 var(--display);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.5);
  transition: transform 0.12s var(--ease), background 0.2s;
}

.draw:hover { background: #fff; }
.draw:active { transform: scale(0.97); }
.draw:disabled { background: var(--muted); }

.foot {
  margin: 0;
  padding: 28px 16px 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

/* ---------- 對話框 ---------- */
dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100svh - 24px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--ink-2);
  color: var(--paper);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.6);
}

dialog::backdrop { background: rgb(10 9 8 / 0.78); }
dialog form { padding: 24px 20px 20px; }

dialog h2 {
  margin: 0 0 6px;
  font: 900 30px/1.15 var(--display);
}

dialog label { display: block; margin: 14px 0; font-weight: 800; }
dialog label textarea { margin-top: 8px; font-weight: 400; }

.switch {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin: 4px 0 !important;
  border-bottom: 1px solid var(--line);
}

.switch input {
  appearance: none;
  flex: none;
  position: relative;
  width: 50px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--ink-3);
  cursor: pointer;
  transition: background 0.2s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--paper);
  transition: transform 0.25s var(--ease);
}

.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(20px); }

.hint {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
}

dialog details { margin-top: 10px; }

dialog summary {
  min-height: 48px;
  line-height: 48px;
  font-weight: 800;
  cursor: pointer;
}

.custom-row {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 8px 0 !important;
}

.custom-row span {
  flex: none;
  width: 2.4em;
  font: 900 var(--t-body)/1 var(--display);
  text-align: center;
}

.row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  font-weight: 800;
}

.btn.solid { border: 0; background: var(--paper); color: var(--ink); }
.btn.quiet { border: 2px solid var(--line); background: none; color: var(--paper); }

/* 年齡確認 */
.age-band {
  margin: -24px -20px 18px;
  padding: 22px 20px 18px;
  border-radius: 16px 16px 0 0;
  background: var(--grain-soft), var(--red);
  background-blend-mode: multiply;
  color: #fff;
  font: 900 88px/0.9 var(--display);
  letter-spacing: -0.04em;
}

.age .row { justify-content: stretch; }
.age .btn { flex: 1; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 112px;
  z-index: 10;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.5);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.35s var(--ease);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 規則頁 ---------- */
.page-head {
  position: relative;
  isolation: isolate;
  background: var(--bg);
  color: var(--fg);
}

.page-head::before, .page-head .wrap { padding-top: 30px; padding-bottom: 30px; }

.page-head h1 {
  margin: 0;
  font: 900 clamp(44px, 12.5vw, 72px)/1.02 var(--display);
  letter-spacing: -0.02em;
  text-wrap: balance;
  transform: rotate(-2deg);
  transform-origin: left center;
}

.page-head p { margin: 14px 0 0; font-weight: 800; }

.jump {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 20px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.jump a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 48px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}

.jump a b {
  flex: none;
  width: 1.6em;
  font: 900 26px/1 var(--display);
  letter-spacing: -0.04em;
}

.jump a:hover b { color: var(--yellow); }

.prose h2 {
  margin: 44px 0 10px;
  font: 900 30px/1.2 var(--display);
}

.prose p { max-width: 34em; }

.rule-band { scroll-margin-top: 8px; margin-top: 18px; }

.rule-band header {
  background: var(--bg);
  color: var(--fg);
  position: relative;
  isolation: isolate;
}

.rule-band .head-in {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 4px 18px;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 18px;
}

.rule-band .rank {
  grid-row: span 2;
  font: 900 clamp(64px, 20vw, 96px)/0.8 var(--display);
  letter-spacing: -0.05em;
}

.rule-band h2 {
  margin: 0;
  font: 900 32px/1.1 var(--display);
}

.rule-band .short { margin: 0; font-weight: 800; text-wrap: pretty; }
.how li { text-wrap: pretty; }
.rule-band .body { padding-top: 14px; padding-bottom: 10px; }
.rule-band .ex { color: var(--muted); }

.cta {
  display: flex;
  justify-content: center;
  margin: 44px 0 0;
}

.cta .text-btn { min-height: 60px; padding: 0 36px; }

@media (min-width: 900px) {
  :root { --cw: min(220px, 30svh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.unit { display: inline-block; }

/* 中文唔好喺詞語中間斷行：只喺標點斷，太長先強制斷 */
.short, .how li, .prose p, .page-head p {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.h1-logo { margin: 0; font-size: inherit; }

.foot-links {
  padding: 0 16px 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 2;
  text-align: center;
}

.foot-links a { color: var(--muted); white-space: nowrap; }
.foot-links a:hover { color: var(--paper); }

.faq h3 { margin: 22px 0 4px; font-weight: 800; font-size: var(--t-body); }
.faq p { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
