:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --line: #2a313c;
  --text: #edf3f8;
  --muted: #8f9ba8;
  --accent: #39d98a;
  --accent-dark: #123d2c;
  --gold: #f4c95d;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: radial-gradient(circle at 15% 0, #15283a 0, var(--bg) 38%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.auth-screen { min-height: 100vh; }
.login-view {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
}
.login-glow { position: absolute; border-radius: 999px; filter: blur(12px); opacity: .38; pointer-events: none; }
.login-glow-one { top: -180px; left: -120px; width: 460px; height: 460px; background: #195b44; }
.login-glow-two { right: -150px; bottom: -220px; width: 520px; height: 520px; background: #173b5c; }
.login-card {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border: 1px solid #33404d;
  border-radius: 26px;
  background: #111820e8;
  box-shadow: 0 36px 100px #0009;
  backdrop-filter: blur(18px);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 54px;
  background:
    linear-gradient(145deg, #16382fdd, #101923ee),
    radial-gradient(circle at 20% 15%, #39d98a55, transparent 42%);
}
.login-brand h1 { margin: 0 0 10px; font-size: clamp(38px, 4vw, 56px); white-space: nowrap; }
.login-brand p:last-child { margin: 0; color: #b9c7d3; font-size: 17px; }
.login-mark {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  border: 2px solid #75efb5;
  border-radius: 50%;
  box-shadow: 0 0 0 12px #39d98a14, inset 0 0 28px #39d98a2c;
}
.login-mark::before, .login-mark::after, .login-mark span {
  content: '';
  position: absolute;
  border: 2px solid #75efb5;
  border-radius: 50%;
}
.login-mark::before { width: 50px; height: 50px; }
.login-mark::after { width: 20px; height: 20px; background: #39d98a; }
.login-mark span { width: 4px; height: 4px; border: 0; background: #062016; z-index: 1; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 54px; background: #121820; }
.login-heading { margin-bottom: 28px; }
.login-heading h2 { margin-bottom: 8px; font-size: 28px; }
.login-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.login-form label { margin-bottom: 18px; color: #c6d0d9; font-weight: 700; }
.login-form input { min-height: 50px; background: #0b1016; font-size: 16px; }
.login-message { min-height: 22px; margin: -3px 0 13px; color: #ff9c9c; font-size: 13px; }
.login-message.success { color: var(--accent); }
.login-submit { width: 100%; min-height: 50px; }
.login-footnote { margin: 18px 0 0; color: #758390; font-size: 11px; line-height: 1.55; text-align: center; }
header, main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
header { min-height: 220px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(32px, 6vw, 64px); letter-spacing: -.04em; margin-bottom: 12px; }
h2 { margin-bottom: 0; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.muted, #summary { color: var(--muted); }
main { display: grid; grid-template-columns: 1fr; gap: 20px; padding-bottom: 60px; }
.panel { background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 24px 60px #0004; }
.panel-title { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 20px; }
.player-picker { display: grid; justify-items: end; gap: 7px; min-width: 250px; }
.player-identity { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #0f141a; color: var(--text); font-weight: 800; }
.player-identity::before { content: ''; width: 11px; height: 11px; flex: 0 0 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #39d98a18; }
#selectedPlayerStatus { color: var(--muted); font-size: 12px; font-weight: 700; }
#selectedPlayerStatus.is-current { color: var(--accent); }
.grid, .resource-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
input, select, textarea, button { border: 1px solid var(--line); border-radius: 10px; background: #0f141a; color: var(--text); font: inherit; }
input, select { min-height: 42px; padding: 8px 12px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
textarea { width: 100%; min-height: 430px; resize: vertical; padding: 14px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
button { min-height: 42px; padding: 9px 16px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { cursor: wait; opacity: .65; }
button.primary { background: var(--accent); border-color: var(--accent); color: #062016; font-weight: 800; }
.header-actions { display: flex; gap: 10px; }
#logout { color: #ffb6b6; }
button.danger { color: #ffdede; border-color: color-mix(in srgb, var(--danger) 58%, var(--line)); }
button.danger:hover { border-color: var(--danger); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.wallet-card, .unlock-card { margin-top: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #0f141a; }
.wallet-card { background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 11%, #0f141a), #0f141a 48%); }
.wallet-card h3, .unlock-card h3 { margin-bottom: 8px; }
.wallet-card > .muted { margin-bottom: 16px; }
.wallet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wallet-grid input { border-color: color-mix(in srgb, var(--gold) 42%, var(--line)); font-size: 18px; font-weight: 800; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-actions button { min-height: 34px; padding: 6px 10px; color: var(--gold); font-size: 12px; }
.resource-details { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.resource-details summary { padding: 14px 16px; cursor: pointer; color: var(--muted); font-weight: 700; }
.resource-details .resource-grid { padding: 0 16px 16px; }
.resource-value-editor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.resource-value-editor button { min-height: 42px; padding-inline: 12px; color: var(--accent); }
.resource-details summary span { float: right; color: var(--accent); font-size: 12px; }
.resource-toolbar { padding: 0 16px 12px; }
.resource-toolbar input { width: 100%; }
.resource-grid label[hidden] { display: none; }
.special-balance-grid small { min-height: 30px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.detail-note { margin: 0; padding: 0 16px 14px; font-size: 12px; }
.player-save-actions { align-items: center; }
.action-result { margin-top: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.action-result.working { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 38%, var(--line)); }
.action-result.success { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 42%, var(--line)); background: color-mix(in srgb, var(--accent-dark) 34%, transparent); }
.action-result.error { color: #ffd2d2; border-color: color-mix(in srgb, var(--danger) 52%, var(--line)); }
.unlock-card { display: grid; gap: 12px; }
.unlock-option { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.unlock-option.recommended { border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); background: color-mix(in srgb, var(--accent-dark) 48%, transparent); }
.unlock-option.danger-option { border-color: color-mix(in srgb, var(--danger) 28%, var(--line)); }
.unlock-option strong, .unlock-option span { display: block; }
.unlock-option span { max-width: 560px; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.inline-action { display: flex; gap: 8px; flex: 0 0 auto; }
.inline-action input { width: 120px; }
.action-note { margin: 0; font-size: 12px; }
.table-badge { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 800; }
.table-badge.is-overridden { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--accent); }
.table-badge.is-dirty { border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); color: var(--gold); }
.table-selector-grid { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(320px, 1.2fr); gap: 12px; margin: 20px 0 14px; }
.table-summary-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--accent-dark) 34%, #0f141a); }
.table-summary-card strong, .table-summary-card small { display: block; }
.table-summary-card strong { margin-top: 4px; font-size: 21px; }
.table-summary-card small, .table-summary-label { color: var(--muted); font-size: 11px; }
#tableRecordCount { flex: 0 0 auto; color: var(--accent); font-size: 13px; font-weight: 800; }
.table-effect-preview { margin-top: 14px; padding: 18px; border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); border-radius: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent-dark) 58%, #0f141a), #0f141a 58%); }
.table-effect-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.table-effect-heading span, .table-effect-heading strong { display: block; }
.table-effect-heading span { margin-bottom: 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.table-effect-heading strong { font-size: 17px; }
.table-effect-heading b { flex: 0 0 auto; color: var(--gold); font-size: 22px; }
.table-effect-control { margin-top: 16px; }
.table-effect-control input { width: 100%; min-height: 26px; padding: 0; accent-color: var(--accent); }
.table-effect-ranges { display: flex; gap: 5px; margin-top: 13px; }
.table-effect-range { min-width: 0; padding: 9px 5px; border: 1px solid var(--line); border-radius: 8px; background: #111820; color: var(--muted); text-align: center; transition: border-color .15s, background .15s, color .15s; }
.table-effect-range span, .table-effect-range strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-effect-range span { font-size: 10px; }
.table-effect-range strong { margin-top: 3px; color: var(--text); font-size: 14px; }
.table-effect-range.is-active { border-color: var(--accent); background: var(--accent-dark); color: var(--accent); box-shadow: 0 0 0 2px #39d98a1c; }
.table-effect-result { margin: 13px 0 0; padding: 10px 12px; border-radius: 9px; background: #0c1217; color: var(--accent); font-weight: 800; }
.table-effect-result.is-warning { color: var(--danger); }
.table-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) 130px auto; align-items: end; gap: 12px; margin: 14px 0; }
.table-pagination { min-height: 42px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.table-pagination button { min-height: 42px; padding-inline: 12px; }
#tablePageStatus { min-width: 78px; color: var(--muted); font-size: 12px; text-align: center; }
.table-visual-editor { display: grid; gap: 10px; min-height: 180px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #0d1218; }
.table-empty { display: grid; min-height: 150px; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.visual-record { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #121820; }
.visual-record[open] { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.visual-record > summary { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; cursor: pointer; list-style-position: inside; }
.visual-record > summary strong { color: var(--text); }
.visual-record > summary span { color: var(--accent); font-size: 11px; font-weight: 800; }
.visual-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 11px; padding: 14px; border-top: 1px solid var(--line); background: #0f141a; }
.visual-field-grid.nested { margin-top: 8px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #0c1117; }
.visual-field { min-width: 0; padding: 10px; border: 1px solid #242c36; border-radius: 10px; background: #141b23; }
.visual-field-label { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--text); font-weight: 700; }
.visual-field-label small { overflow: hidden; color: #65717d; font: 10px ui-monospace, monospace; text-overflow: ellipsis; }
.visual-field input, .visual-field select { width: 100%; }
.visual-field input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 2px #ff6b6b22; }
.visual-group { grid-column: 1 / -1; padding: 10px; border: 1px dashed #303a46; border-radius: 10px; background: #121820; }
.visual-group > summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.visual-group > summary small { margin-left: 9px; color: #65717d; font: 10px ui-monospace, monospace; }
.visual-empty-value { grid-column: 1 / -1; padding: 9px; color: #65717d; font-size: 12px; }
.table-actions { position: sticky; bottom: 12px; z-index: 2; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #111820ee; backdrop-filter: blur(10px); }
#toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 14px 18px; border-radius: 10px; background: var(--accent); color: #062016; font-weight: 700; opacity: 0; transform: translateY(12px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 800px) {
  .login-view { padding: 16px; }
  .login-card { grid-template-columns: 1fr; min-height: auto; }
  .login-brand { gap: 16px; padding: 24px; }
  .login-brand h1 { font-size: 32px; }
  .login-mark { width: 64px; height: 64px; }
  .login-mark::before { width: 38px; height: 38px; }
  .login-form { padding: 32px; }
  header { align-items: flex-start; flex-direction: column; padding: 48px 0 28px; }
  main { grid-template-columns: 1fr; }
  .panel-title { flex-direction: column; }
  .player-picker { justify-items: stretch; width: 100%; }
  .wallet-grid { grid-template-columns: 1fr; }
  .unlock-option { align-items: stretch; flex-direction: column; }
  .inline-action { width: 100%; }
  .inline-action input, .inline-action button { flex: 1; }
  .table-selector-grid, .table-toolbar { grid-template-columns: 1fr; }
  .table-summary-card { align-items: flex-start; flex-direction: column; }
  .table-effect-heading { align-items: flex-start; flex-direction: column; }
  .table-effect-ranges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-pagination { justify-content: space-between; }
  .visual-field-grid { grid-template-columns: 1fr; padding: 10px; }
  .table-actions { position: static; }
}
