:root {
  --theme-main: #6b1f2b;
  --theme-dark: #17070a;
  --theme-mid: #2a0d13;
  --theme-light: #b94355;
  --theme-glow: rgba(185, 67, 85, 0.55);
  --text-main: #fff2f4;
  --text-muted: #d8a6ad;
  --grid-line: rgba(255, 255, 255, 0.08);
  --block-default: #b94355;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text-main);
  min-height: 100vh;
  background: radial-gradient(circle at top, var(--theme-main), transparent 35%), linear-gradient(135deg, var(--theme-dark), #040102);
  overflow: hidden;
}
header {
  min-height: 72px;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--theme-light);
  box-shadow: 0 0 24px var(--theme-glow);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.title h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
.title span { color: var(--text-muted); font-size: 13px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
button, select, input {
  border: 1px solid var(--theme-light);
  background: var(--theme-mid);
  color: var(--text-main);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
}
button { cursor: pointer; transition: 0.15s; touch-action: manipulation; }
button:hover { background: var(--theme-main); box-shadow: 0 0 12px var(--theme-glow); transform: translateY(-1px); }
button.active { background: var(--theme-light); color: white; box-shadow: 0 0 16px var(--theme-glow); }
main { display: flex; height: calc(100vh - 72px); }
aside {
  width: 260px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: auto;
}
aside h2 { margin-top: 0; }
aside p { color: var(--text-muted); line-height: 1.4; font-size: 14px; }
aside label { margin-top: 14px; margin-bottom: 6px; display: block; color: var(--text-muted); font-size: 14px; }
aside select, aside input { width: 100%; }
.info {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.info button { margin-top: 10px; width: 100%; }
.gridWrap { flex: 1; padding: 22px; display: flex; align-items: center; justify-content: center; overflow: auto; touch-action: pan-x pan-y; }
#grid {
  display: grid;
  grid-template-columns: repeat(24, 34px);
  grid-template-rows: repeat(16, 34px);
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--theme-light);
  box-shadow: 0 0 28px var(--theme-glow);
  user-select: none;
  -webkit-user-select: none;
}
.cell { width: 34px; height: 34px; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); position: relative; }
.cell:hover { background: rgba(255, 255, 255, 0.07); }
.block {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  border-radius: 7px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.16), 0 0 10px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  text-shadow: 0 1px 2px black;
  color: white;
  overflow: hidden;
  font-size: 12px;
  text-align: center;
}
.block.off { background: #050505 !important; }
.block.resized { align-items: center; justify-content: center; }
.block.turn { clip-path: polygon(50% 3%, 97% 50%, 50% 97%, 3% 50%); }
.block.display { font-size: 10px; padding: 2px; text-align: center; }
.block.floor { opacity: 0.75; border-style: dashed; }
.block.floorUnder { position: absolute; inset: 4px; width: auto !important; height: auto !important; opacity: 0.65; z-index: 1; }
.block.solidOver { position: absolute; inset: 0; z-index: 2; }
.block.spring { clip-path: polygon(10% 50%, 25% 20%, 40% 80%, 55% 20%, 70% 80%, 90% 50%, 90% 90%, 10% 90%); }
.block.wheel { border-radius: 50%; }
.block.wheel::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 2px solid rgba(255,255,255,0.75); }
.block.debug { border-style: dotted; animation: debugPulse 1.4s infinite alternate; }
@keyframes debugPulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
.selected .block { outline: 3px solid white; box-shadow: 0 0 18px white; }
.wireSource .block { outline: 3px solid yellow; }
.wireDot { position: absolute; right: 2px; bottom: 2px; font-size: 10px; background: black; color: white; border-radius: 999px; padding: 1px 4px; z-index: 5; }
.groupDot { position: absolute; left: 2px; top: 2px; font-size: 9px; background: rgba(255, 255, 255, 0.85); color: black; border-radius: 999px; padding: 1px 4px; z-index: 5; }
#status { position: fixed; left: 280px; bottom: 12px; z-index: 5; padding: 9px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.55); border: 1px solid var(--theme-light); color: var(--text-muted); font-size: 13px; }
#editorBackdrop, #guideBackdrop { position: fixed; inset: 0; display: none; z-index: 30; align-items: center; justify-content: center; padding: 14px; background: rgba(0, 0, 0, 0.7); }
#editor, #guidePanel { width: min(700px, 96vw); max-height: 88vh; overflow-y: auto; padding: 18px; border-radius: 18px; background: rgba(23, 7, 10, 0.96); border: 2px solid var(--theme-light); box-shadow: 0 0 35px var(--theme-glow); }
#editor h2, #guidePanel h2 { margin-top: 0; }
#editor label { margin-top: 12px; margin-bottom: 6px; display: block; color: var(--text-muted); }
#editor input, #editor select { width: 100%; }
.editorActions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.guideItem { margin: 10px 0; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); }
.guideItem b { color: white; }
.guideItem p { margin: 5px 0 0; color: var(--text-muted); }
#shareBtn { border-color: #55ddff; }
#importShareBtn { border-color: #c77dff; }
.toolbarLink { display: inline-block; border: 1px solid var(--theme-light); background: var(--theme-mid); color: var(--text-main); border-radius: 10px; padding: 9px 12px; font-size: 14px; text-decoration: none; transition: 0.15s; }
.toolbarLink:hover { background: var(--theme-main); box-shadow: 0 0 12px var(--theme-glow); transform: translateY(-1px); }
@media (max-width: 850px) {
  body { overflow: auto; }
  header { flex-direction: column; align-items: flex-start; }
  .toolbar { justify-content: flex-start; }
  main { height: auto; flex-direction: column; }
  aside { width: 100%; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
  .gridWrap { justify-content: flex-start; align-items: flex-start; padding-bottom: 70px; }
  #status { left: 12px; right: 12px; bottom: 10px; border-radius: 14px; }
}

