:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5f6b7a;
  --border: #d7deea;
  --accent: #1f7a8c;
  --accent-2: #bf4342;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #dde9ff 0%, transparent 40%),
    radial-gradient(circle at 90% 0%, #d9f5f1 0%, transparent 35%),
    var(--bg);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.activity-markdown {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.breadcrumb {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.activity-markdown h2 {
  margin: 12px 0;
  font-size: 1.1rem;
}

.activity-markdown p {
  margin: 10px 0;
  line-height: 1.5;
}

.activity-markdown pre {
  margin: 10px 0;
  padding: 12px;
  overflow: auto;
  border-radius: 10px;
  background: #0f1720;
  color: #cfe8ff;
  border: 1px solid #2f3b4a;
}

.activity-markdown iframe {
  max-width: 100%;
}

.demo-replacement {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(165deg, #fdfefe, #f2f8ff);
}

.demo-header {
  font-weight: 600;
  margin-bottom: 8px;
}

.demo-hint {
  color: var(--muted);
  margin-bottom: 0;
}

#demoCanvas {
  width: 100%;
  max-width: 500px;
  aspect-ratio: 4 / 3;
  border: 1px solid #9ab2cc;
  border-radius: 8px;
  background: #000;
  image-rendering: pixelated;
}

.playground {
  margin-top: 16px;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

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

.color-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
}

.download-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.download-tools select {
  border: 1px solid var(--border);
  background: #f6f8fb;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
}

#hexPicker {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

#hexValue {
  font-size: 12px;
  color: var(--muted);
}

button {
  border: 1px solid var(--border);
  background: #f6f8fb;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

#runBtn {
  background: color-mix(in srgb, var(--accent) 22%, #f6f8fb);
}

#stopBtn {
  background: color-mix(in srgb, var(--accent-2) 20%, #f6f8fb);
}

textarea {
  width: 100%;
  min-height: 420px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 10px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  background: #f9fbff;
  color: #1e2530;
}

.CodeMirror {
  width: 100%;
  min-height: 420px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
  background: #f9fbff;
}

.CodeMirror-gutters {
  border-right: 1px solid var(--border);
  background: #eef4ff;
}

body.editor-fullscreen {
  overflow: hidden;
}

body.editor-fullscreen .activity-markdown {
  display: none;
}

body.editor-fullscreen .playground {
  position: fixed;
  inset: 12px;
  z-index: 1000;
  margin: 0;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--bg);
  padding: 0;
}

body.editor-fullscreen .panel {
  max-height: calc(100vh - 24px);
  overflow: auto;
  box-shadow: 0 16px 40px #0000002e;
}

body.editor-fullscreen .left-panel .CodeMirror {
  height: calc(100vh - 120px) !important;
  min-height: 0;
}

.status {
  color: var(--muted);
  font-size: 12px;
}

#gameCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  border: 1px solid #9ab2cc;
  border-radius: 8px;
  background: #000;
  image-rendering: pixelated;
}

#log {
  margin: 10px 0 0;
  min-height: 140px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f1720;
  color: #ade3ff;
  font-size: 12px;
}

@media (max-width: 960px) {
  .playground {
    grid-template-columns: 1fr;
  }
}
