:root {
  --bg: #07080c;
  --cu: #ffb15c;
  --cy: #52e3ff;
  --vi: #a78bfa;
  --tx: #eceaf5;
  --dim: #8d8aa8;
  --ln: rgba(255, 255, 255, .12);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--tx);
  font: 400 14px/1.55 var(--mono);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(82, 227, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 227, 255, .05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
  z-index: 0;
}

/* ---------- header ---------- */

.bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--ln);
  background: rgba(7, 8, 12, .78);
  backdrop-filter: blur(10px);
}

.brand {
  font-family: "Space Grotesk", var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .02em;
  color: var(--tx);
  text-decoration: none;
  white-space: nowrap;
}

.brand span { color: var(--cy); opacity: .65; }

.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  padding: 3px 9px;
  border: 1px solid rgba(82, 227, 255, .35);
  border-radius: 999px;
  color: var(--cy);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

button {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--ln);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  color: var(--tx);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: .15s ease;
}

button:hover {
  border-color: var(--cy);
  color: var(--cy);
  background: rgba(82, 227, 255, .07);
}

/* ---------- stage ---------- */

main {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: flex;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 16px;
  border: 1px solid var(--ln);
  border-radius: 14px;
  background: #05060a;
  overflow: hidden;
  box-shadow: 0 30px 80px -40px #000, inset 0 0 60px rgba(0, 0, 0, .6);
}

.stage:fullscreen { margin: 0; border-radius: 0; border: 0; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #05060a;
}

.screen canvas {
  display: block;
  image-rendering: pixelated;
  outline: none;
}

/* невидимое поле: на телефоне именно оно вызывает системную клавиатуру */
.kb-input {
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: 2px;
  height: 2px;
  margin-left: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  z-index: 5;
}

/* экранные клавиши для тач-устройств */
.keys {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 6px;
  border: 1px solid var(--ln);
  border-radius: 10px;
  background: rgba(7, 8, 12, .88);
  backdrop-filter: blur(8px);
  overflow-x: auto;
  scrollbar-width: none;
}

.keys::-webkit-scrollbar { display: none; }
.keys[hidden] { display: none; }

.keys button {
  height: 30px;
  min-width: 42px;
  padding: 0 9px;
  font-size: 12px;
  flex: 0 0 auto;
}

.crash-log {
  margin: 0 0 16px;
  padding: 10px 12px;
  max-height: 34vh;
  overflow: auto;
  border: 1px solid rgba(255, 107, 107, .3);
  border-radius: 8px;
  background: rgba(255, 107, 107, .06);
  color: #ffc9c9;
  font-size: 11.5px;
  line-height: 1.45;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.crash-log[hidden] { display: none; }

/* мягкие сканлайны поверх экрана */
.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .18) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: multiply;
  opacity: .55;
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(82, 227, 255, .07), transparent 60%),
    rgba(5, 6, 10, .96);
}

.overlay[hidden] { display: none; }

.ov-in { max-width: 640px; }

.logo {
  margin: 0 0 18px;
  color: var(--cy);
  font-size: 12px;
  line-height: 1.25;
  opacity: .9;
  text-shadow: 0 0 18px rgba(82, 227, 255, .35);
}

.ov-in h1 {
  margin: 0 0 10px;
  font-family: "Space Grotesk", var(--mono);
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: -.01em;
}

.ov-in p {
  margin: 0 0 18px;
  color: var(--dim);
  font-size: 13.5px;
}

.acts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.acts button {
  height: auto;
  padding: 12px 18px;
  text-align: left;
  font-size: 14px;
  line-height: 1.3;
}

.acts button small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--dim);
}

.acts button.primary {
  border-color: rgba(82, 227, 255, .45);
  color: var(--cy);
  background: rgba(82, 227, 255, .08);
}

.acts button.primary small { color: rgba(82, 227, 255, .7); }

.note {
  min-height: 1.5em;
  margin: 0 0 10px !important;
  color: var(--cu) !important;
  font-size: 12.5px !important;
}

.touch-hint {
  margin: -4px 0 12px !important;
  padding: 8px 10px;
  border-left: 2px solid var(--cy);
  background: rgba(82, 227, 255, .06);
  color: var(--cy) !important;
  font-size: 12px !important;
}

.touch-hint[hidden] { display: none; }

.tips summary {
  color: var(--dim);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}

.tips summary::-webkit-details-marker { display: none; }
.tips summary::before { content: "▸ "; color: var(--cy); }
.tips[open] summary::before { content: "▾ "; }

.cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.cmds code {
  padding: 3px 8px;
  border: 1px solid var(--ln);
  border-radius: 6px;
  color: var(--vi);
  font-size: 11.5px;
}

/* ---------- connecting ---------- */

.connecting {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: 1px solid var(--ln);
  border-radius: 999px;
  background: rgba(7, 8, 12, .9);
  color: var(--dim);
  font-size: 12px;
  white-space: nowrap;
}

.connecting[hidden] { display: none; }

.spin {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(82, 227, 255, .2);
  border-top-color: var(--cy);
  border-radius: 50%;
  animation: sp 800ms linear infinite;
}

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

/* ---------- footer ---------- */

footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px 20px;
  border-top: 1px solid var(--ln);
  color: var(--dim);
  font-size: 11.5px;
}

.st { display: flex; align-items: center; gap: 8px; }

#led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 10px currentColor;
}

#led.run { background: #6ef58b; color: #6ef58b; }
#led.pause { background: var(--cu); color: var(--cu); }
#led.err { background: #ff6b6b; color: #ff6b6b; }

.hint { opacity: .7; }

kbd {
  padding: 1px 5px;
  border: 1px solid var(--ln);
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--tx);
}

@media (max-width: 760px) {
  .hint { display: none; }
  .stage { margin: 8px; border-radius: 10px; }
  .bar { padding: 10px 12px; }
  .ov-in { padding-bottom: 12px; }
  .acts button { flex: 1 1 100%; }
  .keys { bottom: 6px; }
  footer { padding: 6px 12px; font-size: 11px; }
}
