* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
canvas { display: block; }
html[data-app-shell] body {
  position: fixed;
  top: var(--app-shell-top-h, 40px);
  left: 0;
  right: var(--app-dock-right-w, 0px);
  bottom: calc(var(--app-shell-bottom-h, 24px) + var(--app-dock-bottom-h, 0px));
  width: auto;
  height: auto;
}
#attract {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at 50% 40%, #101a18 0%, #000 70%);
  pointer-events: none;
  transition: opacity 260ms ease-out;
}
#attract.is-dismissed { opacity: 0; }
#attract-title {
  color: #6fae8e; font: bold 40px/1.2 monospace; letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(111, 174, 142, 0.7);
  animation: sb-banner-pulse 1.2s ease-in-out infinite;
}
#attract-sub { color: #cdb98a; font: 13px/1.4 monospace; letter-spacing: 1px; }
#attract-bar {
  width: min(260px, 50vw); height: 3px; margin-top: 6px;
  background: #1b2422; border-radius: 2px; overflow: hidden;
}
#attract-bar-fill {
  width: 40%; height: 100%; background: #6fae8e;
  border-radius: 2px; animation: attract-sweep 1.4s ease-in-out infinite;
}
#attract-note { color: #5c6b66; font: 11px/1.4 monospace; }
@keyframes attract-sweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}
@media (prefers-reduced-motion: reduce) {
  #attract-title { animation: none; }
  #attract-bar-fill { animation: none; width: 100%; opacity: 0.5; }
}

html[data-editing] [data-play-only] { display: none !important; }

#info {
  position: absolute; top: 8px; left: 8px;
  color: #aaa; font: 12px/1.4 monospace;
  background: rgba(0,0,0,0.5); padding: 6px 10px;
  border-radius: 4px; pointer-events: none;
}
#perf-hud {
  position: absolute; bottom: calc(8px + var(--touch-band-h, 0px)); left: 8px;
  color: #6fae8e; font: 11px/1.5 monospace; white-space: pre;
  background: rgba(0,0,0,0.62); padding: 6px 10px;
  border-radius: 4px; border: 1px solid #2a2d33; pointer-events: none;
  z-index: 5;
}
#perf-hud[hidden] { display: none; }
#right-rail {
  position: absolute; top: 8px; right: 8px; width: 320px;
  max-height: calc(100% - 16px - var(--touch-band-h, 0px));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; z-index: 4;
}
#right-rail > * { pointer-events: auto; }
#panel {
  width: 100%; flex: 0 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  color: #ddd; font: 12px/1.4 monospace; background: rgba(18,20,24,0.85);
  padding: 12px; border-radius: 6px; border: 1px solid #2a2d33;
  overflow-y: auto;
}
#editor-browser {
  width: 100%; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  color: #ddd; font: 12px/1.4 monospace; background: rgba(18,20,24,0.85);
  padding: 12px; border-radius: 6px; border: 1px solid #2a2d33;
  overflow-y: auto;
}
#editor-browser[hidden] { display: none; }

