/* 推箱子 - 界面样式（深色主题，移动端优先适配） */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #161b28;
  color: #e8ecf5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

#app { position: fixed; inset: 0; }

/* ---------- 屏幕切换 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  background: #161b28;
}
.screen.active { display: flex; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid #3a4763;
  background: #26304a;
  color: #e8ecf5;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
  user-select: none;
  min-height: 42px;
}
.btn:hover { background: #2f3c5c; }
.btn:active { transform: scale(.96); }
.btn.primary { background: #b77f2a; border-color: #d99b38; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #cf9334; }
.btn.danger { background: #6e2f2a; border-color: #93453e; }
.btn.big { width: 240px; padding: 13px 20px; font-size: 17px; }
.btn.small { padding: 7px 13px; font-size: 14px; min-height: 38px; }
.btn.tiny { padding: 4px 10px; font-size: 13px; min-height: 30px; border-radius: 8px; }
.btn.disabled, .btn:disabled { opacity: .4; }
.hidden { display: none !important; }

/* ---------- 主界面 ---------- */
#screen-home { justify-content: center; }
.home-box { text-align: center; padding: 20px; max-width: 420px; }
.logo-art { display: flex; gap: 12px; justify-content: center; margin-bottom: 14px; }
.mini-crate {
  width: 34px; height: 34px; border-radius: 7px;
  background: #d18b3a; border: 3px solid #a66a24;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.12);
}
.mini-crate.on { background: #5fae62; border-color: #47854b; }
.mini-goal {
  width: 34px; height: 34px; border-radius: 7px;
  background: #2b3245; position: relative;
}
.mini-goal::after {
  content: ''; position: absolute; inset: 8px;
  border: 3px solid #f5b942; transform: rotate(45deg);
}
.logo {
  font-size: 52px;
  letter-spacing: 10px;
  color: #f5b942;
  text-shadow: 0 3px 0 #7a5a1c, 0 6px 18px rgba(0,0,0,.5);
  margin-left: 10px;
}
.subtitle { color: #8fa0c2; letter-spacing: 4px; margin: 8px 0 4px; font-size: 13px; }
.progress-line { color: #6d7ea3; font-size: 13px; margin: 10px 0 22px; }
.menu { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.help-text { margin-top: 26px; color: #66779c; font-size: 12.5px; line-height: 1.9; }

/* ---------- 顶栏 ---------- */
.bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1d2433;
  border-bottom: 1px solid #2a3550;
  flex: 0 0 auto;
}
.bar h2 { font-size: 17px; font-weight: 600; color: #dfe6f5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-spacer { width: 62px; }

/* ---------- 选关 ---------- */
.levels-scroll {
  width: 100%;
  max-width: 640px;
  overflow-y: auto;
  padding: 14px;
  flex: 1 1 auto;
}
.section-title { color: #8fa0c2; font-size: 14px; margin: 12px 2px 10px; font-weight: 600; }
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 9px;
}
.lv {
  aspect-ratio: 1;
  border: 1px solid #3a4763;
  background: #232c44;
  border-radius: 12px;
  color: #e8ecf5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: transform .08s, background .15s;
  font-family: inherit;
}
.lv:hover:not(.locked) { background: #2e3a59; }
.lv:active:not(.locked) { transform: scale(.94); }
.lv.locked { opacity: .38; cursor: not-allowed; }
.lv.done { border-color: #b77f2a; background: #2c3049; }
.lv-num { font-size: 19px; font-weight: 700; color: #f5b942; }
.lv.locked .lv-num { color: #93a1c0; }
.lv-name { font-size: 10.5px; color: #9fb0d4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 3px; }
.lv-best { font-size: 10px; color: #e8c56a; }
.lv-lock { font-size: 15px; }

.custom-list { display: flex; flex-direction: column; gap: 8px; }
.custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #232c44;
  border: 1px solid #3a4763;
  border-radius: 10px;
  padding: 8px 10px;
}
.custom-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-name em { color: #e8c56a; font-style: normal; font-size: 12px; }
.custom-btns { display: flex; gap: 6px; flex: 0 0 auto; }
.empty { color: #66779c; font-size: 13px; padding: 10px 2px; }

/* ---------- 游戏界面 ---------- */
.stats {
  display: flex;
  gap: 22px;
  padding: 8px 12px;
  font-size: 14px;
  color: #9fb0d4;
  flex: 0 0 auto;
}
.stats b { color: #f5b942; font-size: 16px; margin-left: 2px; }
#board-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
#board {
  display: block;
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
  touch-action: none;
}
.toolbar {
  display: flex;
  gap: 10px;
  padding: 8px 12px 12px;
  flex: 0 0 auto;
}

/* ---------- 方向盘（触屏设备显示） ---------- */
#dpad { display: none; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 14px; }
.dp-mid { display: flex; gap: 6px; }
.dp {
  width: 62px; height: 52px;
  font-size: 20px;
  border-radius: 12px;
  border: 1px solid #3a4763;
  background: #26304a;
  color: #dfe6f5;
  touch-action: none;
  user-select: none;
}
.dp:active { background: #35436a; }
@media (pointer: coarse) {
  #dpad { display: flex; }
}

/* ---------- 通关浮层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 27, .72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.win-card {
  background: #232c44;
  border: 1px solid #d99b38;
  border-radius: 18px;
  padding: 26px 30px;
  text-align: center;
  box-shadow: 0 14px 44px rgba(0,0,0,.55);
  animation: pop .35s ease-out;
  max-width: 86vw;
}
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.stars { font-size: 34px; color: #f5b942; letter-spacing: 6px; margin-bottom: 6px; }
.stars span { display: inline-block; animation: starpop .5s ease-out backwards; }
.stars span:nth-child(1) { animation-delay: .05s; }
.stars span:nth-child(2) { animation-delay: .2s; }
.stars span:nth-child(3) { animation-delay: .35s; }
@keyframes starpop { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.35) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
.win-card h2 { color: #ffe27a; margin-bottom: 8px; font-size: 24px; }
.win-card p { color: #b9c6e2; font-size: 15px; margin-bottom: 18px; }
.win-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- 编辑器 ---------- */
.editor-top {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px 6px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  width: 100%;
  max-width: 700px;
  justify-content: center;
}
.editor-top input[type="text"] {
  background: #232c44;
  border: 1px solid #3a4763;
  color: #e8ecf5;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  width: 130px;
}
.editor-top label { font-size: 13px; color: #9fb0d4; display: flex; align-items: center; gap: 4px; }
.editor-top input[type="number"] {
  width: 52px;
  background: #232c44;
  border: 1px solid #3a4763;
  color: #e8ecf5;
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 14px;
}
.palette {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  flex-wrap: wrap;
  justify-content: center;
  flex: 0 0 auto;
  max-width: 700px;
}
.pal {
  border: 1px solid #3a4763;
  background: #232c44;
  color: #cfd9ef;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}
.pal.active { border-color: #f5b942; background: #3a341f; color: #ffe27a; }
#ed-canvas-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
#ed-canvas { border-radius: 10px; touch-action: none; box-shadow: 0 8px 26px rgba(0,0,0,.45); }
.ed-status { font-size: 13px; color: #9fb0d4; padding: 4px 10px; min-height: 24px; flex: 0 0 auto; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 27, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: #232c44;
  border: 1px solid #3a4763;
  border-radius: 16px;
  padding: 20px;
  width: min(480px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-card h3 { color: #ffe27a; font-size: 17px; }
#modal-text {
  width: 100%;
  background: #161b28;
  color: #cfe0c8;
  border: 1px solid #3a4763;
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  resize: vertical;
}
#modal-file { color: #9fb0d4; font-size: 13px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #39415e;
  border: 1px solid #55638c;
  color: #ffe27a;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: 88vw;
  text-align: center;
  animation: toastin .18s ease-out;
}
@keyframes toastin { 0% { transform: translateX(-50%) translateY(12px); opacity: 0; } 100% { transform: translateX(-50%) translateY(0); opacity: 1; } }

/* ---------- 窄屏微调 ---------- */
@media (max-width: 480px) {
  .logo { font-size: 42px; }
  .stats { gap: 14px; font-size: 13px; }
  .toolbar .btn.small { flex: 1; }
}
