/* Bảng độ khó — cửa sổ toàn màn hình phủ lên game (thiết kế cho máy tính, vẫn dùng được trên điện thoại). */
#editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
  background: radial-gradient(circle at 15% 0%, #2d2660, #15122a 65%);
  color: #e9f1ff;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  user-select: none;
}
#editor.hidden {
  display: none;
}
body.editor-open #app {
  visibility: hidden;
}
#editor button {
  cursor: pointer;
}
#editor code {
  font-family: Consolas, monospace;
  font-size: 0.95em;
  color: #ffd166;
}
.ed-shell {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 18px 12px;
}

/* ---- đầu trang ---- */
.ed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ed-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ed-logo {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 38px;
  padding: 6px 7px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
}
.ed-logo i {
  width: 7px;
  border-radius: 2px;
}
.ed-logo i:nth-child(1) { height: 32%; background: #5be37d; }
.ed-logo i:nth-child(2) { height: 55%; background: #4c8dff; }
.ed-logo i:nth-child(3) { height: 78%; background: #ffa62b; }
.ed-logo i:nth-child(4) { height: 100%; background: #ff4d6d; }
.ed-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}
.ed-brand p {
  margin: 1px 0 0;
  font-size: 12px;
  opacity: 0.7;
}
.ed-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.ed-state {
  font-size: 12px;
  opacity: 0.7;
  margin-right: 4px;
}
.ed-state.custom {
  color: #ffd166;
  opacity: 1;
}

/* ---- nút ---- */
.ed-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.08);
  color: #e9f1ff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.12s, transform 0.08s;
}
.ed-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.ed-btn:active {
  transform: translateY(1px);
}
.ed-btn.primary {
  background: linear-gradient(#5f8dff, #3d63e6);
  border-color: #86a6ff;
}
.ed-btn.primary:hover {
  background: linear-gradient(#7099ff, #4a6ff0);
}
.ed-btn.ghost {
  background: transparent;
}
.ed-btn.icon {
  width: 34px;
  padding: 0;
  font-size: 17px;
}
.ed-btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}
.ed-btn.icon.small {
  width: 28px;
  padding: 0;
  font-size: 16px;
}
.ed-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.ed-menu-wrap {
  position: relative;
}
.ed-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 40px;
  width: 310px;
  padding: 6px;
  border-radius: 12px;
  background: #241e4a;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  z-index: 6;
}
.ed-menu.show {
  display: block;
}
.ed-menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  text-align: left;
  font: inherit;
}
.ed-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}
.ed-menu b {
  display: block;
  font-size: 13px;
}
.ed-menu span {
  font-size: 12px;
  opacity: 0.7;
}

/* ---- thanh công cụ ---- */
.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.ed-seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
}
.ed-seg button {
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.75;
}
.ed-seg button.on {
  background: #e9f1ff;
  color: #1d1938;
  opacity: 1;
}
.ed-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.ed-zoom span {
  min-width: 104px;
  text-align: center;
  opacity: 0.8;
}
.ed-legend {
  display: flex;
  gap: 12px;
  margin-left: auto;
  font-size: 12px;
  flex-wrap: wrap;
}
.ed-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.9;
}
.ed-legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* ---- biểu đồ ---- */
.ed-overview-wrap {
  height: 44px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
}
.ed-overview {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}
.ed-chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 230px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.ed-chart {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.ed-tip {
  position: absolute;
  max-width: 270px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(16, 13, 34, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.ed-tip.show {
  opacity: 1;
}
.ed-tip em {
  color: #ffd166;
  font-style: normal;
}

/* ---- thẻ màn + bảng bên ---- */
.ed-bottom {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(320px, 1fr);
  gap: 12px;
  min-height: 0;
}
.ed-card,
.ed-panel {
  max-height: 36vh;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.ed-card-top {
  display: flex;
  gap: 14px;
}
.ed-thumb {
  flex: none;
  width: 118px;
  height: 118px;
  border-radius: 10px;
  background: #000;
  image-rendering: pixelated;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.ed-card-info {
  flex: 1;
  min-width: 0;
}
.ed-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ed-card-title h2 {
  margin: 0;
  font-size: 20px;
}
.ed-chip {
  padding: 2px 10px;
  border-radius: 20px;
  color: #141126;
  font-size: 12px;
  font-weight: 800;
}
.ed-file {
  margin: 4px 0 8px;
  font-size: 12px;
  opacity: 0.75;
}
.ed-file em {
  color: #ffd166;
  font-style: normal;
}
.ed-dval {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ed-dval input[type='range'] {
  flex: 1;
  accent-color: var(--c, #4c8dff);
}
#editor input[type='number'] {
  width: 64px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  user-select: text;
}
.ed-card-btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.ed-facts {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  font-size: 12.5px;
}
.ed-facts div {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
}
.ed-facts span {
  opacity: 0.6;
}
.ed-facts b {
  font-weight: 600;
}
#editor .good { color: #7bf1a8; }
#editor .warn { color: #ffd166; }
#editor .bad { color: #ff8fa3; }
#editor .muted { opacity: 0.62; font-weight: 400; }
.ed-box + .ed-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.ed-box h3 {
  margin: 0 0 6px;
  font-size: 12.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.9;
}
.ed-box h3 .muted {
  text-transform: none;
  letter-spacing: 0;
}
.ed-box p {
  margin: 6px 0;
  font-size: 12.5px;
}
.ed-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ed-row.disabled {
  opacity: 0.35;
  pointer-events: none;
}
.ed-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.ed-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  font-size: 12.5px;
}
.ed-grid2 label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ed-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}
.ed-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #5be37d, #4c8dff);
  transition: width 0.2s;
}

/* ---- hộp thoại ---- */
.ed-modal {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 64px 18px 18px;
  pointer-events: none;
}
.ed-modal.hidden {
  display: none;
}
.ed-modal.center {
  justify-content: center;
  align-items: center;
  background: rgba(8, 6, 20, 0.55);
  pointer-events: auto;
}
.ed-dialog {
  width: 430px;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 90px);
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: rgba(36, 30, 74, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}
.ed-dialog.small {
  width: 380px;
}
.ed-dialog h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.ed-dialog p {
  font-size: 13px;
  line-height: 1.45;
}
.ed-tpls {
  display: grid;
  gap: 6px;
}
.ed-tpl {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  text-align: left;
}
.ed-tpl:hover {
  background: rgba(255, 255, 255, 0.1);
}
.ed-tpl.on {
  border-color: #86a6ff;
  background: rgba(95, 141, 255, 0.2);
}
.ed-tpl b {
  display: block;
  font-size: 13px;
}
.ed-tpl span {
  font-size: 11.5px;
  opacity: 0.72;
}
.ed-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 12px 0 4px;
  font-size: 12.5px;
}
.ed-form label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ed-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.ed-toast {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  max-width: 80vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(16, 13, 34, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 13px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.ed-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 820px) {
  .ed-shell {
    overflow: auto;
    padding: 10px;
  }
  .ed-chart-wrap {
    flex: none;
    height: 48vh;
  }
  .ed-bottom {
    grid-template-columns: 1fr;
  }
  .ed-card,
  .ed-panel {
    max-height: none;
  }
  .ed-legend {
    margin-left: 0;
  }
  .ed-state {
    display: none;
  }
}
