@font-face {
  font-family: "MinecraftTen";
  src: url("/fonts/MinecraftTen.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #0c0d13;
  --surface: #13141c;
  --surface-2: #1a1c27;
  --border: #252838;
  --border-hi: #3a3e57;
  --text: #e9eaf2;
  --muted: #8a8ea3;
  --gold: #c9a227;
  --gold-hi: #f0d36b;
  --gold-lo: #7d6410;
  --ok: #47c585;
  --bad: #ef5f5b;
  --warn: #f0b13a;
  --sky: #0e1020;
  --pixel: "MinecraftTen", ui-monospace, monospace;
  --body: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 400 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-family: var(--pixel); font-weight: normal; text-transform: uppercase; letter-spacing: 0.04em; }
h2 { font-size: 20px; color: var(--gold-hi); }
h3 { font-size: 18px; }
p { margin: 0; }
img.pixel, .icon { image-rendering: pixelated; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* animations */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes twinkle { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(130vw); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.enter { animation: rise 0.3s ease-out both; }
.stagger > * { animation: rise 0.38s ease-out both; animation-delay: calc(var(--i, 0) * 45ms); }

/* buttons and inputs */
.btn {
  font: 600 14px/1 var(--body);
  color: #17140a;
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 3px 0 var(--gold-lo);
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.12s ease;
}
.btn:hover { background: var(--gold-hi); transform: translateY(-1px); box-shadow: 0 4px 0 var(--gold-lo); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--gold-lo); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn.big { font-size: 16px; padding: 15px 26px; }
.btn.ghost { color: var(--text); background: var(--surface-2); box-shadow: 0 3px 0 #0a0b10, inset 0 0 0 1px var(--border-hi); }
.btn.ghost:hover { background: #222536; }
.btn.danger { color: var(--bad); background: transparent; box-shadow: inset 0 0 0 1px var(--bad); }
.btn.danger:hover { color: #fff; background: var(--bad); transform: translateY(-1px); }
.btn.small-btn { font-size: 13px; padding: 8px 12px; box-shadow: none; }
.btn.small-btn:hover { box-shadow: none; }

input, select {
  font: 400 14px/1.2 var(--body);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: #5d6178; }
input:hover, select:hover { border-color: var(--border-hi); }
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.25); }
input.narrow { width: 96px; }

.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.switch span { position: absolute; inset: 0; background: var(--bg); border: 1px solid var(--border-hi); border-radius: 6px; transition: background 0.2s ease; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--muted); border-radius: 3px; transition: transform 0.2s ease, background 0.2s ease; }
.switch input:checked + span { background: rgba(201, 162, 39, 0.25); border-color: var(--gold); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--gold-hi); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.25); }

/* layout */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; font: 22px var(--pixel); text-transform: uppercase; letter-spacing: 0.04em; }
.brand span { color: var(--gold); }
.brand img { transition: transform 0.2s steps(3); }
.brand:hover img { transform: translateY(-4px); }
.userbox { display: flex; align-items: center; gap: 12px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-weight: 500; font-size: 14px; }
.tag { font: 11px var(--pixel); text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 6px; background: rgba(201, 162, 39, 0.16); color: var(--gold-hi); }

.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1280px; margin: 0 auto; min-height: calc(100vh - 64px - 48px); }
.shell.solo { grid-template-columns: minmax(0, 1fr); max-width: 980px; }
.side { position: sticky; top: 64px; align-self: start; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  font: 500 14px var(--body);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.nav-item img { width: 24px; height: 24px; opacity: 0.8; transition: transform 0.15s steps(2); }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item:hover img { transform: translateY(-2px); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-item.active img { opacity: 1; }
.nav-item::before { content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 4px; background: var(--gold); border-radius: 0 3px 3px 0; transform: scaleY(0); transition: transform 0.2s ease; }
.nav-item.active::before { transform: scaleY(1); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }

.main { padding: 28px 24px 48px; min-width: 0; }
.page-head { margin-bottom: 20px; }
.page-head p { margin-top: 6px; color: var(--muted); }
.page-head h1 { font-size: 30px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--border-hi); }
.card h2 { margin-bottom: 12px; }
.section-title { font: 14px var(--pixel); text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-hi); margin: 20px 0 10px; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: rgba(71, 197, 133, 0.14); color: var(--ok); }
.pill::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 1px; }
.pill.bad { background: rgba(239, 95, 91, 0.14); color: var(--bad); }

