/* ผสมสิบ: indigo-dyed cloth (ผ้าคราม) table, ivory cards, marigold (ดาวเรือง) for "your move".
   Motif: ลายประจำยาม four-petal flower on card backs and faintly on the table. */

:root {
  --indigo-950: #0e1629;
  --indigo-900: #121c33;
  --indigo-800: #1a2847;
  --indigo-700: #24365e;
  --indigo-600: #31467a;
  --line: #3d5288;
  --ivory: #f6eedb;
  --ivory-2: #ece1c6;
  --text-dim: #c3cbe0;
  --ink: #1d1d22;
  --red: #b8261b;
  --marigold: #f0a81c;
  --marigold-deep: #c98400;
  --plus: #9fe3b0;
  --minus: #ff9b8f;
  --radius-card: 8px;
  --radius-ui: 10px;
  --cw: clamp(48px, 13.5vw, 84px);
  --font-display: "Mitr", "Sarabun", system-ui, sans-serif;
  --font-body: "Sarabun", "Mitr", system-ui, sans-serif;
  /* Mitr draws a slashed zero; numbers on cards and chips use Sarabun so "10" never reads as "1Ø". */
  --font-num: "Sarabun", system-ui, sans-serif;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --prajamyam: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%23f0a81c' stroke-width='1.1'%3E%3Cpath d='M16 6c3 4 3 6 0 10-3-4-3-6 0-10zM16 26c3-4 3-6 0-10-3 4-3 6 0 10zM6 16c4-3 6-3 10 0-4 3-6 3-10 0zM26 16c-4-3-6-3-10 0 4 3 6 3 10 0z'/%3E%3Cpath d='M0 0l5 5M32 0l-5 5M0 32l5-5M32 32l-5-5' stroke-linecap='round'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='1.6' fill='%23f0a81c'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--indigo-900);
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--marigold); }
a:hover { color: #ffc65a; }

button, select, input, summary, label[for] { font: inherit; }
button, select, summary, a[href], label[for], input[type="checkbox"] { cursor: pointer; }
button:disabled, select:disabled, input:disabled { cursor: not-allowed; }

:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- chrome ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--indigo-700);
  background: var(--indigo-950);
}
.brand {
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
  color: var(--ivory); text-decoration: none; letter-spacing: .01em;
}
.brand span { color: var(--marigold); }
.topnav { display: flex; align-items: center; gap: 6px; }
.room-chip {
  font-family: var(--font-display); font-size: 14px; color: var(--text-dim);
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px;
}

main { flex: 1; display: flex; flex-direction: column; outline: none; }

.foot {
  padding: 16px; color: var(--text-dim); font-size: 13px; text-align: center;
  border-top: 1px solid var(--indigo-700);
}
.foot p { margin: 0; max-width: 60ch; margin-inline: auto; }

