:root {
  color-scheme: light;
  --paper: #f3efe6;
  --white: #fbf8f1;
  --ink: #18362c;
  --muted: #525e54;
  --line: #d8d2c5;
  --green: #1c493a;
  --felt-text: #fcf6e7;
  --felt-muted: #d1dfcd;
  --gold: #ecd7a0;
  --red: #a1352c;
  --heading: "Songti SC", "Noto Serif CJK SC", "STSong", Georgia, serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 16px/1.5 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, summary:focus-visible { outline: 3px solid #b36924; outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.shell { width: min(1240px, calc(100% - 64px)); margin-inline: auto; }
.topline { border-bottom: 1px solid var(--line); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 65px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: .05em; }
.brand-mark {
  display: grid; place-items: center; width: 33px; height: 38px; font: 23px/1 Georgia, serif;
  border: 1px solid var(--green); border-radius: 5px; background: var(--green); color: var(--gold);
  box-shadow: inset 0 0 0 2px var(--green), inset 0 0 0 3px #b7a06f; transform: rotate(-8deg);
}
.help {
  min-height: 44px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px;
  font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 6px;
}
.help:hover, .restart:hover { background: #e9e4d7; }
.top-actions { display: flex; align-items: center; gap: 3px; }
.guide-button { border: 1px solid var(--line); background: var(--white); }
.help span { border: 1px solid #6b7669; border-radius: 50%; font: 700 12px/16px var(--sans); width: 17px; height: 17px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 31px 0 23px; }
h1 { font: 900 clamp(2.6rem, 5.2vw, 4.45rem)/1.04 var(--heading); letter-spacing: .015em; }
.intro p { color: var(--muted); margin-top: 11px; }
.stats { display: flex; gap: 22px; align-items: end; padding-bottom: 2px; }
.stats div { padding-left: 20px; min-width: 108px; border-left: 1px solid #c9c2b2; }
.stats span { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; }
.stats strong { display: block; font: 700 30px/1.2 Georgia, serif; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font: 500 16px var(--sans); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, 302px); align-items: start; gap: 24px; padding-bottom: 28px; }
.game, .lessons { border: 1px solid var(--line); border-radius: 15px; background: var(--white); overflow: hidden; }
.game-heading { display: flex; align-items: center; justify-content: space-between; padding: 13px 21px 14px; min-height: 82px; }
.game-heading p { font-size: 14px; color: var(--muted); }
.game-heading h2 { font: 800 clamp(1.2rem, 2.5vw, 1.65rem)/1.25 var(--heading); margin-top: 3px; }
.restart {
  border: 1px solid var(--line); border-radius: 7px; background: transparent;
  font-size: 14px; font-weight: 650; min-height: 44px; padding: 0 12px; white-space: nowrap; margin-left: 8px;
}
.restart span { font-size: 19px; vertical-align: -1px; }
.felt {
  position: relative; isolation: isolate; color: var(--felt-text); min-height: 482px; overflow: hidden;
  display: flex; flex-direction: column; padding: 26px 32px 20px;
  background:
    repeating-linear-gradient(116deg, #ffffff06 0px 1px, transparent 1px 4px),
    repeating-linear-gradient(28deg, #0000000b 0px 1px, transparent 1px 3px),
    radial-gradient(ellipse at 49% 33%, #30644f 0%, #214e3d 51%, #15362c 100%);
  box-shadow: inset 0 3px 14px #172b2477, inset 0 -2px 14px #172b2488;
}
.felt::before {
  position: absolute; inset: 10px; border: 1px solid #dbc28c55; border-radius: 11px;
  content: ""; pointer-events: none; z-index: -1;
}
.seats { display: flex; justify-content: space-between; gap: 10px; }
.seat {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px 8px 8px;
  min-width: 153px; border: 1px solid #b9d0b745; border-radius: 9px; background: #112c235f;
}
.seat-active { border-color: var(--gold); background: #172f24; }
.seat-mark {
  font: 25px/1 Georgia, serif; color: #eae7ce; width: 39px; height: 40px; flex: 0 0 auto; display: grid;
  place-items: center; border-radius: 6px; border: 1px solid #adbf9d5e; background: #2d5748;
}
.seat-mark.landlord { color: #f3deb1; border-color: #e6be824f; background: #805233; }
.seat-info strong, .seat-info > span { display: block; white-space: nowrap; }
.seat-info strong { font-size: 15px; line-height: 1.2; }
.seat-info small { font-size: 12px; color: var(--gold); }
.seat-info > span { color: var(--felt-muted); font-size: 13px; margin-top: 3px; }
.remaining { display: flex; align-items: baseline; gap: 4px; margin-left: auto; padding-left: 9px; }
.remaining b { color: var(--gold); font: 700 24px/1 Georgia, serif; }
.remaining span { font-size: 12px; color: var(--felt-muted); white-space: nowrap; }
.remaining i {
  position: relative; align-self: center; width: 10px; height: 14px; margin-right: 2px; border: 1px solid #cfb279;
  border-radius: 2px; background: #254c3c; transform: rotate(12deg); box-shadow: -2px 1px #163529, -3px 1px #cfb279;
}
.playarea {
  position: relative; display: grid; place-items: center; min-height: 163px; flex: 1;
}
.suit-mark {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -49%);
  width: 128px; height: 128px; display: grid; place-items: center; border: 1px solid #dfdbaa26; border-radius: 50%;
  color: #dddcb529; font: 104px/1 Georgia, serif; pointer-events: none;
  box-shadow: 0 0 0 6px #dfdbaa0e, 0 0 0 7px #dfdbaa18;
}
.table-status {
  position: relative; display: flex; align-items: center; flex-direction: column; gap: 6px;
  min-width: 170px; padding: 7px 9px; text-align: center;
}
.empty-play { font: 800 27px/1.2 var(--heading); text-shadow: 0 2px #203e33; }
.table-kicker, .table-type { color: var(--felt-muted); font-size: 14px; }
.table-type { font-weight: 600; color: var(--gold); }
.pile, .hand { display: flex; justify-content: center; align-items: center; }
.pile { gap: 4px; }
.player-area { text-align: center; }
.turn-label {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 25px;
  font-size: 14px; margin-bottom: 15px;
}
.role { background: #f4dfa6; color: #2b3e2e; padding: 2px 7px; border-radius: 4px; font: 800 12px/1.4 var(--sans); }
.turn-state { color: var(--gold); padding-left: 9px; border-left: 1px solid #c7d3aa64; }
.hand {
  container-type: inline-size; min-height: 111px; margin-inline: auto; gap: clamp(5px, 1.15vw, 11px);
}
.card {
  --card-w: 74px; position: relative; width: var(--card-w); aspect-ratio: .685;
  flex: 0 0 auto; padding: 0; display: block; border: 1px solid #f8ecd3; border-radius: 8px;
  background: linear-gradient(145deg, #fffdf6, #f6efdf 92%); color: #1c3431;
  box-shadow: 0 3px 0 #c5b99d, 0 6px 12px #102a2460;
  transition: translate 150ms, outline 150ms;
}
.card.red { color: #a6302c; }
.card[aria-pressed="true"] { translate: 0 -11px; outline: 3px solid #edc56b; outline-offset: 2px; }
.card:focus-visible { outline: 3px dashed #f5d681; outline-offset: 4px; }
@media (hover: hover) {
  button.card:not(:disabled):not([aria-pressed="true"]):hover { translate: 0 -5px; }
}
.card-corner { position: absolute; top: 5px; left: 7px; display: grid; place-items: center; gap: 0; }
.card-corner:last-child { top: auto; left: auto; bottom: 5px; right: 7px; transform: rotate(180deg); }
.card-corner b { font: 700 20px/1 Georgia, var(--sans); }
.card-corner i { font: normal 14px/.92 Georgia, serif; }
.card-pip { position: absolute; inset: 0; display: grid; place-items: center; font: 37px/1 Georgia, serif; }
.joker .card-pip { font: 800 16px/1 var(--heading); }
.pile .card { --card-w: 42px; border-radius: 5px; box-shadow: 0 2px 0 #c5b99d, 0 3px 6px #102a2460; }
.pile .card-corner { top: 4px; left: 4px; }
.pile .card-corner:last-child { top: auto; left: auto; bottom: 4px; right: 4px; }
.pile .card-corner b { font-size: 13px; }
.pile .card-corner i { font-size: 8px; }
.pile .card-pip { font-size: 21px; }
.pile .joker .card-pip { font-size: 10px; }
.hand-empty { color: var(--felt-muted); }
.feedback {
  color: var(--felt-muted); min-height: 25px; margin: 10px auto 9px; font-size: 14px;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.feedback.hint-text, .feedback.invalid { color: #ffe3ab; }
.actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.action { min-width: 89px; min-height: 45px; border-radius: 7px; font-weight: 700; }
.action.primary {
  min-width: 120px; background: #efd59a; border: 1px solid #e8c878; color: #273b2b; box-shadow: inset 0 -2px #c3a36388;
}
.action.primary:hover:not(:disabled) { background: #ffe8ad; }
.action.primary:disabled { background: #cbb77e; color: #334234; border-color: #cbb77e; }
.action.secondary { border: 1px solid #a4b59b91; background: #14382b89; color: #f2f0de; }
.action.secondary:hover:not(:disabled) { background: #284e3c; }
.action.secondary:disabled { opacity: .6; }
.public-strip {
  padding: 11px 21px; min-height: 60px; display: flex; align-items: center; gap: 17px;
  border-top: 1px solid #3e5545; flex-wrap: wrap;
}
.public-strip strong { font-size: 14px; }
.public-label { font-size: 13px; color: var(--muted); margin-left: 7px; white-space: nowrap; }
.unseen { display: flex; gap: 5px; flex-wrap: wrap; }
.unseen span {
  display: grid; place-items: center; min-width: 29px; min-height: 29px; padding: 1px 5px;
  border-radius: 4px; border: 1px solid #d3cbbb; background: #f1ede2; font-size: 14px; font-weight: 650;
}
.lessons { padding: 0 12px 12px; }
.lessons-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 19px 7px 15px;
}
.lessons-heading h2 { font: 800 22px/1.25 var(--heading); }
.lessons-heading > span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lesson {
  border: 1px solid transparent; border-top-color: #e7e1d4; background: transparent; border-radius: 0; display: grid;
  grid-template-columns: 30px 1fr auto; place-items: center start; gap: 8px;
  width: 100%; min-height: 63px; padding: 7px 8px; text-align: left;
}
.lesson.active { border: 1px solid #9fae97; background: #e8eee3; border-radius: 8px; }
.lesson:hover:not(.active) { background: #f0ece1; }
.lesson-number { color: #476251; font: 700 19px/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.lesson-copy strong, .lesson-copy small { display: block; }
.lesson-copy strong { font-size: 14px; line-height: 1.35; }
.lesson-copy small { color: var(--muted); font-size: 12px; margin-top: 4px; }
.lesson-state { font-size: 12px; color: #3a5545; justify-self: end; }
dialog {
  border: 1px solid #b8ad97; border-radius: 15px; background: var(--white); color: var(--ink);
  padding: 0; width: min(680px, calc(100% - 28px)); max-height: min(90dvh, 780px);
  box-shadow: 0 30px 85px #081a1480;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #10241bd1; }
.dialog-header {
  display: flex; align-items: start; justify-content: space-between; gap: 14px;
  padding: 22px 24px 17px; border-bottom: 1px solid #e4ded1;
}
.dialog-header h2 { font: 800 clamp(1.4rem, 4.7vw, 2.12rem)/1.2 var(--heading); }
.dialog-header h2:focus { outline: none; }
.dialog-tag { font-size: 14px; color: #45624e; display: block; margin-bottom: 4px; }
.review-tools { display: flex; align-items: center; gap: 8px; }
.outcome { font-size: 13px; font-weight: 700; border-radius: 20px; padding: 4px 10px; white-space: nowrap; }
.outcome.win { background: #dcebdc; color: #244f37; }
.outcome.loss { background: #f0dfd5; color: #7b3827; }
.dialog-body { overflow: auto; overscroll-behavior: contain; padding: 17px 24px; }
.dialog-body p { font-size: 15px; line-height: 1.6; margin-bottom: 10px; }
.review-callout { background: #e9eee4; border-radius: 7px; border-left: 3px solid #587d60; padding: 12px 13px; }
.review-callout p { margin: 4px 0 0; }
.your-reason { margin-top: 12px; }
.review-section { margin: 17px 0; }
.review-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 7px; }
.review-heading h3 { font: 800 21px/1.2 var(--heading); }
.move-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.move-tabs button { min-height: 44px; padding: 4px 9px; background: transparent; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; }
.move-tabs button[aria-pressed="true"] { background: #e3eddf; border-color: #90a489; }
.compare { padding: 0; list-style: none; margin: 0 0 6px; }
.compare li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border-bottom: 1px solid #ddd6c7; }
.compare small { color: var(--muted); font-size: 12px; }
p.method { font-size: 13px; color: var(--muted); }
.replay { border-top: 1px solid var(--line); }
.replay summary { cursor: pointer; padding: 11px 0; min-height: 44px; font-size: 14px; font-weight: 700; }
.replay ol, .help-copy ol { padding-left: 1.7em; }
.replay ol { font-size: 14px; margin-bottom: 0; }
.dialog-actions {
  display: flex; gap: 9px; justify-content: end; border-top: 1px solid var(--line);
  padding: 12px 24px; background: var(--white);
}
.dialog-actions button, .reason { min-height: 44px; border-radius: 7px; font-weight: 700; }
.solid-button { padding: 0 15px; background: #225540; border: 1px solid #225540; color: #fff9e9; }
.solid-button:hover { background: #153c2e; }
.light-button { padding: 0 13px; background: transparent; border: 1px solid var(--line); }
.light-button:hover, .reason:hover { background: #e8eee3; }
.reason-grid { display: grid; gap: 10px; padding-block: 5px 12px; }
.reason { padding: 10px 12px; background: #f6f3e8; border: 1px solid #d9d1be; text-align: left; }
.close { height: 44px; width: 44px; border: 1px solid var(--line); border-radius: 8px; background: none; font-size: 26px; line-height: 1; }
.help-copy li { margin-bottom: 8px; }
.training-stages { display: grid; gap: 12px; }
.training-stage {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  background: #f7f4ec; margin-top: 12px;
}
.training-stages .training-stage { margin-top: 0; }
.training-stage-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px; }
.training-stage h3 { font: 800 20px/1.25 var(--heading); }
.training-stage p { margin: 6px 0 0; }
.training-status { color: #42604e; font-size: 14px; font-weight: 700; }
.training-stage .training-exercises { color: var(--muted); font-size: 14px; }
.training-stage .light-button { margin-top: 9px; border-radius: 7px; min-height: 44px; font-weight: 700; }
p.training-note { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.result-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 13px 0; }
.result-tools .light-button {
  display: inline-flex; align-items: center; min-height: 44px; border-radius: 7px; font-weight: 700; cursor: pointer;
}
.import-label { position: relative; }
.import-label input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.import-label:focus-within { outline: 3px solid #b36924; outline-offset: 3px; }
#history ul { margin: 8px 0 0; padding: 0; list-style: none; }
#history li { display: flex; justify-content: space-between; gap: 9px; padding: 9px 1px; border-bottom: 1px solid var(--line); }
#history small { display: block; color: var(--muted); font-size: 13px; }
#history time { white-space: nowrap; color: var(--muted); font-size: 14px; }
@container (max-width: 570px) {
  .hand .card { --card-w: min(69px, calc((100cqi - 39px) / 7)); }
  .hand .card-corner b { font-size: clamp(12px, 3.65cqi, 20px); }
  .hand .card-corner i { font-size: clamp(9px, 2.5cqi, 14px); }
  .hand .card-pip { font-size: clamp(20px, 6.5cqi, 37px); }
  .hand .joker .card-pip { font-size: clamp(10px, 3.15cqi, 16px); }
}
@media (max-width: 950px) {
  .shell { width: calc(100% - 40px); }
  .workspace { gap: 15px; }
  .felt { padding-inline: 24px; }
}
@media (max-width: 750px) {
  .shell { width: calc(100% - 24px); }
  .topbar { min-height: 55px; }
  .intro { margin: 18px 0 14px; }
  .intro p { font-size: 14px; }
  .workspace { grid-template-columns: 1fr; }
  .lessons-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 7px; }
  .felt { min-height: 445px; }
}
@media (max-width: 490px) {
  h1 { font-size: 2.65rem; }
  .intro { display: block; }
  .intro p { margin-top: 5px; }
  .stats { margin-top: 12px; gap: 14px; }
  .stats div { min-width: auto; padding-left: 9px; }
  .stats span { font-size: 12px; }
  .stats strong { font-size: 22px; margin-top: 0; }
  .stats small { font-size: 13px; }
  .brand { gap: 7px; font-size: 14px; }
  .top-actions .help { padding-inline: 8px; }
  .game-heading { min-height: 72px; padding: 10px 12px; }
  .felt { min-height: 410px; padding: 16px 13px; }
  .felt::before { inset: 6px; }
  .seat { min-width: 0; width: min(150px, 50%); padding: 5px; gap: 5px; }
  .seat-mark { width: 29px; height: 36px; font-size: 21px; }
  .seat-info strong { font-size: 13px; }
  .seat-info small { font-size: 10px; }
  .remaining { padding-left: 3px; gap: 3px; }
  .remaining b { font-size: 20px; }
  .remaining i { display: none; }
  .playarea { min-height: 129px; }
  .suit-mark { width: 103px; height: 103px; font-size: 82px; }
  .hand { min-height: 98px; gap: 5px; }
  .hand:has(.card:nth-child(1):nth-last-child(-n+5)) .card { --card-w: min(59px, calc((100cqi - 24px) / 5)); }
  .hand .card-corner { left: 4px; top: 4px; }
  .hand .card-corner:last-child { left: auto; top: auto; bottom: 4px; right: 4px; }
  .hand:has(.card:nth-child(6)) { gap: 2px; }
  .hand:has(.card:nth-child(6)) .card { --card-w: calc((100cqi - 12px) / 7); border-radius: 4px; }
  .hand:has(.card:nth-child(6)) .card-corner:last-child { display: none; }
  .turn-label { margin-bottom: 6px; }
  .public-strip { padding: 8px 13px; gap: 5px 12px; }
  .dialog-header, .dialog-body, .dialog-actions { padding-inline: 14px; }
  .review-tools { flex-direction: column-reverse; align-items: end; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
