/* =========================================================================
 *  方块解题器 · 样式
 * ========================================================================= */
:root {
  --bg-1: #44629c;
  --bg-2: #2c4574;
  --card: rgba(255, 255, 255, 0.075);
  --card-2: rgba(255, 255, 255, 0.045);
  --stroke: rgba(255, 255, 255, 0.14);
  --text: #ecf1ff;
  --muted: #a7b9de;
  --gold: #ffd25c;
  --gold-2: #e2a423;
  --gold-sh: #a1701a;
  --ok: #5fe08a;
  --bad: #ff8b8b;
  --radius: 18px;
  --shadow: 0 14px 30px rgba(8, 18, 45, 0.28);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 700px at 50% -10%, #5474af 0%, rgba(84, 116, 175, 0) 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding: 18px 16px 40px;
}

.app { max-width: 1080px; margin: 0 auto; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #ffd968, #e6a41d);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.brand-mark svg { width: 24px; height: 24px; display: block; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .02em; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 通用 ---------------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px; align-items: start;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}
.col { display: grid; gap: 16px; min-width: 0; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h2, .card-head h2 {
  font-size: 12.5px; font-weight: 700; letter-spacing: .1em;
  color: var(--muted); margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.hint { font-size: 12px; color: var(--muted); }

.btn {
  appearance: none; border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .09); color: var(--text);
  border-radius: 11px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s, border-color .15s;
  font-family: inherit;
}
.btn:hover { background: rgba(255, 255, 255, .16); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.on { border-color: var(--gold); color: var(--gold); }
.btn.ghost { background: transparent; }

.btn.primary {
  width: 100%; padding: 13px 18px; font-size: 15px; font-weight: 800;
  color: #4b3406; border: 0; border-radius: 14px;
  background: linear-gradient(180deg, #ffdc72, #eaa81f);
  box-shadow: 0 5px 0 var(--gold-sh), 0 12px 22px rgba(0, 0, 0, .28),
              inset 0 1px 0 rgba(255, 255, 255, .7);
  letter-spacing: .04em;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold-sh), 0 6px 12px rgba(0, 0, 0, .25); }

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 2px dashed rgba(255, 255, 255, .26);
  border-radius: 14px; padding: 18px 14px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: rgba(255, 255, 255, .03);
}
.dropzone:hover, .dropzone.over { border-color: var(--gold); background: rgba(255, 210, 92, .08); }
.dropzone .dz-icon { font-size: 22px; line-height: 1; margin-bottom: 6px; opacity: .9; }
.dropzone b { font-size: 14px; }
.dropzone span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }

.upload-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.thumb-wrap {
  display: none; gap: 12px; align-items: flex-start;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed rgba(255, 255, 255, .12);
}
.thumb-wrap.show { display: flex; flex-wrap: wrap; }
#previewCanvas {
  display: block; border-radius: 10px; flex: none;
  background: #1a2240; box-shadow: 0 8px 18px rgba(0, 0, 0, .32);
}
.thumb-info { font-size: 12.5px; color: var(--muted); flex: 1 1 150px; min-width: 0; }
.thumb-info b { color: var(--text); }
.thumb-info .list { margin-top: 4px; }

/* ---------------- 棋盘 ---------------- */
.board-stage { display: grid; place-items: center; }
#boardCanvas { display: block; width: 100%; max-width: 460px; touch-action: manipulation; }

.brush {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px;
  padding-top: 12px; border-top: 1px dashed rgba(255, 255, 255, .12);
}

