:root {
  --bg: #15140f; --panel: #201e17; --panel2: #2a2720; --line: #3a362b; --ink: #ece6d3; --muted: #a39b84;
  --accent: #b5e550; --accent-ink: #1a2205; --warn: #ff9f43; --bad: #ff5d5d; --good: #6ee7a0; --curse: #c084fc;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, system-ui, sans-serif; }
body { background-image: radial-gradient(circle at 20% -10%, #2c3312 0, transparent 45%), radial-gradient(circle at 100% 100%, #2b1a2e 0, transparent 40%); min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.small { padding: 5px 10px; font-size: 13px; }
input, textarea, select { width: 100%; background: #12110d; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
h1, h2, h3 { margin: 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.logo { font-family: 'Rubik Mono One', Inter, sans-serif; font-size: clamp(30px, 7vw, 58px); line-height: 1; color: var(--accent); letter-spacing: -1px; text-shadow: 3px 3px 0 #3d4a12; }
.logo.sm { font-size: 18px; text-shadow: 2px 2px 0 #3d4a12; }
.tag { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); } .cursed { color: var(--curse); }
.seg { display: flex; background: #12110d; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; }
.seg button.on { background: var(--panel2); color: var(--accent); }
.hero { padding: 28px 0 18px; }
.warning18 { display: inline-block; margin-top: 10px; font-size: 12px; font-weight: 800; border: 1px solid var(--bad); color: var(--bad); border-radius: 6px; padding: 2px 8px; }

/* game header */
.top { position: sticky; top: 0; z-index: 5; background: rgba(21,20,15,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top .wrap { padding-top: 10px; padding-bottom: 10px; }
.stats { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; font-weight: 600; }
.stat b { font-size: 17px; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.tabs { display: flex; gap: 4px; margin-top: 10px; overflow-x: auto; }
.tabs button { border-radius: 10px 10px 0 0; border-bottom: 0; white-space: nowrap; }
.tabs button.on { background: var(--panel); color: var(--accent); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 12px; text-align: center; margin-left: 4px; }

/* listings */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.photo { height: 130px; display: grid; place-items: center; font-size: 64px; background: linear-gradient(135deg, #3a3426, #1b1912); position: relative; overflow: hidden; }
.photo span { filter: blur(.6px) saturate(.7) sepia(.25); transform: rotate(var(--r, -6deg)); }
.photo::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 70% 20%, rgba(255,255,220,.14), transparent 40%); }
.price { position: absolute; left: 10px; bottom: 8px; background: rgba(0,0,0,.7); padding: 2px 9px; border-radius: 8px; font-weight: 800; font-size: 17px; z-index: 1; }
.flag { position: absolute; right: 8px; top: 8px; z-index: 1; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--curse); color: #22102e; }
.item .body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.item h3 { font-size: 15px; }
.item .desc { font-size: 13px; color: #d4ccb6; flex: 1; }
.item .seller { font-size: 12px; color: var(--muted); }
.dave { font-size: 12px; background: #12110d; border: 1px dashed var(--line); border-radius: 8px; padding: 7px 9px; }

/* messages */
.threads { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.thread { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.thread.needs { border-color: var(--accent); }
.thread.dead { opacity: .55; }
.th-head { display: flex; gap: 10px; align-items: center; }
.avatar { font-size: 26px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--panel2); border-radius: 50%; }
.bubbles { display: flex; flex-direction: column; gap: 5px; }
.bubble { max-width: 85%; padding: 7px 11px; border-radius: 14px; font-size: 14px; }
.bubble.them { background: var(--panel2); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { background: #34420f; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble small { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.typing { font-size: 13px; color: var(--muted); font-style: italic; }
.replies { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.replies button { text-align: left; font-weight: 400; font-size: 13px; padding: 7px 9px; }
.replies button b { display: block; font-size: 12px; color: var(--accent); }
.state-pill { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 6px; align-self: flex-start; }
.state-pill.sold { background: #164a2c; color: var(--good); }
.state-pill.scammed { background: #4a1616; color: var(--bad); }
.state-pill.ghost, .state-pill.gone { background: var(--panel2); color: var(--muted); }

/* rivals */
.lb { width: 100%; border-collapse: collapse; }
.lb th, .lb td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lb th { color: var(--muted); font-size: 12px; font-weight: 600; }
.feed { display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; font-size: 13px; }
.feed div { padding: 5px 8px; border-radius: 8px; background: #12110d; }
.feed .chat { background: #24301a; }
.feed .curse { background: #2b1a33; }
.feed .sys { background: #332a12; font-weight: 600; }

/* modal / toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; }
.hidden { display: none !important; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; font-weight: 600; max-width: calc(100% - 32px); }
.toast.ok { background: var(--accent); color: var(--accent-ink); }
.events { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.events div { background: #12110d; padding: 9px 11px; border-radius: 10px; }
.code { font-family: 'Rubik Mono One', monospace; font-size: 44px; color: var(--accent); letter-spacing: 6px; }
.empty { padding: 40px 10px; text-align: center; color: var(--muted); }
.rules li { margin-bottom: 6px; }

@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .threads { grid-template-columns: 1fr; }
  .replies { grid-template-columns: 1fr; }
  .stats { font-size: 13px; gap: 4px 12px; }
  .stat b { font-size: 15px; }
}
