:root {
  color-scheme: dark;
  --bg-top: #0b0f17;
  --bg-bottom: #05070c;
  --panel: rgba(9, 13, 22, 0.9);
  --line: rgba(134, 175, 255, 0.18);
  --accent: #f08a24;
  --accent-soft: rgba(240, 138, 36, 0.35);
  --text-main: #eff3ff;
  --text-dim: #8fa1c6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(77, 125, 255, 0.18), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
  font-family: "IBM Plex Mono", "SF Mono", "Consolas", monospace;
}

body {
  min-height: 100vh;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

.frame {
  width: min(100%, 1320px);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 18%),
    var(--panel);
  box-shadow:
    0 20px 80px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body.editor-mode .frame {
  width: min(100%, 1680px);
  height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body.editor-mode .shell {
  place-items: start center;
}

.workspace {
  display: block;
}

.chrome {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(240, 138, 36, 0.08), rgba(77, 125, 255, 0.08)),
    rgba(0, 0, 0, 0.18);
  text-transform: lowercase;
  letter-spacing: 0.08em;
}

.chrome__title {
  color: var(--text-main);
  font-size: 13px;
}

.chrome__meta {
  color: var(--text-dim);
  font-size: 11px;
}

.game-host {
  aspect-ratio: 5 / 3;
  width: 100%;
  min-height: min(72vh, 720px);
}

.game-host canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.editor-sidebar {
  display: none;
}

body.editor-mode .workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

body.editor-mode .editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    rgba(6, 10, 16, 0.92);
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.editor-mode .editor-sidebar--props {
  border-right: 1px solid var(--line);
}

body.editor-mode .editor-sidebar--terrain {
  border-left: 1px solid var(--line);
}

.editor-sidebar__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  color: var(--text-main);
}

.editor-sidebar__subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.editor-sidebar__section {
  display: grid;
  gap: 8px;
}

.editor-sidebar__label {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.editor-sidebar__switches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-sidebar__button {
  border: 1px solid var(--line);
  background: rgba(19, 32, 51, 0.92);
  color: var(--text-dim);
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}

.editor-sidebar__button.is-active {
  border-color: var(--accent);
  color: var(--text-main);
  background: rgba(27, 43, 66, 0.96);
}

.editor-sidebar__button.is-primary {
  color: var(--text-main);
}

.editor-sidebar__button:disabled {
  opacity: 0.5;
  cursor: default;
}

.editor-sidebar__tile-preview {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  background-color: rgba(19, 32, 51, 0.92);
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.editor-sidebar__tile-name {
  color: var(--text-main);
  font-size: 13px;
}

.editor-sidebar__tileset-copy {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.editor-sidebar__mode {
  color: var(--text-main);
  font-size: 13px;
}

.editor-sidebar__prop-groups {
  display: grid;
  gap: 14px;
}

.editor-sidebar__prop-group {
  display: grid;
  gap: 8px;
}

.editor-sidebar__prop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.editor-mode .game-host {
  min-height: 0;
  height: 100%;
  display: grid;
  align-content: start;
  overflow: hidden;
}

.editor-sidebar__prop-button {
  display: grid;
  gap: 8px;
  justify-items: center;
  align-content: start;
  min-height: 110px;
  padding: 10px 8px;
}

.editor-sidebar__prop-button.is-active {
  border-color: var(--accent);
  color: var(--text-main);
  background: rgba(27, 43, 66, 0.96);
}

.editor-sidebar__prop-preview {
  position: relative;
  width: 100%;
  height: 64px;
  background-color: rgba(8, 16, 26, 0.92);
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.editor-sidebar__prop-name {
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
}

.editor-sidebar__selection-copy {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.editor-sidebar__tileset {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(19, 32, 51, 0.92);
  padding: 8px;
}

.editor-sidebar__tileset-sheet {
  position: relative;
  width: 100%;
  background-color: rgba(8, 16, 26, 0.92);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.editor-sidebar__tileset-selection {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 0 0 1px rgba(240, 138, 36, 0.25);
  background: rgba(240, 138, 36, 0.14);
  pointer-events: none;
}

.editor-tileset-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.editor-tileset-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 12, 0.76);
  backdrop-filter: blur(2px);
}

.editor-tileset-overlay__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(86vw, 1180px);
  max-height: 86vh;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    rgba(6, 10, 16, 0.96);
  box-shadow:
    0 20px 80px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.editor-tileset-overlay__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.editor-tileset-overlay__title {
  color: var(--text-main);
  font-size: 20px;
  line-height: 1.1;
}

.editor-tileset-overlay__meta {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

.editor-tileset-overlay__sheet {
  position: relative;
  width: 100%;
  max-height: calc(86vh - 112px);
  background-color: rgba(8, 16, 26, 0.92);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

.editor-tileset-overlay__selection {
  position: absolute;
  border: 3px solid var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 0 1px rgba(240, 138, 36, 0.32);
  background: rgba(240, 138, 36, 0.14);
  pointer-events: none;
}

.editor-sidebar__status,
.editor-sidebar__meta,
.editor-sidebar__help {
  font-size: 12px;
  line-height: 1.45;
}

.editor-sidebar__status {
  color: var(--text-main);
}

.editor-sidebar__meta,
.editor-sidebar__help {
  color: var(--text-dim);
}

@media (max-width: 900px) {
  .shell {
    padding: 8px;
  }

  .chrome {
    flex-direction: column;
    align-items: flex-start;
  }

  body.editor-mode .workspace {
    grid-template-columns: 1fr;
  }

  body.editor-mode .editor-sidebar {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
