:root {
  --navy: #1b2440;
  --ink: #1f2a44;
  --ink-soft: #5b6782;
  --line: #d9e2ee;
  --paper: #ffffff;
  --paper-2: #f4f7fb;
  --blue: #2f8cff;
  --blue-deep: #1f6fd6;
  --yellow: #ffcc33;
  --yellow-deep: #e0a800;
  --st-pending: #f5a524;
  --st-in_progress: #2f8cff;
  --st-waiting: #9b6bff;
  --st-done: #22b45f;
  --st-cancelled: #7a8496;
  --st-overdue: #ef4444;
  --radius: 14px;
  --shadow: 0 4px 0 rgba(16, 24, 48, 0.18), 0 12px 32px rgba(16, 24, 48, 0.22);
  --pixel: 'Pixelify Sans', 'Nunito', system-ui, sans-serif;
  --ui: 'Nunito', system-ui, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); }
body { font-family: var(--ui); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
kbd {
  font-family: var(--pixel);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ------------------------------------------------------------ game + overlay */
#game { position: fixed; inset: 0; overflow: hidden; }
#game::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at 50% 45%, transparent 58%, rgba(12, 18, 40, 0.26) 100%);
}
#game canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#world-overlay {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
  pointer-events: none; z-index: 2; will-change: transform;
}
.ov-room > *, .ov-people > * { position: absolute; }

