/* GTA Live Code Editor prototype — local preview only */
:root {
  --bg: #07090f;
  --bg-2: #0c1018;
  --panel: #121722;
  --panel-2: #181e2b;
  --line: rgba(255,255,255,0.08);
  --cyan: #2ad1d6;
  --cyan-dim: rgba(42,209,214,0.16);
  --amber: #f59e0b;
  --amber-dim: rgba(245,158,11,0.16);
  --green: #34d399;
  --red: #fb7185;
  --text: #e8eef2;
  --muted: #93a0ad;
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
  --header-h: 58px;
  --dev-h: 32px;
  --tabs-h: 46px;
  font-family: Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}
html { overflow-x: clip; }
body { min-height: 100dvh; overflow: hidden; overscroll-behavior-x: none; }
button, select { font: inherit; }
button { cursor: pointer; }

.app {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dev-banner {
  position: relative;
  z-index: 50; /* stay clickable above the signed-out lock overlay */
  min-height: var(--dev-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 14px;
  background: linear-gradient(90deg, #3b2a08, #1d1406);
  color: #fde68a;
  font-size: 12px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(245,158,11,0.35);
}
.dev-banner strong { color: #fff; font-weight: 700; }
.dev-banner .dev-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg {
  display: inline-flex;
  border: 1px solid rgba(253,230,138,0.35);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0,0,0,0.25);
}
.seg button {
  border: 0;
  background: transparent;
  color: #fde68a;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}
.seg button[aria-pressed="true"] {
  background: var(--amber);
  color: #111;
}

.topbar {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: var(--header-h);
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  overflow: hidden;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 28px;
  letter-spacing: 0.04em;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
}
.brand h1 span { color: var(--cyan); }
#current-project-label { color: #e8eef2; font-weight: 650; }
.brand-sep { opacity: 0.45; margin: 0 2px; }
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 220px;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}
.label-short { display: none; }
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.btn:hover { border-color: rgba(42,209,214,0.4); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-run { background: var(--cyan); color: #042426; border-color: transparent; }
.btn-run:hover { filter: brightness(1.08); }
.btn-reset { background: transparent; }
.btn-publish { background: #0f766e; color: #ecfeff; border-color: #14b8a6; }
.btn-publish:hover { filter: brightness(1.08); }
body.role-guest .member-only { display: none !important; }
.status {
  font-size: 12px;
  color: var(--muted);
  min-width: 9rem;
}
.status[data-state="running"] { color: var(--green); }
.status[data-state="loading"] { color: var(--cyan); }
.status[data-state="error"] { color: var(--red); }

.workspace {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  overflow: hidden;
}

.scene-pane, .editor-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #05070c;
}
.editor-pane { background: var(--panel); border-left: 1px solid var(--line); }

.scene-frame-wrap { flex: 1; min-width: 0; min-height: 0; position: relative; overflow: hidden; background: #04060c; }
.scene-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border: 0;
  background: #04060c;
}
.scene-cover, .error-card, .lock-card {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.scene-cover {
  background: #07090f;
  color: var(--muted);
  z-index: 2;
}
.scene-cover[hidden], .error-card[hidden], .lock-card[hidden], .empty-editor[hidden] { display: none !important; }
.scene-cover .spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(42,209,214,0.2);
  border-top-color: var(--cyan);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-card {
  z-index: 3;
  background: rgba(8,6,8,0.92);
  color: #fecdd3;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  overflow: auto;
}
.error-card pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.5 "Fira Code", ui-monospace, monospace;
  color: #fb7185;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top, #15202c, #07090f 55%);
}
.lock-screen[hidden] { display: none !important; }
html.ifs-gate #lock-screen {
  display: flex !important;
}
html.ifs-booting #lock-screen {
  display: none !important;
}
.boot-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at top, #15202c, #07090f 55%);
  color: var(--muted);
}
html.ifs-booting .boot-screen,
html.ifs-booting #boot-screen {
  display: flex !important;
}
.boot-screen[hidden] { display: none !important; }
html.ifs-booting #boot-screen[hidden] { display: flex !important; }
#boot-text {
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #c5d0d8;
}
.lock-card-static {
  max-width: 34rem;
  background: var(--panel);
  border: 1px solid rgba(42,209,214,0.28);
  border-radius: 18px;
  padding: 28px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-card-static h2 {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 42px;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  color: var(--cyan);
}
.lock-card-static p { color: #c5d0d8; line-height: 1.6; margin: 0 0 18px; }
.lock-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-member { background: var(--amber); color: #111; border-color: transparent; }
.btn-signin { background: var(--cyan); color: #042426; border-color: transparent; }

.editor-code {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-head {
  min-width: 0;
  min-height: var(--tabs-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 4px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  overflow: hidden;
  flex-shrink: 0;
}
.step-tabs-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
}
.step-tabs-wrap::before,
.step-tabs-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.step-tabs-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--panel-2) 10%, transparent);
}
.step-tabs-wrap::after {
  right: 0;
  background: linear-gradient(270deg, var(--panel-2) 10%, transparent);
}
.step-tabs-wrap.has-left::before { opacity: 1; }
.step-tabs-wrap.has-right::after { opacity: 1; }
.step-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  min-width: 0;
  flex: 1;
  padding: 2px 2px 4px;
  /* thin, auto-hiding — reserved 4px so hover doesn't jump the layout */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.step-tabs:hover,
.step-tabs:focus-within {
  scrollbar-color: rgba(42, 209, 214, 0.45) transparent;
}
.step-tabs::-webkit-scrollbar {
  height: 4px;
  background: transparent;
}
.step-tabs::-webkit-scrollbar-track { background: transparent; }
.step-tabs::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
.step-tabs:hover::-webkit-scrollbar-thumb,
.step-tabs:focus-within::-webkit-scrollbar-thumb {
  background: rgba(42, 209, 214, 0.45);
}
.step-tabs button, .full-tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.step-tabs button:hover, .full-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
.step-tabs button[aria-selected="true"], .full-tab[aria-selected="true"] {
  background: rgba(42, 209, 214, 0.14);
  color: #7eecef;
  border-color: rgba(42, 209, 214, 0.5);
  box-shadow: inset 0 -2px 0 #2ad1d6;
}
.step-tabs button.is-dirty::after, .full-tab.is-dirty::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--amber);
  vertical-align: middle;
}
.full-tab { border: 1px solid var(--line); border-radius: 999px; }
.step-select {
  display: none;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 650;
}

