:root {
  --bg: #070b16;
  --panel: rgba(9, 14, 28, 0.82);
  --panel-solid: #0b1120;
  --line: rgba(125, 211, 252, 0.14);
  --line-strong: rgba(125, 211, 252, 0.3);
  --text: #e8eefc;
  --muted: #8b9ac2;
  --accent: #22d3ee;
  --c: #22d3ee;
  --radius: 14px;
  --font: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h2, h3 { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
code { font-family: var(--mono); font-size: 11px; background: rgba(125,211,252,0.1); padding: 1px 5px; border-radius: 5px; }

#scene { position: fixed; inset: 0; display: block; touch-action: none; cursor: grab; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px;
  background: linear-gradient(to bottom, rgba(5,7,15,0.92), rgba(5,7,15,0.55) 70%, transparent);
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(34,211,238,0.25), rgba(129,140,248,0.25)),
    #0b1120;
  border: 1px solid var(--line-strong);
  box-shadow: 0 0 18px rgba(34,211,238,0.25), inset 0 0 12px rgba(34,211,238,0.15);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 9px;
  border: 2px solid var(--accent); transform: rotate(45deg); border-radius: 3px;
}
.brand-name { font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.18em; text-transform: uppercase; }

.rank { min-width: 240px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); backdrop-filter: blur(10px); }
.rank-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rank-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-xp { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rank-next { font-size: 10px; color: var(--muted); margin-top: 4px; }
.bar { height: 6px; border-radius: 99px; background: rgba(125,211,252,0.1); overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--c), #fff8); box-shadow: 0 0 10px var(--c); transition: width .4s ease; }

.stat { display: flex; flex-direction: column; align-items: flex-end; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); backdrop-filter: blur(10px); min-width: 84px; }
.stat-label { font-size: 10px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.stat-value { font-size: 16px; font-weight: 600; }
.stat-date .stat-value { font-size: 14px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  backdrop-filter: blur(10px); transition: border-color .15s, box-shadow .15s, color .15s;
}
.icon-btn:hover { border-color: var(--line-strong); box-shadow: 0 0 14px rgba(34,211,238,0.2); }
.icon-btn.is-on { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 16px rgba(34,211,238,0.35); }

.hint {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 4;
  padding: 8px 14px; border-radius: 99px; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  transition: opacity .4s, transform .4s; pointer-events: none; white-space: nowrap;
}
.hint.is-gone { opacity: 0; transform: translateX(-50%) translateY(-8px); }

.sync-badge { font-size: 11px; font-family: var(--mono); color: var(--muted); padding: 4px 9px; border-radius: 99px; border: 1px solid transparent; }
.sync-badge.is-ok { color: #a7f3d0; border-color: rgba(167,243,208,0.3); }
.sync-badge.is-bad { color: #fda4af; border-color: rgba(253,164,175,0.3); }
.toggle.small { margin: 8px 0 6px; }

/* ---------- Dock ---------- */
#dock {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 8px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  backdrop-filter: blur(14px); box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none;
}
#dock::-webkit-scrollbar { display: none; }
.dock-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; text-align: left; min-width: 150px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.dock-item:hover { background: rgba(255,255,255,0.04); border-color: var(--line); }
.dock-item.is-open { background: color-mix(in srgb, var(--c) 12%, transparent); border-color: var(--c); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
.dock-ring {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background:
    radial-gradient(closest-side, var(--panel-solid) 76%, transparent 78% 100%),
    conic-gradient(var(--c) calc(var(--pct) * 1%), rgba(255,255,255,0.08) 0);
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 30%, transparent);
}
.dock-lv { font-size: 13px; font-weight: 600; color: var(--c); }
.dock-text { display: flex; flex-direction: column; line-height: 1.15; }
.dock-name { font-size: 13px; font-weight: 600; white-space: nowrap; }
.dock-sub { font-size: 10px; color: var(--muted); white-space: nowrap; }
.dock-item.is-active .dock-sub { color: var(--c); }
.dock-done { position: absolute; top: 4px; right: 6px; font-size: 10px; color: #a7f3d0; }

/* ---------- Panel ---------- */
.panel {
  position: fixed; top: 76px; right: 14px; bottom: 90px; width: min(420px, calc(100vw - 28px)); z-index: 6;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px color-mix(in srgb, var(--c) 20%, transparent) inset;
  transform: translateX(calc(100% + 24px)); opacity: 0; transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .2s;
}
.panel.is-open { transform: none; opacity: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 12px; }
.panel-title h2 { font-size: 18px; }
.panel-tag { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
.dept-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 14px currentColor; flex: none; }
.panel-body { padding: 14px 16px 18px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.panel-body h3 { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.blurb { margin: 0 0 12px; font-size: 13.5px; line-height: 1.55; color: #c3cde6; }
.level { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.02); }
.level-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.level-lv { font-weight: 600; color: var(--c); }
.level-mult { font-size: 11px; color: var(--muted); margin-top: 6px; }
.targets { margin-top: 10px; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 8px 12px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px dashed var(--line); color: var(--muted); }
.targets.is-done { border-color: #a7f3d0; color: #a7f3d0; background: rgba(167,243,208,0.06); }

.acts { display: flex; flex-direction: column; gap: 6px; }
.act { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.02); transition: border-color .15s, background .15s; }
.act:hover { border-color: var(--line-strong); }
.act.is-met { border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 7%, transparent); }
.act-main { flex: 1; min-width: 0; }
.act-label { font-size: 13.5px; font-weight: 500; }
.act-meta { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.act-bar { height: 3px; border-radius: 99px; background: rgba(255,255,255,0.08); margin-top: 6px; overflow: hidden; }
.act-bar > div { height: 100%; background: var(--c); box-shadow: 0 0 8px var(--c); transition: width .3s; }
.act-ctrl { display: flex; align-items: center; gap: 6px; flex: none; }
.act-count { min-width: 26px; text-align: center; font-size: 15px; font-weight: 600; }
.ctl { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); color: var(--text); font-size: 18px; line-height: 1; display: grid; place-items: center; transition: all .12s; }
.ctl:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(255,255,255,0.06); }
.ctl:disabled { opacity: 0.3; cursor: default; }
.ctl-plus { border-color: var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 25%, transparent); }
.ctl-plus:hover { background: color-mix(in srgb, var(--c) 22%, transparent) !important; }
.ctl-plus:active { transform: scale(0.92); }
.ctl-x { width: 24px; height: 24px; font-size: 14px; }
.chip { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); vertical-align: middle; margin-left: 4px; font-family: var(--mono); }

.upgs { display: flex; flex-direction: column; gap: 6px; }
.upg { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,0.02); }
.upg.is-owned { border-color: color-mix(in srgb, var(--c) 50%, transparent); background: color-mix(in srgb, var(--c) 6%, transparent); }
.upg-label { font-size: 13.5px; font-weight: 600; }
.upg-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.upg-owned { font-size: 11px; color: var(--c); flex: none; }

