:root {
  --bg: #14100b;
  --bg-2: #1d1710;
  --panel: #221b13;
  --line: #4a3a22;
  --line-soft: #33291a;
  --gold: #d9b26a;
  --gold-hi: #f0d48f;
  --gold-lo: #8f6d35;
  --text: #f1e8d8;
  --muted: #a89a82;
  --r-common: #a89a82;
  --r-rare: #6fb3a8;
  --r-epic: #c48ad8;
  --r-legend: #e8795a;
  --serif: "Noto Serif", Georgia, serif;
  --sans: "Be Vietnam Pro", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1100px 520px at 50% -80px, #2c2115 0%, var(--bg) 70%) no-repeat, var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
a { color: var(--gold-hi); }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 32px; border-bottom: 1px solid var(--line-soft);
}
.brand { margin: 0; font: 700 19px/1.2 var(--serif); letter-spacing: .12em; color: var(--gold); }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 12px; }
.sound { padding: 4px 10px; font-size: 12px; }
.sound[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.counter { margin: 0; color: var(--muted); font-size: 12px; }
.counter b { color: var(--gold-hi); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 40px; }

.level {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.badge {
  flex: none; width: 46px; height: 46px; display: grid; place-items: center; align-content: center;
  border: 1px solid var(--gold-lo); border-radius: 50%;
  font: 700 17px/1 var(--serif); color: var(--gold-hi);
}
.badge small { font: 500 8px/1 var(--sans); color: var(--muted); letter-spacing: .1em; margin-top: 2px; }
.level-body { flex: 1; min-width: 0; }
.level-body > small { color: var(--muted); font-size: 11px; }
.level-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.level-head span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.bar { height: 6px; margin: 5px 0 3px; background: #0d0a06; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); transition: width .5s; }

.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; color: var(--gold-hi); white-space: nowrap;
}
.ghost:hover { border-color: var(--gold); }
.pill { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; background: var(--gold); color: #1a130a; border-radius: 9px; font-size: 11px; font-weight: 700; text-align: center; }

.reel-frame {
  position: relative; margin: 12px 0 16px; padding: 14px 0;
  background: #0d0a06; border: 1px solid var(--gold-lo); border-radius: 4px;
}
.reel { overflow: hidden; }
.strip { display: flex; gap: 14px; width: max-content; will-change: transform; }
.reel-marker {
  position: absolute; z-index: 2; top: 0; bottom: 0; left: 50%; width: 3px; margin-left: -1.5px;
  background: var(--gold-hi); box-shadow: 0 0 12px rgba(240, 212, 143, .7); pointer-events: none;
}
.card {
  flex: none; width: 236px; height: 178px; position: relative; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line); border-bottom: 3px solid var(--rarity, var(--line));
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .tag {
  position: absolute; top: 8px; left: 8px; padding: 1px 7px;
  background: rgba(13, 10, 6, .82); border: 1px solid var(--rarity); color: var(--rarity);
  font-size: 10px; font-weight: 600; letter-spacing: .1em;
}
.card .name {
  position: absolute; inset: auto 0 0 0; padding: 22px 10px 8px;
  background: linear-gradient(transparent, rgba(13, 10, 6, .94) 55%);
  font: 600 14px/1.25 var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.r-unknown { --rarity: var(--muted); }
.r-common { --rarity: var(--r-common); }
.r-rare { --rarity: var(--r-rare); }
.r-epic { --rarity: var(--r-epic); }
.r-legend { --rarity: var(--r-legend); }

.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); max-width: 640px; margin: 0 auto;
  background: var(--bg-2); border: 1px solid var(--line-soft); padding: 3px;
}
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 6px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: #3b2d1b; color: var(--gold-hi); border-bottom-color: var(--gold); font-weight: 600; }

.controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; max-width: 640px; margin: 12px auto 0; }
.field span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.field select, .vault-head input {
  width: 100%; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px;
}
.check { display: flex; align-items: center; gap: 6px; padding: 10px 0; font-size: 13px; white-space: nowrap; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }

.cta {
  display: block; width: 100%; max-width: 640px; margin: 12px auto 0; padding: 16px;
  border: 1px solid var(--gold); border-radius: 4px; color: #1a130a;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  font-weight: 700; font-size: 16px; letter-spacing: .1em;
}
.cta:disabled { opacity: .55; cursor: wait; }
.hint { max-width: 640px; min-height: 20px; margin: 8px auto 0; text-align: center; color: var(--muted); font-size: 12px; }

.vault { margin-top: 32px; padding: 20px; background: var(--bg-2); border: 1px solid var(--line-soft); }
.vault-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.vault-head h2 { margin: 0; font: 600 23px/1.2 var(--serif); color: var(--gold); white-space: nowrap; }
.vault-head input { max-width: 280px; }
.picked { margin-top: 24px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--gold-lo); scroll-margin-top: 12px; }
.picked-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.picked-head small { color: var(--muted); letter-spacing: .1em; font-size: 11px; }
.picked-head h2 { margin: 2px 0 0; font: 700 28px/1.2 var(--serif); color: var(--gold-hi); }
.picked-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.picked-actions .ghost { padding: 6px 11px; font-size: 13px; }
.shops { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.shop { display: block; width: 100%; padding: 10px 12px; text-align: left; background: var(--bg-2); border: 1px solid var(--line-soft); border-left: 3px solid var(--rarity); }
.shop:hover { border-color: var(--gold-lo); border-left-color: var(--rarity); }
.shop b { display: block; font: 600 15px/1.3 var(--serif); }
.shop small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop .meta { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 3px; font-size: 12px; color: var(--gold-hi); }
.shop .closed { color: var(--r-legend); }
.shop .open { color: var(--r-rare); }

.card.win { border-color: var(--gold-hi); box-shadow: 0 0 22px rgba(240, 212, 143, .75); animation: pop .5s ease-out; }
@keyframes pop { 40% { transform: scale(1.06); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 14px; }
.item { display: flex; flex-direction: column; padding: 0; text-align: left; overflow: hidden; background: var(--panel); border: 1px solid var(--line-soft); border-bottom: 3px solid var(--rarity); }
.item:hover { border-color: var(--gold-lo); border-bottom-color: var(--rarity); }
.item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.item div { padding: 8px 10px 10px; min-width: 0; }
.item b { display: block; font: 600 14px/1.3 var(--serif); }
.item small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .price { color: var(--gold-hi); font-size: 12px; margin-top: 3px; }
.empty { grid-column: 1 / -1; padding: 28px; text-align: center; color: var(--muted); }
.more { display: block; margin: 16px auto 0; }

.foot { padding: 18px 16px 28px; text-align: center; color: var(--muted); font-size: 12px; }
.foot p { margin: 2px 0; }

.sheet {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  background: var(--panel); color: var(--text); border: 1px solid var(--gold-lo); border-radius: 8px;
}
.sheet::backdrop { background: rgba(0, 0, 0, .72); }
.sheet img.hero { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.sheet-body { padding: 16px 18px 18px; }
.sheet h3 { margin: 4px 0 2px; font: 700 22px/1.25 var(--serif); color: var(--gold-hi); }
.sheet .dish { margin: 0 0 10px; color: var(--muted); }
.rarity-tag { color: var(--rarity); font-size: 11px; font-weight: 600; letter-spacing: .1em; }
.facts { margin: 0; display: grid; grid-template-columns: 74px 1fr; gap: 3px 10px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.note { margin: 10px 0 0; font-size: 14px; }
.warn { margin: 10px 0 0; padding: 7px 10px; border-left: 3px solid var(--r-legend); background: #2c1c15; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions a, .actions button { flex: 1 1 auto; text-align: center; text-decoration: none; }
.actions.small { margin-top: 4px; }
.actions.small .ghost { padding: 5px 10px; font-size: 13px; }
.actions .ghost[aria-pressed="true"] { background: var(--gold); color: #1a130a; border-color: var(--gold); }
.actions .ghost:disabled { opacity: .6; cursor: default; }
.primary { background: var(--gold); color: #1a130a; border: 1px solid var(--gold); border-radius: 8px; padding: 8px 14px; font-weight: 600; }
.close-x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(13, 10, 6, .8); color: var(--text); }
.list { list-style: none; margin: 8px 0 14px; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.list button { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; flex: none; }
.sheet h4 { margin: 12px 0 2px; color: var(--gold); font: 600 15px/1.3 var(--serif); }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0; }

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 16px; }
  .level { flex-wrap: wrap; }
  .level .ghost { width: 100%; }
  .card { width: 190px; height: 150px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .check { grid-column: 1 / -1; padding: 2px 0; }
  .vault, .picked { padding: 14px; }
  .picked-head h2 { font-size: 24px; }
  .shops { grid-template-columns: minmax(0, 1fr); }
  .counter { display: none; }
  .vault-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .vault-head input { max-width: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tabs button { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar i { transition: none; }
  .card.win { animation: none; }
}