/* 棋盘下方的步骤条：手机上就在棋盘边上翻步，不用上下滚 */
.board-steps {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, .12);
}
.board-steps[hidden] { display: none; }
.bs-nav {
  flex: none; width: 40px; height: 36px; border-radius: 10px;
  border: 1px solid var(--stroke); background: rgba(255, 255, 255, .1);
  color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
  font-family: inherit; transition: background .14s, transform .1s;
}
.bs-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.bs-nav:active:not(:disabled) { transform: translateY(1px); }
.bs-nav:disabled { opacity: .32; cursor: default; }
.bs-text { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
.bs-text b { font-size: 12.5px; color: var(--gold); letter-spacing: .02em; }
.bs-text span {
  font-size: 12px; color: var(--muted); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brush-label { font-size: 12px; color: var(--muted); align-self: center; margin-right: 2px; }
.brush button {
  padding: 3px; border-radius: 9px; border: 2px solid transparent;
  background: transparent; cursor: pointer; line-height: 0;
  transition: border-color .15s, background .15s, transform .1s;
}
.brush button:hover { background: rgba(255, 255, 255, .1); }
.brush button.sel { border-color: var(--gold); background: rgba(255, 210, 92, .16); }
.brush button:active { transform: scale(.94); }

/* ---------------- 棋子 ---------------- */
.pieces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.piece {
  background: rgba(0, 0, 0, .16); border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 12px; padding: 8px; min-width: 0;
}
.piece-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px; }
.piece-name { font-size: 12px; font-weight: 700; color: var(--muted); }
.piece canvas.grid { display: block; width: 100%; touch-action: manipulation; }
.piece-kinds { display: flex; gap: 2px; margin-top: 6px; justify-content: center; flex-wrap: wrap; }
.piece-kinds button {
  padding: 1px; border-radius: 6px; border: 1.5px solid transparent;
  background: transparent; cursor: pointer; line-height: 0;
}
.piece-kinds button.sel { border-color: var(--gold); }
.piece-kinds button:active { transform: scale(.9); }

/* ---------------- 目标 ---------------- */
/* 截图顶部识别出的模式条：宝石目标 / 积分模式 / 无尽模式 */
.hud-chip {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(95, 224, 138, .1); border: 1px solid rgba(95, 224, 138, .32);
  font-size: 12.5px; line-height: 1.5;
}
.hud-chip[hidden] { display: none; }
.hud-chip .hc-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hud-chip .hc-tag {
  flex: none; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  background: rgba(95, 224, 138, .22); color: #a8f5c4; letter-spacing: .5px;
}
.hud-chip b { color: var(--text); font-weight: 700; }
.hud-chip .hc-note { margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.hud-chip.score { background: rgba(255, 176, 60, .1); border-color: rgba(255, 176, 60, .34); }
.hud-chip.score .hc-tag { background: rgba(255, 176, 60, .22); color: #ffd08a; }
.hud-chip.endless { background: rgba(120, 170, 255, .1); border-color: rgba(120, 170, 255, .32); }
.hud-chip.endless .hc-tag { background: rgba(120, 170, 255, .22); color: #a9c8ff; }

.goals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.goal {
  display: grid; justify-items: center; gap: 4px;
  padding: 6px 2px; border-radius: 10px;
  background: rgba(0, 0, 0, .15); border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.goal.done { border-color: rgba(95, 224, 138, .55); background: rgba(95, 224, 138, .1); }
.goal canvas { display: block; }
.goal input {
  width: 100%; text-align: center; font: inherit; font-size: 13px; font-weight: 700;
  color: var(--text); background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14); border-radius: 7px;
  padding: 2px 0; -moz-appearance: textfield;
}
.goal input::-webkit-outer-spin-button,
.goal input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.goal input:focus { outline: none; border-color: var(--gold); }

.option-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; align-items: center; font-size: 12.5px; color: var(--muted); }
.option-row span { line-height: 1.4; }

/* ---------------- 结果 ---------------- */
#resultCard { display: none; }
#resultCard.show { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.verdict { display: flex; gap: 9px; align-items: flex-start; font-weight: 700; font-size: 14px; line-height: 1.45; }
.verdict .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; }
.verdict.ok { color: var(--ok); }
.verdict.ok .dot { background: var(--ok); box-shadow: 0 0 10px rgba(95, 224, 138, .8); }
.verdict.bad { color: var(--bad); }
.verdict.bad .dot { background: var(--bad); box-shadow: 0 0 10px rgba(255, 139, 139, .7); }

.alts { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 10px; }
.alts .btn { padding: 5px 11px; font-size: 12px; }

.steps { display: grid; gap: 6px; }
.step {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  background: rgba(0, 0, 0, .14); border: 1px solid transparent;
  transition: background .14s, border-color .14s;
}
.step:hover { background: rgba(0, 0, 0, .22); }
.step.sel { border-color: var(--gold); background: rgba(255, 210, 92, .1); }
.step .no {
  width: 20px; height: 20px; border-radius: 6px; flex: none; margin-top: 1px;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: rgba(255, 255, 255, .16);
}
.step.sel .no { background: var(--gold-2); color: #3a2600; }
.step .txt { font-size: 12.5px; line-height: 1.5; }
.step .txt b { color: var(--gold); font-weight: 700; }
.step .txt em { font-style: normal; color: var(--ok); }

.summary { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.summary b { color: var(--text); }
.warn { color: var(--bad); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
/* 消除格是「褪色发白 + 深红外框」，图例照这个来 */
.legend i.fade { background: #fdf1ea; box-shadow: inset 0 0 0 2px #d81e1e; }

footer { text-align: center; color: rgba(255, 255, 255, .38); font-size: 11.5px; margin-top: 26px; }

/* ---------------- 窄屏（手机） ---------------- */
@media (max-width: 460px) {
  body { padding: 14px 12px 32px; }
  .card { padding: 12px; border-radius: 16px; }
  .card-head { gap: 8px; align-items: baseline; }
  .card-head h2 { font-size: 11.5px; letter-spacing: .06em; }
  .hint { font-size: 11px; line-height: 1.3; text-align: right; flex: 1 1 auto; min-width: 0; }
  .goals { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .goal { padding: 7px 2px; }
  .goal input { font-size: 14px; padding: 4px 0; }
  .brush { gap: 4px; }
  .brush button { padding: 2px; }
  .pieces { gap: 7px; }
  .piece { padding: 6px; }
  .top-actions .btn { padding: 7px 12px; font-size: 12.5px; }
}

