:root {
  --bg: #0b1120;
  --panel: #111827;
  --card: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #0ea5e9;
  --accent: #14b8a6;
  --purple: #8b5cf6;
  --warn: #f59e0b;
  --danger: #ef4444;
  --font: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); direction: rtl; min-height: 100vh; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 16px; }
.brand-dot { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #0ea5e9, #8b5cf6); display: grid; place-items: center; font-size: 18px; }
.brand small { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.nav button { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 7px 13px; border-radius: 10px; cursor: pointer; font-family: var(--font); font-size: 13px; font-weight: 700; transition: 0.15s; }
.nav button:hover { border-color: var(--primary); }
.nav button.active { background: linear-gradient(135deg, #0284c7, #0f766e); border-color: transparent; }

.main { max-width: 1460px; margin: 0 auto; padding: 16px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 16px; color: #fff; }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.65; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--border); background: var(--card); color: #fff; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-family: var(--font); font-size: 12.5px; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.btn:hover { border-color: var(--primary); }
.btn-pri { background: #0284c7; border-color: #0284c7; }
.btn-teal { background: #0f766e; border-color: #0f766e; }
.btn-purp { background: #7c3aed; border-color: #7c3aed; }
.btn-warn { background: #b45309; border-color: #b45309; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(14,165,233,0.16); color: #7dd3fc; border: 1px solid rgba(14,165,233,0.35); padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }

/* Play + Debug Workspace */
.play-shell { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .play-shell { grid-template-columns: 1fr; } }
.stage-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; }
.viewport-frame { background: #020617; border: 1px solid var(--border); border-radius: 16px; padding: 14px; min-height: 540px; display: flex; justify-content: center; overflow: auto; }
.viewport-canvas { width: 100%; max-width: 1120px; background: #f8fafc; color: #0f172a; border-radius: 14px; padding: 18px; box-shadow: 0 22px 50px rgba(0,0,0,0.45); transition: max-width 0.25s; }
.viewport-canvas--tablet { max-width: 768px; }
.viewport-canvas--mobile { max-width: 410px; }

.feedback-banner { background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; font-size: 13.5px; font-weight: 700; }
.finish-banner { background: linear-gradient(135deg, #0f766e, #1d4ed8); color: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* 12-column Game Grid */
.gs-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: minmax(42px, auto); gap: 10px; align-items: stretch; }
.gs-el { position: relative; border-radius: 12px; }
.gs-el--tappable { cursor: pointer; outline: 2px dashed rgba(139, 92, 246, 0.55); outline-offset: 2px; transition: transform 0.14s ease, box-shadow 0.14s ease; }
.gs-el--tappable:hover { transform: scale(1.015); box-shadow: 0 10px 24px rgba(139, 92, 246, 0.25); }
.gs-text { line-height: 1.75; white-space: pre-wrap; font-weight: 600; }
.gs-atlas-wrap { position: relative; width: 100%; height: 100%; min-height: 220px; border-radius: 14px; background: radial-gradient(circle at 50% 80%, #e0f2fe, #f8fafc); border: 1px solid #cbd5e1; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: 6px; }
.gs-atlas-canvas { max-width: 100%; max-height: 280px; width: auto; height: auto; display: block; }
.gs-atlas-cap { font-size: 12px; font-weight: 800; color: #1e293b; background: rgba(255,255,255,0.88); padding: 2px 10px; border-radius: 99px; margin-top: 4px; }
.gs-tap-pill { position: absolute; top: 8px; left: 8px; background: #7c3aed; color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; }

.gs-choices { display: flex; flex-direction: column; gap: 8px; }
.gs-choice-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; background: #fff; color: #0f172a; border: 2px solid #cbd5e1; border-radius: 12px; padding: 11px 14px; font-family: var(--font); font-size: 14.5px; font-weight: 800; cursor: pointer; transition: 0.15s; }
.gs-choice-btn:hover { border-color: #0f766e; background: #f0fdfa; transform: translateX(-2px); }
.gs-choice-btn--revealed { border-color: #7c3aed; background: #f5f3ff; }
.gs-ch-idx { width: 26px; height: 26px; border-radius: 8px; background: #0f766e; color: #fff; display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }

.gs-scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.gs-kpi { background: #fff; border: 1px solid #cbd5e1; border-top: 4px solid #0f766e; border-radius: 11px; padding: 8px; text-align: center; }
.gs-kpi-l { font-size: 11px; color: #64748b; font-weight: 700; }
.gs-kpi-v { font-size: 20px; font-weight: 900; color: #0f172a; margin-top: 2px; }
.gs-prog-head { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.gs-prog-track { height: 12px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.gs-prog-fill { height: 100%; background: linear-gradient(90deg, #0ea5e9, #0f766e); border-radius: 99px; transition: width 0.35s; }
.gs-timer { display: flex; justify-content: space-between; align-items: center; background: #0f172a; color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13.5px; font-weight: 800; }
.gs-badge { background: #fef3c7; color: #92400e; border: 1.5px solid #f59e0b; border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 800; }
.gs-card-t { font-size: 12.5px; font-weight: 800; color: #1e3a5f; margin-bottom: 6px; display: block; }
.gs-bar-row { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; }
.gs-bar-row span { width: 95px; font-weight: 700; }
.gs-bar-tr { flex: 1; height: 14px; background: #e2e8f0; border-radius: 5px; overflow: hidden; }
.gs-bar-fi { height: 100%; background: #0ea5e9; border-radius: 5px; }
.gs-radar { width: 100%; max-height: 195px; display: block; }
.gs-stars { display: flex; gap: 6px; }
.gs-star { border: 0; background: transparent; font-size: 26px; color: #cbd5e1; cursor: pointer; padding: 0; }
.gs-star.on { color: #f59e0b; }
.gs-slider { width: 100%; accent-color: #0f766e; }
.gs-img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; display: block; }
.gs-video { width: 100%; max-height: 240px; border-radius: 12px; background: #000; }
.gs-media-box, .gs-scene-box, .gs-avatar { background: #fff; border: 1px solid #cbd5e1; border-radius: 12px; padding: 10px; font-size: 13px; }
.gs-avatar { display: flex; align-items: center; gap: 10px; }
.gs-avatar-c { width: 42px; height: 42px; border-radius: 50%; background: #e0f2fe; display: grid; place-items: center; font-size: 22px; }
.gs-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; border-radius: 8px; overflow: hidden; }
.gs-tbl th { background: #1e3a5f; color: #fff; padding: 6px; }
.gs-tbl td { border: 1px solid #cbd5e1; padding: 6px; }
.gs-hint-btn { background: #fffbeb; border: 1.5px solid #f59e0b; color: #92400e; padding: 8px 14px; border-radius: 10px; font-family: var(--font); font-weight: 800; cursor: pointer; }
.gs-inp { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 9px; font-family: var(--font); }
.gs-placeholder { border: 1.5px dashed #94a3b8; border-radius: 12px; padding: 14px; text-align: center; color: #64748b; font-size: 12.5px; }

/* Debug Drawer */
.debug-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 10px; max-height: 82vh; overflow-y: auto; }
.debug-sec { background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 9px; }
.debug-sec h4 { margin: 0 0 6px; font-size: 12.5px; color: #7dd3fc; }
.trace-list { max-height: 220px; overflow-y: auto; font-family: ui-monospace, monospace; font-size: 11px; direction: ltr; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.trace-item { background: rgba(15,23,42,0.7); border-left: 3px solid #14b8a6; padding: 4px 6px; border-radius: 4px; word-break: break-word; }
.trace-item--warn { border-left-color: #f59e0b; color: #fde68a; }
.sel, .inp-dark { background: #0f172a; color: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-family: var(--font); font-size: 12.5px; }

/* Atlas Preview Stage */
.checker-stage { background-image: conic-gradient(#334155 25%, #1e293b 0 50%, #334155 0 75%, #1e293b 0); background-size: 18px 18px; border-radius: 14px; border: 1px solid var(--border); padding: 14px; display: flex; justify-content: center; align-items: center; min-height: 260px; }


/* KCE Core Identity & Workspace Switcher Bar */
.identity-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: rgba(30, 41, 59, 0.75); border: 1px solid var(--border); padding: 4px 10px; border-radius: 11px; font-size: 12px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.78); backdrop-filter: blur(4px); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 420px; max-width: 96vw; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 11px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.err-box { background: rgba(239, 68, 68, 0.16); border: 1px solid #ef4444; color: #fecaca; border-radius: 9px; padding: 8px 10px; font-size: 12.5px; }
.pill-tpl { background: rgba(139, 92, 246, 0.2); color: #ddd6fe; border-color: rgba(139, 92, 246, 0.45); }
.pill-ws  { background: rgba(20, 184, 166, 0.2); color: #99f6e4; border-color: rgba(20, 184, 166, 0.45); }
