:root {
  --fg: #ffffff;
  --bg: #000000;
  --accent: #ffee55;
  --dim: #888;
  --panel: #0b0b0b;
  --line: #2a2a2a;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, #101014 0%, #000 70%);
}

/* Header */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 2px solid var(--fg);
  background: #000;
}
#topbar .title {
  font-family: 'VT323', monospace;
  font-size: 30px;
  letter-spacing: 2px;
}
#modes { display: flex; gap: 6px; }
#modes button {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  background: #000;
  color: var(--fg);
  border: 2px solid var(--fg);
  padding: 6px 12px;
  cursor: pointer;
  transition: all .12s;
}
#modes button:hover { background: #1a1a1a; }
#modes button.active { background: var(--fg); color: #000; }

/* Layout */
#app {
  flex: 1;
  display: flex;
  gap: 18px;
  padding: 18px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

#stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

canvas {
  background: #000;
  border: 2px solid var(--line);
  image-rendering: pixelated;
  width: min(560px, 92vw);
  height: auto;
  touch-action: none;
}

/* HP bar */
#hpwrap {
  width: min(560px, 92vw);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'VT323', monospace;
  font-size: 20px;
}
#battlename { flex: 1; color: #dcdcdc; }
#hpbar {
  width: 130px;
  height: 16px;
  border: 2px solid var(--fg);
  background: #300;
}
#hpfill { height: 100%; width: 100%; background: #66ff66; transition: width .15s; }
#hptext { color: var(--accent); white-space: nowrap; }

#hint {
  font-size: 12px;
  color: var(--dim);
  text-align: center;
}

/* Touch pad (mobile only) */
#touchpad { display: none; flex-direction: column; align-items: center; gap: 6px; margin-top: 4px; }
#touchpad .row { display: flex; gap: 6px; }
#touchpad button {
  width: 54px; height: 54px;
  font-size: 22px;
  background: #111;
  color: var(--fg);
  border: 2px solid var(--fg);
  border-radius: 8px;
}
#touchpad button:active { background: var(--fg); color: #000; }

/* Panels */
aside {
  width: min(340px, 92vw);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 14px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}
aside h2 {
  font-family: 'VT323', monospace;
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 14px 0 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
aside h2:first-child { margin-top: 0; }

aside label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin: 6px 0;
  color: #ccc;
}
aside input, aside select, aside textarea {
  background: #000;
  color: var(--fg);
  border: 1px solid #444;
  padding: 5px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  flex: 1;
  min-width: 0;
}
aside input[type=number] { max-width: 90px; }

textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  margin: 6px 0;
  word-break: break-all;
}

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette button {
  background: #000; color: var(--fg);
  border: 1px solid #555; padding: 8px; cursor: pointer;
  font-size: 12px; font-family: 'JetBrains Mono', monospace;
}
.palette button:hover { border-color: var(--fg); background: #161616; }
.palette button:nth-child(1) { color: #fff; }
.palette button:nth-child(2) { color: #00ffff; }
.palette button:nth-child(3) { color: #ff8c00; }
.palette button:nth-child(4) { color: #999; }

#objlist { display: flex; flex-direction: column; gap: 3px; }
.objrow {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; font-size: 12px; cursor: pointer;
  border: 1px solid transparent; background: #060606;
}
.objrow:hover { background: #141414; }
.objrow.sel { border-color: var(--accent); background: #1a1a10; }
.dot { width: 12px; height: 12px; display: inline-block; border: 1px solid #000; }

.editor-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
aside button:not(.palette button):not(.objrow) {
  cursor: pointer;
}
#btn-test, #btn-tocode, #btn-gencode, #btn-copy,
#btn-import-play, #btn-import-edit, #samples button {
  background: var(--fg); color: #000;
  border: none; padding: 9px 12px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  cursor: pointer; flex: 1; min-width: 100px;
}
#btn-test:hover, #btn-tocode:hover, #btn-gencode:hover, #btn-copy:hover,
#btn-import-play:hover, #btn-import-edit:hover, #samples button:hover { background: var(--accent); }
#samples button { margin-top: 4px; width: 100%; }

.danger {
  background: #400 !important; color: #ff8080 !important;
  border: 1px solid #ff4040 !important; padding: 8px; cursor: pointer;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  width: 100%; margin-top: 8px;
}
.danger:hover { background: #600 !important; }

.muted { color: var(--dim); font-size: 12px; margin: 6px 0; }

/* Footer */
#foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 2px solid var(--fg);
  font-size: 12px;
  color: var(--dim);
}
#foot a { color: var(--accent); text-decoration: none; }
#foot a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Mobile: show touchpad, stack panels */
@media (hover: none) and (pointer: coarse) {
  #touchpad { display: flex; }
}
@media (max-width: 760px) {
  #app { flex-direction: column; align-items: center; }
  aside { max-height: none; }
  #topbar .title { font-size: 22px; }
}
</parameter>