/* =========================================================
   魔方 · Rubik's Cube —— 全部样式
   风格：深色 + 简洁科技感，玻璃质感按钮
   ========================================================= */

:root {
  --bg-0: #05070b;
  --bg-1: #0b1018;
  --bg-2: #101725;
  --text: #e8eef8;
  --text-dim: #93a3bd;
  --text-mute: #6a7b96;
  --line: rgba(150, 190, 255, 0.14);
  --line-strong: rgba(150, 190, 255, 0.28);
  --glass: rgba(17, 24, 38, 0.55);
  --glass-hi: rgba(30, 42, 64, 0.72);
  --accent: #4c8dff;
  --accent-2: #35d6e6;
  --warn: #ffb020;
  --danger: #ff5c6c;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1200px 760px at 50% 4%, rgba(76, 141, 255, 0.20), transparent 62%),
    radial-gradient(900px 620px at 50% 104%, rgba(53, 214, 230, 0.12), transparent 66%),
    radial-gradient(700px 500px at 12% 88%, rgba(160, 80, 255, 0.10), transparent 70%),
    linear-gradient(165deg, var(--bg-2) 0%, var(--bg-1) 42%, var(--bg-0) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* 极淡网格，中心略微发光后向四周淡出 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(140, 190, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 190, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(circle at 50% 44%, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 44%, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 78%);
}

/* ---------------- 3D 画布 ---------------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  transition: filter 0.25s ease;
}
#stage:active { cursor: grabbing; }
body.is-paused #stage { filter: blur(7px) brightness(0.5) saturate(0.8); }

/* ---------------- 覆盖层 ---------------- */

#ui {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(14px, 2.6vh, 30px) 18px clamp(10px, 1.8vh, 20px);
  pointer-events: none; /* 空白处的拖拽交给画布 */
}

#topbar { text-align: center; }

#topbar h1 {
  margin: 0;
  font-size: clamp(19px, 2.9vh, 28px);
  font-weight: 600;
  letter-spacing: 0.14em;
  background: linear-gradient(92deg, #ffffff 0%, #cfe1ff 45%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 34px rgba(90, 160, 255, 0.28);
}
#topbar h1 .dot { margin: 0 0.5em; color: var(--text-mute); -webkit-text-fill-color: var(--text-mute); }
#topbar h1 .en { font-size: 0.72em; letter-spacing: 0.22em; opacity: 0.9; }

#topbar .subtitle {
  margin: 0.55em 0 0;
  font-size: clamp(11px, 1.5vh, 13px);
  letter-spacing: 0.08em;
  color: var(--text-mute);
}

#bottom {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.5vh, 16px);
  padding-top: 18px;
}

/* ---------------- HUD ---------------- */

#hud {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.2vw, 26px);
  padding: 9px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.hud-item { display: flex; align-items: baseline; gap: 9px; }

.hud-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--text-mute);
}

.hud-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(19px, 2.6vh, 26px);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #f2f7ff;
  text-shadow: 0 0 18px rgba(110, 170, 255, 0.35);
  min-width: 5.6em;
  display: inline-block;
}
.hud-value.is-best {
  font-size: clamp(15px, 2vh, 20px);
  color: #ffd98a;
  text-shadow: 0 0 16px rgba(255, 190, 80, 0.32);
  min-width: 5.6em;
}
#hud-moves { min-width: 2.2em; }

.hud-sep {
  width: 1px;
  height: 26px;
  background: linear-gradient(transparent, var(--line-strong), transparent);
}

.hud-badge {
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #1b1200;
  background: linear-gradient(120deg, #ffd98a, var(--warn));
  box-shadow: 0 0 16px rgba(255, 176, 32, 0.5);
  animation: badgePop 0.45s ease-out;
}
@keyframes badgePop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------------- 状态文案 ---------------- */

.status {
  margin: 0;
  min-height: 1.4em;
  font-size: clamp(12px, 1.6vh, 14px);
  letter-spacing: 0.06em;
  color: var(--text-dim);
  text-shadow: 0 0 20px rgba(10, 20, 40, 0.8);
}
.status.is-success { color: #8ef0c0; }
.status.is-paused { color: var(--warn); }

/* ---------------- 按钮 ---------------- */

#controls { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.btn {
  pointer-events: auto;
  appearance: none;
  min-width: 116px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: clamp(13px, 1.7vh, 15px);
  letter-spacing: 0.1em;
  color: var(--text);
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05));
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:disabled { opacity: 0.34; cursor: not-allowed; filter: grayscale(0.35); }

