/* klotski — 華容道 */

.app { max-width: 560px; padding-bottom: 32px; }

/* ── HUD ───────────────────────────────────────────────── */
.hud {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0 6px;
}
.hud-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.hud-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }
.hud-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-value.small { font-size: 14px; line-height: 26px; }
:where(body:not(.dark)) .hud-value { color: color-mix(in srgb, var(--accent) 55%, #000); }

.sub-info {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 2px 8px;
}

/* ── Board ─────────────────────────────────────────────── */
.board-wrap {
  position: relative;
  width: min(100%, 360px);
  margin: 0 auto;
  padding: 10px 10px 0;
  background: linear-gradient(180deg, #8d5a32, #6d4223);
  border-radius: 14px 14px 6px 6px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.25), var(--shadow-sm);
  box-sizing: border-box;
}
.board-wrap.is-paused .board,
.board-wrap.is-paused .win-panel { visibility: hidden; }
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  background:
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 100% 20%,
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px) 0 0 / 25% 100%,
    #e9d3a8;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
body.dark .board {
  background:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px) 0 0 / 100% 20%,
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px) 0 0 / 25% 100%,
    #3a2c1e;
}
.exit-mark {
  position: relative;
  height: 18px;
  margin: 0 auto;
  width: 50%;
  background: #e9d3a8;
  border-radius: 0 0 6px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #6d4223;
  line-height: 18px;
}
body.dark .exit-mark { background: #3a2c1e; color: #f0d9b5; }

.piece {
  position: absolute;
  box-sizing: border-box;
  padding: 3px;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  transition: left 0.12s ease, top 0.12s ease;
  font-family: inherit;
  touch-action: none;
}
.piece:active { cursor: grabbing; }
.piece-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  font-weight: 900;
  font-size: clamp(14px, 4.4vw, 20px);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.22), 0 2px 4px rgba(0,0,0,0.25);
  pointer-events: none;
}
.type-C .piece-label { background: linear-gradient(160deg, #e53935, #b71c1c); color: #fff; font-size: clamp(20px, 7vw, 32px); }
.type-V .piece-label { background: linear-gradient(160deg, #1e88e5, #1259a3); color: #fff; writing-mode: vertical-rl; letter-spacing: 4px; }
.type-H .piece-label { background: linear-gradient(160deg, #2e9d58, #1b6e3b); color: #fff; letter-spacing: 4px; }
.type-S .piece-label { background: linear-gradient(160deg, #fff3d6, #e0c48f); color: #4a3216; }
body.dark .type-S .piece-label { background: linear-gradient(160deg, #d9c08e, #a88a55); color: #2a1a08; }
.piece.selected .piece-label,
.piece:focus-visible .piece-label { outline: 3px solid #ffca28; outline-offset: -3px; }
.piece:focus { outline: none; }
.piece.hinted .piece-label { animation: hint-glow 0.9s ease-in-out infinite alternate; }
.piece.hinted::after {
  content: attr(data-hint-dir);
  position: absolute;
  right: 6px; top: 4px;
  font-size: 20px;
  font-weight: 900;
  color: #ffeb3b;
  text-shadow: 0 0 3px #000, 0 0 6px #000;
  pointer-events: none;
}
@keyframes hint-glow {
  from { box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); }
  to   { box-shadow: 0 0 0 4px rgba(255, 235, 59, 0.95); }
}

/* ── Win panel ─────────────────────────────────────────── */
.win-panel {
  position: absolute;
  inset: 10px 10px 18px;
  background: rgba(20, 14, 8, 0.82);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-align: center;
  padding: 12px;
  animation: win-in 0.3s ease;
}
.win-panel[hidden] { display: none; }
@keyframes win-in { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
.win-title { font-size: 22px; font-weight: 900; }
.win-stars { font-size: 34px; color: #ffd54f; letter-spacing: 4px; }
.win-detail { font-size: 13px; color: #f3e6d0; }

/* ── Controls ──────────────────────────────────────────── */
.hint-line { min-height: 20px; text-align: center; font-size: 13px; font-weight: 700; color: var(--text-strong); margin: 8px 0 2px; }
.action-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.action-row .btn.primary { background: linear-gradient(180deg, #e53935, #b71c1c); color: #fff; }

.level-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin: 8px 0;
  box-shadow: var(--shadow-sm);
}
.level-panel[hidden] { display: none; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.level-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "num name" "stars stars" "meta meta";
  gap: 2px 6px;
  text-align: left;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-strong);
  font-family: inherit;
  cursor: pointer;
}
.level-btn:hover { border-color: var(--accent); }
.level-btn.current { box-shadow: 0 0 0 2px var(--accent) inset; }
.lv-num { grid-area: num; font-weight: 900; color: var(--text-muted); }
.lv-name { grid-area: name; font-weight: 800; font-size: 13px; }
.lv-stars { grid-area: stars; color: #8a5d00; letter-spacing: 1px; }
body.dark .lv-stars { color: #ffd54f; }
.lv-meta { grid-area: meta; font-size: 11px; color: var(--text-muted); }

.legend { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.6; }

@media (max-width: 420px) {
  .hud { grid-template-columns: 1fr 1fr 1fr; }
  .hud-wide { grid-column: 1 / -1; }
}

html[lang="en"] .type-V .piece-label,
html[lang="en"] .type-H .piece-label { letter-spacing: 0; font-size: clamp(11px, 3.4vw, 15px); }
html[lang="en"] .type-S .piece-label { font-size: clamp(10px, 3vw, 13px); }
html[lang="en"] .type-C .piece-label { font-size: clamp(16px, 5vw, 24px); }
