:root {
  --stage: #161b22;   /* 預覽動畫的底色，不能改：圖是壓在這個顏色上算好的 */
  --stone: #232a35;
  --line: #3a4453;
  --bronze: #c29a5b;
  --bronze-hi: #e6c88f;
  --parch: #e8dfca;
  --dim: #a59f90;
  --verdigris: #6fb3a0;
  --cinnabar: #e0735a;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100dvh; background: #1c222c; color: var(--parch); font: 15px/1.6 var(--sans); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--bronze-hi); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
[hidden] { display: none !important; }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: var(--stage); border-bottom: 1px solid var(--line); }
.brand { font: 600 21px/1.2 var(--serif); color: var(--bronze-hi); text-decoration: none; letter-spacing: .08em; white-space: nowrap; }
.how { margin: 0; flex: 1; color: var(--dim); font-size: 14px; }
.cart { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; background: var(--stone); border: 1px solid var(--bronze); border-radius: 3px; white-space: nowrap; }
.cart b { min-width: 22px; padding: 0 5px; text-align: center; background: var(--bronze); color: #1c1608; border-radius: 11px; font-size: 13px; }

#shop { display: grid; grid-template-columns: 410px minmax(0, 1fr); align-items: start; }
#altar { position: sticky; top: 56px; height: calc(100dvh - 56px); overflow-y: auto; padding: 18px 26px 22px; background: var(--stage); border-right: 1px solid var(--line); text-align: center; }
#altar .close { display: none; }

/* 八方羅盤：按鈕的位置就是角色面向的方向 */
.ring { position: relative; width: 340px; height: 340px; margin: 0 auto; border-radius: 50%; border: 1px solid var(--bronze); box-shadow: 0 0 0 5px var(--stage), 0 0 0 6px var(--line); }
.stage { position: absolute; inset: 22px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--stage); }
#view { display: block; max-width: none; image-rendering: pixelated; transition: opacity .12s; }
#view.wait { opacity: .35; }
#hint { margin: 0; color: var(--dim); font-family: var(--serif); }
.dir { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px; padding: 0; display: grid; place-items: center; background: var(--stone); border: 1px solid var(--line); border-radius: 50%; color: var(--dim); }
.dir::before { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid currentColor; transform: rotate(var(--turn)); }
.dir:hover { color: var(--bronze-hi); border-color: var(--bronze); }
.dir[aria-pressed="true"] { background: var(--bronze); border-color: var(--bronze-hi); color: #1c1608; }

.face { margin: 24px 0 2px; color: var(--bronze); font-size: 13px; }
#altar h1 { font-size: 25px; line-height: 1.3; }
.kind { margin: 2px 0 12px; color: var(--dim); font-size: 13px; min-height: 20px; }
#altar h2 { font-size: 15px; color: var(--bronze); text-align: left; margin-bottom: 6px; }
.fxs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.fxs button { padding: 7px 4px; background: var(--stone); border: 1px solid var(--line); border-radius: 3px; }
.fxs button:first-child { grid-column: 1 / -1; }
.fxs button:hover { border-color: var(--bronze); }
.fxs button[aria-checked="true"] { background: #3d3320; border-color: var(--bronze-hi); color: var(--bronze-hi); }
.note { margin: 7px 0 0; color: var(--dim); font-size: 13px; min-height: 20px; }
.acts { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 8px; }
.acts button, .linkbox button { padding: 9px 12px; background: var(--stone); border: 1px solid var(--line); border-radius: 3px; }
.acts button[aria-pressed="true"] { border-color: var(--bronze); color: var(--bronze-hi); }
button.main, a.main { background: var(--bronze); border: 1px solid var(--bronze-hi); color: #1c1608; font-weight: 700; border-radius: 3px; }
button.main:hover, a.main:hover { background: var(--bronze-hi); }
button:disabled { opacity: .45; cursor: not-allowed; }

#list { padding: 14px 20px 40px; min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#tabs { display: flex; flex-wrap: wrap; flex: 1; gap: 2px; border-bottom: 1px solid var(--line); }
#tabs button { padding: 7px 12px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--dim); white-space: nowrap; }
#tabs button:hover { color: var(--parch); }
#tabs button[aria-selected="true"] { color: var(--bronze-hi); border-bottom-color: var(--bronze); }
#tabs small { margin-left: 4px; font-size: 11px; opacity: .7; }
#q { width: 170px; padding: 6px 10px; background: var(--stage); border: 1px solid var(--line); border-radius: 3px; }
.count { margin: 8px 0; color: var(--dim); font-size: 13px; }
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 6px; }
.tile { display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 5px 4px 6px; background: var(--stage); border: 1px solid transparent; border-radius: 3px; content-visibility: auto; contain-intrinsic-size: auto 164px; }
.tile:hover { border-color: var(--line); }
.tile[aria-pressed="true"] { border-color: var(--bronze); background: #2a2619; }
.pic { height: 126px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.pic img { display: block; max-width: 100%; max-height: 126px; image-rendering: pixelated; }
.tile span { font-size: 13px; line-height: 1.3; min-height: 2.6em; overflow-wrap: anywhere; }

dialog { width: min(480px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0; background: var(--stage); color: var(--parch); border: 0; border-left: 1px solid var(--bronze); }
dialog::backdrop { background: rgba(8, 10, 14, .62); }
#form { padding: 16px 20px 26px; }
.trayhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.trayhead h2 { font-size: 21px; color: var(--bronze-hi); }
.close { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; background: var(--stone); border: 1px solid var(--line); border-radius: 50%; }
.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--stone); }
.lines img { width: 56px; height: 56px; object-fit: contain; image-rendering: pixelated; }
.lines b { display: block; font-weight: 500; line-height: 1.3; }
.lines small { color: var(--bronze); }
.lines button { padding: 3px 9px; background: none; border: 1px solid var(--line); border-radius: 3px; color: var(--dim); font-size: 13px; }
#fields { display: grid; gap: 11px; margin-top: 14px; }
#fields label { display: grid; gap: 3px; font-size: 13px; color: var(--dim); }
#fields input, #fields select, #fields textarea, .linkbox input { width: 100%; padding: 8px 10px; background: var(--stone); border: 1px solid var(--line); border-radius: 3px; color: var(--parch); font-size: 16px; }
.two { display: grid; grid-template-columns: 120px 1fr; gap: 6px; }
.trap { position: absolute; left: -9999px; }
.err { margin: 0; color: var(--cinnabar); min-height: 22px; }
.wide { width: 100%; padding: 11px; font-size: 16px; }
#pastBox { margin-top: 22px; }
#pastBox h3 { font-size: 15px; color: var(--bronze); }
.past { margin: 6px 0 0; padding: 0; list-style: none; }
.past a { color: var(--parch); }

#orderView { max-width: 680px; margin: 0 auto; padding: 22px 20px 50px; }
.back { color: var(--bronze); }
#orderView h1 { margin: 16px 0 14px; font-size: 27px; color: var(--bronze-hi); }
#orderView h2 { margin: 24px 0 8px; font-size: 18px; color: var(--bronze); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; padding: 0; list-style: none; counter-reset: s; }
.steps li { position: relative; padding-top: 34px; text-align: center; color: var(--dim); counter-increment: s; }
.steps li::before { content: counter(s); position: absolute; left: 50%; top: 0; z-index: 1; width: 26px; height: 26px; margin-left: -13px; line-height: 24px; border: 1px solid var(--line); border-radius: 50%; background: var(--stone); }
.steps li + li::after { content: ""; position: absolute; top: 13px; right: 50%; width: 100%; border-top: 1px solid var(--line); }
.steps li.on { color: var(--bronze-hi); }
.steps li.on::before { background: var(--bronze); border-color: var(--bronze-hi); color: #1c1608; }
.steps li.on::after { border-color: var(--bronze); }
.steps.off li { opacity: .4; }
.lead { font-size: 16px; }
a.btn { display: inline-block; padding: 11px 26px; text-decoration: none; }
.linkbox { margin-top: 16px; padding: 12px 14px; background: var(--stage); border: 1px solid var(--line); border-radius: 3px; }
.linkbox p { margin: 0 0 7px; font-size: 14px; color: var(--dim); }
.linkbox div { display: grid; grid-template-columns: 1fr auto; gap: 6px; }

@media (max-width: 920px) {
  .how { display: none; }
  .brand { flex: 1; font-size: 18px; }
  .bar { padding: 8px 12px; }
  #shop { display: block; }
  #list { padding: 10px 10px 30px; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .pic { height: 104px; }
  .pic img { max-height: 104px; }
  #q { width: 100%; order: -1; }
  #tabs { flex-wrap: nowrap; overflow-x: auto; }
  #altar { position: fixed; inset: auto 0 0; z-index: 8; height: auto; max-height: 92dvh; padding: 26px 14px calc(14px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--bronze); transform: translateY(105%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  #altar.open { transform: none; visibility: visible; }
  #altar .close { display: block; position: absolute; right: 10px; top: 10px; z-index: 2; }
  .ring { width: min(290px, 74vw, 42dvh); height: min(290px, 74vw, 42dvh); }
  #altar h1 { font-size: 20px; }
  .kind { margin-bottom: 6px; }
  .fxs { grid-template-columns: repeat(3, 1fr); }
  .fxs button { padding: 5px 2px; font-size: 13px; }
  .fxs button:first-child { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
