:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #071019;
  --panel: #101c27;
  --panel-2: #142532;
  --line: rgba(255, 255, 255, .1);
  --text: #f6f8fa;
  --muted: #91a3b2;
  --mint: #63e6c6;
  --blue: #78a9ff;
  --gold: #ffd36e;
  --red: #ff7d86;
  --green-soft: rgba(99, 230, 198, .12);
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 92% 0, #183c4a 0, transparent 34rem), radial-gradient(circle at 0 35%, #14233c 0, transparent 30rem), var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 28px; background: rgba(16, 28, 39, .94); box-shadow: 0 32px 90px rgba(0, 0, 0, .38); }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--mint); color: #071019; font-weight: 900; margin-bottom: 28px; }
.eyebrow { margin: 0 0 9px; color: var(--mint); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin-bottom: 12px; font-size: 34px; letter-spacing: -.04em; }
.muted, .lead { color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 14px; margin-top: 28px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; color: var(--text); border: 1px solid var(--line); border-radius: 11px; outline: none; background: rgba(3, 10, 16, .5); }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(99, 230, 198, .1); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(120, 169, 255, .8); outline-offset: 3px; }
button { min-height: 42px; padding: 0 15px; border: 0; border-radius: 11px; font-weight: 780; cursor: pointer; color: var(--text); background: #223747; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: wait; }
.primary { color: #06131a; background: var(--mint); }
.danger { color: #ffb8bd; background: rgba(255, 125, 134, .13); border: 1px solid rgba(255, 125, 134, .22); }
.ghost { border: 1px solid var(--line); background: transparent; }
.login-form .primary { width: 100%; margin-top: 4px; }
.feedback { min-height: 21px; margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.feedback.error { color: #ffadb2; }
.feedback-banner { margin: 8px 4px 0; }

.app-shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 24px 0 72px; }
.topbar { position: sticky; top: 14px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(8, 18, 27, .88); backdrop-filter: blur(18px); box-shadow: 0 18px 55px rgba(0,0,0,.22); }
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand .brand-mark { width: 34px; height: 34px; border-radius: 10px; margin: 0; }
.topbar-brand strong { display: block; }
.topbar-brand small { display: block; margin-top: 2px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-pill { padding: 7px 10px; border: 1px solid rgba(99,230,198,.22); border-radius: 999px; color: var(--mint); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }

.page-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding: 52px 4px 28px; }
.page-head h1 { margin-bottom: 8px; font-size: clamp(36px, 5vw, 68px); line-height: .95; letter-spacing: -.055em; }
.page-head .lead { max-width: 670px; margin-bottom: 0; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metrics-five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric { min-height: 126px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(20,37,50,.92), rgba(12,23,32,.94)); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 18px; color: var(--gold); font-size: clamp(25px, 3vw, 38px); letter-spacing: -.045em; }
.metric small { display: block; color: var(--muted); margin-top: 5px; }
.metric-button { width: 100%; height: auto; color: var(--text); text-align: left; font-weight: inherit; cursor: pointer; }
.metric-button:hover { filter: none; border-color: rgba(99,230,198,.45); background: linear-gradient(145deg, rgba(25,48,61,.98), rgba(13,27,37,.98)); }
.metric-button:active { transform: translateY(1px); }

.layout { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(0, 1.7fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 21px; background: rgba(16, 28, 39, .92); box-shadow: 0 20px 60px rgba(0,0,0,.17); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; grid-column: 1 / -1; margin-top: 3px; }

.entity-list { display: grid; gap: 10px; }
.entity-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(2, 10, 16, .28); }
.entity-title { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.entity-title h3 { margin: 0; font-size: 16px; }
.entity-title small { display: block; color: var(--muted); margin-top: 4px; }
.amount { color: var(--gold); font-weight: 850; white-space: nowrap; }
.entity-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.entity-list-spaced { margin-top: 16px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 13px; color: #c7d4dd; background: rgba(255,255,255,.035); text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 13px; border-top: 1px solid rgba(255,255,255,.065); vertical-align: top; }
tbody tr:hover { background: rgba(255,255,255,.025); }
.history-section-gap { height: 16px; }
.game-history-head { align-items: end; }
.game-history-toolbar { display: flex; align-items: end; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.game-history-toolbar label { min-width: 170px; }
.game-history-toolbar select { min-height: 38px; padding-block: 7px; }
.history-count { min-width: 94px; padding: 10px 12px; color: var(--mint); border: 1px solid rgba(99,230,198,.22); border-radius: 11px; background: rgba(99,230,198,.07); text-align: center; font-size: 11px; font-weight: 800; }
.game-history-table { min-width: 1120px; table-layout: fixed; }
.game-history-table th:nth-child(1) { width: 155px; }
.game-history-table th:nth-child(2) { width: 170px; }
.game-history-table th:nth-child(3) { width: 174px; }
.game-history-table th:nth-child(4) { width: 170px; }
.game-history-table th:nth-child(5) { width: 190px; }
.game-history-table th:nth-child(6) { width: 230px; }
.game-history-row td { padding-block: 14px; }
.game-history-row .status { margin-top: 9px; }
.round-screen { display: grid; grid-template-columns: repeat(5, 28px); grid-template-rows: repeat(3, 28px); gap: 2px; width: max-content; padding: 5px; border: 1px solid rgba(255,211,110,.32); border-radius: 8px; background: #7381ad; box-shadow: inset 0 0 0 2px rgba(5,11,17,.42); }
.round-symbol { display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(98,20,20,.65); color: #101820; background: #94a3d3; font-size: 16px; font-weight: 950; line-height: 1; text-shadow: 0 1px rgba(255,255,255,.35); }
.round-symbol__image { display: block; width: 100%; height: 100%; object-fit: contain; }
.round-symbol__fallback { display: grid; place-items: center; width: 100%; height: 100%; }
.round-symbol.symbol-0 { color: #e52a21; background: #ffe34c; }
.round-symbol.symbol-8 { color: #f6f8fa; background: #45515c; }
.history-lines, .history-features { margin-top: 6px; color: var(--muted); line-height: 1.55; white-space: pre-line; }
.history-value { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--muted); }
.history-value strong { color: var(--text); text-align: right; white-space: nowrap; }
.history-value.gold strong { color: var(--gold); }
.history-value.balance { margin-top: 4px; padding-top: 7px; border-top: 1px solid var(--line); }
.history-value.balance strong { color: var(--mint); }
.mono { max-width: 150px; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--mint); background: var(--green-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.status.closed, .status.alert { color: #ffabb0; background: rgba(255,125,134,.12); }
.compact-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.compact-actions input { width: 94px; min-height: 34px; padding: 6px 8px; }
.compact-actions button, .compact-actions a { min-height: 34px; padding: 8px 10px; border-radius: 9px; font-size: 11px; }
.compact-actions a { color: #06131a; background: var(--gold); text-decoration: none; font-weight: 800; }
.diagnostic { color: var(--muted); }
.diagnostic.alert { color: var(--red); font-weight: 750; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
.section-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; }
.section-tabs button.active { color: #06131a; background: var(--mint); }
.section-nav { position: sticky; top: 92px; z-index: 9; flex-wrap: nowrap; overflow-x: auto; margin: 12px 0 0; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(8,18,27,.92); backdrop-filter: blur(18px); scrollbar-width: thin; }
.section-nav button { flex: 0 0 auto; min-height: 38px; }
.view-section { margin-top: 18px; }
.narrow-section { width: min(760px, 100%); }
.cabinet-context { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; margin: 0 0 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(10, 25, 34, .72); }
.cabinet-context label { min-width: min(320px, 100%); }
.cabinet-context .field-hint { flex: 1 1 260px; margin: 0 0 9px; }
.cabinet-context button { margin-left: auto; }
.field-hint { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.source-note { margin: 0; padding: 14px 16px; color: var(--muted); font-size: 12px; line-height: 1.55; border: 1px dashed rgba(99,230,198,.25); border-radius: 13px; background: rgba(99,230,198,.045); }
.stake-grid-field { min-width: 0; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.stake-grid-field legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.stake-grid-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.stake-chip { position: relative; cursor: pointer; }
.stake-chip input { position: absolute; opacity: 0; pointer-events: none; }
.stake-chip span { display: block; min-width: 52px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.025); text-align: center; transition: border-color .16s ease, color .16s ease, background .16s ease; }
.stake-chip input:checked + span { border-color: rgba(99,230,198,.48); color: var(--mint); background: rgba(99,230,198,.1); }
.stake-chip input:focus-visible + span { outline: 2px solid var(--mint); outline-offset: 2px; }

.secure-chat { min-height: 600px; }
.encryption-pill { flex: 0 0 auto; padding: 6px 9px; color: var(--mint); border: 1px solid rgba(99,230,198,.25); border-radius: 999px; background: rgba(99,230,198,.07); font: 800 10px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .06em; }
.message-layout { display: grid; grid-template-columns: minmax(220px, .42fr) minmax(0, 1fr); min-height: 535px; }
.message-sidebar { padding: 12px; border-right: 1px solid var(--line); background: rgba(3,10,16,.22); }
.message-threads { display: grid; gap: 7px; }
.message-thread { display: grid; width: 100%; min-height: 66px; padding: 11px 12px; text-align: left; border: 1px solid transparent; background: transparent; }
.message-thread:hover, .message-thread.active { border-color: rgba(99,230,198,.25); background: rgba(99,230,198,.08); filter: none; }
.message-thread strong, .message-thread small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-thread small { margin-top: 5px; color: var(--muted); font-weight: 500; }
.message-thread-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.message-unread { min-width: 21px; padding: 4px 6px; color: #06131a; background: var(--mint); border-radius: 999px; text-align: center; font-size: 10px; }
.message-conversation { display: grid; grid-template-rows: auto minmax(260px, 1fr) auto auto; min-width: 0; }
.message-conversation-head { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.message-conversation-head strong, .message-conversation-head small { display: block; }
.message-conversation-head small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.message-list { display: flex; flex-direction: column; gap: 9px; overflow: auto; max-height: 55vh; padding: 18px; scroll-behavior: smooth; }
.message-bubble { width: fit-content; max-width: min(72ch, 84%); padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; background: rgba(255,255,255,.045); overflow-wrap: anywhere; white-space: pre-wrap; }
.message-bubble.own { align-self: flex-end; border-color: rgba(99,230,198,.24); border-radius: 14px 14px 4px 14px; background: rgba(99,230,198,.1); }
.message-bubble p { margin: 0; line-height: 1.45; }
.message-bubble small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; text-align: right; }
.message-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; padding: 12px 14px 0; border-top: 1px solid var(--line); }
.message-form button { min-height: 66px; }
.message-feedback { margin: 4px 14px 10px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

dialog { width: min(620px, calc(100% - 24px)); color: var(--text); border: 1px solid var(--line); border-radius: 21px; background: var(--panel); box-shadow: 0 34px 100px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(1, 7, 11, .72); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; }
.credential-list { display: grid; gap: 10px; margin: 20px 0 14px; }
.credential-list div { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(3, 10, 16, .5); }
.credential-list dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.credential-list dd { margin: 0; color: var(--gold); font: 800 21px/1.25 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .04em; overflow-wrap: anywhere; }
.credential-list a { color: var(--gold); font-size: 14px; letter-spacing: 0; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.credential-actions { margin-top: 18px; }
code { color: #cfe8ff; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .metrics, .metrics-five { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 660px) {
  .app-shell { width: min(100% - 20px, 620px); padding-top: 10px; }
  .topbar { top: 8px; }
  .role-pill { display: none; }
  .page-head { padding-top: 38px; align-items: start; flex-direction: column; }
  .metrics, .metrics-five, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .panel-body { padding: 15px; }
  .login-card { padding: 25px; }
  .section-nav { top: 79px; margin-inline: -2px; }
  .section-nav button { min-height: 44px; }
  .message-layout { grid-template-columns: 1fr; }
  .message-sidebar { overflow-x: auto; padding: 9px; border-right: 0; border-bottom: 1px solid var(--line); }
  .message-threads { display: flex; }
  .message-thread { flex: 0 0 min(240px, 78vw); }
  .message-list { min-height: 280px; max-height: 48vh; }
  .message-form { grid-template-columns: 1fr; }
  .message-form button { min-height: 44px; }
  .game-history-head { align-items: stretch; flex-direction: column; }
  .game-history-toolbar { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .game-history-toolbar label { min-width: 0; }
  .history-count { grid-column: 1 / -1; width: 100%; }
}
