* {
  box-sizing:border-box;
}
[hidden] {
  display:none!important;
}
:root {
  color-scheme:dark;
  --paper:#f7e8ce;
  --muted:#d0bda1;
  --seam:#70543e;
  --gold:#ffcd87;
  --dark:#201c1c;
  font-family:system-ui,sans-serif;
  color:var(--paper);
  background:#171517;
  font-variant-numeric:tabular-nums;
}
body {
  margin:0;
  background:radial-gradient(ellipse at 25% 0%,#55362b 0,transparent 55%),linear-gradient(130deg,#211b1d,#161a1c);
  min-height:100vh;
}
main {
  max-width:1220px;
  margin:auto;
  padding:clamp(10px,2.2vw,32px);
  padding-bottom:max(12px,env(safe-area-inset-bottom));
}
header,footer,.brand,.settings,.actions,.plate,.result,.expected {
  display:flex;
  align-items:center;
  gap:.7rem;
}
header,footer,.plate,.result,.expected {
  justify-content:space-between;
}
header {
  margin-bottom:14px;
}
.brand {
  gap:12px;
}
h1,h2 {
  font-family:Georgia,'Songti SC',serif;
  font-weight:500;
  line-height:1.06;
  margin:0;
}
h1 {
  font-size:clamp(26px,3vw,40px);
  letter-spacing:-.055em;
}
h1 em {
  font-size:.73em;
  color:var(--gold);
  font-style:normal;
}
h2 {
  font-size:clamp(23px,2.5vw,34px);
}
.insignia {
  color:#41261a;
  background:linear-gradient(150deg,#ffe3a9,#c47e44);
  border:1px solid #ffdc99;
  border-radius:6px 6px 50% 50%;
  padding:6px 10px;
  font-size:19px;
}
.panel {
  border:1px solid var(--seam);
  border-radius:10px;
  background:linear-gradient(135deg,#302827,#231f20);
  box-shadow:0 5px 16px #0003,inset 0 1px #f9d8a812;
}
.ledger {
  display:grid;
  grid-template-columns:1fr 1fr 1.8fr 1fr;
  align-items:center;
  margin-bottom:12px;
  padding:10px 4px;
}
.ledger>div {
  padding:0 clamp(8px,2vw,28px);
  border-right:1px solid #70543e88;
}
.ledger>div:last-child {
  border:0;
}
.ledger strong {
  display:block;
  font-size:clamp(16px,2vw,23px);
  font-weight:600;
}
.rent {
  position:relative;
}
progress {
  display:block;
  width:100%;
  height:5px;
  border:0;
  border-radius:8px;
  background:#171717;
  accent-color:#e8b975;
}
progress::-webkit-progress-bar {
  background:#171717;
  border-radius:5px;
}
progress::-webkit-progress-value {
  background:linear-gradient(90deg,#b87949,#ffd98a);
  border-radius:5px;
}
.workbench {
  display:grid;
  grid-template-columns:minmax(0,2.25fr) minmax(240px,1fr);
  gap:12px;
  align-items:start;
}
.hearth {
  overflow:hidden;
}
.plate {
  padding:8px 16px;
  background:#272021;
}
.engrave,.gold {
  color:var(--gold);
}
.viewport {
  position:relative;
  width:100%;
  background:#30231f;
  aspect-ratio:2.25;
  max-height:360px;
  border-block:1px solid var(--seam);
}
#stage {
  display:block;
  width:100%;
  height:100%;
  touch-action:manipulation;
}
.viewport p {
  position:absolute;
  inset:25% 12%;
  text-align:center;
}
.tray,.slots,.offers {
  display:grid;
  gap:6px;
  grid-template-columns:repeat(5,minmax(0,1fr));
}
.tray {
  padding:8px;
  background:#211d1e;
  border-bottom:1px solid var(--seam);
}
button,select {
  font:inherit;
  color:var(--paper);
  background:linear-gradient(#403430,#332b29);
  border:1px solid #84674c;
  border-radius:6px;
  padding:7px 12px;
  min-height:38px;
  cursor:pointer;
}
button:hover:not(:disabled),select:hover {
  background:#544135;
  border-color:#d3ac74;
}
button:focus-visible,select:focus-visible {
  outline:3px solid #ffda8d;
  outline-offset:2px;
}
button:disabled {
  opacity:.55;
  cursor:default;
}
button[aria-pressed=true] {
  border-color:var(--gold);
  box-shadow:inset 0 -3px #ffbb76;
  background:#543925;
}
.primary {
  font-weight:700;
  color:#2d1f17;
  background:linear-gradient(#ffe0a3,#df9a5f);
  border-color:#ffe3b0;
}
.primary:hover:not(:disabled) {
  background:#ffdfaa;
}
.tray button,.slots button,.offers button {
  min-width:0;
  padding:5px 3px;
}
.tray button b,.offers button b {
  display:block;
}
.tray button b {
  font:600 20px Georgia,serif;
}
.tray button small {
  font-size:10px;
  letter-spacing:.04em;
}
.controls,.book {
  padding:clamp(12px,1.6vw,22px);
}
p {
  color:var(--muted);
  font-size:.9rem;
  line-height:1.4;
  margin:.55rem 0 .85rem;
}
small,.kicker {
  display:block;
  color:var(--muted);
  font-size:.71rem;
  font-weight:650;
  text-transform:uppercase;
  letter-spacing:.09em;
}
.gold {
  font:600 clamp(27px,3vw,40px) Georgia,serif;
}
.actions {
  flex-wrap:wrap;
}
.actions button {
  flex:1 1 auto;
}
.book {
  background:linear-gradient(155deg,#37302b,#252527 80%);
  border-top:3px solid #b98552;
}
.book h2,.controls h2 {
  margin-top:4px;
}
.book table {
  width:100%;
  border-collapse:collapse;
  font-size:.875rem;
}
.book th {
  text-align:right;
  color:#d7bd9a;
  font-size:.76rem;
}
.book td {
  text-align:right;
  padding:7px 0;
  border-bottom:1px solid #80634766;
}
.book td:first-child,.book th:first-child {
  text-align:left;
}
.book td:nth-child(2) {
  color:var(--gold);
}
.book tr.current {
  font-weight:700;
}
.expected {
  padding:.7rem 0;
  color:var(--gold);
}
.rule {
  border-top:1px solid var(--seam);
  padding-top:.7rem;
  margin-bottom:0;
}
.slots {
  grid-template-columns:repeat(6,minmax(0,1fr));
  margin:8px 0;
}
.offers {
  grid-template-columns:repeat(3,minmax(0,1fr));
}
.offers button {
  font-size:.84rem;
}
.offers b {
  color:var(--gold);
}
footer {
  color:var(--muted);
  font-size:.83rem;
  padding:10px 0;
}
footer button {
  font-size:.78rem;
  flex-shrink:0;
}
.settings>* {
  font-size:.85rem;
}
@media(max-width:500px) {
  header { flex-wrap:wrap; gap:6px; }
  .settings { margin-left:auto; flex-wrap:wrap; }
}
@media(max-width:760px) {
  .workbench {
    grid-template-columns:1fr;
  }
  .ledger>div {
    padding:0 6px;
  }
  .book {
    width:100%;
  }
  .viewport {
    max-height:280px;
  }
  .tray small {
    letter-spacing:0;
  }
  .brand {
    gap:6px;
  }
  .actions {
    gap:5px;
  }
  .settings {
    gap:4px;
  }
  .settings>* {
    padding:5px 7px;
  }
  .insignia {
    font-size:16px;
    padding:4px 8px;
  }
}
@media(min-width:761px) and (max-height:650px) {
  main {
    padding:8px 14px;
  }
  header {
    margin-bottom:6px;
  }
  .ledger {
    padding:5px;
    margin-bottom:6px;
  }
  .viewport {
    max-height:34vh;
  }
  .controls,.book {
    padding:10px 14px;
  }
  .book td {
    padding:4px 0;
  }
  .tray {
    padding:5px;
  }
  .rule {
    font-size:.8rem;
  }
}

/* The itch embed is a landscape table, not a vertically scrolling phone. */
@font-face { font-family:HearthCJK; src:url('./vendor/HearthCJK.ttf') format('truetype'); }
:lang(zh-Hans) { font-family:HearthCJK, system-ui, sans-serif; }
@media(min-width:550px) and (max-height:620px) {
  main { padding:5px 9px; } .workbench { grid-template-columns:minmax(0,2fr) minmax(174px,1fr);gap:7px; }
  header,.ledger { margin-bottom:4px; } .ledger {padding:3px;} .ledger strong {font-size:15px;} progress {height:3px;}
  h1 {font-size:24px;} h2 {font-size:20px;} .settings>* {min-height:26px;padding:2px 7px;}
  .plate {padding:3px 8px;} .viewport {height:clamp(110px,36vh,197px);max-height:none;} .tray {padding:3px;gap:3px;}
  .tray button {padding:1px;min-height:25px;} .tray button b {font-size:16px;}.tray button small {font-size:9px;}
  .controls,.book {padding:5px 8px;} .controls p,.book p {font-size:11px;margin:4px 0;} small,.kicker {font-size:9px;}
  .gold {font-size:24px;} .actions button,.slots button,.offers button {min-height:25px;font-size:12px;padding:3px;}
  .book table {font-size:11px;} .book td {padding:3px 0;} .book th {font-size:10px;} .expected {padding:5px 0;font-size:12px;} footer {padding:3px 0;}
  [data-phase=shop] .viewport {height:clamp(75px,22vh,140px);} .slots {margin:3px 0;}
}
@media(min-width:550px) and (max-height:400px) {
  .plate {padding-block:1px;} .insignia {padding:1px 5px;} .tray button small {display:block;white-space:nowrap;font-size:8px;letter-spacing:0;}
  .tray button b {line-height:16px;} #hint {display:none;} .result small {display:none;} .actions {margin-top:4px;}
  .book td,.book th {padding:1px 0;} .book td:first-child,.book th:first-child {font-size:10px;} .book h2 {font-size:17px;}
}