.wall-sign {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--pixel); color: #2b3a67; white-space: nowrap;
}
.wall-sign b { font-size: 34px; font-weight: 700; letter-spacing: 3px; color: #1f6fd6; text-shadow: 3px 3px 0 #bfe1ff; }
.wall-sign span { font-size: 18px; color: #6a5a3f; }

.floor-label {
  transform: translateX(-50%);
  font-family: var(--pixel); font-size: 18px; letter-spacing: 2px; text-transform: uppercase;
  color: rgba(80, 48, 18, 0.45);
}

/* Desk name tags */
.desk-tag {
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: auto; min-width: 150px;
}
.desk-name {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--pixel); font-size: 15px; font-weight: 600; line-height: 1;
  padding: 5px 10px 6px 8px; border-radius: 999px; cursor: pointer;
  color: var(--ink); background: #fff; border: 2px solid #1f2a44;
  box-shadow: 0 3px 0 #1f2a44;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.desk-name::before {
  content: ''; width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--st-done); box-shadow: 0 0 0 2px rgba(34, 180, 95, 0.25);
}
.desk-pts { color: #b07d00; font-weight: 700; }
.desk-role {
  font-size: 12px; padding: 2px 7px; border-radius: 999px; color: #fff;
  background: linear-gradient(90deg, #6c4bd6, #ff4fd8);
}
.desk-tag.hover .desk-name, .desk-name:hover { transform: translateY(-3px); border-color: var(--blue-deep); box-shadow: 0 5px 0 var(--blue-deep); }
.desk-tag[data-level="1"] .desk-name { background: #fff4dc; border-color: #b06a00; box-shadow: 0 3px 0 #b06a00; }
.desk-tag[data-level="1"] .desk-name::before { background: var(--st-pending); box-shadow: 0 0 0 2px rgba(245, 165, 36, 0.3); }
.desk-tag[data-level="2"] .desk-name {
  color: #fff; background: #d62f2f; border-color: #6e1010; box-shadow: 0 3px 0 #6e1010;
  animation: alarm 0.9s steps(2, jump-none) infinite;
}
.desk-tag[data-level="2"] .desk-name::before { background: #fff; box-shadow: none; }
.desk-tag[data-level="2"] .desk-pts { color: #ffe58a; }

/* Developer's gamer desk */
.desk-tag.dev .desk-name {
  color: #e9f6ff; background: #1a1430; border-color: #6c4bd6;
  box-shadow: 0 3px 0 #3b2a63, 0 0 14px rgba(108, 75, 214, 0.55);
}
.desk-tag.dev .desk-name::before { display: none; }
.desk-tag.dev.empty .desk-role { background: #4a4366; }
.desk-tag.dev .desk-pts { color: #25e3c4; }
.desk-tag.dev.hover .desk-name, .desk-tag.dev .desk-name:hover { border-color: #25e3c4; box-shadow: 0 5px 0 #3b2a63, 0 0 18px rgba(37, 227, 196, 0.6); }
.neon-sign {
  transform: translateX(-50%); display: flex; align-items: baseline; gap: 10px; white-space: nowrap;
  font-family: var(--pixel); font-weight: 700; padding: 4px 12px 6px; border-radius: 8px;
  background: #140f26; border: 2px solid #3b2a63; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.neon-sign .n1 { font-size: 18px; color: #25e3c4; text-shadow: 0 0 6px #25e3c4, 0 0 14px #25e3c4; }
.neon-sign .n2 { font-size: 18px; letter-spacing: 3px; color: #ff9cf0; text-shadow: 0 0 6px #ff4fd8, 0 0 16px #ff4fd8; animation: neon 6s infinite; }
@keyframes neon { 0%, 92%, 96%, 100% { opacity: 1; } 94% { opacity: 0.35; } }
.seat-prompt {
  transform: translateX(-50%); pointer-events: auto; cursor: default; white-space: nowrap;
  font-family: var(--pixel); font-size: 15px; font-weight: 700; padding: 6px 12px 7px; border-radius: 10px;
  color: #fff; background: rgba(20, 28, 56, 0.88); border: 2px solid #3b4a78;
}
.seat-prompt.can-sit {
  cursor: pointer; color: #1a1430; background: #25e3c4; border-color: #0f8f7b; box-shadow: 0 3px 0 #0f8f7b;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob { 50% { translate: 0 -4px; } }
@keyframes alarm { 50% { background: #ff5a47; } }

.desk-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 230px; cursor: pointer; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--pixel); font-size: 13px; font-weight: 600; line-height: 1;
  padding: 3px 6px 4px; border-radius: 6px; color: #fff;
  border: 2px solid rgba(0, 0, 0, 0.25);
}
.chip i { font-style: normal; font-size: 11px; opacity: 0.95; }
.st-pending.chip { background: var(--st-pending); color: #3a2400; }
.st-in_progress.chip { background: var(--st-in_progress); }
.st-waiting.chip { background: var(--st-waiting); }
.st-done.chip { background: var(--st-done); }
.st-cancelled.chip { background: var(--st-cancelled); }
.st-overdue.chip { background: var(--st-overdue); }
.st-free.chip { background: #e7f6ff; color: #23608f; border-color: #a9d3ef; }

/* Central board screen (inside the pixel-art TV) */
.board-screen {
  pointer-events: auto; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 7px; padding: 8px 10px;
  background: transparent; border: 0; border-radius: 2px;
  color: #dbe7ff; font-family: var(--pixel);
}
.board-screen:hover { background: rgba(47, 140, 255, 0.12); }
.board-screen:focus-visible { outline: 3px solid var(--yellow); }
.bs-head { display: flex; justify-content: space-between; align-items: center; }
.bs-title { font-size: 14px; font-weight: 700; letter-spacing: 1.5px; color: #8fc3ff; }
.bs-alarm { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: #1d6b3f; color: #c9ffdd; }
.board-screen[data-level="1"] .bs-alarm { background: #8a5a12; color: #ffe4b0; }
.board-screen[data-level="2"] .bs-alarm { background: #c62828; color: #fff; animation: alarm 0.9s steps(2, jump-none) infinite; }
.bs-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kpi { display: flex; flex-direction: column; align-items: center; background: #13213d; border-radius: 4px; padding: 4px 0 3px; }
.kpi b { font-size: 26px; line-height: 1; color: #fff; }
.kpi span { font-size: 11px; color: #9fb3d9; }
.kpi.warn b { color: var(--st-pending); }
.kpi.bad b { color: #ff6b6b; }
.bs-bar { display: flex; height: 9px; border-radius: 2px; overflow: hidden; background: #22314f; }
.bs-bar i { display: block; min-width: 3px; }
.bs-foot { font-size: 11px; color: #7f93bb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Ranking whiteboard */
.ranking-board {
  pointer-events: auto; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 2px; padding: 6px 9px;
  background: transparent; border: 0; font-family: var(--pixel); color: #23304f;
}
.ranking-board:hover { background: rgba(47, 140, 255, 0.07); }
.ranking-board:focus-visible { outline: 3px solid var(--blue); }
.rk-title { font-size: 13px; font-weight: 700; letter-spacing: 1px; color: #e8459b; margin-bottom: 2px; }
.rk-row { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 6px; font-size: 14px; line-height: 1.15; }
.rk-pos { font-weight: 700; color: #fff; background: #9aa6b8; border-radius: 4px; text-align: center; font-size: 12px; }
.rk-1 .rk-pos { background: #e0a800; }
.rk-2 .rk-pos { background: #8f9bb0; }
.rk-3 .rk-pos { background: #c07a3e; }
.rk-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-pts { font-weight: 700; color: #1f6fd6; }
.rk-empty { font-size: 13px; color: #8a96aa; }

/* Visitors */
.player-tag { left: 0; top: 0; display: flex; flex-direction: column; align-items: center; width: 0; overflow: visible; }
.player-name {
  transform: translateX(0); white-space: nowrap;
  font-family: var(--pixel); font-size: 14px; font-weight: 600; line-height: 1;
  padding: 3px 7px 4px; border-radius: 7px; color: #fff; background: rgba(20, 28, 56, 0.82);
}
.player-tag.me .player-name { background: var(--blue-deep); box-shadow: 0 0 0 2px #fff; }
.bubble {
  position: absolute; bottom: 26px; white-space: normal; width: max-content; max-width: 220px;
  font-family: var(--ui); font-weight: 700; font-size: 14px; line-height: 1.25;
  padding: 7px 11px; border-radius: 14px; background: #fff; color: var(--ink);
  border: 2px solid #1f2a44; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: #1f2a44; border-bottom: 0;
}

.float-points {
  transform: translateX(-50%);
  font-family: var(--pixel); font-size: 26px; font-weight: 700; color: var(--yellow);
  text-shadow: 2px 2px 0 #6b3f00, -2px -2px 0 #6b3f00, 2px -2px 0 #6b3f00, -2px 2px 0 #6b3f00;
  animation: floatUp 1.8s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; translate: 0 10px; }
  15% { opacity: 1; translate: 0 0; }
  100% { opacity: 0; translate: 0 -70px; }
}

/* ------------------------------------------------------------ HUD */
.hud-top {
  position: fixed; top: 12px; left: 12px; right: 12px; z-index: 10;
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  background: var(--paper); border-radius: var(--radius); padding: 8px 12px 8px 10px;
  box-shadow: var(--shadow); border: 2px solid #c8d6ea;
}
.logo {
  width: 32px; height: 32px; flex: none; border-radius: 8px;
  background:
    linear-gradient(#ffcc33, #ffcc33) 9px 9px / 6px 10px no-repeat,
    linear-gradient(#22b45f, #22b45f) 18px 14px / 5px 5px no-repeat,
    linear-gradient(#2f8cff, #2f8cff) 5px 5px / 22px 18px no-repeat,
    linear-gradient(#30364f, #30364f) 13px 24px / 6px 5px no-repeat,
    #30364f;
  image-rendering: pixelated;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-family: var(--pixel); font-size: 19px; font-weight: 700; line-height: 1.05; color: var(--ink); }
.brand-text small { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.live {
  flex: none; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.6px;
  padding: 4px 8px 4px 20px; border-radius: 999px; position: relative; color: #fff; background: var(--st-cancelled);
}
.live::before {
  content: ''; position: absolute; left: 8px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: #fff;
}
.live[data-state="live"] { background: var(--st-done); }
.live[data-state="live"]::before { animation: pulse 1.6s ease-in-out infinite; }
.live[data-state="demo"] { background: var(--st-waiting); }
.live[data-state="error"] { background: var(--st-pending); color: #3a2400; }
.live[data-state="error"]::before { background: #3a2400; }
.live[data-state="offline"] { background: var(--st-overdue); }
@keyframes pulse { 50% { opacity: 0.25; } }

.kpis { display: flex; gap: 8px; margin: 0 auto; }
.kpi-pill {
  display: flex; align-items: baseline; gap: 6px; padding: 7px 12px; border-radius: 12px;
  background: var(--paper); box-shadow: var(--shadow); border: 2px solid #c8d6ea; white-space: nowrap;
}
.kpi-pill b { font-family: var(--pixel); font-size: 22px; line-height: 1; color: var(--ink); }
.kpi-pill span { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.kpi-pill.warn { border-color: var(--st-pending); }
.kpi-pill.warn b { color: #c47d00; }
.kpi-pill.bad { border-color: var(--st-overdue); }
.kpi-pill.bad b { color: #d62f2f; }
.kpi-pill.good b { color: #178a47; }

.hud-actions { display: flex; align-items: center; gap: 8px; }
.online {
  display: flex; align-items: center; gap: 2px; padding: 5px 10px 5px 6px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.95); box-shadow: var(--shadow); font-size: 12px; font-weight: 800; color: var(--ink-soft);
  white-space: nowrap;
}
.online:empty { display: none; }
.online .mini { width: auto; height: 21px; image-rendering: pixelated; margin-right: 1px; }
.online span { margin-left: 6px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  font-weight: 900; font-size: 14px; padding: 9px 14px; border-radius: 12px;
  color: #fff; background: var(--blue); border: 2px solid #1553a8; box-shadow: 0 4px 0 #1553a8;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { background: #4a9dff; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #1553a8; }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.btn-yellow { color: #3d2a00; background: var(--yellow); border-color: #a87b00; box-shadow: 0 4px 0 #a87b00; }
.btn-yellow:hover { background: #ffd95c; }
.btn-yellow:active { box-shadow: 0 1px 0 #a87b00; }
.btn-ghost { color: var(--ink); background: #fff; border-color: #b9c6da; box-shadow: 0 4px 0 #b9c6da; }
.btn-ghost:hover { background: #f1f6fd; }
.join-btn { display: none; }
body:not(.joined) .join-btn { display: inline-flex; }

.legend {
  position: fixed; left: 12px; bottom: 12px; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 6px; max-width: min(760px, calc(100vw - 24px));
  padding: 8px 10px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.95); box-shadow: var(--shadow);
}
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 800; color: var(--ink); }
.lg i {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px;
  font-style: normal; font-size: 10px; color: #fff; background: var(--c, #999);
}
.lg.st-pending i { --c: var(--st-pending); color: #3a2400; }
.lg.st-in_progress i { --c: var(--st-in_progress); }
.lg.st-waiting i { --c: var(--st-waiting); }
.lg.st-done i { --c: var(--st-done); }
.lg.st-cancelled i { --c: var(--st-cancelled); }
.lg.st-overdue i { --c: var(--st-overdue); }
.lg.lg-fire i { --c: #ffe3cf; font-size: 12px; }
.lg + .lg { padding-left: 6px; border-left: 1px solid var(--line); }

.hint {
  position: fixed; right: 12px; bottom: 12px; z-index: 9; max-width: 460px;
  font-size: 12px; font-weight: 700; color: #dfe8ff; text-align: right; line-height: 1.7;
  padding: 6px 12px; border-radius: 12px; background: rgba(20, 28, 56, 0.72);
}

/* ------------------------------------------------------------ Toasts */
.toasts {
  position: fixed; left: 12px; top: 80px; z-index: 20;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none;
}
.toast {
  max-width: 380px; padding: 10px 14px; border-radius: 12px;
  font-size: 14px; font-weight: 800; line-height: 1.3;
  background: #fff; color: var(--ink); border-left: 6px solid var(--blue); box-shadow: var(--shadow);
  animation: toastIn 0.25s ease-out;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.toast-good { border-left-color: var(--st-done); }
.toast-warn { border-left-color: var(--st-pending); }
.toast.out { opacity: 0; transform: translateX(-20px); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-30px); } }

/* ------------------------------------------------------------ Chat */
.chat { position: fixed; left: 50%; bottom: 70px; z-index: 30; transform: translateX(-50%); width: min(520px, calc(100vw - 32px)); }
.chat input {
  width: 100%; font: inherit; font-size: 16px; font-weight: 700; padding: 12px 16px;
  border-radius: 14px; border: 3px solid var(--blue); background: #fff; box-shadow: var(--shadow); outline: none;
}

/* ------------------------------------------------------------ Side panel */
.panel {
  position: fixed; top: 76px; right: 12px; bottom: 64px; z-index: 15;
  width: min(480px, calc(100vw - 24px));
  display: flex; flex-direction: column;
  background: var(--paper); border-radius: 18px; border: 3px solid #1f3d6e;
  box-shadow: var(--shadow); overflow: hidden;
  transform: translateX(calc(100% + 30px)); transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.panel.open { transform: none; }
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
  background: linear-gradient(180deg, #3aa0ff, #1f6fd6); color: #fff;
  border-bottom: 3px solid #1f3d6e;
}
.panel-head .avatar { width: auto; height: 64px; image-rendering: pixelated; flex: none; background: rgba(255, 255, 255, 0.18); border-radius: 10px; padding: 4px; }
.ph-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; font-size: 30px; background: rgba(255, 255, 255, 0.2); border-radius: 12px; }
.ph-text { flex: 1; min-width: 0; }
.ph-text h2 { margin: 0; font-family: var(--pixel); font-size: 24px; font-weight: 700; line-height: 1.1; text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2); }
.ph-sub { margin: 3px 0 0; font-size: 13px; font-weight: 700; opacity: 0.92; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #fff3c4; color: #6b4b00; white-space: nowrap; }
.panel-head .badge { background: rgba(255, 255, 255, 0.95); }
.close {
  flex: none; align-self: flex-start; width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  font-size: 16px; font-weight: 900; background: rgba(255, 255, 255, 0.2); border: 2px solid rgba(255, 255, 255, 0.4); color: #fff;
}
.close:hover { background: rgba(255, 255, 255, 0.35); }

.pressure { padding: 12px 16px 10px; border-bottom: 1px solid var(--line); background: var(--paper-2); }
.pr-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.pr-top b { font-weight: 900; }
.pr-top span { color: var(--ink-soft); font-weight: 700; }
.pressure.lvl-0 .pr-top b { color: #178a47; }
.pressure.lvl-1 .pr-top b { color: #b06a00; }
.pressure.lvl-2 .pr-top b { color: #d62f2f; }
.pr-bar { position: relative; height: 10px; margin: 7px 0 4px; border-radius: 999px; background: #e3e9f2; overflow: visible; }
.pr-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #22b45f, #f5a524 60%, #ef4444); }
.pr-bar em { position: absolute; top: -3px; width: 2px; height: 16px; background: #8a96aa; }
.pr-bar em.fire { background: #ef4444; }
.pr-legend { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--ink-soft); }

.toolbar { display: flex; gap: 8px; padding: 12px 16px 8px; align-items: center; }
.seg { display: flex; background: #e9eef6; border-radius: 10px; padding: 3px; flex: none; }
.seg button { border: 0; background: transparent; cursor: pointer; font-size: 13px; font-weight: 800; padding: 6px 10px; border-radius: 8px; color: var(--ink-soft); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.search {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; font-weight: 600; padding: 8px 12px;
  border-radius: 10px; border: 2px solid var(--line); outline: none; background: #fff;
}
.search:focus { border-color: var(--blue); }

.filters { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.fchip {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; font-weight: 800; padding: 5px 9px; border-radius: 999px;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
}
.fchip i { font-style: normal; font-size: 10px; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: #fff; background: var(--c, #8a96aa); }
.fchip small { font-size: 11px; font-weight: 900; color: var(--ink-soft); background: #eef2f8; padding: 0 6px; border-radius: 999px; }
.fchip:hover { border-color: #aebdd3; }
.fchip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.fchip.on small { background: rgba(255, 255, 255, 0.2); color: #fff; }
.fchip.st-pending { --c: var(--st-pending); }
.fchip.st-in_progress { --c: var(--st-in_progress); }
.fchip.st-waiting { --c: var(--st-waiting); }
.fchip.st-done { --c: var(--st-done); }
.fchip.st-cancelled { --c: var(--st-cancelled); }
.fchip.st-overdue { --c: var(--st-overdue); }

.items { list-style: none; margin: 0; padding: 8px 10px 14px; overflow-y: auto; flex: 1; }
.item {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 10px 10px 8px; margin-bottom: 6px; border-radius: 12px;
  background: #fff; border: 2px solid var(--line); border-left: 6px solid var(--c, #8a96aa);
}
.item:hover { border-color: #b8c7dc; border-left-color: var(--c); background: #fbfdff; }
.item.st-pending { --c: var(--st-pending); }
.item.st-in_progress { --c: var(--st-in_progress); }
.item.st-waiting { --c: var(--st-waiting); }
.item.st-done { --c: var(--st-done); }
.item.st-cancelled { --c: var(--st-cancelled); }
.item.st-done .item-title, .item.st-cancelled .item-title { color: #56627a; }
.item.st-cancelled .item-title { text-decoration: line-through; text-decoration-color: rgba(86, 98, 122, 0.5); }
.item.is-overdue { background: #fff6f6; }
.item-icon {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px; font-weight: 900; color: #fff; background: var(--c);
}
.item.st-pending .item-icon { color: #3a2400; }
.item-main { min-width: 0; }
.item-top { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 2px; }
.ref { font-family: var(--pixel); font-size: 14px; font-weight: 700; color: var(--ink); }
.stage { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, #fff); }
.item.st-pending .stage { color: #9a6200; }
.late-pill { font-size: 11px; font-weight: 900; padding: 1px 7px; border-radius: 999px; color: #fff; background: var(--st-overdue); }
.free-pill { font-size: 11px; font-weight: 900; padding: 1px 7px; border-radius: 999px; color: #7a4a00; background: #ffe7b3; }
.prio { font-size: 12px; color: #e0a800; letter-spacing: -1px; }
.item-title {
  display: block; font-size: 15px; font-weight: 800; line-height: 1.3; color: var(--ink); text-decoration: none;
  overflow-wrap: anywhere;
}
.item-title:hover { color: var(--blue-deep); text-decoration: underline; }
.item-meta { margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--ink-soft); line-height: 1.4; }
.deadline { margin-left: 6px; white-space: nowrap; font-weight: 800; }
.deadline.late { color: #d62f2f; }
.open-btn {
  align-self: center; white-space: nowrap; text-decoration: none;
  font-size: 12px; font-weight: 900; padding: 6px 10px; border-radius: 9px;
  color: var(--blue-deep); background: #eaf3ff; border: 2px solid #c5dcfb;
}
.open-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.empty { padding: 30px 10px; text-align: center; color: var(--ink-soft); font-weight: 700; }

.ranking .rank-row {
  display: grid; grid-template-columns: 30px 32px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
}
.rank-pos { font-family: var(--pixel); font-size: 18px; font-weight: 700; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: #e9eef6; }
.r1 .rank-pos { background: #ffcc33; color: #5a3d00; }
.r2 .rank-pos { background: #d4dbe6; }
.r3 .rank-pos { background: #e7b07e; color: #4d2a0a; }
.r1 { border-color: #ffd95c !important; background: #fffbea !important; }
.avatar.small { width: auto; max-width: 40px; height: 40px; image-rendering: pixelated; }
.rank-main { min-width: 0; }
.rank-name { border: 0; background: none; padding: 0; cursor: pointer; font-size: 15px; font-weight: 900; color: var(--ink); text-align: left; }
.rank-name:hover { color: var(--blue-deep); text-decoration: underline; }
.rank-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }
.rank-pts { font-family: var(--pixel); font-size: 24px; color: var(--blue-deep); }
.rank-pts small { font-family: var(--ui); font-size: 12px; color: var(--ink-soft); }
.rules { padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--paper-2); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.rules h3 { margin: 0 0 6px; font-size: 14px; color: var(--ink); }
.rules ul { margin: 0 0 6px; padding-left: 18px; columns: 2; }
.rules p { margin: 0; line-height: 1.5; }

/* ------------------------------------------------------------ Join modal */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(16, 24, 48, 0.55); backdrop-filter: blur(3px);
}
.modal[hidden] { display: none; }
.join-card {
  width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: #fff; border-radius: 22px; border: 3px solid #1f3d6e; box-shadow: var(--shadow);
}
.join-head { padding: 18px 22px 14px; color: #fff; background: linear-gradient(180deg, #3aa0ff, #1f6fd6); border-bottom: 3px solid #1f3d6e; }
.join-head h1 { margin: 0; font-family: var(--pixel); font-size: 30px; font-weight: 700; text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2); }
.join-head p { margin: 4px 0 0; font-size: 14px; font-weight: 700; opacity: 0.95; }
.join-body { display: grid; grid-template-columns: 150px 1fr; gap: 20px; padding: 20px 22px 22px; }
.join-preview {
  display: grid; place-items: center; border-radius: 16px; align-self: start; padding: 16px 0;
  background: repeating-conic-gradient(#a9d9e8 0 25%, #9fd1e2 0 50%) 0 0 / 24px 24px;
  border: 3px solid #7fb9cc;
}
.join-preview canvas { image-rendering: pixelated; width: auto; height: 140px; }
.join-fields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 900; color: var(--ink); }
.field input {
  font: inherit; font-size: 16px; font-weight: 700; padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--line); outline: none;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 140, 255, 0.2); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw {
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; background: var(--c);
  border: 3px solid #fff; box-shadow: 0 0 0 2px #c9d4e4;
}
.sw.on { box-shadow: 0 0 0 3px var(--ink); transform: translateY(-1px); }
.join-error { margin: 0; min-height: 18px; color: #d62f2f; font-size: 13px; font-weight: 800; }
.join-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ Small screens */
@media (max-width: 1100px) {
  .kpis { display: none; }
  .hint { display: none; }
}
@media (max-width: 720px) {
  .hud-top { flex-wrap: wrap; }
  .brand-text small { max-width: 160px; }
  .online { display: none; }
  .legend { display: none; }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: 100%; height: 72vh; border-radius: 18px 18px 0 0; transform: translateY(105%); }
  .join-body { grid-template-columns: 1fr; }
  .join-preview { justify-self: center; padding: 10px 24px; }
}

/* ------------------------------------------------------------ v2: new pieces */
.btn-round { width: 40px; justify-content: center; padding: 9px 0; font-size: 16px; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.minimap {
  position: fixed; right: 12px; bottom: 12px; z-index: 9; width: 236px;
  padding: 8px; border-radius: var(--radius); background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow); border: 2px solid #c8d6ea;
}
.mm-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px 6px; }
.mm-head b { font-family: var(--pixel); font-size: 15px; }
.mm-head span { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
#minimap { display: block; width: 100%; border-radius: 8px; cursor: pointer; background: #b3dfec; }

.help-card {
  position: fixed; left: 50%; bottom: 76px; z-index: 40; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px)); padding: 18px 20px;
  background: #fff; border-radius: 20px; border: 3px solid #1f3d6e; box-shadow: var(--shadow);
  animation: pop 0.25s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 14px) scale(0.97); } }
.help-card h2 { margin: 0 0 10px; font-family: var(--pixel); font-size: 22px; color: var(--blue-deep); }
.help-card ul { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.help-card li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; font-size: 14px; font-weight: 600; line-height: 1.35; }
.help-card .hk { width: 34px; height: 34px; display: grid; place-items: center; font-size: 18px; border-radius: 10px; background: #eef5ff; }
.help-card kbd { background: #eef2f8; border-color: #c9d4e4; color: var(--ink); }

.kinds { display: flex; gap: 8px; }
.kind {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  padding: 10px 12px; border-radius: 12px; font-weight: 900; font-size: 14px;
  background: #fff; border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line);
}
.kind span { font-size: 20px; }
.kind.on { border-color: var(--blue); box-shadow: 0 3px 0 var(--blue); background: #eef5ff; }
.join-colors { display: flex; flex-direction: column; gap: 12px; }

.head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.head-row .badges { margin-top: 0; }
.goto-btn {
  cursor: pointer; font-size: 12px; font-weight: 900; padding: 3px 10px; border-radius: 999px;
  color: var(--blue-deep); background: #fff; border: 0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.goto-btn:hover { background: var(--yellow); color: #3d2a00; }

.team .team-card {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 12px; margin-bottom: 7px; border-radius: 14px; background: #fff;
  border: 2px solid var(--line); border-left: 6px solid var(--st-done);
}
.team .team-card.lvl-1 { border-left-color: var(--st-pending); background: #fffaf0; }
.team .team-card.lvl-2 { border-left-color: var(--st-overdue); background: #fff4f4; }
.team-main { min-width: 0; }
.team-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.team-name { border: 0; background: none; padding: 0; cursor: pointer; font-size: 15px; font-weight: 900; color: var(--ink); text-align: left; }
.team-name:hover { color: var(--blue-deep); text-decoration: underline; }
.dev-pill { font-size: 11px; font-weight: 900; padding: 1px 7px; border-radius: 999px; color: #fff; background: linear-gradient(90deg, #6c4bd6, #ff4fd8); }
.lvl-dot { font-size: 11px; font-weight: 900; padding: 1px 8px; border-radius: 999px; color: #fff; background: var(--st-done); }
.team-top .lvl-dot { margin-left: auto; }
.lvl-dot.lvl-1 { background: var(--st-pending); color: #3a2400; }
.lvl-dot.lvl-2 { background: var(--st-overdue); }
.mini-bar { display: flex; height: 8px; margin: 6px 0 4px; border-radius: 999px; overflow: hidden; background: #e3e9f2; }
.mini-bar i { display: block; min-width: 4px; }
.team-meta { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.team-meta .late { color: #d62f2f; }
.team-meta .pts { color: #b07d00; font-weight: 900; }
.team-actions { display: flex; gap: 6px; }
.mini-btn {
  cursor: pointer; white-space: nowrap; font-size: 12px; font-weight: 900; padding: 6px 10px; border-radius: 9px;
  color: var(--blue-deep); background: #eaf3ff; border: 2px solid #c5dcfb;
}
.mini-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }
.mini-btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }

/* Developer console */
.admin { flex: 1; overflow-y: auto; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 10px; background: #f4f2fb; }
.ad-card { background: #fff; border-radius: 14px; border: 2px solid #ddd6f3; padding: 12px 14px; }
.ad-card.muted { background: #faf9fe; }
.ad-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 900; color: #3b2a63; }
.ad-card p { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); line-height: 1.45; }
.ad-row { display: flex; gap: 10px; align-items: center; }
.ad-row b { display: block; font-size: 14px; }
.ad-row small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.ad-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--st-overdue); }
.ad-dot.ok { background: var(--st-done); box-shadow: 0 0 0 4px rgba(34, 180, 95, 0.2); }
.ad-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ad-actions.end { justify-content: flex-end; margin-top: 0; }
.ad-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ad-kpi { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 10px; background: #f4f2fb; }
.ad-kpi b { font-family: var(--pixel); font-size: 24px; line-height: 1; }
.ad-kpi span { font-size: 11px; font-weight: 800; color: var(--ink-soft); }
.ad-kpi.warn b { color: #c47d00; }
.ad-kpi.bad b { color: #d62f2f; }
.ad-kpi.good b { color: #178a47; }
.ad-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.ad-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.ad-list small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.ad-ok { margin-top: 10px !important; }
.ad-people { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-person { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: #f4f2fb; font-size: 13px; font-weight: 800; }
.ad-person .mini { height: 21px; width: auto; image-rendering: pixelated; }

@media (max-width: 1100px) { .minimap { width: 180px; } }
@media (max-width: 720px) { .minimap { display: none; } .help-card { bottom: 12px; } }

/* Collapsible legend */
.legend { padding: 6px; gap: 0; align-items: center; }
.lg-toggle {
  cursor: pointer; border: 0; background: none; font-size: 13px; font-weight: 900; color: var(--ink);
  padding: 4px 8px; border-radius: 9px;
}
.lg-toggle:hover { background: #eef2f8; }
.lg-items { display: none; flex-wrap: wrap; gap: 6px; padding: 2px 6px 2px 4px; }
.legend.open .lg-items { display: flex; }
.lg-items .lg:first-child { padding-left: 6px; border-left: 1px solid var(--line); }

/* Meetings */
.meet-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fbfcff; }
.meet-btn {
  cursor: pointer; font-weight: 900; font-size: 13px; padding: 7px 12px; border-radius: 10px;
  color: #fff; background: #1a73e8; border: 2px solid #1557b0; box-shadow: 0 3px 0 #1557b0;
}
.meet-btn:hover { background: #2b82f0; }
.meet-btn:disabled { cursor: not-allowed; color: #7a8496; background: #e9eef6; border-color: #d3dbe7; box-shadow: none; }
.meet-hint { flex: 1; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.meet-form { padding: 12px 16px 14px; border-bottom: 1px solid var(--line); background: #f3f8ff; display: grid; gap: 8px; }
.meet-head { display: flex; justify-content: space-between; align-items: center; }
.meet-head b { font-size: 14px; }
.meet-x { cursor: pointer; border: 0; background: none; font-size: 14px; font-weight: 900; color: var(--ink-soft); }
.meet-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.meet-field { display: grid; gap: 3px; font-size: 11px; font-weight: 900; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.meet-field input, .meet-field select, .meet-field textarea {
  font: inherit; font-size: 14px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--ink);
  padding: 7px 9px; border-radius: 9px; border: 2px solid var(--line); background: #fff; outline: none; min-width: 0;
}
.meet-field textarea { resize: vertical; }
.meet-field input:focus, .meet-field select:focus, .meet-field textarea:focus { border-color: #1a73e8; }
.meet-note { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-soft); line-height: 1.4; }
.meet-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* CEO office */
.desk-tag.ceo .desk-name {
  color: #fff8e1; background: #3a2416; border-color: #d4a637;
  box-shadow: 0 3px 0 #7a5a1c, 0 0 12px rgba(212, 166, 55, 0.45);
}
.desk-tag.ceo .desk-name::before { display: none; }
.desk-tag.ceo .desk-role { background: linear-gradient(90deg, #b8860b, #e6c35c); color: #2e1a10; }
.desk-tag.ceo.empty .desk-role { background: #6b5a45; color: #fff; }
.desk-tag.ceo .desk-pts { color: #ffd76a; }
.desk-tag.ceo.hover .desk-name, .desk-tag.ceo .desk-name:hover { border-color: #ffe08a; box-shadow: 0 5px 0 #7a5a1c, 0 0 16px rgba(255, 224, 138, 0.6); }
.desk-tag.dev .desk-name { color: #e9f6ff; background: #1a1430; border-color: #6c4bd6; box-shadow: 0 3px 0 #3b2a63, 0 0 14px rgba(108, 75, 214, 0.55); }
.desk-tag.dev .desk-name::before { display: none; }
.ceo-plate {
  transform: translateX(-50%); display: flex; align-items: baseline; gap: 8px; white-space: nowrap;
  padding: 3px 12px 5px; border-radius: 6px; font-family: var(--pixel);
  background: linear-gradient(180deg, #e6c35c, #b8860b); border: 2px solid #7a5a1c; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.ceo-plate b { font-size: 18px; letter-spacing: 3px; color: #2e1a10; }
.ceo-plate span { font-size: 12px; color: #4a3010; }
.ceo-screen {
  pointer-events: auto; cursor: pointer; display: flex; flex-direction: column; gap: 1px; text-align: left;
  width: 116px; padding: 4px 7px 5px; border-radius: 4px; font-family: var(--pixel);
  color: #dbe7ff; background: #0b1529; border: 3px solid #30364f; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.ceo-screen:hover { border-color: #4a9dff; }
.ceo-screen[data-level="2"] { border-color: #ef4444; }
.ceo-screen[data-level="1"] { border-color: #f5a524; }
.cs-title { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: #8fc3ff; }
.cs-row { font-size: 11px; white-space: nowrap; }
.dev-pill.ceo { background: linear-gradient(90deg, #b8860b, #e6c35c); color: #2e1a10; }
.ad-podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ad-podium li { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; }
.rank-pos.small { width: 26px; height: 26px; font-size: 14px; }

/* Entered from Factory */
body.via-factory .join-btn { display: inline-flex; }
.factory-link { display: block; margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--blue-deep); }
