:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #11172b;
  --surface-2: #171f37;
  --surface-3: #1d2743;
  --border: #273352;
  --border-soft: #202b48;
  --text: #f4f7ff;
  --muted: #94a1be;
  --muted-2: #6f7d9c;
  --blue: #7387ff;
  --blue-bright: #91a1ff;
  --green: #37d2a2;
  --amber: #ffbe55;
  --danger: #ff6f8c;
  --sidebar-width: 286px;
  --bar-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input { font: inherit; }

button { color: inherit; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 85% 0%, rgba(101, 120, 255, .08), transparent 28%),
    var(--bg);
}

.app-shell[aria-hidden="true"] { visibility: hidden; }

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--border-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .02), transparent 20%),
    var(--surface);
  box-shadow: 16px 0 50px rgba(0, 0, 0, .12);
}

.brand-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--bar-height);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark,
.auth-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(145, 161, 255, .42);
  border-radius: 13px;
  background: linear-gradient(145deg, #7588ff, #4d5ac4);
  color: #fff;
  box-shadow: 0 10px 28px rgba(84, 101, 220, .32), inset 0 1px rgba(255, 255, 255, .28);
  font-weight: 850;
  letter-spacing: -.04em;
}

.brand-lockup strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand-lockup span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px 14px 26px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #3a486c transparent;
}

.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 20px; background: #3a486c; background-clip: padding-box; }

.menu-label,
.eyebrow {
  margin: 0 6px 10px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.game-menu { display: grid; gap: 7px; }

.game-option {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 68px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.game-option:hover { border-color: var(--border); background: rgba(255, 255, 255, .035); }
.game-option:active { transform: scale(.985); }
.game-option.is-active {
  border-color: rgba(124, 141, 255, .38);
  background: linear-gradient(100deg, rgba(101, 120, 255, .17), rgba(101, 120, 255, .055));
  box-shadow: inset 3px 0 #7c8dff;
}

.game-icon,
.active-game-icon {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .08);
  background: var(--surface-3);
}

.game-icon { width: 44px; height: 44px; border-radius: 13px; font-size: 20px; }
.active-game-icon { width: 43px; height: 43px; border-radius: 13px; font-size: 20px; }
.game-icon.tidy, .active-game-icon.tidy { background: linear-gradient(145deg, rgba(55, 210, 162, .22), rgba(55, 210, 162, .06)); }
.game-icon.packing, .active-game-icon.packing { background: linear-gradient(145deg, rgba(255, 174, 66, .23), rgba(255, 174, 66, .06)); }
.game-icon.cosplay, .active-game-icon.cosplay { background: linear-gradient(145deg, rgba(182, 104, 255, .24), rgba(182, 104, 255, .06)); }

.game-copy { min-width: 0; }
.game-copy strong { display: block; font-size: 13px; }
.game-copy small { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--muted-2); font-size: 24px; font-weight: 300; transform: translateY(-1px); }
.game-option.is-active .chevron { color: var(--blue-bright); }

.sidebar-divider { height: 1px; margin: 20px 6px; background: var(--border-soft); }
.sidebar-section { margin: 0; }

.info-card {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: rgba(255, 255, 255, .018);
}

.info-card div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.info-card span { color: var(--muted); font-size: 10px; }
.info-card strong { max-width: 125px; overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.risk-card {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  margin-top: 16px;
  padding: 13px;
  border: 1px solid rgba(255, 190, 85, .2);
  border-radius: 13px;
  background: rgba(255, 190, 85, .065);
}

.risk-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 190, 85, .18);
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
}

.risk-card strong { color: #ffd48e; font-size: 11px; }
.risk-card p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.sidebar-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 10px;
}

.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(255, 190, 85, .08); }
.connection-dot.is-online { background: var(--green); box-shadow: 0 0 0 4px rgba(55, 210, 162, .09); }
.connection-dot.is-error { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 111, 140, .09); }
.version { margin-left: auto; color: var(--muted-2); }

.workspace {
  display: grid;
  grid-template-rows: var(--bar-height) minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.workspace-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 16, 32, .86);
  backdrop-filter: blur(16px);
}

