:root {
  --bg: #06131a;
  --bg-elevated: rgba(8, 24, 32, 0.86);
  --bg-soft: rgba(13, 37, 48, 0.72);
  --ink: #ecf2eb;
  --muted: #93aba7;
  --line: rgba(160, 205, 198, 0.16);
  --accent: #0fb8a4;
  --accent-soft: rgba(15, 184, 164, 0.18);
  --sun: #f4b73b;
  --coral: #ff7a59;
  --blue: #3da7ff;
  --mint: #6de6bb;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(15, 184, 164, 0.15), transparent 22rem),
    radial-gradient(circle at top right, rgba(244, 183, 59, 0.1), transparent 20rem),
    linear-gradient(180deg, #0b1d25 0%, #051118 100%);
  color: var(--ink);
  font-family: "Bahnschrift", "Trebuchet MS", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, black 55%, transparent 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.app-shell {
  max-width: 1940px;
  margin: 0 auto;
  padding: 1.3rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  align-items: stretch;
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(130deg, rgba(4, 22, 29, 0.95), rgba(10, 34, 44, 0.82)),
    radial-gradient(circle at right center, rgba(61, 167, 255, 0.14), transparent 18rem);
  box-shadow: var(--shadow);
}

.hero-copy {
  max-width: 54rem;
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--sun);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(2.1rem, 4vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.hero-quote {
  margin: 0.55rem 0 0.35rem;
  color: #d9ebd8;
  font-size: 1.05rem;
}

.hero-summary {
  margin: 0;
  max-width: 52rem;
  color: var(--muted);
}

.hero-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(6.5rem, 1fr));
  gap: 0.85rem;
  min-width: 21rem;
}

.status-tile {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.status-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(24rem, 31rem) minmax(38rem, 1fr) minmax(20rem, 24rem);
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
}

.panel,
.board-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  padding: 1rem;
}

.panel-section + .panel-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-left {
  align-self: start;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.panel-copy {
  margin: 0 0 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.palette-card,
.tool-button,
.control-button,
.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink);
  background: var(--bg-soft);
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.palette-card:hover,
.tool-button:hover,
.control-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(18, 47, 59, 0.95);
}

.palette-card.is-active,
.tool-button.is-active,
.control-button.is-active {
  border-color: rgba(15, 184, 164, 0.6);
  background:
    linear-gradient(145deg, rgba(15, 184, 164, 0.22), rgba(9, 37, 47, 0.95));
  box-shadow: 0 0 0 1px rgba(15, 184, 164, 0.24) inset;
}

.palette-card {
  padding: 0.8rem;
  border-radius: 18px;
  text-align: left;
}

.palette-card strong {
  display: block;
  margin-bottom: 0.2rem;
}

.palette-card span {
  display: block;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.9rem;
}

.palette-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.tool-button,
.control-button,
.ghost-button {
  border-radius: 999px;
  padding: 0.72rem 1rem;
}

.tool-button-accent,
.control-button-primary {
  border-color: rgba(244, 183, 59, 0.45);
  background: linear-gradient(135deg, rgba(244, 183, 59, 0.28), rgba(92, 52, 7, 0.32));
}

.brush-summary,
.selection-summary,
.scene-meta {
  margin-top: 0.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.45;
}

.scene-meta strong {
  display: block;
  color: var(--ink);
}

.scene-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.scene-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.scene-action-grid .ghost-button {
  flex: 1 1 6.75rem;
  min-width: 6.75rem;
  padding: 0.68rem 0.85rem;
  border-radius: 16px;
  text-align: center;
  white-space: nowrap;
}

.note-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
  line-height: 1.5;
}

.note-list.compact li + li {
  margin-top: 0.2rem;
}

.board-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
}

.toolbar-cluster {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.range-wrap {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--bg-soft);
}

.speed-value {
  color: var(--muted);
  min-width: 4.3rem;
}

.canvas-frame {
  position: relative;
  flex: 1;
  padding: 1.1rem;
  height: min(72vh, 880px);
  min-height: 34rem;
  overflow: hidden;
}

