:root {
  --bg: #f4efe2;
  --bg-2: #e9e1cc;
  --panel: #fffaf0;
  --ink: #2c2a22;
  --muted: #6f6a58;
  --line: #ddd3b8;
  --green: #3f8f4f;
  --green-ink: #ffffff;
  --accent: #e0a526;
  --live: #d9573b;
  --shadow: 0 2px 0 #d8ceb2, 0 6px 18px rgba(60, 50, 20, 0.08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15201a;
    --bg-2: #1b2a21;
    --panel: #1f3127;
    --ink: #eef3e8;
    --muted: #a3b3a2;
    --line: #2f4637;
    --green: #5cbf6d;
    --green-ink: #0f1c13;
    --accent: #f0bf4c;
    --live: #ff8a6b;
    --shadow: 0 2px 0 #0d150f, 0 6px 18px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Sarabun", system-ui, sans-serif;
}
h1, h2, h3, .btn, .label { font-family: "Mitr", "Sarabun", system-ui, sans-serif; font-weight: 500; }
h1, h2, h3, p { margin: 0; }
main, .top, footer { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 40px; line-height: 1; }
h1 { font-size: 24px; }
.sub { color: var(--muted); font-size: 14px; }
.status::before { content: "●"; color: var(--green); margin: 0 4px 0 6px; }
.status.offline::before { color: var(--live); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink);
  padding: 8px 16px; font-size: 15px; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 0 var(--line);
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--green); color: var(--green-ink); border-color: transparent; }
.btn-ghost { box-shadow: none; }
.btn.on { border-color: var(--green); }

.hud { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px;
}
.panel.live { border-color: var(--live); }
.panel.away { opacity: 0.75; }
.label { font-size: 13px; color: var(--muted); }
.panel.live .label { color: var(--live); }
.row { display: flex; align-items: center; gap: 10px; }
.big-icon { font-size: 30px; line-height: 1; }
.panel h2 { font-size: 19px; }
.line { color: var(--muted); font-size: 14px; min-height: 1.5em; }
.when { font-size: 14px; }
time { font-variant-numeric: tabular-nums; font-weight: 600; }
.drain { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--bg-2); }
.drain i { display: block; height: 100%; width: calc(var(--left, 0) * 100%); background: var(--accent); transition: width 1s linear; }

.wall { margin-top: 24px; }
.wall-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.tab .count { font-size: 12px; opacity: 0.7; }
.wall-note { margin-top: 8px; color: var(--muted); font-size: 14px; }

.cards { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--rarity, #ccc);
  border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
  animation: pop 0.35s both; animation-delay: calc(var(--i, 0) * 15ms);
}
.card.sold-out { opacity: 0.45; }
.card .well { position: relative; font-size: 40px; line-height: 1; height: 52px; display: flex; align-items: center; }
.card .from { position: absolute; right: 0; top: 0; font-size: 18px; }
.tag-new { position: absolute; right: 0; bottom: 0; background: var(--live); color: #fff; font: 600 11px "Mitr", sans-serif; padding: 1px 7px; border-radius: 999px; }
.card h3 { font-size: 15px; }
.card .rarity { font-size: 12px; color: var(--rarity); filter: saturate(1.2) brightness(0.8); font-weight: 600; }
@media (prefers-color-scheme: dark) { .card .rarity { filter: none; } }
.card-foot { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-top: auto; gap: 6px; }
.price { color: var(--muted); }
.stock b { font-size: 15px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 32px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .card { animation: none; } .drain i { transition: none; } }

footer { margin-top: 36px; padding-bottom: 32px; color: var(--muted); font-size: 13px; text-align: center; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }

.sheet {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border: 1px solid var(--line); border-radius: 18px; padding: 18px;
  background: var(--panel); color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 20, 10, 0.45); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-intro { color: var(--muted); font-size: 14px; margin: 6px 0 12px; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notify-status { font-size: 14px; margin: 8px 0; min-height: 1.5em; }
.notify-group { margin-top: 14px; }
.notify-group h3 { font-size: 15px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink); padding: 4px 10px; font: 14px "Sarabun", sans-serif; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--green); color: var(--green-ink); border-color: transparent; }
