*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  overflow-wrap: break-word;
  hyphens: auto;
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  user-select: none;
  cursor: default;
}

:root {
  --fg: #fff;
  --bg: #333;
}

html,
body,
svg,
canvas {
  position: absolute;
  inset: 0;
  height: 100svh;
  overflow: hidden;
}

body {
  display: grid; /* So that things can easily center themselves */
  font-size: 16px;
  font-family: system-ui;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--fg);
  background-color: var(--bg);
}

svg,
canvas {
  width: 100%;
  height: 100%;
}

svg {
  text-anchor: middle;
  font-family: monospace;
}

#spark {
  left: auto;
  box-shadow: 0 0.5px 4px #8882;
}

text.spark {
  font-size: 6px;
  text-anchor: end;
}

#ErrorMessage {
  position: relative;
  place-self: center;
  padding: 3em 4em 2em;
  border: 4px solid #222;
  background: #0007;
  backdrop-filter: blur(32px);
  z-index: 200;

  &.hidden {
    display: none;
  }

  a {
    display: inline-block;
    padding-top: 1em;
    font-size: 0.8em;
    font-weight: 700;
    color: #ccc;
    cursor: pointer;
    &:hover {
      color: #fff;
    }
    &:first-of-type {
      margin-right: 1em;
    }
  }

  p {
    white-space: pre-wrap;
  }
}

#settings {
  position: absolute;
  display: none;
  inset: 0;
  place-content: center;

  &.active {
    display: grid;
  }
}

#settings > div {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  --last-column: 5;
  grid-auto-flow: row;
  padding: 1.5em;
  gap: 2em 1.5em;
  background: #f7f7f7;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: black;
  box-shadow: 0 0.2em 2em #0002;
}

h1 {
  grid-column: 1 / var(--last-column);
  font-size: 1.3em;
  span {
    padding-left: 0.1em;
    font-size: 0.8em;
    font-weight: 200;
  }
}

.option {
  padding: 0.6em;
  margin: 0.8em 0;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 2px;

  &.disabled {
    pointer-events: none;
    opacity: 0.5;
  }
}

#debug {
  position: fixed;
  top: 0;
  right: -320px;
  width: 320px;
  height: 100vh;
  z-index: 300;
}

#debug.active {
  right: 0;
}

#debug > div {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100%;
  padding: 0;
  gap: 0;
  background: rgba(26, 26, 26, 0.9);
  border-left: 1px solid #444;
  color: #fff;

  font-family: "Courier New", monospace;
  font-size: 0.9em;
  overflow-y: auto;
}

.debug-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2em;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-left: auto;
  padding: 0;
}

#debug .debug-close {
  align-self: start;
  margin-top: 0.5em;
}

.debug-delete {
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 0.8em;
  padding: 0.2em 0.5em;
  cursor: pointer;
  transition: all 0.2s;
  margin-right: 0.5em;
}

.debug-delete:hover {
  background: #ff4444;
  border-color: #ff4444;
}

.debug-tabs {
  display: flex;
  align-items: end;
  gap: 0;
  border-bottom: 1px solid #444;
  padding: 0 1em;
}

.debug-tab {
  padding: 0.4em 0.8em;
  background: #2a2a2a;
  border: 1px solid #444;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  margin-bottom: -1px;
  position: relative;
}

.debug-tab:hover {
  background: #333;
}

.debug-tab.active {
  background: #00ff88;
  color: #000;
  border-color: #00ff88;
  border-bottom: 1px solid #00ff88;
}

.debug-content {
  overflow-y: auto;
}

.debug-content section {
  margin-bottom: 1.5em;
}

.debug-content section h3 {
  color: #00ff88;
  margin-bottom: 0.5em;
  font-size: 1em;
}

.debug-content section h4 {
  color: #88ddff;
  margin: 1em 0 0.5em 0;
  font-size: 0.9em;
}

.perf-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5em;
  padding: 1em;
}

.perf-info > div:not(.system-times-table) {
  padding: 0.5em;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 4px;
}

.perf-info div strong {
  color: #ffaa00;
}

.fps-graph-container {
  margin: 1em;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 4px;
  margin-top: 0.5em;
  height: 100px;
}

#fps-graph {
  position: relative;
  width: 100%;
  height: 100px;
  border: 1px solid #333;
  display: block;
}

.system-times-table {
  margin-top: 0.5em;
  width: 100%;
}

.table-header {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  background: #333;
  padding: 0.3em;
  font-weight: bold;
  color: #ffaa00;
  font-size: 0.8em;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  background: #2a2a2a;
  padding: 0.2em 0.3em;
  font-size: 0.8em;
  font-family: monospace;
}

.table-row:hover {
  background: #333;
}

.table-row.over-budget {
  color: #f44;
}

.table-row.over-budget:hover {
  background: #5a2a2a;
}

.scene-graph-tree {
  height: 100%;
  overflow-y: auto;
  width: 100%;
  padding: 0.5em;
}

.tree-node {
  margin: 0.2em 0;
}

.tree-node-content {
  padding: 0.2em 0.6em;
  border-radius: 2px;
  font-size: 0.8em;
  font-family: monospace;
  line-height: 1.4;
}

.tree-node-content:hover {
  background: #444;
}

.tree-node-content strong {
  color: #88ddff;
}

.tree-children {
  margin-left: 10px;
  border-left: 1px solid #555;
  padding-left: 2px;
}

.deploy {
  padding: 0.2em 0 0;
  margin-bottom: 0em;
  border: 1px solid transparent;
  opacity: 0.5;
}

.entity-details-panel {
  position: fixed;
  right: 319px;
  top: -1px;
  width: 300px;
  height: 100vh;
  z-index: 10001;
  display: grid;
  grid-template-rows: auto 1fr;
  height: calc(100vh - 20px);
  padding: 0;
  gap: 0;
  background: rgba(26, 26, 26, 0.9);
  border: 1px solid #444;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}

.entity-details-panel .header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  border-bottom: 1px solid #444;
  padding: 0.5em 1em;
}

.entity-details-panel .header .title {
  color: #00ff88;
  font-size: 1em;
  flex: 1;
}

.entity-details-panel .header .close-button {
  background: #333;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-size: 1.2em;
  line-height: 1;
  width: 1.8em;
  height: 1.8em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.entity-details-panel .header .close-button:hover {
  background: #ff4444;
  border-color: #ff4444;
}

.entity-details-panel .content {
  overflow-y: auto;
}

.entity-details-panel .template-info {
  margin-bottom: 1.5em;
}

.entity-details-panel .template-info strong {
  color: #ffaa00;
}

.entity-details-panel .props-title {
  color: #88ddff;
  margin: 1em 0 0.5em 0;
  font-size: 0.9em;
}

.entity-details-panel .props-tree {
  height: 100%;
  overflow-y: auto;
  width: 100%;
  padding: 0.5em;
}

.entity-details-panel .tree-node-content:hover {
  background: #444;
}

.log-container {
  overflow-y: auto;
  background: #1a1a1a;
  border: 1px solid #333;
  padding: 8px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
}