.canvas-help {
  position: absolute;
  right: 1.9rem;
  top: 1.9rem;
  z-index: 1;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(3, 16, 21, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.84rem;
  backdrop-filter: blur(10px);
}

#worldCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 22px;
  background:
    radial-gradient(circle at top, rgba(15, 184, 164, 0.08), transparent 30%),
    linear-gradient(180deg, #08151b, #0a1f28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  touch-action: none;
}

#worldCanvas[data-tool="paint"] {
  cursor: crosshair;
}

#worldCanvas[data-tool="paint"][data-direction="north"] {
  cursor: n-resize;
}

#worldCanvas[data-tool="paint"][data-direction="east"] {
  cursor: e-resize;
}

#worldCanvas[data-tool="paint"][data-direction="south"] {
  cursor: s-resize;
}

#worldCanvas[data-tool="paint"][data-direction="west"] {
  cursor: w-resize;
}

#worldCanvas[data-tool="select"] {
  cursor: cell;
}

#worldCanvas[data-tool="pan"] {
  cursor: grab;
}

#worldCanvas[data-dragging="pan"] {
  cursor: grabbing;
}

.objective-card,
.inspector-card,
.event-log,
.module-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.objective-card,
.inspector-card {
  padding: 0.95rem;
}

.objective-card p,
.inspector-card p,
.module-card p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.progress-bar {
  position: relative;
  margin-top: 0.8rem;
  height: 0.75rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--sun));
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.stat-pill,
.muted-chip,
.tiny-chip,
.traveller-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
}

.stat-pill,
.muted-chip,
.tiny-chip {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.traveller-chip {
  margin: 0.3rem 0.35rem 0 0;
  color: #031015;
  font-weight: 700;
}

.traveller-chip .swatch,
.tiny-chip .swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
}

.inspector-meta,
.property-grid,
.module-meta {
  display: grid;
  gap: 0.75rem;
}

.property-grid {
  margin-top: 0.9rem;
}

.property-row {
  display: grid;
  gap: 0.35rem;
}

.property-row label {
  color: var(--muted);
  font-size: 0.88rem;
}

.property-row input,
.property-row select {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(4, 18, 23, 0.88);
  color: var(--ink);
}

.module-list {
  display: grid;
  gap: 0.7rem;
}

.module-card {
  padding: 0.85rem;
  border: 1px solid transparent;
}

.module-card.is-selected {
  border-color: rgba(15, 184, 164, 0.55);
}

.module-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: start;
}

.module-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.mini-button {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.module-port-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.event-log {
  max-height: 18rem;
  overflow: auto;
}

.event-item {
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.event-item:last-child {
  border-bottom: 0;
}

.event-tick {
  color: var(--sun);
  font-size: 0.9rem;
}

.event-body {
  color: var(--muted);
  line-height: 1.45;
}

.empty-state {
  color: var(--muted);
  padding: 0.3rem 0;
}

code {
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

body.is-play-mode {
  overflow: hidden;
}

body.is-play-mode .app-shell {
  max-width: none;
  padding: 0;
}

body.is-play-mode .hero,
body.is-play-mode .panel {
  display: none;
}

body.is-play-mode .workspace {
  display: block;
  margin-top: 0;
}

body.is-play-mode .board-panel {
  min-height: 100vh;
  height: 100vh;
  border-radius: 0;
  border: 0;
}

body.is-play-mode .board-toolbar {
  padding: 0.95rem 1rem;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.is-play-mode .canvas-frame {
  height: auto;
  min-height: 0;
  padding: 1rem;
}

body.is-play-mode [data-edit-only="true"] {
  display: none;
}

@media (min-width: 1540px) {
  .panel-left {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    align-content: start;
  }

  .panel-left .panel-section {
    margin: 0;
    padding: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.02);
  }

  .panel-left .panel-section + .panel-section {
    margin-top: 0;
    padding-top: 0.95rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .panel-left .panel-section-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1320px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    min-width: 0;
  }

  .panel-left {
    display: block;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 0.85rem;
  }

  .hero,
  .panel,
  .board-panel {
    border-radius: 22px;
  }

  .hero-actions {
    grid-template-columns: 1fr;
  }

  .canvas-frame {
    min-height: 26rem;
  }

  .canvas-help {
    left: 1.5rem;
    right: auto;
    max-width: calc(100% - 3rem);
  }

  .scene-action-grid .ghost-button {
    flex-basis: calc(50% - 0.55rem);
    min-width: 0;
  }
}
