/* Velvet Comet v2: platform layout (shell, auth, lobby, admin).
   Minimal and semantic on purpose: vc.css (the design system) restyles these classes. */
:root {
  --pf-bg: #0b0710;
  --pf-bg-2: #160d22;
  --pf-panel: #1c1229;
  --pf-panel-2: #251836;
  --pf-line: rgba(232, 196, 104, .18);
  --pf-text: #f3ecff;
  --pf-muted: #a99bbd;
  --pf-gold: #e8c468;
  --pf-gold-2: #b98a2e;
  --pf-violet: #6d3fc0;
  --pf-ruby: #e0475e;
  --pf-emerald: #2fbf86;
  --pf-radius: 16px;
  --pf-display: 'Cinzel', 'Times New Roman', serif;
  --pf-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--pf-ui); color: var(--pf-text); line-height: 1.45;
  background: radial-gradient(1200px 600px at 50% -10%, #2a1747 0%, transparent 60%), var(--pf-bg);
  font-variant-numeric: tabular-nums;
}
a { color: var(--pf-gold); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--pf-gold); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(11, 7, 16, .86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--pf-line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--pf-gold); margin-right: auto; min-width: 0; }
.brand-mark { width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6c8, var(--pf-gold) 45%, var(--pf-gold-2) 100%);
  box-shadow: 0 0 14px rgba(232, 196, 104, .45); }