.editor-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding: 4px 16px 4px 14px;
  border-bottom: 1px solid var(--line);
  background: #0e141d;
  flex-shrink: 0;
}
.step-title {
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #d7e0e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-wrap {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-wrap:hover { color: var(--text); border-color: rgba(42,209,214,0.35); }
.btn-wrap[aria-pressed="true"] {
  background: rgba(42, 209, 214, 0.14);
  color: #7eecef;
  border-color: rgba(42, 209, 214, 0.45);
}

#cm-host, .empty-editor { flex: 1; min-width: 0; min-height: 0; }
#cm-host { overflow: hidden; background: #0a0e16; }
#cm-host .cm-editor { height: 100%; width: 100%; max-width: 100%; min-width: 0; font-size: 13px; }
#cm-host .cm-scroller {
  overflow: auto;
  max-width: 100%;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, "Cascadia Mono", ui-monospace, monospace;
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: rgba(42, 209, 214, 0.38) rgba(255,255,255,0.04);
}
#cm-host .cm-scroller::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
#cm-host .cm-scroller::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.03);
  border-radius: 999px;
}
#cm-host .cm-scroller::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
#cm-host .cm-scroller::-webkit-scrollbar-thumb:hover {
  background: rgba(42, 209, 214, 0.55);
  background-clip: padding-box;
  border: 2px solid transparent;
}
#cm-host .cm-scroller::-webkit-scrollbar-corner { background: transparent; }
.empty-editor { display: flex; align-items: center; justify-content: center; color: var(--muted); }

.hintbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 12px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: #0d121a;
  overflow: hidden;
  min-width: 0;
  flex-wrap: wrap;
}
.hintbar > span:first-child { min-width: 0; }
.hintbar-keys { flex-shrink: 0; white-space: nowrap; padding-top: 1px; }
.hintbar a {
  color: #7eecef;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.hintbar a:hover, .hintbar a:focus-visible {
  color: #fbbf24;
}
.hintbar kbd {
  font: 600 10px "Fira Code", ui-monospace, monospace;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
  color: #d5dee6;
}

.view-toggle { display: none; }

