/* ============ Sik Wu · Mahjong Scorer ============ */
:root {
  --font-display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --font-ui: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-cjk: 'Noto Serif SC', 'Songti SC', 'SimSun', 'PMingLiU', 'Microsoft JhengHei', serif;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, .6);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-theme='night'] {
  color-scheme: dark;
  --bg: #0c1311;
  --bg-2: #111b17;
  --card: #16211d;
  --card-2: #1c2a24;
  --line: rgba(214, 181, 110, .16);
  --line-strong: rgba(214, 181, 110, .42);
  --ink: #f1eadb;
  --ink-2: #cfc7b5;
  --muted: #8f9b93;
  --gold: #d6b56e;
  --gold-2: #b8923f;
  --gold-ink: #231a06;
  --jade: #4fb58a;
  --jade-2: #2e8a66;
  --red: #d85a4f;
  --red-soft: rgba(216, 90, 79, .14);
  --gold-soft: rgba(214, 181, 110, .12);
  --jade-soft: rgba(79, 181, 138, .14);
  --backdrop: rgba(5, 9, 8, .72);
  --glow: radial-gradient(60% 50% at 20% 0%, rgba(79, 181, 138, .18), transparent 60%), radial-gradient(50% 40% at 90% 10%, rgba(214, 181, 110, .14), transparent 60%);
}

html[data-theme='day'] {
  color-scheme: light;
  --bg: #f4eee2;
  --bg-2: #ede5d4;
  --card: #fffdf8;
  --card-2: #f7f1e4;
  --line: rgba(120, 90, 30, .14);
  --line-strong: rgba(120, 90, 30, .4);
  --ink: #1c2622;
  --ink-2: #3c4a43;
  --muted: #727e77;
  --gold: #a8812a;
  --gold-2: #8a6a1e;
  --gold-ink: #fff9ec;
  --jade: #2c8863;
  --jade-2: #1f6b4c;
  --red: #b4322a;
  --red-soft: rgba(180, 50, 42, .1);
  --gold-soft: rgba(168, 129, 42, .12);
  --jade-soft: rgba(44, 136, 99, .12);
  --backdrop: rgba(40, 32, 18, .5);
  --shadow: 0 18px 50px -24px rgba(60, 40, 10, .35);
  --glow: radial-gradient(60% 50% at 20% 0%, rgba(44, 136, 99, .12), transparent 60%), radial-gradient(50% 40% at 90% 10%, rgba(168, 129, 42, .14), transparent 60%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gold); }
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
html { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.45;
  font-variant-numeric: lining-nums;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.cjk { font-family: var(--font-cjk); }

.bg-art {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    var(--glow),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(214, 181, 110, .035) 22px 23px),
    repeating-linear-gradient(45deg, transparent 0 22px, rgba(214, 181, 110, .035) 22px 23px),
    var(--bg);
}

