:root {
  --bg: #0f1117; --panel: #181b24; --panel-2: #20242f; --line: #2c3140; --text: #eef0f5; --muted: #9aa1b2;
  --accent: #f2b544; --accent-ink: #1a1405; --good: #3ccf8e; --bad: #ff6b6b; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
header.top .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: .02em; }
.logo:hover { text-decoration: none; }
nav.main { display: flex; gap: 14px; }
nav.main a { color: var(--muted); font-weight: 600; }
nav.main a.on, nav.main a:hover { color: var(--text); text-decoration: none; }
.spacer { flex: 1; }
.wallet { display: flex; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.wallet .pill { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.wallet .pill b { color: var(--text); }
.wallet .pill span { color: var(--muted); margin-right: 6px; }

.btn { display: inline-block; border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 700; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.danger { background: var(--bad); color: #fff; }
form.inline { display: inline; }

main { padding: 24px 0 48px; }
h1 { font-size: 28px; margin: 8px 0 16px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.notice { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; background: #173326; border: 1px solid #23573f; }
.notice.err { background: #3a1a1d; border-color: #6a2a30; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.tile { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: linear-gradient(135deg, #3b2a6b, #a8442f); color: #fff; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 12px 10px; font-weight: 800; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.tile .badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.tile:hover { text-decoration: none; transform: translateY(-2px); transition: transform .15s; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin-top: 0; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input, select { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; }
input[type=checkbox], input[type=radio] { width: auto; margin-right: 8px; }
.check { display: flex; align-items: flex-start; font-weight: 400; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.field-err { color: var(--bad); font-size: 14px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
.pos { color: var(--good); }

.auth { max-width: 420px; margin: 24px auto; }
.play-frame { width: 100%; height: calc(100vh - 140px); min-height: 480px; border: 0; border-radius: var(--radius); background: #000; }

footer.bottom { border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; padding: 24px 0; }
footer.bottom .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 640px) {
  header.top .wrap { gap: 10px; padding-top: 8px; padding-bottom: 8px; }
  .wallet { order: 3; width: 100%; }
  h1 { font-size: 24px; }
  .row { flex-direction: column; }
}

.chat { position: fixed; right: 16px; bottom: 16px; z-index: 50; }
.chat-bubble { border-radius: 999px; padding: 12px 20px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.chat-panel { width: min(360px, calc(100vw - 32px)); height: min(520px, calc(100vh - 100px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--panel-2); white-space: pre-wrap; word-wrap: break-word; }
.chat-msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.chat-msg.sys { align-self: center; background: transparent; border: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.chat-who { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.chat-typing { padding: 0 12px; margin: 0 0 6px; font-size: 13px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }

.chat [hidden] { display: none !important; }
.chat-bubble.has-new::after { content: ''; position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); border: 2px solid var(--bg); }
.chat-bubble { position: relative; }