.clients { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.client { display: flex; align-items: center; gap: 8px; padding: 7px 8px 7px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 13px; }
.client-name { flex: 1; }
.client-form { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.client-form input, .client-form select { min-width: 0; }

input[type="text"], input[type="url"], select, textarea {
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); outline: none; font-size: 13px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,0.12); }
select option { background: var(--panel-solid); }
textarea { font-family: var(--mono); font-size: 11.5px; resize: vertical; }

.btn {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--text); font-weight: 600; font-size: 13px; white-space: nowrap;
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 20%, transparent); transition: all .12s; display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { background: color-mix(in srgb, var(--c) 26%, transparent); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 10px; font-size: 12px; font-family: var(--mono); }
.btn-ghost { border-color: var(--line); background: rgba(255,255,255,0.03); box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,0.06); }
.btn-danger { --c: #fb7185; }

/* ---------- Music ---------- */
.music {
  position: fixed; left: 14px; bottom: 90px; z-index: 6; width: min(380px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform .25s, opacity .2s;
}
.music.is-open { transform: none; opacity: 1; pointer-events: auto; }
.music-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.music-title { font-weight: 600; }
.music-sub { font-size: 11px; color: var(--muted); }
.music-frame { padding: 10px; min-height: 120px; }
.music-frame iframe { display: block; border-radius: 12px; }
.music-foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 16px 14px; font-size: 12px; color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(3,5,12,0.6); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal-card { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,0.7); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 6px 20px 20px; }
.modal-body h3 { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.modal-body p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }
.details { margin-top: 10px; }
.details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.details textarea { margin: 8px 0; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { --c: var(--accent); padding: 9px 14px; border-radius: 99px; font-size: 13px; background: var(--panel-solid); border: 1px solid var(--c); box-shadow: 0 0 20px color-mix(in srgb, var(--c) 35%, transparent); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; max-width: min(520px, calc(100vw - 40px)); text-align: center; }
.toast.is-in { opacity: 1; transform: none; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .rank { min-width: 180px; }
  .stat { min-width: 64px; padding: 5px 9px; }
  .stat-date, .hint { display: none; }
  .dock-item { min-width: 0; padding-right: 10px; }
  .dock-text { display: none; }
  .panel { top: 70px; bottom: 84px; }
}
@media (max-width: 600px) {
  #hud { padding: 10px 12px; gap: 8px; }
  .brand-sub, .rank-next, .sync-badge, .brand-name { display: none; }
  .brand-mark { width: 30px; height: 30px; }
  .hud-left { gap: 8px; }
  .rank { min-width: 110px; padding: 6px 10px; }
  .hud-right { gap: 6px; }
  .hud-right .stat:nth-child(3) { display: none; }
  .stat { min-width: 0; }
  .icon-btn { width: 32px; height: 32px; }
  .panel { top: auto; bottom: 78px; right: 8px; left: 8px; width: auto; height: min(62vh, 560px); transform: translateY(calc(100% + 100px)); }
  .panel.is-open { transform: none; }
  .music { left: 8px; right: 8px; width: auto; bottom: 78px; }
  #dock { bottom: 8px; padding: 6px; gap: 4px; }
  .dock-item { padding: 6px; }
}