#event-tree-panel {
  position: absolute; top: 48px; left: 8px; width: 500px;
  max-height: calc(100% - 100px - var(--touch-band-h, 0px)); min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  color: #ddd; font: 12px/1.4 monospace; background: rgba(18,20,24,0.9);
  padding: 12px; border-radius: 6px; border: 1px solid #2a2d33;
  box-shadow: 0 18px 40px -12px rgba(0,0,0,0.7);
  overflow: hidden; z-index: 5;
}
#event-tree-panel[hidden] { display: none; }
#event-tree-panel > .pane-header { cursor: grab; user-select: none; }
#event-tree-panel > .pane-header button { cursor: pointer; }
#event-tree-panel.is-dragging > .pane-header { cursor: grabbing; }
#event-tree-panel.is-dragging { transition: none; }
.et-status { flex: none; color: #6c7086; font-size: 11px; }
.et-body {
  flex: 1 1 auto; min-height: 8rem;
  margin: 0; overflow: auto;
  font: 11px/1.45 monospace; white-space: pre;
}
.et-body:focus { outline: 1px solid #3a3e46; outline-offset: -1px; }
.et-hint { color: #6c7086; font-size: 11px; }
.et-row { display: block; border-radius: 2px; cursor: pointer; }
.et-row:hover { background: rgba(137,180,250,0.12); }
.et-row.is-selected { background: rgba(137,180,250,0.18); box-shadow: inset 2px 0 0 #89b4fa; }
.et-tree { color: #45475a; }
.et-dim { color: #6c7086; }
.et-time { color: #7f849c; }
.et-points { color: #e8c84a; }
.et-game { color: #cdd6f4; font-weight: 600; }
.et-player { color: #89b4fa; }
.et-ball { color: #94e2d5; }
.et-section { color: #b4befe; }
.et-mode { color: #cba6f7; }
.et-pri { color: #6c7086; }
.et-event { color: #a6adc8; }
.et-hit { color: #f38ba8; }
.et-lifecycle { color: #f9e2af; }

.pane-minimized { display: none !important; }
.pane-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pane-header label { flex: 1; }
.pane-minimize {
  flex: none; cursor: pointer; color: #ddd; background: #22252b;
  border: 1px solid #3a3e46; border-radius: 4px; width: 22px; height: 22px;
  line-height: 1; font: inherit;
}
.pane-minimize:hover { background: #2e323a; }
.pane-restore {
  position: absolute; z-index: 5; cursor: pointer; color: #ddd;
  background: rgba(18,20,24,0.85); border: 1px solid #2a2d33; border-radius: 4px;
  padding: 6px 10px; font: 12px/1.4 monospace;
}
.pane-restore:hover { background: rgba(24,26,30,0.95); }
.pane-restore[hidden] { display: none; }
#panel-restore { top: 8px; right: 8px; }
#editor-browser-restore { top: 44px; right: 8px; }
#editor-panel-restore { top: 8px; left: 8px; }
#scoreboard { display: flex; flex-direction: column; gap: 2px; }
.sb-row { display: flex; justify-content: space-between; }
.sb-row span:last-child { color: #6fae8e; font-weight: bold; }
#sb-score { font-size: 16px; }
.ev {
  flex: 1; cursor: pointer; color: #ddd; background: #22252b;
  border: 1px solid #3a3e46; border-radius: 4px; padding: 6px 4px; font: inherit;
}
.ev:hover { background: #2e323a; }
label { color: #9aa0aa; font-size: 11px; }
#plunger-meter {
  height: 8px; background: #101216; border: 1px solid #2a2d33; border-radius: 4px;
  overflow: hidden;
}
#plunger-fill { height: 100%; width: 0%; background: #b8a173; }
#restore-notice {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border-radius: 4px;
  border: 1px solid #6b5a33; background: rgba(90, 74, 40, 0.35);
  color: #e8d9b0; font-size: 11px; line-height: 1.45;
}
#restore-notice[hidden] { display: none; }
#preview-notice {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px; border-radius: 4px;
  border: 1px solid #35566b; background: rgba(40, 66, 90, 0.35);
  color: #b8d4e8; font-size: 11px; line-height: 1.45;
}
#preview-notice[hidden] { display: none; }
#game-actions { display: flex; gap: 6px; }
#editor-actions { display: flex; gap: 6px; }
#editor-panel {
  position: absolute; top: 8px; left: 8px; width: 300px;
  display: flex; flex-direction: column; gap: 8px;
  color: #ddd; font: 12px/1.4 monospace; background: rgba(18,20,24,0.85);
  padding: 12px; border-radius: 6px; border: 1px solid #2a2d33; z-index: 4;
  max-height: calc(100% - 16px - var(--touch-band-h, 0px)); overflow-y: auto;
}
#editor-panel[hidden] { display: none; }

.ed-collapsible > .ed-tb-label,
.ed-collapsible > .ed-layers-head .ed-tb-label { cursor: pointer; user-select: none; }
.ed-collapsible > .ed-tb-label::before,
.ed-collapsible > .ed-layers-head .ed-tb-label::before {
  content: "▼"; display: inline-block; width: 14px; color: #6fae8e; font-size: 11px;
}
.ed-collapsible.ed-collapsed > .ed-tb-label::before,
.ed-collapsible.ed-collapsed > .ed-layers-head .ed-tb-label::before { content: "►"; }
.ed-collapsible.ed-collapsed > *:not(.ed-tb-label):not(.ed-layers-head) { display: none; }
#ed-tags-panel.ed-collapsed > #ed-tags-chips,
#ed-behaviors-panel.ed-collapsed > #ed-behaviors-list,
#ed-bindings-panel.ed-collapsed > #ed-bindings-list { display: none; }


#ed-context {
  display: flex; flex-direction: column; gap: 5px;
  background: #101216; border: 1px solid #2a2d33; border-radius: 4px; padding: 8px;
}
#ed-ctx-hint { color: #9aa0aa; font-size: 11px; }
#ed-ctx-hint[hidden], #ed-place[hidden], #ed-inspector[hidden], #ed-wall-inspector[hidden] { display: none; }
#ed-wall-inspector { display: flex; flex-direction: column; gap: 3px; }
#ed-wall-inspector .sb-row[hidden] { display: none; }
#ed-wall-name { width: 150px; font: inherit; text-align: right; }
#ed-wall-name[readonly] { color: #6fae8e; border-color: transparent; background: transparent; }
#ed-wall-actions { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
#ed-wall-actions button {
  flex: 1; cursor: pointer; color: #ddd; background: #22252b; border: 1px solid #3a3e46;
  border-radius: 4px; padding: 5px 4px; font: inherit; font-size: 11px;
}
#ed-wall-actions button:hover:not(:disabled) { background: #2e323a; }
#ed-wall-actions button:disabled { opacity: 0.4; cursor: default; }
.ed-ctx-head { display: flex; align-items: center; gap: 6px; color: #6fae8e; font-weight: bold; }
.ed-glyph { font-size: 15px; line-height: 1; width: 18px; text-align: center; }
#ed-place { display: flex; flex-direction: column; gap: 3px; }
#ed-place-desc { color: #9aa0aa; font-size: 11px; }
#ed-inspector { display: flex; flex-direction: column; gap: 3px; }
#ed-name { width: 150px; font: inherit; text-align: right; }
#ed-name[readonly] { color: #6fae8e; border-color: transparent; background: transparent; }
#ed-inspector .sb-row[hidden] { display: none; }
#ed-inspector .ed-tags { text-align: right; font-weight: normal; word-break: break-word; max-width: 62%; }
.ed-num { width: 90px; font: inherit; text-align: right; }
#ed-row-sling[hidden] { display: none; }
#ed-row-sling { display: flex; flex-direction: column; gap: 3px; margin-top: 2px; }
.ed-sub-head { color: #6fae8e; font-weight: bold; font-size: 11px; opacity: 0.8; margin-top: 4px; }
.ed-slider-row { align-items: center; gap: 6px; }
.ed-slider-row > span:first-child { flex: 0 0 auto; }
.ed-slider { flex: 1 1 auto; min-width: 0; accent-color: #6fae8e; }
.ed-slider-num { width: 56px; }
#ed-actions { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
#ed-actions button {
  flex: 1; cursor: pointer; color: #ddd; background: #22252b; border: 1px solid #3a3e46;
  border-radius: 4px; padding: 5px 4px; font: inherit; font-size: 11px;
}
#ed-actions button:hover:not(:disabled) { background: #2e323a; }
#ed-actions button:disabled { opacity: 0.4; cursor: default; }
#ed-status { font-size: 11px; min-height: 14px; }
#ed-status.ok { color: #7e7; }
#ed-status.err { color: #f77; }

#ed-outliner { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
#ed-outliner .ed-tb-label { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: #9aa0aa; }
#ed-outliner-search {
  color: #ccd0cc0cc; background: #101216; border: 1px solid #2a2d33; border-radius: 4px;
  padding: 3px 6px; font: inherit; font-size: 11px;
}
#ed-outliner-search:focus { outline: none; border-color: #6fae8e; }
#ed-outliner-list { display: flex; flex-direction: column; gap: 2px; max-height: 168px; overflow-y: auto; }
#ed-tags-panel { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
#ed-tags-panel[hidden], #ed-behaviors-panel[hidden], #ed-bindings-panel[hidden] { display: none; }
#ed-tags-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ed-tag-chip { font: inherit; font-size: 11px; color: #c3c6c1; background: #20242b; border: 1px solid #2a2d33; border-radius: 10px; padding: 1px 8px; cursor: pointer; }
.ed-tag-chip:hover { background: #2e323a; }
.ed-tag-chip.active { background: #6fae8e; color: #0c1712; border-color: #6fae8e; font-weight: bold; }
.ed-tags-empty { font-size: 11px; color: #6a7078; }
#ed-behaviors-panel { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
#ed-behaviors-list { display: flex; flex-direction: column; gap: 2px; max-height: 140px; overflow-y: auto; }
.ed-behavior-row { display: flex; align-items: baseline; gap: 6px; font-size: 11px; }
.ed-behavior-glyph { color: #6fae8e; }
.ed-behavior-name { color: #ccd0cc; }
.ed-behavior-meta { color: #6a7078; margin-left: auto; font-size: 10px; }
.ed-behaviors-empty { font-size: 11px; color: #6a7078; }

#ed-bindings-panel { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
#ed-bindings-list { display: flex; flex-direction: column; gap: 2px; max-height: 140px; overflow-y: auto; }
.ed-binding-row.jumpable { cursor: pointer; }
.ed-binding-row.jumpable:hover { background: #2e323a; }
.ed-binding-row.inherited .ed-behavior-name { color: #9aa0aa; font-style: italic; }
.ed-binding-remove {
  flex: none; margin-left: 6px; padding: 0 3px;
  background: none; border: 0; border-radius: 3px;
  color: #6a7078; font: inherit; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 80ms linear;
}
.ed-binding-row:hover .ed-binding-remove,
.ed-binding-remove:focus-visible { opacity: 1; }
.ed-binding-remove:hover { color: #e6685e; background: #3a2b2b; }
.ed-binding-remove:focus-visible { outline: 1px solid #6fae8e; }


.ed-outliner-row {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 2px 4px; border-radius: 3px; font-size: 11px;
}
.ed-outliner-row:hover { background: #2e323a; }
.ed-outliner-row.selected { background: #333842; color: #d6e2db; }
.ed-outliner-glyph { color: #8fc4a8; width: 14px; text-align: center; }
.ed-outliner-kind { color: #9aa0aa; margin-left: auto; font-size: 10px; }
.ed-outliner-empty { color: #6a7078; font-size: 11px; }

#ed-grid {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid #2a2d33; padding-top: 8px;
}
#ed-grid label { color: #9aa0aa; font-size: 11px; display: flex; align-items: center; gap: 5px; }
#ed-grid #ed-grid-step { width: 56px; }

#ed-rot-grid {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: 6px;
}
#ed-rot-grid label { color: #9aa0aa; font-size: 11px; display: flex; align-items: center; gap: 5px; }
#ed-rot-grid #ed-rot-step { width: 56px; }

#ed-rot-hint { color: #6a7078; font-size: 10px; line-height: 1.4; margin: 4px 0 0; }
#ed-rot-hint kbd {
  font-family: inherit; font-size: 10px; color: #9aa0aa;
  background: #1c1f24; border: 1px solid #2a2d33; border-radius: 3px;
  padding: 0 4px;
}

#ed-toolbox[hidden], #ed-layers[hidden] { display: none; }
#ed-toolbox { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
.ed-tb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
#ed-toolbox .ed-tb-label { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: #9aa0aa; }
.ed-tb-active {
  font-size: 10px; color: #6fae8e; letter-spacing: 0.3px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#ed-tb-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
#ed-tb-buttons button {
  display: flex; align-items: center; gap: 7px; min-width: 0; text-align: left;
  cursor: pointer; color: #ccd0cc; background: #22252b; border: 1px solid #3a3e46;
  border-radius: 5px; padding: 5px 7px; font: inherit; font-size: 11px;
}
#ed-tb-buttons button:hover { background: #2e323a; border-color: #4a4f58; }
#ed-tb-buttons button.active {
  border-color: #6fae8e; background: #223028; color: #dfeae4; box-shadow: 0 0 0 1px #6fae8e inset;
}
#ed-tb-buttons .ed-tb-glyph { flex: none; width: 18px; text-align: center; font-size: 15px; line-height: 1; color: #8fc4a8; }
#ed-tb-buttons button.active .ed-tb-glyph { color: #d6e2db; }
#ed-tb-buttons .ed-tb-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ed-tb-buttons .ed-tb-key {
  flex: none; font-family: inherit; font-size: 9px; line-height: 1; color: #787d85;
  background: #16181c; border: 1px solid #3a3e46; border-radius: 3px; padding: 2px 4px;
}
#ed-tb-buttons button:hover .ed-tb-key { color: #9aa0aa; }
#ed-tb-buttons button.active .ed-tb-key { color: #bcc6c0; border-color: #6fae8e; }

.ed-wall-kind { margin-left: auto; font-size: 10px; font-weight: normal; letter-spacing: 0.4px; text-transform: uppercase; color: #9aa0aa; }

#ed-layer-select { font: inherit; font-size: 11px; max-width: 150px; }
#ed-layer-select:disabled { opacity: 0.4; }
#ed-layers { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2a2d33; padding-top: 8px; }
.ed-layers-head { display: flex; align-items: center; justify-content: space-between; }
.ed-layers-head .ed-tb-label { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: #9aa0aa; }
#ed-layer-add {
  cursor: pointer; color: #ddd; background: #22252b; border: 1px solid #3a3e46;
  border-radius: 4px; padding: 3px 8px; font: inherit; font-size: 11px;
}
#ed-layer-add:hover { background: #2e323a; }
#ed-layers-list { display: flex; flex-direction: column; gap: 2px; }
.ed-layers-empty { color: #6a7078; font-size: 11px; }
.ed-layer-row { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.ed-layer-row button {
  cursor: pointer; background: transparent; border: none; padding: 0; font-size: 13px;
  line-height: 1; width: 18px; text-align: center; color: #ddd;
}
.ed-layer-vis.off { opacity: 0.55; }
.ed-layer-name {
  flex: 1; color: #ccd0cc0cc; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-layer-row.hidden .ed-layer-name { color: #6a7078; text-decoration: line-through; }
.ed-layer-rename {
  flex: 1; min-width: 0; color: #ccd0cc0cc; background: #101216; border: 1px solid #3a3e46;
  border-radius: 4px; padding: 1px 4px; font: inherit;
}
.ed-layer-count { color: #9aa0aa; font-size: 10px; min-width: 14px; text-align: right; }
.ed-layer-del { color: #a55; }
.ed-layer-del:hover { color: #f77; }

.ed-ctxmenu {
  position: fixed; z-index: 1100; min-width: 140px;
  display: flex; flex-direction: column; padding: 4px;
  color: #ddd; font: 12px/1.4 monospace; background: rgba(18,20,24,0.95);
  border: 1px solid #2a2d33; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.ed-ctxmenu .head {
  color: #6fae8e; font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase;
  padding: 2px 8px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-ctxmenu .sep { height: 1px; background: #2a2d33; margin: 4px 2px; }
.ed-ctxmenu .item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  color: #ddd; background: transparent; border: none; border-radius: 4px;
  padding: 5px 8px; font: inherit;
}
.ed-ctxmenu .item:hover:not(:disabled) { background: #2e323a; }
.ed-ctxmenu .item.danger { color: #d66; }
.ed-ctxmenu .item.danger:hover:not(:disabled) { background: #4a2436; }
.ed-ctxmenu .item.has-sub { display: flex; justify-content: space-between; gap: 12px; }
.ed-ctxmenu .item:disabled { opacity: 0.4; cursor: default; }

#sb-banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none; z-index: 3;
  color: #6fae8e; font: bold 32px/1.5 monospace;
  text-shadow: 0 0 14px rgba(111, 174, 142, 0.7);
  animation: sb-banner-pulse 1.2s ease-in-out infinite;
}
#sb-banner[hidden] { display: none; }
.sb-banner-sub { font-size: 16px; color: #cdb98a; }
@keyframes sb-banner-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

@media (max-width: 720px) {
  #right-rail { width: min(320px, 52vw); }
  #panel, #editor-browser { font-size: 11px; }
  #event-tree-panel { width: min(500px, 92vw); }
  #editor-panel { width: min(300px, 88vw); }
  #sb-banner { font-size: clamp(18px, 7vw, 32px); }
  .sb-banner-sub { font-size: clamp(11px, 3.4vw, 16px); }
}