.btn-primary {
  color: #f4f9ff;
  border-color: rgba(120, 180, 255, 0.5);
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.95), rgba(38, 92, 200, 0.92));
  box-shadow: 0 10px 30px rgba(46, 110, 235, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.26);
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(96, 160, 255, 1), rgba(50, 108, 220, 0.95));
  border-color: rgba(160, 205, 255, 0.7);
  box-shadow: 0 14px 36px rgba(56, 125, 250, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn-primary:disabled {
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.5), rgba(38, 92, 200, 0.45));
  color: rgba(240, 246, 255, 0.75);
}

.btn-danger {
  color: #fff2f3;
  border-color: rgba(255, 120, 135, 0.5);
  background: linear-gradient(180deg, rgba(255, 92, 108, 0.92), rgba(190, 44, 62, 0.9));
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255, 116, 130, 1), rgba(206, 52, 70, 0.95));
}

.btn:focus-visible,
.help-toggle:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ---------------- 折叠说明 ---------------- */

#help {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.help-toggle {
  pointer-events: auto;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 15px;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--text-mute);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.help-toggle:hover { color: var(--text-dim); border-color: var(--line); background: rgba(255, 255, 255, 0.03); }

.chevron {
  width: 0;
  height: 0;
  border-left: 4.5px solid transparent;
  border-right: 4.5px solid transparent;
  border-top: 5.5px solid currentColor;
  transition: transform 0.28s ease;
}
#help.is-open .chevron { transform: rotate(180deg); }

.help-body {
  pointer-events: auto;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  width: 100%;
  transform: translateY(4px);
  transition: max-height 0.34s ease, opacity 0.26s ease, transform 0.3s ease, margin 0.3s ease;
}
#help.is-open .help-body {
  max-height: 320px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 8px;
}

.help-body ul {
  margin: 0;
  padding: 14px 20px 14px 34px;
  list-style: none;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-size: 12.5px;
  line-height: 1.95;
  color: var(--text-dim);
  user-select: text;
}
.help-body li { position: relative; }
.help-body li::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 0.82em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px rgba(53, 214, 230, 0.8);
}
.help-body b { color: #dbe7fb; font-weight: 600; }

/* ---------------- 弹窗 ---------------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 6, 12, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: maskIn 0.2s ease-out;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  width: 100%;
  max-width: 380px;
  padding: 22px 24px 18px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(24, 33, 50, 0.96), rgba(13, 18, 29, 0.96));
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  animation: dialogIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.dialog h2 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.dialog p {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; }
.dialog-actions .btn { min-width: 96px; padding: 9px 16px; }

/* ---------------- 轻提示 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  top: clamp(18px, 12vh, 120px);
  transform: translateX(-50%);
  z-index: 70;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 190, 80, 0.45);
  background: linear-gradient(180deg, rgba(58, 44, 16, 0.94), rgba(34, 26, 10, 0.94));
  color: #ffdf9e;
  font-size: 13.5px;
  letter-spacing: 0.08em;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 176, 32, 0.22);
  animation: toastIn 0.3s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------------- 右上角按钮组（阶数 / 皮肤） ---------------- */

#top-right {
  position: absolute;
  top: clamp(12px, 2.2vh, 26px);
  right: clamp(12px, 1.4vw, 24px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: none;
}

.order-btn {
  pointer-events: auto;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 9px 15px;
  font-family: var(--mono);
  font-size: clamp(13px, 1.7vh, 15px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.order-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  border-color: var(--line-strong);
  transform: translateY(-1px);
}
.order-btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.order-btn:disabled { opacity: 0.34; cursor: not-allowed; filter: grayscale(0.35); }
.order-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.order-btn-caret {
  width: 0;
  height: 0;
  border-left: 4.5px solid transparent;
  border-right: 4.5px solid transparent;
  border-top: 5.5px solid currentColor;
  opacity: 0.7;
}

.skin-btn { font-family: var(--sans); letter-spacing: 0.06em; }
.skin-btn-icon { width: 17px; height: 17px; fill: currentColor; opacity: 0.85; flex: 0 0 auto; }
.skin-btn.is-fallback { color: var(--text-dim); }
.skin-btn.is-fallback .order-btn-value { font-size: 0.92em; }

/* ---------------- 皮肤选择：横向缩略图刻度轮 ---------------- */

.dialog-skin { max-width: 420px; }

.skin-reel {
  position: relative;
  height: 196px;
  margin: 6px 0 10px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 10, 18, 0.72), rgba(10, 16, 26, 0.5));
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 14%, #000 86%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 14%, #000 86%, transparent 100%);
}
.skin-reel.is-dragging { cursor: grabbing; }
.skin-reel:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.skin-track {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  will-change: transform;
}