.net-banner {
  background: var(--marigold); color: var(--ink); text-align: center;
  padding: 6px 16px; font-weight: 600; font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ivory); color: var(--ink); padding: 10px 16px; border-radius: var(--radius-ui);
  font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .35);
  transition: opacity .2s, transform .2s var(--ease-out); z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- buttons + fields ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: var(--radius-ui);
  border: 1px solid var(--line); background: var(--indigo-700); color: var(--ivory);
  font-weight: 600; text-decoration: none; transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover:not(:disabled) { background: var(--indigo-600); border-color: #5068a3; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn.primary:disabled { opacity: 1; background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn.primary { background: var(--marigold); border-color: var(--marigold); color: var(--ink); font-family: var(--font-display); font-weight: 500; font-size: 17px; }
.btn.primary:hover:not(:disabled) { background: #ffbb3d; border-color: #ffbb3d; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover:not(:disabled) { background: var(--indigo-800); color: var(--ivory); border-color: var(--indigo-700); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.danger-text { color: var(--minus); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--text-dim); }
.input {
  min-height: 48px; padding: 10px 14px; border-radius: var(--radius-ui);
  border: 1px solid var(--line); background: var(--indigo-950); color: var(--ivory); font-size: 17px;
  width: 100%;
}
.input::placeholder { color: #8d98b8; }
.input:hover { border-color: #5068a3; }
.input.code { font-family: var(--font-display); letter-spacing: .2em; text-transform: uppercase; }

/* ---------- cards ---------- */

.card {
  --w: var(--cw);
  display: inline-block; position: relative; flex: none;
  width: var(--w); height: calc(var(--w) * 1.4);
  border-radius: var(--radius-card);
  background: var(--ivory);
  color: var(--ink);
  border: 1px solid #d8cba8;
  font-family: var(--font-display);
  /* Elevation: cards rest on cloth; the shadow separates them from the table. */
  box-shadow: 0 2px 0 #cbbd98, 0 4px 10px rgb(0 0 0 / .28);
  padding: 0; user-select: none; -webkit-user-select: none;
}
.card.red { color: var(--red); }
.card .rank {
  font-family: var(--font-num);
  position: absolute; top: 4%; left: 8%;
  font-size: calc(var(--w) * .34); line-height: 1; font-weight: 600;
}
.card .rank.ten { letter-spacing: -.06em; }
.card .suit-sm {
  position: absolute; top: 30%; left: 9%;
  font-size: calc(var(--w) * .22); line-height: 1;
}
.card .suit-lg {
  position: absolute; right: 9%; bottom: 6%;
  font-size: calc(var(--w) * .52); line-height: 1;
}
.card .tag {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  font-family: var(--font-body); font-size: 11px; font-weight: 600; line-height: 1;
  padding: 3px 6px; border-radius: 5px; white-space: nowrap;
}
.card .tag.wild { background: var(--marigold); color: var(--ink); }
.card .tag.dead { background: var(--ink); color: var(--ivory); }
.card .tag.taken { background: var(--indigo-600); color: var(--ivory); }
.card.dead::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgb(29 29 34 / .13) 6px 8px);
}
.card.wild { border-color: var(--marigold); box-shadow: 0 2px 0 var(--marigold-deep), 0 4px 10px rgb(0 0 0 / .28); }

.card.back {
  background-color: var(--indigo-700);
  background-image: var(--prajamyam);
  background-size: calc(var(--w) * .42) calc(var(--w) * .42);
  background-position: center;
  border: 3px solid var(--ivory-2);
  box-shadow: 0 2px 0 #0b1222, 0 4px 10px rgb(0 0 0 / .3);
}
.card.mini { --w: 22px; border-width: 1.5px; box-shadow: 0 1px 0 #0b1222; border-radius: 3px; }
.card.small { --w: clamp(40px, 11vw, 56px); }
.card.tiny { --w: 34px; border-radius: 5px; box-shadow: 0 1px 0 #cbbd98; }
.card.tiny .tag { display: none; }

/* ---------- home ---------- */

.home {
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 28px 16px 40px;
  display: grid; gap: 28px; align-content: start;
}
.home-hero h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(44px, 13vw, 88px); line-height: 1.05; margin: 0;
}
.home-hero h1 span { color: var(--marigold); }
.home-hero p { margin: 10px 0 0; color: var(--text-dim); font-size: 18px; max-width: 32ch; }

.fan {
  position: relative; height: calc(var(--cw) * 2.1); margin-top: 18px;
  --cw: clamp(64px, 18vw, 104px);
}
.fan .card { position: absolute; top: 10px; }
.fan .card:nth-child(1) { left: 0; transform: rotate(-9deg); }
.fan .card:nth-child(2) { left: calc(var(--cw) * .62); transform: rotate(3deg) translateY(-6px); }
.fan .eq {
  position: absolute; left: calc(var(--cw) * 1.85); top: calc(var(--cw) * .45);
  font-family: var(--font-num); font-size: calc(var(--cw) * .5); color: var(--marigold); font-weight: 600;
}

.panel {
  background: var(--indigo-800); border: 1px solid var(--indigo-700);
  border-radius: 14px; padding: 18px;
}
.home-forms { display: grid; gap: 16px; align-content: start; }
.home-forms h2 { font-family: var(--font-display); font-weight: 500; font-size: 20px; margin: 0; }
#homeForm { display: grid; gap: 14px; }
#homeForm .or, #homeForm .form-error { margin: 0; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.or { text-align: center; color: var(--text-dim); font-size: 14px; }
.form-error { color: var(--minus); font-size: 14px; margin: 6px 0 0; }
.form-error:empty { display: none; }

@media (min-width: 760px) {
  .home { grid-template-columns: 1.1fr 1fr; padding-top: 56px; gap: 40px; }
}

/* ---------- lobby ---------- */

.lobby {
  width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 32px;
  display: grid; gap: 18px; align-content: start;
}
.lobby-head h1 { font-family: var(--font-display); font-weight: 500; font-size: 24px; margin: 0; }
.invite { display: grid; gap: 10px; }
.invite .code {
  font-family: var(--font-num); font-weight: 600; font-size: 44px; letter-spacing: .14em;
  color: var(--marigold); line-height: 1;
}
.invite .link { color: var(--text-dim); font-size: 14px; word-break: break-all; }
.invite .meta { color: var(--text-dim); font-size: 14px; }
.panel .seats + .btn { margin-top: 10px; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seat {
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  padding: 8px 8px 8px 14px; border-radius: var(--radius-ui);
  background: var(--indigo-800); border: 1px solid var(--indigo-700);
}
.seat.empty { border-style: dashed; color: var(--text-dim); background: transparent; min-height: 44px; }
.seat .who { flex: 1; min-width: 0; }
.seat .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.seat .meta { font-size: 13px; color: var(--text-dim); }
.label {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 5px;
  background: var(--indigo-700); color: var(--ivory); vertical-align: 2px; margin-left: 4px;
}
.label.host { background: var(--marigold); color: var(--ink); }
.label.off { background: transparent; border: 1px solid var(--minus); color: var(--minus); }

.settings { display: grid; gap: 12px; }
.settings h2 { font-family: var(--font-display); font-weight: 500; font-size: 18px; margin: 0; }
.switch-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--indigo-700);
}
.switch-row:last-of-type { border-bottom: 0; }
.switch-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; margin: 2px 0 0;
  width: 46px; height: 28px; border-radius: 14px; background: var(--indigo-950);
  border: 1px solid var(--line); position: relative; transition: background .15s;
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-dim); transition: transform .15s var(--ease-out), background .15s;
}
.switch-row input[type="checkbox"]:checked { background: var(--marigold); border-color: var(--marigold); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--ink); }
.switch-row input[type="checkbox"]:hover:not(:disabled) { border-color: #6a82c0; }
.switch-row input[type="checkbox"]:disabled { opacity: .5; }
.switch-row label { flex: 1; }
.switch-row .hint { display: block; color: var(--text-dim); font-size: 13px; }
.selects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.selects select {
  min-height: 44px; width: 100%; padding: 6px 10px; border-radius: var(--radius-ui);
  background: var(--indigo-950); color: var(--ivory); border: 1px solid var(--line);
}
.selects select:hover:not(:disabled) { border-color: #6a82c0; }
.rules-summary { margin: 0; padding-left: 18px; color: var(--text-dim); }
.start-zone { display: grid; gap: 8px; }
.start-zone .why { text-align: center; color: var(--text-dim); font-size: 14px; margin: 0; }

@media (max-width: 420px) {
  .selects { grid-template-columns: 1fr 1fr; }
}

/* ---------- table ---------- */

.table {
  flex: 1; display: grid; grid-template-rows: auto 1fr auto; gap: 10px;
  width: 100%; max-width: 900px; margin: 0 auto;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  background-color: var(--indigo-800);
  background-image: var(--prajamyam);
  background-size: 64px 64px;
  position: relative;
}
.table::before {
  /* tones the motif down so it reads as cloth, not wallpaper */
  content: ""; position: absolute; inset: 0; background: rgb(26 40 71 / .93); pointer-events: none;
}
.table > .opponents, .table > .center, .table > .me { position: relative; }

.opponents { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; }
.opp {
  position: relative; padding: 8px 10px; border-radius: var(--radius-ui);
  background: var(--indigo-900); border: 2px solid var(--indigo-700);
  min-height: 64px; transition: border-color .2s, background .2s;
}
.opp.turn { border-color: var(--marigold); background: #1d2a48; }
.opp.out { opacity: .55; }
.opp .nm { font-weight: 600; font-size: 14px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .sub { font-size: 12px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.opp .backs { display: flex; margin-top: 4px; height: 31px; }
.opp .backs .card + .card { margin-left: -12px; }
.opp .dealer { color: var(--marigold); font-weight: 600; }

.bubble {
  /* centred over the seat it belongs to, so it never hides under the sticky top bar */
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--ivory); color: var(--ink); font-weight: 600; font-size: 15px;
  padding: 4px 12px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 12px rgb(0 0 0 / .35);
  animation: bubble 2.4s var(--ease-out) forwards;
}
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  10%, 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

.center { display: grid; align-content: center; justify-items: center; gap: 12px; min-height: 0; }
.piles { display: flex; align-items: flex-end; justify-content: center; gap: clamp(14px, 5vw, 36px); }
.pile { display: grid; justify-items: center; gap: 6px; background: none; border: 0; padding: 0; color: inherit; }
.pile .cap { font-size: 13px; color: var(--text-dim); text-align: center; line-height: 1.3; }
.pile .cap b { color: var(--ivory); font-weight: 600; }
button.pile { border-radius: 12px; padding: 6px; }
button.pile:not(:disabled):hover .card { transform: translateY(-4px); }
button.pile .card { transition: transform .15s var(--ease-out); }
button.pile.can .card { outline: 3px solid var(--marigold); outline-offset: 3px; }
.pile .stack { position: relative; }
.pile .stack .card.back:nth-child(2) { position: absolute; left: 3px; top: -3px; z-index: -1; }
.pile .empty-slot {
  width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: var(--radius-card);
  border: 2px dashed var(--line);
}
.joke .card { --w: calc(var(--cw) * .8); transform: rotate(-6deg); }
.joke .cap .jk { color: var(--marigold); font-weight: 600; }

.prompt { text-align: center; min-height: 52px; }
.prompt .main { font-family: var(--font-display); font-size: 19px; font-weight: 500; margin: 0; }
.prompt .main.mine { color: var(--marigold); }
.prompt .sub { margin: 2px 0 0; color: var(--text-dim); font-size: 14px; }
.timer { width: min(320px, 80%); height: 6px; margin: 8px auto 0; background: var(--indigo-950); border-radius: 3px; overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--marigold); width: 100%; transform-origin: left; }
.timer.low i { background: var(--minus); }

.me { display: grid; gap: 10px; }
.me-bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--text-dim); }
.me-bar b { color: var(--ivory); font-family: var(--font-display); font-weight: 500; }
.hand {
  display: flex; justify-content: center; align-items: flex-end; gap: 6px;
  min-height: calc(var(--cw) * 1.4 + 22px); padding-bottom: 14px;
}
.hand .grp { display: flex; gap: 3px; position: relative; padding-bottom: 6px; }
.hand .grp.pair::after {
  /* pair bracket: shows which cards already make a pair */
  content: ""; position: absolute; left: 4px; right: 4px; bottom: -4px; height: 4px; border-radius: 2px;
  background: var(--marigold);
}
.hand .grp.pair + .grp { margin-left: 4px; }
button.card { transition: transform .14s var(--ease-out), box-shadow .14s; }
button.card:hover:not(:disabled) { transform: translateY(-5px); }
button.card[aria-pressed="true"] { transform: translateY(-16px); box-shadow: 0 2px 0 #cbbd98, 0 0 0 3px var(--marigold), 0 10px 16px rgb(0 0 0 / .35); }
button.card:disabled { cursor: default; }
.hand-note { text-align: center; color: var(--text-dim); margin: 0; align-self: center; }

.actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.reacts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.reacts .btn { min-height: 44px; padding: 4px 2px; font-size: 14px; font-weight: 400; white-space: nowrap; }

details.log { font-size: 14px; color: var(--text-dim); }
details.log summary { min-height: 44px; display: flex; align-items: center; justify-content: center; }
details.log ol { margin: 0; padding: 0 0 0 20px; max-height: 180px; overflow: auto; }

@media (min-width: 760px) {
  :root { --cw: 82px; }
  .opponents { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .actions { grid-template-columns: 1fr auto; align-items: center; }
}
@media (max-height: 700px) and (max-width: 500px) {
  :root { --cw: clamp(44px, 12.5vw, 60px); }
  .opp .backs { display: none; }
  .opp { min-height: 0; }
}

/* ---------- round result ---------- */

.result {
  /* full sheet under the sticky top bar; opaque so the table underneath never ghosts through */
  position: fixed; inset: 0; z-index: 30; overflow: auto; overscroll-behavior: contain;
  background: var(--indigo-950);
  padding: 80px 16px calc(24px + env(safe-area-inset-bottom));
}
.result-inner { max-width: 640px; margin: 0 auto; display: grid; gap: 16px; }
.result #resTitle { font-family: var(--font-display); font-weight: 600; font-size: 28px; margin: 0; line-height: 1.2; }
.settings h3 { font-family: var(--font-display); font-weight: 500; font-size: 18px; margin: 0; }
.result #resTitle em { font-style: normal; color: var(--marigold); }
.result .why { margin: 4px 0 0; color: var(--text-dim); }
.win-pairs { display: flex; flex-wrap: wrap; gap: 14px; }
.win-pairs .pr { display: flex; gap: 4px; padding: 8px 8px 12px; border-radius: 10px; background: var(--indigo-800); position: relative; }
.win-pairs .pr::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--marigold); }
.flip-in .card { animation: flip .5s var(--ease-out) both; }
.flip-in .pr:nth-child(2) .card { animation-delay: .18s; }
.flip-in .pr:nth-child(3) .card { animation-delay: .36s; }
@keyframes flip { from { transform: rotateY(90deg) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.payouts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.payouts li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 8px 12px; background: var(--indigo-800); border-radius: var(--radius-ui);
}
.payouts .hand-row { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.payouts .delta { font-family: var(--font-num); font-weight: 600; font-size: 18px; }
.payouts .delta.plus { color: var(--plus); }
.payouts .delta.minus { color: var(--minus); }
.payouts .total { color: var(--text-dim); font-size: 14px; min-width: 64px; text-align: right; }
.minus-chips { color: var(--minus); }
.result-actions { display: grid; gap: 8px; }
.result details summary { min-height: 44px; display: flex; align-items: center; color: var(--text-dim); }
details > summary::before {
  content: ""; width: 0; height: 0; margin-right: 10px; flex: none;
  border: 5px solid transparent; border-right: 0; border-left: 7px solid var(--marigold);
  transition: transform .15s var(--ease-out);
}
details[open] > summary::before { transform: rotate(90deg); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:hover { color: var(--ivory); }

.history { margin: 0; padding-left: 20px; color: var(--text-dim); font-size: 14px; }

/* ---------- dialogs ---------- */

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--indigo-800); color: var(--ivory);
}
dialog::backdrop { background: rgb(8 12 24 / .7); }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--indigo-700);
  position: sticky; top: 0; background: var(--indigo-800);
}
.dialog-head h2 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 20px; }
.rules-body { padding: 4px 18px 18px; }
.rules-body h3 { font-family: var(--font-display); font-weight: 500; font-size: 16px; color: var(--marigold); margin: 18px 0 4px; }
.rules-body p, .rules-body ul, .rules-body ol { margin: 0; color: var(--ivory); }
.rules-body ul, .rules-body ol { padding-left: 20px; }
.rules-body .lead { font-family: var(--font-display); font-size: 18px; margin-top: 14px; }

.loading-view, .error-view { margin: auto; padding: 40px 16px; text-align: center; color: var(--text-dim); }

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