/* ---------- Shell ---------- */
.app { max-width: 1240px; margin: 0 auto; padding: 14px 16px calc(32px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand > div { min-width: 0; }
.brand-tile { width: 48px; height: 67px; flex: none; line-height: 0; filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .45)); transition: transform .3s var(--ease); }
.brand-tile:hover { transform: rotate(-4deg) translateY(-2px); }
.logo-svg { width: 100%; height: 100%; display: block; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: .005em; line-height: 1; display: flex; align-items: baseline; gap: 6px; }
.brand-title .v { font-size: 38px; background: linear-gradient(180deg, #e0574a, #a1241c); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); }
.brand-title em { font-style: italic; font-weight: 600; background: linear-gradient(180deg, #ecd39a, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; position: relative; }
.brand-title em::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: -4px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .8; }
html[data-theme='day'] .brand-title em { background: linear-gradient(180deg, #b48c2e, #7f5f17); -webkit-background-clip: text; background-clip: text; }
.brand-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (min-width: 600px) { .brand-sub { font-size: 12.5px; white-space: nowrap; display: block; text-overflow: ellipsis; } }
.topbar-actions { display: flex; gap: 8px; flex: none; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; color: var(--ink-2); transition: .2s var(--ease);
}
.icon-btn[hidden] { display: none; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--gold); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn-text { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--gold); }

.layout { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
.layout > * { min-width: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); align-items: start; }
  .col-board { position: sticky; top: 16px; }
}

.notice {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  background: var(--red-soft); border: 1px dashed rgba(216, 90, 79, .4); color: var(--ink-2); font-size: 13px;
}
.notice strong { color: var(--red); letter-spacing: .14em; text-transform: uppercase; font-size: 12px; }

.eyebrow {
  font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 700;
  display: flex; align-items: center; gap: 12px;
}
.eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.eyebrow.no-line::after { display: none; }
.eyebrow .cjk { font-size: 14px; letter-spacing: 0; color: var(--gold); }

/* ---------- Board ---------- */
.board-head { margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.board-head .eyebrow { flex: 1; }
.streak { font-size: 11px; color: var(--gold); border: 1px solid var(--line-strong); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }

.table {
  display: grid; gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: 'top top top' 'left center right' 'bottom bottom bottom';
}
.seat {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; min-width: 0;
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
  box-shadow: var(--shadow);
}
.seat.pos-top { grid-area: top; }
.seat.pos-bottom { grid-area: bottom; }
.seat.pos-left { grid-area: left; flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 150px; }
.seat.pos-right { grid-area: right; flex-direction: column; align-items: flex-end; justify-content: space-between; text-align: right; min-height: 150px; }
.seat.is-dealer { border-color: var(--line-strong); background: linear-gradient(160deg, var(--card-2), var(--card)); }
.seat .wind {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  font-family: var(--font-cjk); font-size: 20px; font-weight: 700; color: var(--ink);
  background: var(--gold-soft); border: 1px solid var(--line);
}
.seat.is-dealer .wind { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--gold-ink); border-color: transparent; }
.seat .who { flex: 1; min-width: 0; }
.seat .name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.seat .score { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums lining-nums; }
.seat.is-lead .score { color: var(--gold); }
.seat .delta { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.pos { color: var(--jade); }
.delta.neg { color: var(--red); }
.delta.zero { color: var(--muted); }
.seat .badge-dealer {
  position: absolute; top: -9px; right: 14px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  background: var(--gold); color: var(--gold-ink); padding: 2px 8px; border-radius: 999px; font-weight: 800;
}
.seat.pos-left .badge-dealer, .seat.pos-right .badge-dealer { right: auto; left: 50%; transform: translateX(-50%); }
.seat.pos-left.is-dealer, .seat.pos-right.is-dealer { padding-top: 22px; }
.seat.pos-left .meta, .seat.pos-right .meta { flex-direction: column; align-items: flex-start; gap: 2px; }
.seat.pos-right .meta { align-items: flex-end; }
.seat .stack { display: flex; flex-direction: column; gap: 4px; }
.seat.pos-right .stack { align-items: flex-end; }

.center-disc {
  grid-area: center; align-self: center; justify-self: center;
  width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, var(--card-2), var(--card) 70%);
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 0 6px var(--bg), 0 0 0 7px var(--line), var(--shadow);
  position: relative;
}
.center-disc .ring { position: absolute; inset: 8px; border-radius: 50%; border: 1px dashed var(--line-strong); opacity: .7; }
.center-disc .rw { font-family: var(--font-cjk); font-size: 34px; font-weight: 700; color: var(--gold); line-height: 1; }
.center-disc .rl { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 6px; font-weight: 700; }
.center-disc.done .rw { color: var(--jade); }

.actions { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin-top: 16px; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: 14px; border: 1px solid transparent; padding: 11px 16px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 12.5px;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s, opacity .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; line-height: 1.2;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { padding: 16px 14px; min-height: 60px; }
.btn-sm { padding: 7px 12px; font-size: 11px; border-radius: 10px; }
.btn-primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--gold-ink); box-shadow: 0 12px 28px -14px var(--gold-2); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-outline { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--gold-soft); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--line-strong); }
.btn-danger { background: var(--red-soft); border-color: rgba(216, 90, 79, .5); color: var(--red); }
.btn-jade { background: linear-gradient(180deg, var(--jade), var(--jade-2)); color: #fff; }
.btn-block { width: 100%; }

/* ---------- History ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head .eyebrow { flex: 1; }
.history { display: flex; flex-direction: column; gap: 10px; }
.round-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); animation: rise .35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.round-card .rc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.round-card .rc-no { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.round-card .rc-sum { color: var(--muted); font-size: 13px; flex: 1; min-width: 160px; }
.round-card .rc-sum b { color: var(--ink); font-weight: 700; }
.round-card .rc-faan { font-weight: 800; color: var(--gold); font-size: 13px; white-space: nowrap; }
.round-card .rc-tiles { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 10px; }
.round-card .rc-items { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-mini { font-size: 11px; color: var(--ink-2); background: var(--gold-soft); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.chip-mini.limit { color: var(--gold); border-color: var(--line-strong); }
.rc-pay { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 12px; color: var(--muted); }
.rc-pay span b { font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 14px; }
.empty .cjk { font-size: 40px; color: var(--gold); display: block; margin-bottom: 8px; opacity: .8; }

/* ---------- Tiles ---------- */
.tile { display: inline-block; width: 34px; aspect-ratio: 60 / 84; line-height: 0; vertical-align: middle; border-radius: 6px; transition: transform .15s var(--ease), box-shadow .15s; position: relative; }
.tile .tile-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.tile.sm { width: 26px; }
.tile.lg { width: 44px; }
.tile.pick { cursor: pointer; }
.tile.pick:hover { transform: translateY(-3px); }
.tile.pick.used { opacity: .3; filter: grayscale(.6); pointer-events: none; }
.tile.removable { cursor: pointer; }
.tile.removable:hover { transform: translateY(-3px) rotate(-2deg); }
.tile .cnt { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--gold); color: var(--gold-ink); font-size: 10px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; line-height: 1; }

/* ---------- Modal ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(6px); animation: fade .25s var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: 100%; max-height: 92dvh; background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 26px 26px 0 0; display: flex; flex-direction: column; animation: sheet .35s var(--ease) both; box-shadow: 0 -20px 60px -30px rgba(0, 0, 0, .8);
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-grip { width: 48px; height: 4px; border-radius: 2px; background: var(--gold); margin: 12px auto 0; opacity: .8; }
.modal-head { padding: 12px 22px 14px; text-align: center; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.1; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.modal-body { padding: 18px 22px 24px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.modal-foot { padding: 12px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--bg-2); }
.modal-foot .btn { flex: 1; min-height: 52px; }
.modal-foot .btn.btn-outline { flex: .6; }
@media (min-width: 720px) {
  .modal-layer { align-items: center; padding: 24px; }
  .modal { max-width: 640px; max-height: min(88dvh, 920px); border-radius: 26px; border-bottom: 1px solid var(--line); animation: pop .3s var(--ease) both; }
  .modal.wide { max-width: 820px; }
  .modal-foot { border-radius: 0 0 26px 26px; }
  @keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ---------- Form pieces ---------- */
.fld { margin-bottom: 22px; }
.fld > .eyebrow { margin-bottom: 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.hint b { color: var(--ink-2); }
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips.one { grid-template-columns: 1fr; }
.chips.three { grid-template-columns: repeat(3, 1fr); }
.chips.four { grid-template-columns: repeat(4, 1fr); }
.chip {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); border-radius: 14px; padding: 12px 12px; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: .18s var(--ease); min-height: 48px; text-align: center; position: relative;
}
.chip .cjk { color: var(--gold); font-size: 15px; }
.chip small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.chip .col { display: flex; flex-direction: column; }
.chip:hover:not(:disabled) { border-color: var(--gold); }
.chip.on { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--gold-ink); border-color: transparent; box-shadow: 0 10px 24px -14px var(--gold-2); }
.chip.on .cjk, .chip.on small { color: var(--gold-ink); opacity: .85; }
.chip.on.jade { background: linear-gradient(180deg, var(--jade), var(--jade-2)); color: #fff; }
.chip.on.jade small { color: #fff; }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chip .fv { margin-left: auto; font-weight: 800; color: var(--gold); font-size: 13px; }
.chip.on .fv { color: var(--gold-ink); }
.chip.row { justify-content: flex-start; text-align: left; }

.input {
  width: 100%; border: 1px solid var(--line-strong); background: var(--card); border-radius: 14px; padding: 12px 14px; color: var(--ink); outline: none; font-size: 15px;
  transition: border-color .2s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.input[type=number]::-webkit-outer-spin-button, .input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.name-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.name-row .wind { width: 42px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-family: var(--font-cjk); font-size: 20px; font-weight: 700; background: var(--gold-soft); border: 1px solid var(--line); color: var(--gold); flex: none; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 54px; height: 54px; border-radius: 16px; border: 1px solid var(--line-strong); background: var(--card); font-size: 24px; color: var(--ink); }
.stepper button:hover { border-color: var(--gold); }
.stepper .val { flex: 1; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; }
.stepper .val small { display: block; font-family: var(--font-ui); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

.faan-box { display: flex; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--card); margin-bottom: 14px; }
.faan-box .fb-num { width: 110px; flex: none; display: grid; place-items: center; background: var(--gold-soft); text-align: center; padding: 14px 8px; border-right: 1px solid var(--line); }
.faan-box .fb-num .n { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; color: var(--gold); }
.faan-box .fb-num .n.dash { color: var(--muted); }
.faan-box .fb-num .l { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-top: 4px; }
.faan-box .fb-body { padding: 12px 14px; flex: 1; min-width: 0; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.faan-box .fb-body .items { display: flex; flex-wrap: wrap; gap: 6px; }
.faan-box.ok { border-color: var(--line-strong); }
.faan-box.limit .fb-num .n { color: var(--jade); }

.hand-area { min-height: 72px; border: 1px dashed var(--line-strong); border-radius: 16px; padding: 10px; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; background: var(--card); }
.hand-area.empty-hand { justify-content: center; color: var(--muted); font-size: 13px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette .tile { width: 42px; }
@media (min-width: 720px) { .palette .tile { width: 48px; } }
.pal-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 8px; }
.pal-head .eyebrow { flex: 1; }
.cond-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.pay-preview { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.pay-preview .row { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pay-preview .row:last-child { border-bottom: 0; }
.pay-preview .row .nm { display: flex; gap: 10px; align-items: center; }
.pay-preview .row .nm .cjk { color: var(--gold); font-size: 14px; }
.pay-preview .row .amt { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px; }
.pay-preview .total { padding: 8px 14px; font-size: 12px; color: var(--muted); background: var(--gold-soft); display: flex; justify-content: space-between; }

.warn { background: var(--red-soft); border: 1px solid rgba(216, 90, 79, .4); color: var(--red); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.info { background: var(--jade-soft); border: 1px solid rgba(79, 181, 138, .4); color: var(--jade); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.scan-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 8px; margin-top: 14px; }
.scan-row .btn { min-height: 50px; }
.ico { width: 18px; height: 18px; flex: none; }
.with-ico { display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; display: inline-block; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.key-row { display: flex; gap: 8px; align-items: center; }
.key-row .input { flex: 1; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* ---------- Recap ---------- */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.rank .pos { font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--gold); width: 26px; text-align: center; }
.rank.first { border-color: var(--line-strong); background: linear-gradient(150deg, var(--card-2), var(--card)); }
.rank .who { flex: 1; min-width: 0; }
.rank .who .name { font-weight: 700; font-size: 16px; }
.rank .who .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rank .score { font-family: var(--font-display); font-weight: 700; font-size: 34px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.stat .k { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stat .v { font-family: var(--font-display); font-weight: 700; font-size: 26px; margin-top: 2px; line-height: 1.1; }
.stat .v small { font-family: var(--font-ui); font-size: 12px; color: var(--muted); font-weight: 500; }
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.chart svg { width: 100%; height: auto; aspect-ratio: 3 / 1; display: block; }
.chart-line { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: drawLine 1.4s var(--ease) forwards; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.stat-row { display: flex; flex-wrap: wrap; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.stat-row span { white-space: nowrap; }
.rank.rk .who { display: block; min-width: 0; }
.rank.rk .who .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-score { text-align: right; flex: none; }
.rk-score .delta { font-size: 12px; font-weight: 700; margin-top: 2px; }
.rank .who { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Rules ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2); border-radius: 999px; padding: 8px 14px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; white-space: nowrap; flex: 1 1 auto; }
.tab.on { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.rule { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 10px; }
.rule .r-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.rule .r-name { font-weight: 700; font-size: 15px; }
.rule .r-name .cjk { color: var(--gold); margin-left: 6px; font-weight: 600; }
.rule .r-faan { background: var(--gold); color: var(--gold-ink); border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 800; letter-spacing: .1em; white-space: nowrap; }
.rule .r-faan.limit { background: var(--jade); color: #fff; }
.rule .r-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.rule .r-ex { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 10px; }
.rule .r-ex .gap { width: 8px; }
.table-faan { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px 16px; }
.table-faan .tcol { display: flex; flex-direction: column; }
.table-faan .tcol > div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.table-faan .tcol > div:last-child { border-bottom: 0; }
.table-faan .tcol > div b { color: var(--gold); font-variant-numeric: tabular-nums; }
.table-faan .tcol > div.limit b { color: var(--jade); }

.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.toggle-row .t { font-weight: 600; font-size: 14px; }
.toggle-row .t small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.toggle-row.modified { border-color: var(--line-strong); background: var(--gold-soft); }
.switch { width: 48px; height: 28px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--bg); position: relative; flex: none; transition: .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: .2s var(--ease); }
.switch.on { background: var(--jade); border-color: transparent; }
.switch.on::after { left: 23px; background: #fff; }

.danger-zone { border: 1px dashed rgba(216, 90, 79, .5); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 100; max-width: calc(100vw - 32px); text-align: center; box-sizing: border-box; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 36px; line-height: 1.7; }
.foot .cjk { color: var(--gold); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.small-list { font-size: 13px; color: var(--muted); line-height: 1.6; padding-left: 18px; margin: 6px 0 0; }
.small-list b { color: var(--ink-2); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { color: var(--ink); text-align: right; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }

@media (max-width: 400px) {
  .icon-btn { width: 38px; height: 38px; border-radius: 12px; }
  .topbar-actions { gap: 6px; }
  .brand { gap: 10px; }
  .brand-tile { width: 42px; height: 59px; }
  .seat .score { font-size: 32px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .btn:first-child { grid-column: 1 / -1; }
  .brand-title { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { *:not(.keep-motion) { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* ================= Premium layer ================= */

/* Avatars — seal / medallion in the player's colour */
.avatar { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); }
.avatar svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar b { position: relative; z-index: 1; font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; color: var(--c); filter: brightness(.8) saturate(1.2); }
.avatar.xs { width: 22px; height: 22px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.avatar.xs b { font-size: 11px; }
.avatar.lg { width: 68px; height: 68px; }
.avatar.lg b { font-size: 34px; }
.seat .avatar { width: 46px; height: 46px; }
html[data-theme='day'] .avatar { filter: drop-shadow(0 6px 10px rgba(80,60,20,.28)); }
.id-stack { position: relative; flex: none; display: inline-block; }
.wind-tag { position: absolute; right: -9px; bottom: -7px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 7px; display: grid; place-items: center;
  font-family: var(--font-cjk); font-weight: 700; font-size: 13px; color: var(--ink); background: var(--card-2); border: 1px solid var(--line-strong); box-shadow: 0 4px 10px -6px rgba(0,0,0,.6); }
.wind-tag.dealer { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: var(--gold-ink); border-color: transparent; }
.seat.pos-left .id-stack, .seat.pos-right .id-stack { margin-bottom: 6px; }
.rank .who { display: flex; align-items: center; gap: 12px; }
/* Score flash */
@keyframes flashWin { 0% { box-shadow: 0 0 0 0 rgba(214,181,110,.0); } 25% { box-shadow: 0 0 0 4px rgba(214,181,110,.55), 0 0 40px rgba(214,181,110,.35); border-color: var(--gold); } 100% { box-shadow: var(--shadow); } }
@keyframes flashLose { 0%,100% { background: var(--card); } 30% { background: color-mix(in srgb, var(--red) 18%, var(--card)); } }
.seat.flash-win { animation: flashWin 1.3s var(--ease); }
.seat.flash-win .score { animation: popNum .6s var(--ease); }
.seat.flash-lose { animation: flashLose 1.2s var(--ease); }
@keyframes popNum { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
.seat .badge-dealer { will-change: transform; }

/* Tile 3D press */
.tile.pick, .tile.removable { transform-style: preserve-3d; perspective: 300px; }
.tile.pick::after, .tile.removable::after { content: ''; position: absolute; inset: 2% 3% 6% 3%; border-radius: 14%; background: linear-gradient(120deg, rgba(255,255,255,.55), rgba(255,255,255,0) 45%); pointer-events: none; opacity: 0; transition: opacity .18s; }
.tile.pick:hover::after { opacity: .8; }
.tile.pick:active, .tile.removable:active { transform: translateY(2px) scale(.94) rotateX(8deg) !important; transition-duration: .06s; }
.tile.pick:active .tile-svg { filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
@keyframes tileIn { from { opacity: 0; transform: translateY(-10px) rotate(-6deg) scale(.9); } to { opacity: 1; transform: none; } }
.hand-area .tile { animation: tileIn .28s var(--ease) both; }

/* Ticket cards */
.round-card.ticket { display: grid; grid-template-columns: 74px 1fr; padding: 0; overflow: hidden; }
.ticket .stamp { position: relative; background: linear-gradient(180deg, var(--card-2), var(--card)); border-right: 1px dashed var(--line-strong); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 14px 6px; }
.ticket .stamp::before, .ticket .stamp::after { content: ''; position: absolute; right: -7px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); }
.ticket .stamp::before { top: -8px; } .ticket .stamp::after { bottom: -8px; }
.ticket .st-l { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.ticket .st-n { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; color: var(--gold); }
.ticket .st-w { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.ticket .tk-body { padding: 14px 16px; min-width: 0; }
.ticket.is-draw .stamp { opacity: .7; }
.ticket .rc-faan small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ticket .rc-faan.muted { color: var(--muted); }
.ticket .rc-pay { gap: 6px; }
.ticket .pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); font-size: 12px; color: var(--ink-2); }
.ticket .pill .pn { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket .pill b { font-variant-numeric: tabular-nums; }
.ticket .pill.pos { border-color: rgba(79,181,138,.5); } .ticket .pill.pos b { color: var(--jade); }
.ticket .pill.neg b { color: var(--red); } .ticket .pill.zero b { color: var(--muted); }

/* Empty state art */
.empty-art { display: flex; justify-content: center; gap: 3px; margin-bottom: 14px; perspective: 500px; }
.empty-art .tile { width: 24px; animation: floatTile 3.4s ease-in-out infinite; animation-delay: calc(var(--i) * -.22s); opacity: .9; }
@keyframes floatTile { 0%,100% { transform: translateY(0) rotateX(0); } 50% { transform: translateY(-6px) rotateX(12deg); } }

/* Splash */
.splash { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; background: var(--bg); opacity: 0; pointer-events: none; }
.splash.go { opacity: 1; pointer-events: auto; }
.splash.out { opacity: 0; transition: opacity .45s var(--ease); }
.splash-tile { width: 92px; height: 129px; transform-style: preserve-3d; animation: flipIn .9s var(--ease) both; filter: drop-shadow(0 24px 30px rgba(0,0,0,.5)); }
.splash-tile svg { width: 100%; height: 100%; display: block; }
@keyframes flipIn { 0% { transform: rotateY(180deg) scale(.6); opacity: 0; } 60% { transform: rotateY(0) scale(1.06); opacity: 1; } 100% { transform: none; } }
body.locked .app { filter: blur(6px); pointer-events: none; user-select: none; }

/* Lock screen */
.lock { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg); opacity: 0; transition: opacity .5s var(--ease); overflow: hidden; }
.lock.in { opacity: 1; }
.lock[hidden] { display: none !important; }
.splash[hidden] { display: none !important; }
.lock.open { opacity: 0; transform: scale(1.04); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.lk-bg { position: absolute; inset: 0; pointer-events: none; }
.lk-tile { position: absolute; left: var(--x); bottom: -120px; width: calc(46px * var(--s)); opacity: 0; animation: lkRise var(--d) linear infinite; animation-delay: calc(var(--i) * -1.3s); filter: blur(calc((1.2 - var(--s)) * 2px)); }
.lk-tile svg { width: 100%; display: block; }
@keyframes lkRise { 0% { transform: translateY(0) rotate(-8deg); opacity: 0; } 10% { opacity: .35; } 90% { opacity: .25; } 100% { transform: translateY(-120vh) rotate(14deg); opacity: 0; } }
.lk-glow { position: absolute; inset: 0; background: radial-gradient(50% 40% at 50% 35%, rgba(214,181,110,.22), transparent 70%), radial-gradient(40% 30% at 20% 90%, rgba(79,181,138,.18), transparent 70%); pointer-events: none; }
.lk-card { position: relative; width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.lk-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lk-logo { width: 96px; height: 134px; animation: flipIn 1s var(--ease) both; filter: drop-shadow(0 24px 30px rgba(0,0,0,.5)); }
.lk-logo svg { width: 100%; height: 100%; }
.lk-title { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; margin-top: 10px; display: flex; }
.lk-title span { display: inline-block; opacity: 0; animation: letter .6s var(--ease) both; animation-delay: calc(.5s + var(--i) * .05s); background: linear-gradient(180deg, #f1e3b8, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lk-title span:first-child { background: linear-gradient(180deg, #e0574a, #a1241c); -webkit-background-clip: text; background-clip: text; font-size: 52px; margin-right: 4px; }
@keyframes letter { from { opacity: 0; transform: translateY(14px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.lk-sub { color: var(--gold); letter-spacing: .5em; font-size: 14px; opacity: 0; animation: letter .7s var(--ease) 1.1s both; margin-left: .5em; }
.lk-tag { color: var(--muted); font-size: 13px; opacity: 0; animation: letter .7s var(--ease) 1.3s both; }
.lk-pin { width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0; animation: letter .7s var(--ease) 1.4s both; }
.lk-pin.shake { animation: shake .45s var(--ease); }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.lk-dots { display: flex; gap: 14px; }
.lk-dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); transition: .18s var(--ease); }
.lk-dots i.on { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 12px var(--gold); transform: scale(1.1); }
.lk-dots i.err { background: var(--red); border-color: var(--red); box-shadow: none; }
.lk-hint { color: var(--muted); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; }
.lk-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.lk-key { height: 64px; border-radius: 20px; border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 80%, transparent); backdrop-filter: blur(8px); color: var(--ink); font-family: var(--font-display); font-size: 28px; font-weight: 600; font-variant-numeric: lining-nums; transition: .12s var(--ease); }
.lk-key:active { transform: scale(.94); background: var(--gold-soft); border-color: var(--gold); }
.lk-key.del { font-family: var(--font-ui); font-size: 20px; color: var(--muted); }
.lk-enter { min-width: 220px; }
.lk-foot { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; text-align: center; }

/* Game over */
.modal.celebrate { position: relative; overflow: hidden; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 10px; align-items: end; margin-top: 6px; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: rise2 .7s var(--ease) both; }
.pod-1 { animation-delay: .25s; } .pod-2 { animation-delay: .1s; } .pod-3 { animation-delay: .4s; }
@keyframes rise2 { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.pod-top { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pod-name { font-weight: 700; font-size: 14px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1; }
.pod-1 .pod-score { font-size: 40px; color: var(--gold); }
.pod-delta { font-size: 12px; font-weight: 700; }
.pod-bar { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 26px; color: var(--gold-ink); background: linear-gradient(180deg, var(--gold), var(--gold-2)); box-shadow: inset 0 2px 0 rgba(255,255,255,.35); }
.pod-1 .pod-bar { height: 96px; } .pod-2 .pod-bar { height: 68px; background: linear-gradient(180deg, #cfd3d8, #9aa1aa); } .pod-3 .pod-bar { height: 50px; background: linear-gradient(180deg, #d19a6a, #9c6a3f); }
.swatch { display: inline-grid; place-items: center; width: 24px; height: 32px; border-radius: 5px; border: 2px solid; font-family: var(--font-cjk); font-weight: 700; font-size: 14px; margin-right: 6px; }

/* ---------- iPad / tablet ---------- */
@media (min-width: 700px) and (max-width: 1100px) and (orientation: portrait) {
  .app { padding: 20px 28px; }
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 760px; margin: 0 auto; }
  .col-board { position: static; }
  .seat { padding: 18px 20px; }
  .seat .score { font-size: 46px; }
  .seat.pos-left, .seat.pos-right { min-height: 180px; }
  .center-disc { width: 136px; height: 136px; }
  .center-disc .rw { font-size: 42px; }
  .btn-lg { min-height: 68px; font-size: 14px; }
  .chip { min-height: 54px; font-size: 15px; }
  .palette .tile { width: 56px; }
  .modal { max-width: 720px; }
}
@media (min-width: 900px) and (orientation: landscape) and (max-width: 1400px) {
  .layout { grid-template-columns: minmax(440px, 540px) minmax(0, 1fr); }
  .seat .score { font-size: 44px; }
  .palette .tile { width: 52px; }
}
@media (hover: none) { .tile.pick:hover { transform: none; } .tile.pick::after { display: none; } }
@media (display-mode: standalone) { .app { padding-top: calc(14px + env(safe-area-inset-top)); } .lock { padding-top: env(safe-area-inset-top); } }

/* ================= Motion layer 2 ================= */
/* Coin flight */
.coin-layer { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.coin { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3c4, #e3c27a 45%, #a97f2a 100%); box-shadow: 0 0 10px rgba(227,194,122,.8), inset 0 -2px 0 rgba(0,0,0,.25); will-change: transform, opacity; }
.coin::after { content: ''; position: absolute; inset: 3px; border-radius: 50%; border: 1px solid rgba(120,80,20,.5); }
.seat.coin-hit { animation: coinHit .5s var(--ease); }
@keyframes coinHit { 0% { transform: scale(1); } 30% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(214,181,110,.35), 0 0 50px rgba(214,181,110,.45); } 100% { transform: scale(1); } }

/* Ripple */
.btn, .chip, .icon-btn, .tab, .lk-key, .seat { position: relative; overflow: hidden; }
.seat { overflow: visible; }
.seat .ripple { display: none; }
.ripple { position: absolute; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.35) 0%, rgba(255,255,255,.12) 40%, rgba(255,255,255,0) 70%); transform: scale(0); animation: ripple .55s var(--ease) forwards; pointer-events: none; }
.btn-primary .ripple, .chip.on .ripple { background: radial-gradient(circle, rgba(255,255,255,.55) 0%, rgba(255,255,255,.2) 40%, rgba(255,255,255,0) 70%); }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Modal close */
.modal-layer.closing .modal-backdrop { animation: fadeOut .28s var(--ease) forwards; }
.modal-layer.closing .modal { animation: sheetOut .3s var(--ease) forwards; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes sheetOut { to { transform: translateY(40px); opacity: 0; } }
@media (min-width: 720px) { .modal-layer.closing .modal { animation: popOut .26s var(--ease) forwards; } @keyframes popOut { to { transform: translateY(10px) scale(.98); opacity: 0; } } }

/* Tile just added + faan pop */
.hand-area .tile.just-added { animation: tileIn .28s var(--ease) both, wobble .5s var(--ease) .25s; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-5deg) translateY(-2px); } 60% { transform: rotate(3deg); } }
.fb-num .n.pop { animation: popNum .45s var(--ease); }
.faan-box.limit .fb-num { background: linear-gradient(135deg, rgba(79,181,138,.25), rgba(214,181,110,.25)); }
.faan-box.limit .fb-num .l { color: var(--jade); letter-spacing: .3em; }
.faan-box.shine { position: relative; overflow: hidden; }
.faan-box.shine::after { content: ''; position: absolute; top: -50%; bottom: -50%; width: 40%; left: -40%; background: linear-gradient(100deg, rgba(255,255,255,0), rgba(255,255,255,.35), rgba(255,255,255,0)); transform: skewX(-20deg); animation: shine 1.4s var(--ease) .1s 2; }
@keyframes shine { to { left: 140%; } }

/* Center disc spin / pulse */
.center-disc .rw { display: inline-block; }
.center-disc.spin .rw { animation: discSpin .9s var(--ease); }
@keyframes discSpin { 0% { transform: rotateY(0); } 50% { transform: rotateY(90deg); opacity: .3; } 51% { transform: rotateY(-90deg); } 100% { transform: rotateY(0); opacity: 1; } }
.center-disc.pulse { animation: discPulse 1.6s var(--ease) 2; }
@keyframes discPulse { 0%,100% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 7px var(--line), var(--shadow); } 50% { box-shadow: 0 0 0 6px var(--bg), 0 0 0 8px var(--gold), 0 0 40px rgba(214,181,110,.45); } }

/* Hot streak */
.streak.hot { background: linear-gradient(90deg, #ffb347, #ff6a3d, #ffb347); background-size: 200% 100%; color: #2b1200; border-color: transparent; font-weight: 800; animation: hotShift 1.8s linear infinite; box-shadow: 0 0 18px rgba(255,120,60,.45); }
@keyframes hotShift { to { background-position: 200% 0; } }

/* History slide-out */
.round-card.slide-out { animation: slideOut .28s var(--ease) forwards; }
@keyframes slideOut { to { transform: translateX(60px); opacity: 0; height: 0; margin: 0; padding: 0; } }

/* Ambient dust + parallax */
.dust { position: fixed; inset: 0; z-index: -1; pointer-events: none; width: 100%; height: 100%; }
@media (min-width: 960px) and (hover: hover) { .bg-art { background-attachment: fixed; } }

/* ================= Layer 3: lock polish, onboarding, player, confirm ================= */
.lk-logo { position: relative; z-index: 1; transition: transform .25s var(--ease); transform-style: preserve-3d; }
.lk-aura { position: absolute; left: 50%; top: 66px; width: 0; height: 0; pointer-events: none; }
.lk-aura i { position: absolute; left: 0; top: 0; width: 220px; height: 220px; margin: -110px 0 0 -110px; border-radius: 50%; border: 1px solid rgba(214,181,110,.35); animation: aura 4s var(--ease) infinite; }
.lk-aura i:nth-child(2) { animation-delay: 1.3s; } .lk-aura i:nth-child(3) { animation-delay: 2.6s; }
@keyframes aura { 0% { transform: scale(.55); opacity: 0; } 30% { opacity: .55; } 100% { transform: scale(1.5); opacity: 0; } }
.lk-brand { position: relative; }
.lk-title span { background: linear-gradient(100deg, #f1e3b8 0%, var(--gold-2) 40%, #fff6d8 50%, var(--gold-2) 60%, #f1e3b8 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; animation: letter .6s var(--ease) both, sheen 4s linear 1.6s infinite; animation-delay: calc(.5s + var(--i) * .05s), calc(1.6s + var(--i) * .04s); }
.lk-title span:first-child { background: linear-gradient(180deg, #e0574a, #a1241c); -webkit-background-clip: text; background-clip: text; animation: letter .6s var(--ease) both; }
@keyframes sheen { to { background-position: -250% 0; } }
.lk-sub span { display: inline-block; opacity: 0; animation: letter .5s var(--ease) both; animation-delay: calc(1s + var(--i) * .07s); }
.lk-key { position: relative; overflow: hidden; }
.lk-key::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 120%, rgba(214,181,110,.35), transparent 60%); opacity: 0; transition: opacity .2s; }
.lk-key:active::after { opacity: 1; }
.lock.open .lk-card { animation: zoomThrough .65s var(--ease) forwards; }
@keyframes zoomThrough { to { transform: scale(1.35); opacity: 0; filter: blur(6px); } }
body.entered .app { animation: enterApp .8s var(--ease) both; }
@keyframes enterApp { from { opacity: 0; transform: scale(.97) translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }

/* Onboarding */
.ob-hero { text-align: center; margin-bottom: 16px; }
.ob-hero .cjk { font-size: 44px; color: var(--gold); display: block; line-height: 1; letter-spacing: .2em; margin-left: .2em; }
.ob-hero p { color: var(--muted); margin-top: 8px; font-size: 14px; }
.ob-dealer { width: 48px; min-height: 46px; padding: 0; flex: none; font-family: var(--font-cjk); font-size: 18px; }
.name-row .avatar { width: 40px; height: 40px; }

/* Player detail */
.pd-score { display: flex; align-items: baseline; gap: 12px; justify-content: center; margin-bottom: 14px; }
.pd-score .score { font-family: var(--font-display); font-weight: 700; font-size: 56px; line-height: 1; }
.pd-score .delta { font-weight: 800; font-size: 16px; }
.mini-chart { width: 100%; height: 110px; display: block; }
.modal-head h2 .avatar { vertical-align: -4px; margin-right: 4px; }

/* Confirm flow */
.cf-flow { display: grid; grid-template-columns: 1fr auto 1.2fr; gap: 10px; align-items: center; }
.cf-from, .cf-to { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 6px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.cf-from { flex-direction: row; justify-content: flex-start; gap: 10px; text-align: left; padding: 8px 10px; }
.cf-from.idle { opacity: .45; }
.cf-from .cf-name { flex: 1; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-from b { font-weight: 800; }
.cf-flow > .cf-from:nth-child(1), .cf-flow > .cf-from:nth-child(2), .cf-flow > .cf-from:nth-child(3) { grid-column: 1; }
.cf-arrow { grid-column: 2; grid-row: 1 / span 3; width: 44px; align-self: center; animation: arrowPulse 1.4s var(--ease) infinite; }
.cf-arrow svg { width: 100%; display: block; }
@keyframes arrowPulse { 0%,100% { transform: translateX(0); opacity: .6; } 50% { transform: translateX(6px); opacity: 1; } }
.cf-to { grid-column: 3; grid-row: 1 / span 3; align-self: stretch; justify-content: center; border-color: var(--line-strong); background: linear-gradient(160deg, var(--card-2), var(--card)); }
.cf-to .cf-name { font-weight: 700; font-size: 15px; }

/* History filter + share */
.hist-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.hist-filter .tab { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 12px; padding: 6px 10px 6px 6px; }
.icon-mini { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; }
.icon-mini svg { width: 15px; height: 15px; }
.icon-mini:hover { color: var(--gold); border-color: var(--line-strong); }
.timer { color: var(--gold); font-variant-numeric: tabular-nums; }
.id-stack { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.id-stack:active .avatar { transform: scale(.93); }

/* iPad landscape: board locked, history scrolls */
@media (min-width: 900px) and (orientation: landscape) {
  .layout { align-items: start; }
  .col-board { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; scrollbar-width: none; }
  .col-board::-webkit-scrollbar { display: none; }
}

/* Theme: table felt */
html[data-theme='felt'] {
  color-scheme: dark;
  --bg: #0f3b2a; --bg-2: #124431; --card: #16503a; --card-2: #1b5c43;
  --line: rgba(230, 210, 150, .18); --line-strong: rgba(230, 210, 150, .45);
  --ink: #f6efdc; --ink-2: #d9d1b8; --muted: #a7b9a8;
  --gold: #e3c37a; --gold-2: #b8923f; --gold-ink: #231a06; --jade: #7fe0b0; --jade-2: #3fa678; --red: #ff7a6a;
  --red-soft: rgba(255, 122, 106, .16); --gold-soft: rgba(227, 195, 122, .14); --jade-soft: rgba(127, 224, 176, .16);
  --backdrop: rgba(5, 25, 15, .72); --shadow: 0 18px 50px -24px rgba(0, 0, 0, .7);
  --glow: radial-gradient(60% 50% at 20% 0%, rgba(227,195,122,.16), transparent 60%), radial-gradient(50% 40% at 90% 10%, rgba(127,224,176,.14), transparent 60%);
}
html[data-theme='felt'] .bg-art { background: var(--glow), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence 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 .09 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E"), var(--bg); }

/* ================= Lock screen v2 (premium) ================= */
.lock { justify-content: flex-start; padding: 0; }
.lk-glow { background: radial-gradient(70% 45% at 50% 22%, rgba(214,181,110,.28), transparent 70%), radial-gradient(50% 35% at 15% 95%, rgba(79,181,138,.2), transparent 70%), radial-gradient(40% 30% at 90% 80%, rgba(180,42,34,.14), transparent 70%); }
.lk-card { max-width: 460px; gap: 0; height: 100dvh; justify-content: space-between; padding: calc(28px + env(safe-area-inset-top)) 24px calc(70px + env(safe-area-inset-bottom)); }
.lk-brand { gap: 0; margin-top: 4vh; }
.lk-aura { top: 76px; }
.lk-aura i { width: 260px; height: 260px; margin: -130px 0 0 -130px; border-color: rgba(214,181,110,.28); }
.lk-logo { width: 104px; height: 146px; margin-bottom: 18px; filter: drop-shadow(0 30px 34px rgba(0,0,0,.6)) drop-shadow(0 0 40px rgba(214,181,110,.25)); }
.lk-title { font-size: clamp(46px, 13vw, 60px); letter-spacing: -.01em; }
.lk-title span { filter: drop-shadow(0 6px 14px rgba(0,0,0,.6)); }
.lk-title span:first-child { font-size: 1.22em; margin-right: 6px; }
.lk-sub { font-size: 15px; letter-spacing: .55em; margin: 10px 0 0 .55em; color: var(--gold); opacity: .9; }
.lk-tag { font-size: 12.5px; letter-spacing: .02em; margin-top: 10px; max-width: 320px; line-height: 1.5; }

.lk-pin { max-width: 340px; width: 100%; gap: 10px; padding: 22px 20px 20px; border-radius: 30px; position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015)); border: 1px solid rgba(214,181,110,.22);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.08); backdrop-filter: blur(14px); }
.lk-pin::before { content: ''; position: absolute; inset: 6px; border-radius: 24px; border: 1px solid rgba(214,181,110,.12); pointer-events: none; }
.lk-orn { display: flex; align-items: center; gap: 12px; width: 100%; color: var(--gold); font-size: 13px; letter-spacing: .4em; margin-left: .4em; }
.lk-orn i { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold)); opacity: .6; }
.lk-orn i:last-child { background: linear-gradient(90deg, var(--gold), transparent); }
.lk-dots { gap: 12px; margin-top: 4px; }
.lk-dots i { width: 26px; height: 34px; border-radius: 6px; border: 1px solid rgba(214,181,110,.35); background: rgba(255,255,255,.03); position: relative; transition: .22s var(--ease); }
.lk-dots i::after { content: ''; position: absolute; inset: 0; border-radius: 6px; background: linear-gradient(180deg, #fffbf1, #e9dcc0); transform: scaleY(0); transform-origin: bottom; transition: transform .22s var(--ease); }
.lk-dots i.on { border-color: #e9dcc0; box-shadow: 0 6px 14px -6px rgba(0,0,0,.7), 0 0 0 1px rgba(214,181,110,.3); transform: translateY(-2px); }
.lk-dots i.on::after { transform: scaleY(1); }
.lk-dots i.err { border-color: var(--red); box-shadow: 0 0 14px rgba(216,90,79,.6); }
.lk-dots i.err::after { background: linear-gradient(180deg, #ff8a7c, #b42a22); transform: scaleY(1); }
.lk-hint { font-size: 11px; letter-spacing: .22em; margin-top: 2px; }
.lk-pad { gap: 10px 14px; margin-top: 6px; }
.lk-key { height: 66px; border-radius: 50%; width: 66px; justify-self: center; border: 1px solid rgba(214,181,110,.35); background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.1), rgba(255,255,255,.02) 60%), rgba(12,19,17,.6); color: var(--ink); font-size: 26px; font-weight: 600; font-variant-numeric: lining-nums; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 8px 18px -10px rgba(0,0,0,.8); transition: transform .12s var(--ease), box-shadow .2s, border-color .2s, background .2s; backdrop-filter: none; }
.lk-key span { position: relative; z-index: 1; }
.lk-key:active { transform: scale(.92); border-color: var(--gold); background: radial-gradient(120% 120% at 30% 20%, rgba(214,181,110,.45), rgba(214,181,110,.12) 60%), rgba(12,19,17,.6); box-shadow: 0 0 0 4px rgba(214,181,110,.18), 0 0 24px rgba(214,181,110,.35); }
.lk-key::after { display: none; }
.lk-key.del { font-size: 18px; color: var(--muted); border-style: dashed; }
.lk-foot { font-size: 10.5px; letter-spacing: .14em; opacity: .7; bottom: calc(22px + env(safe-area-inset-bottom)); }
@media (max-height: 760px) { .lk-logo { width: 84px; height: 118px; margin-bottom: 10px; } .lk-brand { margin-top: 1vh; } .lk-tag { display: none; } .lk-key { height: 56px; width: 56px; font-size: 22px; } .lk-pin { padding: 16px 16px 14px; } .lk-dots i { width: 22px; height: 28px; } }
@media (min-width: 700px) { .lk-card { height: auto; min-height: 100dvh; justify-content: center; gap: 36px; } .lk-brand { margin-top: 0; } .lk-pin { max-width: 360px; } }
html[data-theme='day'] .lk-key { background: radial-gradient(120% 120% at 30% 20%, rgba(255,255,255,.9), rgba(255,255,255,.6) 60%), #fff; box-shadow: inset 0 1px 0 #fff, 0 8px 18px -10px rgba(80,60,20,.5); }
html[data-theme='day'] .lk-pin { background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,.35)); border-color: rgba(168,129,42,.35); }
html[data-theme='day'] .lk-dots i { background: rgba(255,255,255,.5); }

/* Lock v3: native keyboard */
.lk-input { position: absolute; opacity: 0; width: 1px; height: 1px; left: 50%; top: 50%; border: 0; padding: 0; margin: 0; font-size: 16px; caret-color: transparent; pointer-events: none; }
.lk-pin { cursor: pointer; padding: 22px 20px 22px; gap: 14px; }
.lk-dots { gap: 14px; margin-top: 6px; cursor: pointer; }
.lk-dots i { width: 44px; height: 58px; border-radius: 10px; }
.lk-dots i::after { border-radius: 10px; }
.lk-dots i.on::before { content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: #b42a22; z-index: 1; box-shadow: 0 1px 0 rgba(255,255,255,.6); }
.lock.typing .lk-dots i:not(.on) { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(214,181,110,.25); }
.lock.typing .lk-dots i:not(.on):first-of-type::after { content: ''; transform: none; background: none; }
.lk-dots i:not(.on)::after { background: none; }
.lk-hint { font-size: 11px; letter-spacing: .22em; }
.lock.typing .lk-hint { opacity: .5; }
@media (max-height: 560px) { .lk-brand { display: none; } .lk-card { justify-content: center; } }
.lk-card { height: auto; min-height: 100dvh; justify-content: center; gap: 30px; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.lk-brand { margin-top: 0; }

/* ================= Lock v4: hero polish ================= */
.lk-aura { display: none !important; }
.lk-brand { position: relative; isolation: isolate; }
.lk-sparks { position: absolute; inset: -40px -60px; pointer-events: none; z-index: 0; }
.lk-sparks i { position: absolute; left: var(--x); top: var(--y); width: 4px; height: 4px; border-radius: 50%; background: #f3dc9a; box-shadow: 0 0 8px 2px rgba(227,195,122,.6); opacity: 0; animation: spark var(--d) ease-in-out infinite; animation-delay: calc(var(--i) * -.37s); transform: scale(.4); }
.lk-sparks i:nth-child(odd) { width: 2.5px; height: 2.5px; }
@keyframes spark { 0%,100% { opacity: 0; transform: scale(.3) translateY(0); } 50% { opacity: .9; transform: scale(1) translateY(-10px); } }

.lk-logo-wrap { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; margin-bottom: 6px; }
.lk-logo { width: 104px; height: 146px; margin: 0; animation: flipIn 1s var(--ease) both, hover 5s ease-in-out 1s infinite; filter: drop-shadow(0 26px 30px rgba(0,0,0,.6)) drop-shadow(0 0 30px rgba(214,181,110,.22)); }
@keyframes hover { 0%,100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-8px) rotate(1.5deg); } }
.lk-reflect { width: 104px; height: 60px; overflow: hidden; margin-top: 4px; transform: scaleY(-1); opacity: .22; -webkit-mask-image: linear-gradient(180deg, transparent 10%, #000 100%); mask-image: linear-gradient(180deg, transparent 10%, #000 100%); filter: blur(1px); pointer-events: none; animation: hoverR 5s ease-in-out 1s infinite; }
.lk-reflect svg { width: 100%; height: 146px; display: block; }
@keyframes hoverR { 0%,100% { transform: scaleY(-1) translateY(0); } 50% { transform: scaleY(-1) translateY(8px); } }

.lk-title { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 8px; font-size: clamp(50px, 14vw, 66px); margin-top: 6px; }
.lk-title .lk-v { font-size: 1.25em; line-height: .9; background: linear-gradient(180deg, #ff8a74 0%, #d3473a 40%, #8f1a13 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(90,10,5,.6)) drop-shadow(0 12px 18px rgba(0,0,0,.6)); animation: letter .7s var(--ease) .4s both; }
.lk-title .lk-word { display: inline-block; position: relative; opacity: 0; animation: letterK .7s var(--ease) .7s both, foil 5s linear 1.8s infinite;
  background: linear-gradient(105deg, #b8923f 0%, #f6e7bf 22%, #d6b56e 38%, #fff8e1 50%, #d6b56e 62%, #f6e7bf 78%, #b8923f 100%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(90,65,10,.75)) drop-shadow(0 10px 16px rgba(0,0,0,.6)); }
@keyframes foil { 0% { background-position: 100% 0; } 100% { background-position: -200% 0; } }
@keyframes letterK { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.lk-title span { -webkit-text-stroke: 0; }
.lk-sub { display: flex; align-items: center; gap: 14px; margin: 14px 0 0; width: min(320px, 80vw); opacity: 1; animation: none; letter-spacing: 0; }
.lk-sub i { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, rgba(214,181,110,.8)); opacity: 0; animation: letter .8s var(--ease) 1.2s both; }
.lk-sub i:last-child { background: linear-gradient(90deg, rgba(214,181,110,.8), transparent); }
.lk-sub .cjk { color: var(--gold); font-size: 15px; letter-spacing: .5em; margin-left: .5em; white-space: nowrap; }
.lk-tag { opacity: 0; animation: letter .7s var(--ease) 1.5s both; }
.lock.open .lk-sparks { display: none; }

/* Lock title: V and M equal size, "ahjong" smaller & vertically centred on the M */
.lk-title { align-items: center; gap: 10px; }
.lk-title .lk-v { font-size: 1.3em; line-height: .85; }
.lk-title .lk-word { display: inline-flex; align-items: center; line-height: .85; }
.lk-title .lk-m { font-size: 1.3em; line-height: .85; }
.lk-title .lk-rest { font-size: .62em; letter-spacing: .02em; margin-left: 2px; transform: translateY(6%); }

.lk-title { gap: 0; }
.lk-title .lk-v { margin-right: -0.04em; }


.lk-title .lk-v { margin-right: 0.06em; }


/* Header brand title — matches lock screen */
.brand-title { display: flex; align-items: center; gap: 0; font-size: 26px; line-height: 1; }
.brand-title .v { font-size: 1.3em; line-height: .85; margin-right: .06em; background: linear-gradient(180deg, #ff8a74 0%, #d3473a 40%, #8f1a13 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 1px 0 rgba(90,10,5,.6)) drop-shadow(0 4px 8px rgba(0,0,0,.45)); }
.brand-title .word { display: inline-flex; align-items: center; line-height: .85; background: linear-gradient(105deg, #b8923f 0%, #f6e7bf 22%, #d6b56e 38%, #fff8e1 50%, #d6b56e 62%, #f6e7bf 78%, #b8923f 100%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: foil 6s linear infinite; filter: drop-shadow(0 1px 0 rgba(90,65,10,.7)) drop-shadow(0 4px 8px rgba(0,0,0,.45)); }
.brand-title .m { font-size: 1.3em; line-height: .85; font-style: normal; font-weight: 700; }
.brand-title em { font-size: .62em; font-style: normal; font-weight: 700; letter-spacing: .02em; margin-left: 2px; transform: translateY(6%); position: relative; display: inline-block; background: linear-gradient(105deg, #b8923f 0%, #f6e7bf 22%, #d6b56e 38%, #fff8e1 50%, #d6b56e 62%, #f6e7bf 78%, #b8923f 100%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: foil 6s linear infinite; }
.brand-title .m { display: inline-block; background: inherit; background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: foil 6s linear infinite; }
.brand-title em::after { bottom: -3px; left: 1px; right: 1px; }
html[data-theme='day'] .brand-title .word, html[data-theme='day'] .brand-title em { background: linear-gradient(105deg, #7f5f17 0%, #c9a24a 30%, #e6cf8a 50%, #c9a24a 70%, #7f5f17 100%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; filter: none; }
html[data-theme='day'] .brand-title .v { filter: none; }
@media (max-width: 400px) { .brand-title { font-size: 23px; } }

/* Lock title: gold hairline under "ahjong" (same as header) */
.lk-title .lk-rest { position: relative; }
.lk-title .lk-rest::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: -6px; height: 1.5px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: 0; animation: letterK .6s var(--ease) 1.3s both; }

.update-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translate(-50%, 80px); z-index: 120; display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; transition: transform .4s var(--ease); white-space: nowrap; }
.update-bar.show { transform: translate(-50%, 0); }


html, body { overflow-x: hidden; max-width: 100vw; }
.app { max-width: min(1240px, 100vw); }
.notice { word-break: break-word; }


.last-game { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.lg-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.lg-body { flex: 1; min-width: 0; }
.lg-body .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-body .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }


/* Keyboard mode: PIN input focused on touch devices — keep the PIN boxes above the keyboard. */
.lk-logo-wrap { max-height: 420px; transition: max-height .35s var(--ease), opacity .25s var(--ease), transform .35s var(--ease), margin .35s var(--ease); }
.lk-card { transition: transform .3s var(--ease); }
@media (hover: none) {
  .lock.kb { height: var(--vvh, 100dvh); top: var(--vvt, 0); bottom: auto; display: flex; align-items: center; justify-content: center; }
  .lock.kb .lk-logo-wrap { max-height: 120px; margin-bottom: 0; }
  .lock.kb .lk-logo { width: 64px; height: 90px; margin-bottom: 0; }
  .lk-logo { transition: width .3s var(--ease), height .3s var(--ease), transform .25s var(--ease); }
  .lock.kb .lk-sparks, .lock.kb .lk-tag, .lock.kb .lk-foot, .lock.kb .lk-reflect { display: none; }
  .lock.kb .lk-title { font-size: clamp(36px, 10vw, 46px); margin-top: 4px; }
  .lock.kb .lk-sub { margin-top: 8px; }
  .lock.kb .lk-brand { margin-top: 0; }
  .lock.kb .lk-card { min-height: 0; height: auto; justify-content: center; gap: 20px; padding: 12px 24px; }
  .lock.kb .lk-bg { opacity: .35; }
  @media (max-height: 480px) { .lock.kb .lk-logo-wrap { max-height: 0; opacity: 0; margin: 0; } .lock.kb .lk-sub { display: none; } }
}

/* Photo scan progress panel */
.scan-progress { margin-top: 10px; padding: 14px 16px; border-radius: 16px; border: 1px solid rgba(214,181,110,.35); background: linear-gradient(135deg, rgba(214,181,110,.12), rgba(27,107,80,.14)); position: relative; overflow: hidden; animation: fadeUp .3s var(--ease) both; }
.scan-progress::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.07) 50%, transparent 70%); background-size: 250% 100%; animation: foil 1.6s linear infinite; pointer-events: none; }
.scan-progress .sp-head { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.scan-progress .sp-head .spin { width: 18px; height: 18px; border-color: rgba(214,181,110,.3); border-top-color: var(--gold); }
.scan-progress .sp-time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.scan-progress .sp-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.scan-progress .sp-steps span { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.1); color: var(--muted); transition: all .3s var(--ease); }
.scan-progress .sp-steps span.done { border-color: rgba(42,157,120,.5); color: var(--jade-2, #6fcf9f); }
.scan-progress .sp-steps span.done::before { content: '✓ '; }
.scan-progress .sp-steps span.now { border-color: var(--gold); color: var(--gold); background: rgba(214,181,110,.1); animation: pulseStep 1s ease-in-out infinite; }
@keyframes pulseStep { 0%, 100% { box-shadow: 0 0 0 0 rgba(214,181,110,.35); } 50% { box-shadow: 0 0 0 5px rgba(214,181,110,0); } }
.scan-progress .hint { margin-top: 0; }
.scan-row.busy .btn { opacity: .5; }

/* Viewing an archived game while another is in progress */
.view-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 14px; border: 1px dashed rgba(214,181,110,.45); background: rgba(214,181,110,.08); font-size: 13px; color: var(--muted); animation: rise .35s var(--ease) both; }
.view-bar b { color: var(--ink); }
.view-bar .btn { white-space: nowrap; }

/* Give background-clip:text room for descenders (j, g) — the tight line-height otherwise clips them. */
.lk-title .lk-word, .brand-title .word { line-height: 1.1; padding-bottom: .12em; margin-bottom: -.12em; }
.lk-title .lk-rest, .brand-title em { line-height: 1.1; padding: 0 .06em .2em 0; margin-bottom: -.2em; }
.lk-title .lk-m, .lk-title .lk-v, .brand-title .m, .brand-title .v { line-height: 1; }
.lk-title .lk-rest::after { bottom: .02em; }
.brand-title em::after { bottom: .06em; }

/* Previous-game card: chip on the eyebrow line, time row */
.last-game .eyebrow.no-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.last-game .eyebrow .chip-mini { letter-spacing: 0; text-transform: none; white-space: nowrap; flex: none; }
.lg-body .sub.time { font-variant-numeric: tabular-nums; opacity: .85; }
.timer { font-variant-numeric: tabular-nums; }
.timer.stopped { opacity: .75; }

.ico-clock { vertical-align: -2px; margin-right: 1px; opacity: .8; }

/* Board head: text may wrap, never push the row wider than the viewport (iOS Safari lets the page pan otherwise) */
.board-head { flex-wrap: wrap; row-gap: 8px; }
.board-head .eyebrow { flex: 1 1 200px; min-width: 0; }
.eyebrow .eb-text { flex: 0 1 auto; min-width: 0; line-height: 1.5; }
.eyebrow::after { min-width: 14px; }
.app { overflow-x: clip; overflow-y: visible; }
/* html now carries the boot background, so body must stay transparent or it paints over the fixed .bg-art (z-index -1). */
body { background: transparent; }

/* Notice bar (same look as the update bar): important, actionable messages */
.notice-bar { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translate(-50%, 90px); z-index: 120; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; transition: transform .45s var(--ease), opacity .3s, bottom .3s var(--ease); width: min(calc(100vw - 24px), 440px); box-sizing: border-box; --nb-off: 0px; bottom: calc(16px + var(--nb-off) + env(safe-area-inset-bottom)); }
.notice-bar.show { transform: translate(-50%, 0); }
.notice-bar.hide { opacity: 0; transform: translate(-50%, 90px); }
.notice-bar .nb-ico { color: var(--gold); flex: none; }
.notice-bar .nb-txt { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.notice-bar .btn { white-space: nowrap; flex: none; }
.notice-bar .nb-x { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.notice-bar.warn { border-color: rgba(224, 87, 74, .5); }
.notice-bar.warn .nb-ico { color: #e0574a; }

/* Board head on phones: when there is an action button, give it its own full-width row */
.nw { white-space: nowrap; }
@media (max-width: 640px) {
  .board-head.has-btn { flex-direction: column; align-items: stretch; gap: 10px; }
  .board-head.has-btn .eyebrow { flex: 1 1 auto; }
  .board-head.has-btn > .btn { width: 100%; min-height: 44px; }
  .board-head .streak { margin-left: auto; }
}
.view-bar { flex-direction: column; align-items: flex-start; padding: 12px 14px 14px; margin-bottom: 14px; box-sizing: border-box; width: 100%; }
.view-bar .btn { align-self: stretch; text-align: center; justify-content: center; }
@media (min-width: 641px) { .view-bar { flex-direction: row; align-items: center; } .view-bar .btn { align-self: auto; } }

/* Modal: never taller than the visible viewport on iOS; chips never break mid-text */
.modal-layer { height: 100dvh; }
.modal { max-height: calc(100dvh - 16px); }
.modal-body { min-height: 0; }
.modal-foot { flex: none; }
.rc-items > *, .items > *, .faan-box .items > * { white-space: nowrap; }

/* Body pinned while a modal is open (iOS background-scroll fix) */
body.frozen { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