.skin-card {
  flex: 0 0 auto;
  width: 104px;
  padding: 8px 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.skin-card.is-active {
  border-color: rgba(120, 180, 255, 0.55);
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.16), rgba(76, 141, 255, 0.04));
  box-shadow: 0 0 26px rgba(76, 141, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.skin-card.is-locked { filter: grayscale(0.7); }
.skin-thumb {
  width: 92px;
  height: 92px;
  display: block;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}
.skin-name {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.skin-card.is-active .skin-name { color: #fff; }
.skin-tag {
  display: none;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--warn);
  border: 1px solid rgba(255, 176, 32, 0.45);
  background: rgba(255, 176, 32, 0.1);
}
.skin-card.is-locked .skin-tag { display: inline-block; }

/* ---------------- 小屏兜底（移动端适配本期不做，仅避免明显错位） ---------------- */

.dialog-order { max-width: 340px; }

.drum {
  position: relative;
  height: 224px; /* 4 档均可见（4 × 56） */
  margin: 6px 0 10px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 10, 18, 0.72), rgba(10, 16, 26, 0.5));
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
}
.drum.is-dragging { cursor: grabbing; }
.drum:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.drum-track { will-change: transform; }

.drum-row {
  height: 56px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  transition: color 0.18s ease;
}
.drum-row .drum-main {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  letter-spacing: 0.06em;
}
.drum-row .drum-sub {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-mute);
}
.drum-row.is-active { color: #ffffff; }
.drum-row.is-active .drum-main { font-size: 25px; text-shadow: 0 0 20px rgba(110, 170, 255, 0.45); }
.drum-row.is-active .drum-sub { color: var(--accent-2); }

.drum-band {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 56px;
  transform: translateY(-50%);
  border-radius: 12px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(76, 141, 255, 0.18), rgba(76, 141, 255, 0.05));
  box-shadow: inset 0 0 24px rgba(76, 141, 255, 0.2);
  pointer-events: none;
}

.order-hint {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-mute);
  text-align: center;
}

/* ---------------- 右侧中部：翻转按钮 ---------------- */

.flip-btn {
  pointer-events: auto;
  position: absolute;
  right: clamp(12px, 1.4vw, 24px);
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  cursor: pointer;
  animation: flipIn 0.26s ease-out;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}
.flip-btn svg { width: 26px; height: 26px; fill: currentColor; }
.flip-btn:hover:not(:disabled) {
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  border-color: var(--line-strong);
  transform: translateY(calc(-50% - 1px));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42), 0 0 22px rgba(76, 141, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.flip-btn:active:not(:disabled) { transform: translateY(calc(-50% + 1px)) scale(0.97); }
.flip-btn:disabled { opacity: 0.34; cursor: not-allowed; filter: grayscale(0.35); }
.flip-btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

@keyframes flipIn {
  from { opacity: 0; transform: translateY(-50%) scale(0.9); }
  to { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* ---------------- 小屏兜底（移动端适配本期不做，仅避免明显错位） ---------------- */

@media (max-width: 560px) {
  .btn { min-width: 92px; padding: 10px 14px; letter-spacing: 0.06em; }
  #hud { gap: 10px; padding: 8px 14px; }
  .hud-value { min-width: 4.8em; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
