:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #111418;
  color: #f7f2e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell,
.stage,
#rpg-board {
  width: 100%;
  height: 100%;
}

.stage {
  position: relative;
  background: #111418;
}

#rpg-board {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.topbar,
.hud,
.piece-panel,
.map-panel {
  position: absolute;
  z-index: 2;
  color: #f7f2e8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 20, 24, 0.72);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.topbar {
  top: 18px;
  left: 18px;
  right: 18px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px 12px 18px;
  border-radius: 8px;
}

.topbar > div:first-child {
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.4vw, 1.75rem);
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  max-width: min(58vw, 640px);
  margin: 5px 0 0;
  color: #cfc7b7;
  font-size: 0.92rem;
  line-height: 1.35;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 8px;
  flex: 0 0 auto;
}

.actions button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(247, 242, 232, 0.08);
  color: #f7f2e8;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.actions button:hover {
  transform: translateY(-1px);
  background: rgba(247, 242, 232, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

.actions button.is-active {
  background: #d79b42;
  border-color: #ffc26b;
  color: #15120d;
}

.actions span {
  font-size: 1.35rem;
  line-height: 1;
}

.hud {
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
}

.hud div {
  min-width: 0;
}

.hud span {
  display: block;
  color: #b9c0c4;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hud strong {
  display: block;
  margin-top: 3px;
  color: #fff7e6;
  font-size: 1.1rem;
  line-height: 1.1;
}

.piece-panel {
  top: 106px;
  right: 18px;
  width: 250px;
  padding: 14px;
  border-radius: 8px;
}

.piece-panel[hidden],
.map-panel[hidden] {
  display: none;
}

.map-panel {
  top: 106px;
  left: 18px;
  width: 290px;
  padding: 14px;
  border-radius: 8px;
}

.piece-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.piece-panel__head span,
.file-control span,
.size-editor > span {
  display: block;
  color: #b9c0c4;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.piece-panel__head strong {
  display: block;
  margin-top: 3px;
  color: #fff7e6;
  font-size: 1.15rem;
  line-height: 1.1;
}

.piece-panel__head button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(247, 242, 232, 0.08);
  color: #f7f2e8;
  cursor: pointer;
}

.piece-avatar-preview {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  margin: 16px auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(215, 155, 66, 0.18), rgba(90, 143, 207, 0.22)),
    rgba(247, 242, 232, 0.06);
  background-position: center;
  background-size: cover;
  color: #d7dce0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow: hidden;
}

.size-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.size-editor > span {
  grid-column: 1 / -1;
}

.size-editor label {
  display: grid;
  gap: 6px;
  color: #d7dce0;
  font-size: 0.78rem;
}

.size-editor input {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(247, 242, 232, 0.08);
  color: #f7f2e8;
  padding: 0 10px;
  font-size: 0.95rem;
}

.size-editor label:last-child:nth-child(6) {
  grid-column: 1 / -1;
}

.object-editor {
  margin: 14px 0 0;
}

.object-editor .secondary-action {
  grid-column: 1 / -1;
  margin-top: 0;
}

.piece-avatar-preview.has-image span {
  display: none;
}

.file-control {
  display: grid;
  gap: 7px;
}

.file-control input {
  width: 100%;
  color: #d7dce0;
  font-size: 0.82rem;
}

.file-control input::file-selector-button,
.secondary-action {
  min-height: 38px;
  margin-right: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(247, 242, 232, 0.08);
  color: #f7f2e8;
  cursor: pointer;
}

.file-control input::file-selector-button {
  padding: 0 12px;
}

.secondary-action {
  width: 100%;
  margin-top: 12px;
}

.secondary-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.tool-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tool-grid button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(247, 242, 232, 0.08);
  color: #f7f2e8;
  cursor: pointer;
}

.tool-grid button:hover {
  background: rgba(247, 242, 232, 0.14);
}

.tool-grid button.is-active {
  background: #d79b42;
  border-color: #ffc26b;
  color: #15120d;
}

@media (max-width: 680px) {
  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
  }

  .topbar > div:first-child {
    max-width: calc(100% - 126px);
  }

  p {
    max-width: 100%;
    font-size: 0.78rem;
  }

  .actions {
    grid-template-columns: repeat(3, 36px);
    gap: 6px;
  }

  .actions button {
    width: 36px;
    height: 36px;
  }

  .hud {
    right: 10px;
    bottom: 10px;
    width: min(calc(100vw - 20px), 210px);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px;
  }

  .piece-panel {
    top: 92px;
    right: 10px;
    width: min(calc(100vw - 20px), 230px);
  }

  .map-panel {
    top: 92px;
    left: 10px;
    width: min(calc(100vw - 20px), 270px);
  }
}