@media (max-width: 900px) and (orientation: portrait) {
  #current-project-label { color: #e8eef2; font-weight: 650; }
.brand-sep { opacity: 0.45; margin: 0 2px; }
.brand p { display: none; }
  .toolbar { justify-content: flex-start; width: 100%; flex: 1 1 100%; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, 42vh) minmax(0, 1fr);
  }
  .editor-pane { border-left: 0; border-top: 1px solid var(--line); }
  .view-toggle { display: inline-flex; }
  body.scene-max .workspace { grid-template-rows: minmax(0, 1fr) 0; }
  body.scene-max .editor-pane { display: none; }
  body.editor-max .workspace { grid-template-rows: 0 minmax(0, 1fr); }
  body.editor-max .scene-pane { display: none; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .brand h1 { font-size: 20px; }
  #current-project-label { color: #e8eef2; font-weight: 650; }
.brand-sep { opacity: 0.45; margin: 0 2px; }
.brand p { display: none; }
  .dev-banner { font-size: 11px; padding: 3px 10px; }
  .topbar { min-height: 0; padding: 4px 10px; }
  .hintbar { display: none; }
  .step-tabs-wrap { display: none; }
  .step-tabs { display: none; }
  .step-select { display: block; }
  .editor-subbar { min-height: 24px; padding: 2px 16px 2px 10px; }
  .step-title { font-size: 11px; }
  .workspace { grid-template-columns: minmax(0, 1.1fr) minmax(240px, 0.9fr); }
  .btn { padding: 6px 10px; font-size: 12px; }
}

@media (max-width: 640px) {
  .brand h1 { font-size: 22px; }
  .btn { padding: 6px 8px; font-size: 12px; }
  .status { display: none; }
  .toolbar { gap: 6px; width: 100%; justify-content: flex-start; }
  .label-full { display: none; }
  .label-short { display: inline; }
}


/* ---- My Projects drawer + Save/Publish modals ---- */
.drawer-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 6, 12, 0.62);
}
.drawer-backdrop[hidden], .modal-backdrop[hidden],
.projects-drawer[hidden] { display: none !important; }

.projects-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 61;
  width: min(420px, 100%);
  height: 100dvh;
  background: #10161f;
  border-left: 1px solid rgba(42,209,214,0.22);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  color: var(--text);
}
.drawer-head, .modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}
.drawer-head h2, .modal h2 {
  margin: 0;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: #fff;
}
.drawer-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.drawer-actions { padding: 0 16px 12px; }
.drawer-actions .btn { width: 100%; }

.project-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 18px 8px;
  text-align: center;
}
.project-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px;
}
.project-card.is-current {
  border-color: rgba(42,209,214,0.45);
  box-shadow: inset 0 0 0 1px rgba(42,209,214,0.18);
}
.project-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.project-meta {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}
.project-meta .pub-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(52,211,153,0.16);
  color: #6ee7b7;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.project-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.project-card-actions .btn { padding: 5px 9px; font-size: 11px; }
