:root {
  color-scheme: dark;
  --background: #101117;
  --sidebar: #14151d;
  --surface: #191b24;
  --elevated: #20232e;
  --border: #2b2e3b;
  --border-strong: #414554;
  --text: #f2f0f8;
  --muted: #9c9eaf;
  --purple: #c1a5ff;
  --purple-bg: #302444;
  --green: #76e3b4;
  --blue: #88c0ff;
  --amber: #efbd80;
  --red: #ff9b9b;
  --font: Inter, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  font: 14px/1.5 var(--font);
  background: var(--background);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: default; opacity: .58; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, canvas:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 3.1vw, 39px); line-height: 1.15; letter-spacing: -.038em; font-weight: 680; }
h2 { font-size: 17px; line-height: 1.25; letter-spacing: -.018em; }
h3 { font-size: 15px; line-height: 1.3; }
strong, b { font-weight: 650; }
.icon-library { position: absolute; overflow: hidden; width: 0; height: 0; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }

.button { min-height: 37px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #21232c; color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap; }
.button:hover:not(:disabled) { background: #2c2e3a; border-color: #555a6e; }
.button .trailing { width: 15px; height: 15px; opacity: .77; }
.button.primary { background: #bd9dff; border-color: #bd9dff; color: #1b112b; box-shadow: 0 2px 10px #9e75ff1f; }
.button.primary:hover:not(:disabled) { background: #d1baff; border-color: #d1baff; }
.button.danger { color: #ffd1d1; background: #45262e; border-color: #73383f; }
.button.danger:hover:not(:disabled) { background: #5e2f38; border-color: #a45a61; }
.button.bare { background: transparent; border-color: transparent; color: #b6b6c9; }
.button.bare:hover:not(:disabled) { background: var(--elevated); border-color: var(--border); color: var(--text); }
.button.icon-button { width: 37px; padding: 0; }
.actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #d8d6e5; }
label small { font-size: 12px; font-weight: 400; color: var(--muted); }
input, select, textarea { border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; color: var(--text); background: #14151d; }
input::placeholder, textarea::placeholder { color: #828598; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--purple); }
select { padding-right: 25px; min-height: 37px; }
.actions select { width: auto; max-width: 250px; }
textarea { resize: vertical; min-height: 83px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; align-items: center; }
.form-actions :first-child:not(button) { margin-right: auto; }
.form-error { color: var(--red); font-size: 13px; overflow-wrap: anywhere; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; }

.boot { display: flex; align-items: center; justify-content: center; min-height: 100dvh; gap: 12px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--purple); border-radius: 100%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-layout { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background-color: var(--background); background-image: radial-gradient(ellipse at 50% 16%, #4d326655 0%, transparent 58%), linear-gradient(#a494d30c 1px, transparent 1px), linear-gradient(90deg, #a494d30c 1px, transparent 1px); background-size: auto, 33px 33px, 33px 33px; }
.login-card { width: min(100%, 420px); border: 1px solid #39354a; border-radius: 16px; padding: clamp(22px, 5vw, 35px); background: #1a1a24; box-shadow: 0 22px 70px #0007; }
.login-card h1 { font-size: 29px; margin-bottom: 8px; }
.login-card > p { margin-bottom: 22px; color: var(--muted); }
.login-card > .form-error { color: var(--red); margin: 12px 0 0; }
.login-card > .button { margin-top: 17px; }
.login-card form .button.primary { margin-top: 3px; width: 100%; }
.login-card #open-claim { margin-top: -5px; }
.brand { display: flex; align-items: center; gap: 11px; line-height: 1.15; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.015em; }
.brand small { display: block; font: 10px/1.4 var(--mono); color: #aba2bd; letter-spacing: .095em; margin-top: 5px; }
.brand-mark, .claim-emblem { width: 39px; height: 39px; border-radius: 10px; display: grid; place-items: center; background: #302444; border: 1px solid #674f85; color: #d2b5ff; flex: none; }
.brand-mark svg { width: 29px; height: 29px; }
.login-brand, .claim-emblem { margin-bottom: 27px; }
.claim-emblem .icon { width: 22px; height: 22px; }
#own-profile .profile-meta { margin-top: 15px; }

.workspace { display: grid; grid-template-columns: 233px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100dvh; display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border); padding: 23px 15px 15px; z-index: 3; }
.sidebar > .brand { margin: 0 7px 39px; }
.sidebar-section { margin: 0 12px 10px; color: #85879b; font: 10px/1 var(--mono); letter-spacing: .13em; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; padding: 10px 11px; border: 1px solid transparent; border-radius: 8px; color: #b1b2c4; font-weight: 550; }
.sidebar nav a:hover { background: var(--elevated); color: var(--text); }
.sidebar nav a[aria-current="page"] { border-color: #4b3a60; background: #2b223b; color: #e0cbff; }
.nav-count { border-radius: 5px; background: #2d2f3b; color: #d3d2e1; margin-left: auto; min-width: 21px; padding: 1px 5px; text-align: center; font: 11px/1.6 var(--mono); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); margin-top: auto; }
.account-mark, .avatar { width: 34px; height: 34px; display: grid; flex: none; place-items: center; border-radius: 8px; color: #e0c8ff; background: #302342; border: 1px solid #443158; font-weight: 650; }
.account-label { display: grid; min-width: 0; line-height: 1.25; flex: 1; }
.account-label strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-label small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.main-panel { min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(16px, 2.8vw, 40px); border-bottom: 1px solid var(--border); background: #15161e; }
.topbar-start, .breadcrumbs { display: flex; align-items: center; gap: 10px; color: #a7a8ba; }
.breadcrumbs strong { color: var(--text); }
.slash { color: #666879; }
.nav-toggle { display: none; }
.status { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #2d5c4c; border-radius: 100px; color: var(--green); background: #1b3029; padding: 4px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-dot { width: 6px; height: 6px; border-radius: 100%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.status.offline { color: #efadac; border-color: #633c45; background: #322228; }
.status.pending { color: #d5bf8f; border-color: #54482f; background: #2c281f; }
.view { display: grid; gap: 20px; padding: 29px clamp(16px, 2.8vw, 40px) 36px; width: 100%; max-width: 1620px; margin: auto; }
.view-heading { display: flex; justify-content: space-between; gap: 15px; align-items: flex-end; padding-bottom: 2px; }
.view-heading p { margin-top: 6px; color: var(--muted); }
.card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 13px; padding: 17px 18px; border-bottom: 1px solid var(--border); min-height: 70px; }
.card-header p, .section-heading p, .dialog-header p { color: var(--muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.card-content { padding: 16px 18px; }
.card-content.compact { padding: 0; }
.panel-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; color: var(--purple); background: #302444; border: 1px solid #4c3b61; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { position: relative; min-height: 122px; display: grid; align-content: start; justify-items: start; padding: 15px 15px; }
.stat-label { display: flex; align-items: center; gap: 8px; color: #c8c7d8; font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.stat-icon { width: 29px; height: 29px; padding: 6px; border-radius: 7px; outline: 1px solid #ffffff16; outline-offset: -1px; }
.stat-icon.purple { background: #33264a; color: var(--purple); }
.stat-icon.blue { background: #213149; color: var(--blue); }
.stat-icon.green { background: #203a36; color: var(--green); }
.stat-icon.amber { background: #3f3026; color: var(--amber); }
.stat strong { font-size: clamp(23px, 2.4vw, 31px); line-height: 1; letter-spacing: -.03em; }
.stat > span:last-of-type { font-size: 12px; margin-top: 6px; color: var(--muted); }
.sparkline { position: absolute; bottom: 14px; right: 12px; width: 30%; height: 29px; color: #76e3b4; fill: none; stroke: currentColor; stroke-width: 1.3px; opacity: .62; pointer-events: none; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.36fr) minmax(0, 1fr); gap: 18px; }
.inline-alert { padding: 9px 12px; border: 1px solid #69424b; border-radius: 8px; background: #301f26; color: #edb5b5; }

.empty { min-height: 122px; display: grid; justify-items: center; align-content: center; gap: 4px; padding: 18px; color: var(--muted); text-align: center; font-size: 13px; }
.empty strong { color: #d2d0df; }
.empty .icon { width: 23px; height: 23px; color: #9890b0; margin-bottom: 5px; }
.row-list { list-style: none; padding: 0; margin: 0; }
.row-list li { border-bottom: 1px solid var(--border); }
.row-list li:last-child { border-bottom: 0; }
.player-preview, .activity-entry, .plugin-row { width: 100%; display: flex; align-items: center; gap: 11px; color: var(--text); padding: 11px 18px; }
.player-preview { border: 0; text-align: left; background: transparent; }
.player-preview:hover { background: var(--elevated); }
.player-label { display: grid; flex: 1; min-width: 0; justify-items: start; align-content: center; gap: 2px; }
.player-label strong { overflow-wrap: anywhere; }
.player-label small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.avatar[data-tone="1"] { background: #25334c; border-color: #394f68; color: #9ecdff; }
.avatar[data-tone="2"] { background: #243d34; border-color: #3e554a; color: #87e1bc; }
.avatar[data-tone="3"] { background: #3f3029; border-color: #5e463b; color: #f0ba8c; }
.activity-mark { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; border: 1px solid var(--border); background: var(--elevated); color: #b9a8da; }
.activity-entry time { text-align: right; flex: none; color: var(--muted); font-size: 12px; }
.search { position: relative; min-width: 120px; width: min(30vw, 213px); }
.search .icon { position: absolute; top: 10px; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }
.table-scroll { overflow: auto; }
.roster { width: 100%; min-width: 675px; border-collapse: collapse; text-align: left; }
.roster th { padding: 11px 15px; font-size: 12px; color: var(--muted); background: #171922; }
.roster td { padding: 10px 15px; border-top: 1px solid var(--border); }
.roster tr:hover td { background: #20222c; }
.roster .player-cell { display: flex; align-items: center; gap: 9px; min-width: 145px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-flex; align-items: center; color: #c5c3d4; background: #2b2b39; border: 1px solid #3b3c4c; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.green { color: var(--green); background: #1d342b; border-color: #315442; }
.badge.red { color: var(--red); background: #3a252b; border-color: #59333a; }
.badge.amber { color: var(--amber); background: #372b23; border-color: #534032; }
.table-action { text-align: right; }
.plugin-row .actions { justify-content: flex-end; }

.dialog { width: min(590px, calc(100% - 24px)); max-width: none; max-height: calc(100dvh - 24px); overscroll-behavior: contain; padding: 0; color: var(--text); background: var(--surface); border: 1px solid #454354; border-radius: 13px; box-shadow: 0 20px 85px #0009; }
.dialog::backdrop { background: #090912c7; }
.dialog.player-dialog { width: min(740px, calc(100% - 24px)); }
.dialog.confirmation { width: min(430px, calc(100% - 24px)); }
.dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; background: var(--surface); padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { font-size: 21px; }
.dialog-body { padding: 15px 18px 18px; }
.confirm-actions { justify-content: flex-end; }
.profile-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; gap: 9px; margin: 9px 0 0; }
.profile-meta div { border-radius: 7px; padding: 7px 9px; background: var(--elevated); }
.profile-meta dt { color: var(--muted); font-size: 11px; }
.profile-meta dd { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
details { padding: 10px 11px; background: #151720; border: 1px solid var(--border); border-radius: 8px; }
details form { padding-top: 10px; }
summary { font-weight: 630; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inventory-grid { display: grid; gap: 9px; }
.slot-group { display: grid; gap: 4px; }
.slot-group p { color: var(--muted); font-size: 11px; }
.slot-row { display: grid; grid-template-columns: repeat(var(--slots, 9), minmax(0, min(9.8vw, 45px))); gap: 4px; }
.slot-row.equipment { --slots: 5; }
.slot { position: relative; border: 1px solid #393a4a; border-radius: 5px; aspect-ratio: 1; display: grid; place-items: center; background: #14151e; color: #9b8caf; padding: 0; }
.slot:hover, .slot[aria-pressed="true"] { border-color: var(--purple); background: #2a213a; }
.slot img { width: 69%; image-rendering: pixelated; }
.slot .icon { width: 48%; height: 48%; }
.slot-count { position: absolute; bottom: 0; right: 2px; color: #fff; font: 10px/1.35 var(--mono); text-shadow: -1px -1px #000, 1px 1px #000; }
.slot-edit { background: #151720; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.segmented { display: flex; align-items: center; width: fit-content; border: 1px solid var(--border); border-radius: 7px; padding: 3px; background: #13141d; }
.segmented button { border: 1px solid transparent; background: none; color: var(--muted); padding: 4px 8px; border-radius: 5px; }
.segmented button[aria-pressed="true"] { background: var(--purple-bg); color: var(--purple); border-color: #513c6c; }

.map-surface { position: relative; min-height: 320px; height: clamp(320px, 61vh, 810px); isolation: isolate; overflow: hidden; background: #1b2029; background-image: repeating-linear-gradient(135deg, #bbc4ff0b 0px 1px, transparent 1px 8px); }
.map-surface canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.map-surface canvas.dragging { cursor: grabbing; }
.map-surface canvas:focus-visible { outline-offset: -3px; }
.map-markers { position: absolute; inset: 0; pointer-events: none; }
.map-marker { position: absolute; transform: translate(-50%, -100%); display: grid; justify-items: center; gap: 2px; color: #fff; background: transparent; border: 0; text-shadow: 0 1px 2px #000; pointer-events: auto; font-weight: 650; }
.map-marker span { background: #191422e8; border: 1px solid #a18dd1; padding: 0 5px; border-radius: 4px; white-space: nowrap; }
.map-marker i { width: 9px; height: 9px; border-radius: 50%; background: var(--purple); border: 2px solid #302444; box-shadow: 0 0 4px #000; }
.map-compass, .map-coords, .map-scale { position: absolute; color: #e8e3f1; background: #14151de8; border: 1px solid #484959; border-radius: 6px; pointer-events: none; }
.map-compass { top: 11px; left: 11px; display: grid; justify-items: center; padding: 4px 9px; font: 11px/1.2 var(--mono); }
.map-compass b { font-size: 17px; color: var(--purple); }
.map-controls { position: absolute; top: 11px; right: 11px; display: grid; gap: 4px; }
.map-coords, .map-scale { bottom: 11px; padding: 4px 7px; font-size: 11px; }
.map-coords { left: 11px; }
.map-scale { right: 11px; display: grid; gap: 3px; justify-items: center; }
.map-scale div { border: 1px solid var(--purple); border-top: 0; height: 3px; }
.map-footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 12px; border-top: 1px solid var(--border); }
.map-footer label { display: flex; align-items: center; }
.map-footer input { width: clamp(61px, 11vw, 95px); padding: 6px; }
.map-legend { margin-right: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.map-legend span { width: 12px; height: 12px; border: 1px solid var(--border-strong); border-radius: 2px; background: repeating-linear-gradient(135deg, #a1acd326 0px 1px, transparent 1px 4px); }

.toasts { position: fixed; z-index: 8; bottom: 15px; right: 15px; display: grid; gap: 7px; width: min(375px, calc(100% - 30px)); pointer-events: none; }
.toast { display: flex; gap: 10px; padding: 10px 12px; border: 1px solid #476152; border-radius: 9px; background: #26382e; color: #d4f3df; box-shadow: 0 2px 14px #0007; overflow-wrap: anywhere; }
.toast.error { border-color: #80545c; background: #482c34; color: #ffcbce; }
.toast .icon { width: 17px; height: 17px; margin-top: 2px; }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: 197px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .sidebar > .brand { margin-inline: 4px; }
  .stats { gap: 9px; }
  .stat { padding-inline: 10px; }
}
@media (max-width: 800px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: 55px; left: 0; bottom: 0; width: min(233px, 90vw); height: auto; z-index: 5; display: none; box-shadow: 14px 8px 25px #0006; }
  .sidebar.open { display: flex; }
  .topbar { height: 55px; }
  .nav-toggle { display: inline-flex; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { padding-top: 22px; }
}
@media (max-width: 570px) {
  .overview-grid { grid-template-columns: 1fr; gap: 13px; }
  .view { gap: 13px; }
  .view-heading { align-items: flex-start; flex-wrap: wrap; }
  .list-header { flex-wrap: wrap; }
  .card-header, .card-content { padding-inline: 12px; }
  .activity-entry, .player-preview, .plugin-row { padding-inline: 12px; }
  .activity-entry time { font-size: 11px; max-width: 80px; }
  .breadcrumbs > span { display: none; }
  .topbar { padding-inline: 8px; }
  .map-panel .actions select { max-width: 155px; }
  .map-legend { width: 100%; }
  .slot-row { gap: 3px; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
