/* UNPLUG Desktop Studio & PWA Stylesheet */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #21262d;
  --bg-input: #0d1117;
  --border: #30363d;
  --border-active: #58a6ff;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #388bfd;
  --accent-hover: #58a6ff;
  --green: #2ea043;
  --green-hover: #3fb950;
  --gold: #d29922;
  --red: #f85149;
  --purple: #a371f7;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

header.studio-header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-tag {
  font-size: 11px;
  background: var(--bg-card);
  color: var(--accent-hover);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.nav-tab {
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s;
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ad-economy-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
}

.economy-pill {
  font-weight: 600;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 5px;
}

.economy-pill.adfree {
  color: var(--green-hover);
}

.btn-adfree-toggle {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-adfree-toggle:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

main.studio-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.studio-view {
  display: none;
  width: 100%;
  height: 100%;
}

.studio-view.active {
  display: flex;
}

/* WORKSHOP VIEW */
#view-workshop {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
}

.workshop-left {
  flex: 1.15;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  min-width: 480px;
}

.editor-toolbar {
  height: 48px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-primary);
  gap: 10px;
}

.template-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-selector-group label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

select.select-game {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.meta-inputs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.meta-inputs-bar input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
}

.meta-inputs-bar input:focus {
  border-color: var(--accent);
  outline: none;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

textarea#code-editor {
  flex: 1;
  width: 100%;
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  border: 0;
  padding: 16px;
  resize: none;
  outline: none;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  overflow: auto;
}

.editor-footer {
  height: 48px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 8px;
}

.footer-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.tag-sdk-helper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--accent-hover);
}

.tag-sdk-helper:hover {
  background: var(--border);
}

.workshop-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 420px;
}

.sandbox-header {
  height: 48px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-secondary);
}

.sandbox-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sandbox-device-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.device-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 0;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  border-radius: 4px;
}

.device-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sandbox-runner-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #090c10;
  position: relative;
  overflow: hidden;
  padding: 12px;
}

.sandbox-device-frame {
  background: #000;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.25s ease;
}

.sandbox-device-frame.portrait {
  width: 360px;
  height: 600px;
}

.sandbox-device-frame.landscape {
  width: 600px;
  height: 360px;
}

.sandbox-device-frame.responsive {
  width: 100%;
  height: 100%;
}

iframe#game-sandbox-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  display: block;
}

.ad-simulator-panel {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-subheading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ad-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ad-action {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-ad-action:hover {
  background: var(--border);
  border-color: var(--text-secondary);
}

.btn-ad-action.gold {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-ad-action.green {
  border-color: var(--green);
  color: var(--green-hover);
}

.event-monitor-console {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  height: 75px;
  overflow-y: auto;
  color: var(--text-secondary);
  line-height: 1.4;
}

.event-log-entry {
  display: flex;
  gap: 8px;
}

.log-time { color: var(--text-muted); }
.log-rx { color: var(--accent-hover); font-weight: 600; }
.log-tx { color: var(--green-hover); font-weight: 600; }
.log-warn { color: var(--gold); }
.log-err { color: var(--red); }

.btn-primary {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--green);
  color: white;
  border: 0;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-success:hover {
  background: var(--green-hover);
}

/* ARCADE PLAY VIEW */
#view-arcade {
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  overflow-y: auto;
  gap: 20px;
}

.arcade-hero {
  background: linear-gradient(135deg, #1b273b, #121926);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.arcade-hero h2 {
  font-size: 24px;
  margin-bottom: 6px;
}

.arcade-hero p {
  color: var(--text-secondary);
  font-size: 13.5px;
  max-width: 540px;
}

.arcade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.arcade-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}

.arcade-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card-banner {
  height: 140px;
  display: grid;
  place-items: center;
  font-size: 54px;
  position: relative;
}

.card-banner.bounce { background: linear-gradient(135deg, #422915, #8c4c1a); }
.card-banner.snake { background: linear-gradient(135deg, #1a382b, #2b704c); }
.card-banner.memory { background: linear-gradient(135deg, #372347, #663d8a); }
.card-banner.space_dodge { background: linear-gradient(135deg, #162444, #2a4788); }
.card-banner.custom { background: linear-gradient(135deg, #2b2b2b, #444); }

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-body h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.card-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  flex: 1;
  margin-bottom: 14px;
  line-height: 1.4;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-badge {
  font-size: 11.5px;
  color: var(--gold);
  font-weight: 600;
}

/* PLATFORM & APK SYNC VIEW */
#view-platform {
  display: flex;
  flex-direction: column;
  padding: 24px 32px;
  overflow-y: auto;
  gap: 20px;
}

.sync-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sync-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sync-header h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.sync-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.installed-games-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-sync-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.game-sync-row code {
  color: var(--accent-hover);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* Simulated Rewarded Ad Modal */
.ad-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  place-items: center;
}

.ad-modal-backdrop.open {
  display: grid;
}

.ad-modal-window {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  box-shadow: 0 25px 50px rgba(0,0,0,0.8);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ad-modal-top {
  padding: 14px 18px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ad-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--gold);
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
}

.ad-countdown {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.ad-video-mockup {
  height: 220px;
  background: linear-gradient(135deg, #091a36, #1c356b);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  text-align: center;
  padding: 20px;
  color: white;
}

.ad-sponsor-logo {
  font-size: 40px;
  margin-bottom: 8px;
}

.ad-progress-track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255,255,255,0.2);
}

.ad-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--green-hover);
  transition: width 1s linear;
}

.ad-modal-bottom {
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
}

.ad-reward-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-hover);
}

/* Fullscreen Play Modal */
.play-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  z-index: 500;
  display: none;
  flex-direction: column;
}

.play-modal-backdrop.open {
  display: flex;
}

.play-modal-header {
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.play-modal-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.play-frame-holder {
  width: 100%;
  max-width: 960px;
  height: 85vh;
  background: #000;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

.play-frame-holder iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
