:root {
  --paper: #F4EBD3;
  --paper-2: #FBF6EA;
  --ink: #2A2016;
  --muted: #CDBFA0;
  --amber: #FFB23F;
  --gold: #E9C35A;
  --seal: #C8372D;
  --brass: #C9A24A;
  --felt: #1F4A38;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #1A120C; color: var(--paper); font: 15px/1.6 var(--sans); overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }
button, select { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 6px; padding: 8px 14px; min-height: 40px; background: var(--paper); color: var(--ink); font-weight: 600; }
button.primary { background: var(--amber); color: var(--ink); }
button.ghost { background: rgba(244,235,211,.12); color: var(--paper); box-shadow: inset 0 0 0 1px rgba(244,235,211,.28); }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
select { padding: 4px 8px; border-radius: 6px; border: 0; background: var(--paper); color: var(--ink); min-height: 32px; }
.why { color: #FFD08A; font-size: 12px; margin: 4px 0 0; }

/* ---------- 开局 ---------- */
.setup { position: fixed; inset: 0; overflow: auto; padding: 6vh 16px 40px;
  background: radial-gradient(ellipse at 50% 20%, #5A3A1E, #2A1A0E 60%, #150D07); }
.setup-card { max-width: 640px; margin: 0 auto; background: var(--paper-2); color: var(--ink); border-radius: 14px; padding: 28px 32px;
  box-shadow: 0 0 0 6px #4A2A16, 0 0 0 8px var(--brass), 0 30px 60px rgba(0,0,0,.6); }
.setup h1 { font-size: 34px; }
.lede { color: #5A4A33; }
#setup-form { display: grid; gap: 14px; margin: 18px 0; }
#setup-form label { display: grid; gap: 4px; font-weight: 600; }
#setup-form select { box-shadow: inset 0 0 0 1px #CDBF9F; }
fieldset { border: 1px solid #D6C9AA; border-radius: 8px; padding: 8px 14px 10px; margin: 0; }
legend { font-weight: 600; padding: 0 4px; }
label.radio { display: flex !important; gap: 8px; align-items: center; font-weight: 400 !important; }
#setup-form button { justify-self: start; min-width: 120px; font-size: 17px; }
.rules { background: #EFE4C8; border-radius: 8px; padding: 8px 14px; }
.rules summary { cursor: pointer; font-weight: 600; }
.rules li { margin: 6px 0; }

/* ---------- 结算 ---------- */
.modal { position: fixed; inset: 0; background: rgba(8,5,3,.72); display: grid; place-items: center; padding: 20px; z-index: 30; }
.modal[hidden] { display: none; }
.modal-box { background: var(--paper-2); color: var(--ink); border-radius: 12px; padding: 20px 24px; width: min(920px, 100%); max-height: 90vh; overflow: auto;
  box-shadow: 0 0 0 6px #4A2A16, 0 0 0 8px var(--brass), 0 30px 60px rgba(0,0,0,.6); }
.modal-box h2 { font-size: 24px; }
.modal-box h3 { color: #6b5d48; margin-top: 14px; font-size: 14px; font-family: var(--sans); }
.hint { font-size: 13px; color: #6b5d48; margin: 6px 0; }
.scroll { overflow-x: auto; }
table.result { border-collapse: collapse; width: 100%; font-size: 13px; }
table.result th, table.result td { border-bottom: 1px solid #DCCFB2; padding: 5px 6px; text-align: center; white-space: nowrap; }
table.result th[scope="row"] { text-align: left; }
table.result td.note { text-align: left; white-space: normal; color: #4a3d2a; min-width: 14em; }
table.result td.boss { font-weight: 800; background: rgba(255,178,63,.3); }
table.result tr.win { background: rgba(255,178,63,.25); font-weight: 700; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 5px; }
.final { font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions button:not(.primary) { background: #E4D9BF; }

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

.setup-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.archive-entry { display: grid; gap: 1px; text-decoration: none; color: var(--ink); background: #EFE4C8; border-radius: 8px; padding: 7px 14px;
  font: 800 16px var(--serif); box-shadow: inset 0 0 0 1.5px var(--brass); }
.archive-entry small { font: 400 12px var(--sans); color: #6b5d48; }
.archive-entry:hover { background: #F6ECD2; }
.ah-go { display: inline-block; margin-top: 8px; font: 800 15px var(--serif); color: #8A3A12; }
.tutorial-entry { color: var(--ink); background: #EFE4C8; border-radius: 8px; padding: 10px 18px; font: 800 16px var(--serif); box-shadow: inset 0 0 0 1.5px var(--brass); }
.tutorial-entry:hover { background: #F6ECD2; }