.license-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.license-title { display: flex; align-items: center; gap: 12px; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin: 16px 0 4px; }
.meta .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.meta .value { font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.slots { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.slots i { width: 12px; height: 12px; background: var(--border); border-radius: 2px; transition: background 0.25s ease; }
.slots i.used { background: var(--gold); }
.keychip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.keychip img { width: 20px; height: 20px; }

.table-wrap { overflow-x: auto; margin: 4px -8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
tbody tr:last-child td { border-bottom: 0; }
td .row { flex-wrap: nowrap; }

.alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-top: 8px; background: rgba(240, 177, 58, 0.08); border-left: 3px solid var(--warn); border-radius: 0 8px 8px 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 8px; }
.stat { display: flex; align-items: center; gap: 16px; margin: 0; padding: 18px; }
.stat:hover { transform: translateY(-3px); }
.stat img { width: 40px; height: 40px; }
.stat img.dim { filter: grayscale(1) brightness(0.7); }
.stat strong { display: block; font: 30px/1 var(--pixel); }
.stat span { color: var(--muted); font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.setting:last-of-type { border-bottom: 0; }
.setting p { color: var(--muted); font-size: 13px; margin-top: 2px; max-width: 460px; }
.setting strong { font-weight: 600; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty img { width: 64px; height: 64px; margin-bottom: 8px; opacity: 0.9; animation: bob 2.4s steps(4) infinite; }

.skeleton { height: 120px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin-bottom: 16px; animation: pulse 1.2s ease-in-out infinite; }

.ground { height: 48px; background: url("/img/grass.png") repeat-x; background-size: 48px 48px; image-rendering: pixelated; }

/* toasts and modal */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 240px; max-width: 360px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border-hi); border-left: 4px solid var(--ok); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: toast-in 0.25s ease-out both; font-weight: 500; }
.toast.error { border-left-color: var(--bad); }
.toast.leaving { opacity: 0; transform: translateX(24px); transition: opacity 0.25s ease, transform 0.25s ease; }

.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 6, 10, 0.72); animation: fade 0.18s ease-out both; }
.dialog { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border-hi); border-radius: 14px; padding: 24px; animation: pop 0.22s ease-out both; }
.dialog h3 { margin-bottom: 10px; color: var(--gold-hi); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.keybox { font: 500 20px/1.4 var(--mono); padding: 16px; margin: 14px 0 4px; background: var(--bg); border: 1px dashed var(--gold); border-radius: 10px; text-align: center; color: var(--gold-hi); letter-spacing: 0.04em; overflow-wrap: anywhere; }

/* gate */
.gate { position: relative; min-height: 100vh; overflow: hidden; background: var(--sky); display: flex; flex-direction: column; }
.gate-content { position: relative; z-index: 3; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 48px 20px 14vw; }
.gate h1 { font-size: clamp(34px, 7vw, 64px); line-height: 1.05; animation: rise 0.6s ease-out both; }
.gate h1 span { color: var(--gold); }
.gate .lead { max-width: 440px; color: #9ea2bb; font-size: 16px; animation: rise 0.6s 0.1s ease-out both; }
.gate .btn { animation: rise 0.6s 0.2s ease-out both; }
.logo-badge { display: inline-flex; align-items: center; }
.logo-badge img { width: 26px; height: 26px; }
.gate .fine { max-width: 380px; color: #6f7391; font-size: 13px; animation: rise 0.6s 0.3s ease-out both; }
.gate .alert-gate { max-width: 420px; padding: 12px 16px; border-radius: 10px; background: rgba(239, 95, 91, 0.12); border: 1px solid rgba(239, 95, 91, 0.4); color: #ffb4b1; font-size: 14px; animation: pop 0.3s ease-out both; }
.devform { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.stars span { position: absolute; background: #cfd3ff; animation: twinkle 3s steps(2) infinite; }
.cloud { position: absolute; left: 0; image-rendering: pixelated; animation: drift linear infinite; z-index: 1; }
.scene { position: absolute; left: 0; right: 0; bottom: 0; aspect-ratio: 240 / 150; background: url("/img/scene.png") bottom / 100% 100% no-repeat; image-rendering: pixelated; z-index: 2; }

.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.boot img { width: 96px; image-rendering: pixelated; animation: bob 1s steps(4) infinite; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; flex-direction: row; overflow-x: auto; padding: 12px 16px 0; gap: 6px; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item::before { display: none; }
  .nav-sep { display: none; }
  .main { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .chip .name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.setting + .row { margin-top: 20px; }
