* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #14161c;
  color: #eef0f4;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* 画布和下方面板上下分栏(不是叠在一起),这样面板变高(比如展开步骤详情)时
   画布会相应变矮、魔方跟着重新居中,而不会被面板盖住 */
#canvas {
  flex: 1 1 auto;
  min-height: 160px; /* 面板内容再多也至少留出这么高的魔方可视区域 */
  width: 100%;
  display: block;
  touch-action: none; /* 手势交给 three.js OrbitControls,避免和浏览器自身缩放/滚动打架 */
}

#panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: #1a1c24;
  border-top: 1px solid #262a34;
}

h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #c9cdd8;
  letter-spacing: 0.02em;
}

#status {
  font-size: 13px;
  color: #9aa2b1;
  min-height: 18px;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

button {
  appearance: none;
  border: 1px solid #383d4a;
  background: #23262f;
  color: #eef0f4;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
  background: #2c303c;
  border-color: #4a5064;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#btnScramble {
  border-color: #5b3df0;
  background: #372a80;
}
#btnScramble:hover:not(:disabled) {
  background: #43349a;
}

#btnSolve {
  border-color: #1e8f6e;
  background: #164f3f;
}
#btnSolve:hover:not(:disabled) {
  background: #1c6650;
}

label {
  font-size: 12px;
  color: #9aa2b1;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 40px;
  touch-action: manipulation;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

input[type="range"] {
  width: 110px;
  height: 32px;
}

#moveList {
  display: none; /* 默认收起,避免逐步走法列表把屏幕上的魔方挤没了 */
  overflow-y: auto;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  max-height: 22vh;
}

#moveList.open {
  display: flex;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stage-title {
  font-size: 11px;
  color: #7d8497;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #23262f;
  border: 1px solid #383d4a;
  color: #b7bcc9;
}

.chip.active {
  background: #5b3df0;
  border-color: #5b3df0;
  color: #fff;
  font-weight: 700;
}

.chip.done {
  color: #5c6274;
  background: #1c1e26;
  border-color: #262a34;
}

@media (max-width: 520px) {
  #panel {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }
  #moveList {
    max-height: 26vh;
  }
  h1 {
    font-size: 13px;
  }
  #controls {
    gap: 8px;
  }
  button {
    padding: 8px 12px;
    font-size: 12px;
  }
  label {
    font-size: 11px;
  }
  input[type="range"] {
    width: 72px;
  }
}