.brand-word { font-family: var(--pf-display); font-weight: 900; letter-spacing: .06em; font-size: 20px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.wallet-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px;
  background: linear-gradient(180deg, #2c1d40, #1a1027); border: 1px solid var(--pf-line); font-weight: 800; }
.wallet-pill .coin { width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6b0, #ffcf4a 50%, #b8650a); }
.wallet-amount { min-width: 4ch; text-align: right; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--pf-line); background: var(--pf-panel);
  color: var(--pf-text); cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  border-radius: 999px; border: 1px solid var(--pf-line); background: var(--pf-panel); }
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, var(--pf-violet), #3b1f6e); color: #fff; }
.user-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; padding: 6px; margin: 0;
  background: var(--pf-panel-2); border: 1px solid var(--pf-line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.user-menu-list a, .user-menu-list button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  color: var(--pf-text); text-decoration: none; background: none; border: 0; cursor: pointer; }
.user-menu-list a:hover, .user-menu-list button:hover { background: rgba(255,255,255,.06); }
.user-menu-list form { margin: 0; }
.page { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { text-align: center; color: var(--pf-muted); font-size: 13px; padding: 18px 16px 26px; border-top: 1px solid var(--pf-line); }

.flashes { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--pf-panel-2); border: 1px solid var(--pf-line); }
.flash-error { border-color: rgba(224, 71, 94, .6); }
.flash-ok { border-color: rgba(47, 191, 134, .6); }
.toast-host { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--pf-panel-2); border: 1px solid var(--pf-line); box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* ---------- buttons and forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px;
  border-radius: 12px; border: 1px solid var(--pf-line); background: var(--pf-panel-2); color: var(--pf-text);
  font-weight: 800; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold { background: linear-gradient(180deg, #f6dc8c, var(--pf-gold) 45%, var(--pf-gold-2)); color: #2a1a02; border-color: #f6dc8c; }
.btn-danger { border-color: rgba(224, 71, 94, .7); color: #ffd0d6; }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn-block { width: 100%; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 14px; color: var(--pf-muted); }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--pf-line);
  background: #120b1b; color: var(--pf-text); }
.hint { font-size: 13px; color: var(--pf-muted); margin: 0; }
.form-error { padding: 10px 12px; border-radius: 10px; background: rgba(224, 71, 94, .12); border: 1px solid rgba(224, 71, 94, .5); margin-bottom: 14px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: calc(100vh - 220px); display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; border-radius: 22px; background: linear-gradient(180deg, var(--pf-panel-2), var(--pf-panel));
  border: 1px solid var(--pf-line); box-shadow: 0 24px 80px rgba(0,0,0,.55); }
.auth-title { font-family: var(--pf-display); font-weight: 900; color: var(--pf-gold); text-align: center; margin: 0 0 4px; font-size: 28px; letter-spacing: .04em; }
.auth-sub { text-align: center; color: var(--pf-muted); margin: 0 0 22px; }
.auth-switch { text-align: center; margin: 18px 0 0; color: var(--pf-muted); }

/* ---------- lobby ---------- */
.hero { position: relative; border-radius: 24px; overflow: hidden; min-height: 260px; display: grid; align-items: end;
  background: radial-gradient(600px 300px at 70% 30%, rgba(109,63,192,.45), transparent 70%), linear-gradient(180deg, #1d1030, #0e0816);
  border: 1px solid var(--pf-line); margin-bottom: 26px; }
#hero3d { position: absolute; inset: 0; }
.hero-copy { position: relative; padding: 28px; max-width: 560px; }
.hero-title { font-family: var(--pf-display); font-weight: 900; font-size: clamp(30px, 6vw, 52px); line-height: 1.05; margin: 0 0 8px; color: var(--pf-gold); }
.hero-text { color: var(--pf-muted); margin: 0 0 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.lobby-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .lobby-layout { grid-template-columns: minmax(0, 1fr); } }
.section-title { font-family: var(--pf-display); font-weight: 700; font-size: 22px; margin: 0 0 12px; color: var(--pf-text); letter-spacing: .03em; }
.section { margin-bottom: 30px; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.game-card { display: flex; flex-direction: column; border-radius: var(--pf-radius); overflow: hidden; text-decoration: none; color: var(--pf-text);
  background: var(--pf-panel); border: 1px solid var(--pf-line); transition: transform .15s ease, border-color .15s ease; }
.game-card:hover { transform: translateY(-2px); border-color: rgba(232,196,104,.5); }
.game-art { aspect-ratio: 4 / 3; background: #120b1b; display: block; width: 100%; object-fit: cover; }
.game-meta { padding: 10px 12px 12px; display: grid; gap: 2px; }
.game-name { font-weight: 800; }
.game-tag { font-size: 13px; color: var(--pf-muted); }
.game-kind { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--pf-gold); }
.empty-note { color: var(--pf-muted); padding: 18px; border: 1px dashed var(--pf-line); border-radius: var(--pf-radius); margin: 0; }
.panel { background: linear-gradient(180deg, var(--pf-panel-2), var(--pf-panel)); border: 1px solid var(--pf-line); border-radius: 20px; padding: 18px; margin-bottom: 20px; }
.panel-title { font-family: var(--pf-display); font-weight: 700; margin: 0 0 12px; font-size: 19px; }

.wheel { position: relative; width: min(280px, 100%); margin: 0 auto 14px; aspect-ratio: 1; }
.wheel-svg { width: 100%; height: 100%; display: block; transform: rotate(0deg); }
.wheel-svg.spinning { transition: transform 4.2s cubic-bezier(.12, .7, .14, 1); }
.wheel-pointer { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); width: 0; height: 0;
  border-left: 13px solid transparent; border-right: 13px solid transparent; border-top: 24px solid var(--pf-gold);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.wheel-seg-label { font-family: var(--pf-ui); font-weight: 800; font-size: 13px; fill: #fff; }
.wheel-status { text-align: center; color: var(--pf-muted); margin: 10px 0 0; min-height: 1.4em; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tab { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--pf-line); background: transparent; color: var(--pf-muted); cursor: pointer; font-size: 13px; font-weight: 700; }
.tab[aria-selected="true"] { background: var(--pf-gold); color: #2a1a02; border-color: var(--pf-gold); }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board td, .board th { padding: 7px 4px; border-bottom: 1px solid rgba(255,255,255,.06); text-align: left; }
.board td.num, .board th.num { text-align: right; }
.board .rank { width: 2.5em; color: var(--pf-gold); font-weight: 800; }
.board-empty { color: var(--pf-muted); font-size: 14px; margin: 8px 0 0; }

/* ---------- game shell ---------- */
.game-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-weight: 800; }
.game-title { font-family: var(--pf-display); font-weight: 900; margin: 0; font-size: 26px; color: var(--pf-gold); }
.game-stage { position: relative; min-height: 420px; border-radius: 22px; border: 1px solid var(--pf-line); background: #0f0918; overflow: hidden; }

/* ---------- admin ---------- */
.admin-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.admin-nav a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--pf-line); text-decoration: none; color: var(--pf-text); font-weight: 700; }
.admin-nav a[aria-current="page"] { background: var(--pf-gold); color: #2a1a02; }
.admin-title { font-family: var(--pf-display); margin: 0 0 16px; font-size: 26px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 16px; border-radius: 16px; background: var(--pf-panel); border: 1px solid var(--pf-line); }
.stat-label { color: var(--pf-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--pf-line); background: var(--pf-panel); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.06); text-align: left; white-space: nowrap; }
.data-table th { color: var(--pf-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.data-table .num { text-align: right; }
.pos { color: var(--pf-emerald); } .neg { color: var(--pf-ruby); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; border: 1px solid var(--pf-line); }
.badge-admin { color: var(--pf-gold); } .badge-banned { color: var(--pf-ruby); border-color: rgba(224,71,94,.6); }
.search-form { display: flex; gap: 8px; margin-bottom: 14px; max-width: 480px; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 22px; }
.action-card { padding: 16px; border-radius: 16px; background: var(--pf-panel); border: 1px solid var(--pf-line); }
.action-card h3 { margin: 0 0 10px; font-size: 16px; }
.inline-form { display: inline; margin: 0; }
.stat-value-small { font-size: 16px; }
.admin-lead { margin-bottom: 14px; }