.btn-danger { color: #fecdd3; border-color: rgba(251,113,133,0.35); }
.btn-danger:hover { border-color: var(--red); }

.modal-backdrop {
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: min(520px, 100%);
  max-height: min(92dvh, 720px);
  overflow: auto;
  background: #121922;
  border: 1px solid rgba(42,209,214,0.28);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 4px 16px 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.field span { font-size: 12px; font-weight: 700; color: #d7e0e7; }
.field input, .field textarea {
  background: #0b1018;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
}
.field input:focus, .field textarea:focus {
  outline: 2px solid rgba(42,209,214,0.45);
  border-color: var(--cyan);
}
.field-hint { font-size: 12px; color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.field-hint-inline {
  display: block;
  margin: 6px 0 0;
  font-size: 11px;
}

.url-previews {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #0b1018;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.url-previews > div { min-width: 0; }
.url-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9eeff1;
  margin-bottom: 2px;
}
.url-previews code {
  display: block;
  font: 12px/1.4 "Fira Code", ui-monospace, monospace;
  color: #e8eef2;
  word-break: break-all;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-play-link {
  text-decoration: none;
  background: var(--cyan-dim);
  color: var(--cyan);
  border-color: rgba(42,209,214,0.4);
  display: inline-flex;
  align-items: center;
}
.btn-play-link[hidden], #btn-unpublish[hidden] { display: none !important; }

@media (max-width: 900px) and (orientation: portrait) {
  .projects-drawer {
    width: 100%;
  }
  .project-card-actions .btn { flex: 1 1 auto; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .projects-drawer { width: min(380px, 70%); }
  .drawer-head, .modal-head { padding: 8px 12px 6px; }
  .drawer-head h2, .modal h2 { font-size: 22px; }
  .drawer-head p { display: none; }
  .modal { max-height: 96dvh; padding-bottom: 10px; }
  .field { margin-bottom: 8px; }
  .field input, .field textarea { padding: 6px 9px; }
  .field textarea { rows: 2; min-height: 52px; }
  .url-previews { padding: 6px 8px; gap: 4px; }
}


/* ---- My Game Analytics panel ---- */
#analytics-backdrop { z-index: 90; }
.modal-analytics {
  width: min(840px, 100%);
  max-height: min(92dvh, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(14, 20, 29, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding-bottom: 16px;
}
.modal-analytics .modal-head {
  align-items: flex-start;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 4px;
}
.modal-analytics .modal-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.analytics-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.analytics-error {
  margin: 8px 16px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fecdd3;
  font-size: 13px;
}
.analytics-error[hidden] { display: none !important; }
.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px 6px;
  flex-shrink: 0;
}
.analytics-kpi {
  background: #0b1018;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.analytics-kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9eeff1;
  margin-bottom: 4px;
}
.analytics-kpi-value {
  font-size: 20px;
  font-weight: 750;
  color: #fff;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analytics-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 16px 8px;
}
.analytics-loading, .analytics-empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px 18px;
}
.analytics-empty h3 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 18px;
}
.analytics-empty p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.5;
}
.analytics-game-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.analytics-game-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px 10px;
}
.analytics-game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.analytics-game-titles { min-width: 0; flex: 1 1 16rem; }
.analytics-game-card h3 {
  margin: 0 0 2px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.analytics-game-scene {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analytics-game-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.analytics-play-link {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  border: 1px solid rgba(42,209,214,0.35);
  background: var(--cyan-dim);
  border-radius: 8px;
  padding: 5px 9px;
}
.analytics-play-link:hover { filter: brightness(1.08); }
.analytics-copy-btn { padding: 5px 9px; font-size: 11px; }
.analytics-game-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 8px;
}
.analytics-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.analytics-stat-value {
  font-size: 15px;
  color: #e8eef2;
  font-weight: 700;
}
.plays-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 72px;
  margin-top: 4px;
}
.plays-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
  cursor: default;
}
.plays-bar-track {
  width: 100%;
  max-width: 22px;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  background: rgba(42, 209, 214, 0.08);
  border-radius: 4px 4px 2px 2px;
  overflow: hidden;
}
.plays-bar {
  width: 100%;
  min-height: 0;
  background: linear-gradient(180deg, #5eead4, #14b8a6);
  border-radius: 4px 4px 2px 2px;
}
.plays-bar.is-empty { height: 0; background: transparent; }
.plays-bar-dow {
  margin-top: 3px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
  text-transform: uppercase;
}
.analytics-drafts {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed rgba(42,209,214,0.28);
  border-radius: 12px;
  background: rgba(11, 16, 24, 0.6);
}
.analytics-drafts-lead {
  margin: 0 0 6px;
  font-size: 12px;
  color: #c5d0d8;
  line-height: 1.45;
}
.analytics-draft-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}
.analytics-draft-list li { margin: 2px 0; }

@media (max-width: 720px) {
  #analytics-backdrop { padding: 8px; align-items: stretch; }
  .modal-analytics {
    width: 100%;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-game-stats { grid-template-columns: 1fr; }
  .analytics-kpi-value { font-size: 18px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #analytics-backdrop { padding: 4px; align-items: stretch; }
  .modal-analytics {
    width: 100%;
    height: calc(100dvh - 8px);
    max-height: calc(100dvh - 8px);
  }
  .modal-analytics .modal-head p { display: none; }
  .analytics-kpis { gap: 6px; padding: 6px 12px 2px; }
  .analytics-kpi { padding: 6px 8px; }
  .analytics-kpi-value { font-size: 16px; }
  .analytics-body { padding: 4px 12px 6px; }
  .plays-chart { height: 52px; }
}
