:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #dfe2e7;
    --text: #1d2129;
    --muted: #6b7280;
    --accent: #2f6fed;
    --accent-soft: #e8efff;
    --ok: #1f9d55;
    --warn: #d97706;
    --bad: #dc2626;
    --sidebar-w: 320px;
    --info-w: 280px;
    --radius: 6px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; cursor: pointer; }
.link { background: none; border: 0; color: var(--accent); padding: 0; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: #1d2433; color: #fff; flex: none; }
.brand { font-weight: 700; font-size: 16px; }
.tag { background: var(--accent); border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-left: 4px; vertical-align: middle; }
.load-summary { font-size: 13px; color: #c9d1e0; margin-left: auto; }

/* user menu, sign-in, dialogs */
.user-menu { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #c9d1e0; }
.user-menu[hidden] { display: none; }
.user-menu .role { background: #334155; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin-left: 4px; }
.top-btn { background: #2a3347; color: #fff; border: 1px solid #3b4660; border-radius: 4px; padding: 3px 10px; font-size: 12px; text-decoration: none; }
.top-btn:hover { background: #34405a; }
.top-btn[hidden] { display: none; }
.signin { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 50; }
.signin[hidden] { display: none; }
.signin-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 32px 36px; max-width: 400px; text-align: center; }
.signin-card .brand { font-size: 22px; margin-bottom: 8px; }
.signin-card p { color: var(--muted); }
.ms-btn { display: inline-flex; align-items: center; gap: 10px; border: 1px solid #8c8c8c; background: #fff; color: #5e5e5e; font-weight: 600; padding: 9px 16px; border-radius: 3px; text-decoration: none; margin-top: 8px; }
.ms-btn:hover { background: #f3f3f3; }
.modal { border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: 80vh; }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; margin: 0; }
#modalBody { padding: 14px 18px; overflow: auto; max-height: calc(80vh - 60px); }
#modalBody form { display: flex; gap: 8px; margin: 10px 0; }
#modalBody input[type=text] { flex: 1; padding: 6px 9px; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
#modalBody button { border: 1px solid var(--border); background: var(--panel); border-radius: 4px; padding: 4px 10px; }
#modalBody button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
#modalBody button.danger { color: var(--bad); }
.newkey { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 6px; padding: 10px; margin: 8px 0; word-break: break-all; }
.newkey code { font-size: 13px; }
.muted { color: var(--muted); font-size: 12px; }

/* three resizable columns */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: var(--sidebar-w); min-width: 200px; max-width: 60vw; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--border); }
.info { width: var(--info-w); min-width: 0; max-width: 50vw; background: var(--panel); border-left: 1px solid var(--border); overflow: auto; padding: 12px 14px; font-size: 13px; }
.main { flex: 1; min-width: 300px; display: flex; flex-direction: column; position: relative; }

.splitter { flex: none; background: transparent; position: relative; z-index: 2; }
.splitter.v { width: 6px; margin: 0 -3px; cursor: col-resize; }
.splitter.h { height: 6px; margin: -3px 0; cursor: row-resize; }
.splitter:hover, .splitter.dragging { background: var(--accent-soft); }
body.resizing { user-select: none; }
body.resizing.col { cursor: col-resize; }
body.resizing.row { cursor: row-resize; }

/* sidebar */
.sidebar-head { padding: 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
#search { width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
#search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filters { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.filters label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.compare-bar[hidden], .toolbar[hidden] { display: none; }
.compare-bar { display: flex; justify-content: space-between; background: var(--accent-soft); padding: 5px 8px; border-radius: var(--radius); font-size: 12px; }
.game-list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.game-list li { display: grid; grid-template-columns: 18px 10px 1fr auto; align-items: center; gap: 7px; padding: 6px 10px; border-bottom: 1px solid #f0f1f4; cursor: pointer; }
.game-list li:hover { background: #f7f8fa; }
.game-list li.selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.game-list li input { margin: 0; cursor: pointer; }
.g-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-name small { color: var(--muted); margin-left: 4px; }
.g-rtp { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.game-list .empty-row { display: block; color: var(--muted); padding: 16px; cursor: default; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 7px 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 4px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.queued { border: 2px solid #c3c8d1; }
.dot.loading { background: var(--accent); animation: pulse 0.9s ease-in-out infinite alternate; }
.dot.ready { background: var(--ok); }
.dot.error { background: var(--bad); }
@keyframes pulse { from { opacity: .3; } to { opacity: 1; } }
.warn { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 10px; font-style: normal; font-weight: 700; align-items: center; justify-content: center; }

/* main */
.game-header { padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); min-height: 52px; }
.game-header .empty { color: var(--muted); padding-top: 6px; }
.gh-title { font-size: 16px; font-weight: 600; }
.gh-sub { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.gh-issue { margin-top: 6px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: var(--radius); padding: 5px 8px; font-size: 12px; }
.chip { display: inline-block; background: #eef0f4; border-radius: 10px; padding: 1px 8px; margin-right: 4px; font-size: 12px; }

.tabs { display: flex; gap: 2px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.tabs button { background: none; border: 0; padding: 9px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 16px; padding: 6px 16px; font-size: 13px; background: #fafbfc; border-bottom: 1px solid var(--border); min-height: 38px; }
.toolbar select, .toolbar button { border: 1px solid var(--border); background: var(--panel); border-radius: 4px; padding: 2px 8px; }
.tb-page { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.panel { flex: 1; min-height: 0; display: none; flex-direction: column; padding: 8px 12px; gap: 0; }
.panel.active { display: flex; }
.panel.scroll { overflow: auto; display: none; }
.panel.scroll.active { display: block; }
.chart-box { position: relative; flex: 1 1 50%; min-height: 120px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; }
.chart-box.grow { flex: 1; }
.chart-box canvas { position: absolute; inset: 6px; width: calc(100% - 12px) !important; height: calc(100% - 12px) !important; }
.chart-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(244, 245, 247, .7); color: var(--muted); font-size: 15px; z-index: 3; }
.chart-overlay[hidden] { display: none; }

.compare-table { flex: 1 1 40%; min-height: 80px; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table.kv, table.cmp { border-collapse: collapse; width: 100%; font-size: 13px; }
table.cmp th, table.cmp td { padding: 5px 10px; border-bottom: 1px solid #f0f1f4; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); }
table.cmp thead th { position: sticky; top: 0; background: #fafbfc; z-index: 1; }
table.kv td { padding: 4px 8px; border-bottom: 1px solid #f0f1f4; vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 220px; }
table.kv pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 220px; overflow: auto; }

/* info panel */
.info h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
.info h3:first-child { margin-top: 0; }
.info .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.info .row span:first-child { color: var(--muted); }
.info .big { font-size: 22px; font-weight: 700; }
.info .empty { color: var(--muted); }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