.workspace-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.workspace-title > div:last-child { min-width: 0; }
.title-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-line h2 { overflow: hidden; margin: 0; font-size: 16px; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.workspace-title p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(55, 210, 162, .18);
  border-radius: 99px;
  background: rgba(55, 210, 162, .07);
  color: #69e4be;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .08em;
}

.live-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); }

.workspace-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.action-button,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.action-button:hover,
.icon-button:hover { border-color: #3a496f; background: var(--surface-3); }
.action-button:active,
.icon-button:active { transform: scale(.96); }

.action-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 37px;
  padding: 0 11px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
}

.action-button > span:first-child { color: var(--text); font-size: 15px; }
.danger-action:hover { border-color: rgba(255, 111, 140, .35); background: rgba(255, 111, 140, .08); color: #ff9eb1; }

.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.sidebar-close,
.menu-button { display: none; }

.frame-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0f1220;
}

.game-frame {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0f1220;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.game-frame.is-active {
  z-index: 1;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.frame-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  background: var(--bg);
  color: var(--muted);
  transition: opacity .18s ease, visibility .18s ease;
}

.frame-loading.is-hidden { visibility: hidden; opacity: 0; pointer-events: none; }
.loader-logo { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: 18px; }
.frame-loading strong { font-size: 12px; font-weight: 650; }

.spinner {
  display: inline-block;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(145, 161, 255, .2);
  border-top-color: var(--blue-bright);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sidebar-backdrop { display: none; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 25%, rgba(105, 124, 255, .15), transparent 35%),
    linear-gradient(145deg, #0a0e1c, #10162a 58%, #0b1020);
}

.auth-gate::before {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 36px 36px;
  content: "";
  mask-image: radial-gradient(circle, black, transparent 70%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(126, 143, 255, .23);
  border-radius: 22px;
  background: rgba(17, 23, 43, .92);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .42), inset 0 1px rgba(255, 255, 255, .04);
  backdrop-filter: blur(18px);
}

.auth-mark { width: 54px; height: 54px; margin-bottom: 22px; border-radius: 16px; font-size: 17px; }
.auth-card .eyebrow { margin: 0 0 9px; }
.auth-card h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.auth-copy { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.login-form label { display: block; margin-bottom: 7px; color: #c3cbe0; font-size: 11px; font-weight: 650; }
.password-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.password-row input { min-width: 0; height: 43px; padding: 0 13px; border: 1px solid var(--border); border-radius: 11px; background: #0d1325; color: var(--text); }
.password-row input::placeholder { color: var(--muted-2); }
.primary-button { height: 43px; padding: 0 16px; border: 0; border-radius: 11px; background: linear-gradient(145deg, #7f91ff, #5d6dd8); color: white; font-size: 12px; font-weight: 750; cursor: pointer; box-shadow: 0 8px 24px rgba(84, 101, 220, .28); }
.primary-button:disabled { opacity: .55; cursor: wait; }

.auth-status { display: flex; align-items: flex-start; gap: 9px; min-height: 20px; margin-top: 16px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-status.is-error { color: #ff9eb1; }
.auth-status.is-success { color: #73e4c1; }
.auth-status.is-error .spinner,
.auth-status.is-success .spinner { display: none; }

noscript { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg); color: var(--text); }

@media (max-width: 920px) {
  :root { --bar-height: 68px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), calc(100vw - 46px));
    transform: translateX(-103%);
    transition: transform .22s ease;
  }
  body.is-menu-open .sidebar { transform: translateX(0); }
  .sidebar-close,
  .menu-button { display: grid; }
  .menu-button { grid-template-rows: repeat(3, 2px); align-content: center; gap: 4px; }
  .menu-button span { width: 16px; height: 2px; border-radius: 4px; background: var(--text); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: block;
    visibility: hidden;
    border: 0;
    background: rgba(4, 7, 15, .66);
    opacity: 0;
    transition: opacity .22s ease, visibility .22s ease;
  }
  body.is-menu-open .sidebar-backdrop { visibility: visible; opacity: 1; }
}

@media (max-width: 640px) {
  .workspace-bar { padding: 10px 11px; }
  .active-game-icon { display: none; }
  .workspace-title { gap: 8px; }
  .workspace-title p { max-width: 46vw; }
  .live-badge { display: none; }
  .action-label { display: none; }
  .action-button { width: 37px; padding: 0; justify-content: center; }
  .password-row { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .auth-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
