/* ===== Cubesolver Web Styles ===== */
* { margin:0; padding:0; box-sizing:border-box; }
:root {
  --primary: #667eea; --primary-dark: #5a6fd6;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --bg-gradient: linear-gradient(180deg, #f8f9ff 0%, #eef1ff 100%);
  --text-dark: #1a1a2e; --text-light: #666; --text-muted: #999;
  --danger: #ff4d4f; --success: #52c41a;
  --warning-bg: #fff8e1; --warning-text: #856404; --warning-text-dark: #6d5a00;
  --white: #fff; --radius: 12px; --shadow: 0 4px 20px rgba(0,0,0,0.06);
}
html,body { height:100%; font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; font-size:16px; color:#333; background:var(--bg-gradient); -webkit-font-smoothing:antialiased; }
body { min-height:100vh; }
button { font-family:inherit; cursor:pointer; border:none; outline:none; }
.page { min-height:100vh; padding:20px 16px; max-width:480px; margin:0 auto; }
.nav-bar { display:flex; align-items:center; padding:12px 0; margin-bottom:8px; }
.nav-back { font-size:24px; color:var(--text-dark); background:none; padding:4px 8px; margin-right:8px; font-weight:600; }
.nav-title { font-size:18px; font-weight:700; color:var(--text-dark); flex:1; }
.btn-primary { display:block; width:100%; background:var(--primary-gradient); color:white; padding:14px 24px; border-radius:var(--radius); font-size:16px; font-weight:600; text-align:center; box-shadow:0 6px 16px rgba(102,126,234,0.3); transition:transform 0.1s; }
.btn-primary:active { transform:scale(0.97); }
.btn-primary.disabled { background:#ccc; box-shadow:none; color:#999; cursor:not-allowed; }
.btn-primary.disabled:active { transform:none; }
.btn-secondary { display:block; width:100%; background:white; color:var(--primary); border:2px solid var(--primary); padding:12px 24px; border-radius:var(--radius); font-size:16px; font-weight:600; text-align:center; transition:transform 0.1s; }
.btn-secondary:active { transform:scale(0.97); }
.btn-secondary.disabled { opacity:0.4; cursor:not-allowed; }
.btn-small { padding:10px 20px; border-radius:10px; font-size:14px; font-weight:500; text-align:center; background:var(--primary); color:white; }
.btn-small.danger { background:var(--danger); color:white; }
.progress-bar { display:flex; justify-content:center; gap:8px; margin-bottom:20px; }
.progress-dot { width:12px; height:12px; border-radius:50%; background:#ddd; transition:all 0.3s; }
.progress-dot.active { background:var(--primary); transform:scale(1.3); }
.progress-dot.done { background:var(--success); }
.face-title { font-size:22px; font-weight:700; color:var(--text-dark); text-align:center; margin-bottom:4px; }
.hint-text { font-size:14px; color:var(--text-light); text-align:center; }
.step-indicator { font-size:13px; color:var(--text-muted); text-align:center; margin:8px 0 20px; }
.grid-section { margin-bottom:24px; }
.grid-label { font-size:14px; color:var(--text-light); margin-bottom:12px; text-align:center; }
.cube-grid { width:210px; margin:0 auto; background:#333; padding:4px; border-radius:10px; }
.grid-row { display:flex; }
.grid-cell { width:70px; height:70px; border:1.5px solid #444; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:transform 0.1s; position:relative; }
.grid-cell:hover { filter:brightness(1.1); }
.grid-cell.selected { border:3px solid var(--primary); transform:scale(1.05); box-shadow:0 0 12px rgba(102,126,234,0.5); z-index:1; }
.grid-cell.center-cell { cursor:default; opacity:0.85; }
.center-marker { font-size:14px; color:white; background:rgba(0,0,0,0.3); padding:2px 6px; border-radius:6px; }
.color-picker { background:white; border-radius:var(--radius); padding:16px; margin-bottom:24px; box-shadow:var(--shadow); }
.picker-label { font-size:14px; color:var(--text-light); margin-bottom:12px; text-align:center; }
.picker-swatches { display:flex; flex-wrap:wrap; gap:10px; justify-content:center; }
.color-swatch { width:56px; height:56px; border-radius:10px; display:flex; align-items:center; justify-content:center; border:2px solid #eee; cursor:pointer; transition:transform 0.1s; position:relative; }
.color-swatch:active { transform:scale(0.9); }
.swatch-name { font-size:11px; color:#333; background:rgba(255,255,255,0.85); padding:1px 4px; border-radius:3px; position:absolute; bottom:2px; }
.action-buttons { display:flex; flex-direction:column; gap:12px; margin-top:16px; }
.action-row { display:flex; gap:12px; justify-content:center; }
.action-row > * { flex:1; }
.rotate-section { margin-top:20px; background:white; border-radius:var(--radius); padding:16px; box-shadow:var(--shadow); }
.rotate-label { font-size:14px; color:var(--text-light); text-align:center; margin-bottom:14px; }
.rotate-grid { display:grid; grid-template-columns:repeat(3,1fr); grid-template-areas:". up ." "left right down"; gap:10px; max-width:300px; margin:0 auto; }
.rotate-grid .btn-rot:nth-child(1) { grid-area:up; }
.rotate-grid .btn-rot:nth-child(2) { grid-area:left; }
.rotate-grid .btn-rot:nth-child(3) { grid-area:right; }
.rotate-grid .btn-rot:nth-child(4) { grid-area:down; }
.btn-rot { background:var(--primary); color:white; border-radius:10px; padding:14px 0; font-size:15px; font-weight:600; text-align:center; box-shadow:0 4px 12px rgba(102,126,234,0.25); }
.btn-rot:active { transform:scale(0.96); }
.logo-section { text-align:center; padding:40px 0 36px; }
.cube-icon-img { width:80px; height:80px; margin-bottom:16px; border-radius:10px; }
.app-title { font-size:28px; font-weight:800; color:var(--text-dark); margin-bottom:8px; }
.app-subtitle { font-size:15px; color:var(--text-muted); }
.mode-section { margin-bottom:24px; }
.mode-card { background:white; border-radius:14px; padding:20px; margin-bottom:14px; display:flex; align-items:center; box-shadow:var(--shadow); cursor:pointer; transition:transform 0.15s; }
.mode-card:active { transform:scale(0.98); }
.mode-icon { font-size:32px; width:52px; height:52px; display:flex; align-items:center; justify-content:center; background:#f0f3ff; border-radius:12px; margin-right:16px; flex-shrink:0; }
.mode-info { flex:1; }
.mode-title { font-size:17px; font-weight:600; color:var(--text-dark); margin-bottom:4px; }
.mode-desc { font-size:13px; color:var(--text-muted); }
.mode-arrow { font-size:22px; color:#ccc; margin-left:12px; }
.tip-section { background:var(--warning-bg); border-radius:var(--radius); padding:16px; margin-top:12px; }
.tip-title { font-size:14px; font-weight:600; color:var(--warning-text); margin-bottom:10px; }
.tip-item { font-size:13px; color:var(--warning-text-dark); line-height:1.7; }
.camera-area { position:relative; width:100%; max-height:320px; border-radius:var(--radius); overflow:hidden; margin-bottom:20px; background:#000; }
.camera-area video { width:100%; height:auto; display:block; }
.overlay-grid { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:78%; aspect-ratio:1/1; display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); pointer-events:none; }
.overlay-grid .ov-cell { border:2px solid rgba(255,255,255,0.85); }
.overlay-grid .ov-center { border:3px solid #ffeb3b; }
.camera-placeholder { width:100%; height:240px; display:flex; flex-direction:column; align-items:center; justify-content:center; background:#f5f5f5; border-radius:var(--radius); margin-bottom:20px; color:var(--text-muted); font-size:14px; }
.camera-icon-big { font-size:48px; margin-bottom:12px; }
.photo-preview { width:100%; max-height:200px; object-fit:contain; border-radius:10px; margin-bottom:16px; }
.solving-section { display:flex; flex-direction:column; align-items:center; padding:80px 0; }
.solving-icon { font-size:48px; animation:spin 1.5s linear infinite; margin-bottom:16px; }
@keyframes spin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } }
.solving-text { font-size:18px; font-weight:600; color:var(--text-dark); margin-bottom:8px; }
.solving-sub { font-size:14px; color:var(--text-muted); }
.error-section { display:flex; flex-direction:column; align-items:center; padding:60px 0; }
.error-icon { font-size:48px; margin-bottom:16px; }
.error-text { font-size:15px; color:var(--danger); text-align:center; margin-bottom:24px; }
.solution-progress { height:8px; background:#eee; border-radius:4px; margin-bottom:20px; overflow:hidden; }
.progress-bar-fill { height:100%; background:var(--primary-gradient); border-radius:4px; transition:width 0.3s ease; }
.step-text { font-size:18px; font-weight:700; color:var(--text-dark); text-align:center; margin-bottom:8px; }
.move-highlight { background:var(--warning-bg); color:var(--warning-text); padding:10px 16px; border-radius:var(--radius); font-size:14px; font-weight:600; text-align:center; margin-bottom:20px; }
.cube-all-faces { display:flex; flex-wrap:wrap; gap:12px; justify-content:center; margin-bottom:20px; }
.face-view { display:flex; flex-direction:column; align-items:center; }
.face-label { font-size:12px; color:var(--text-light); margin-bottom:4px; font-weight:500; }
.mini-grid { width:108px; height:108px; background:#333; padding:3px; border-radius:6px; }
.mini-row { display:flex; }
.mini-cell { width:34px; height:34px; border:1px solid #444; }
.mini-cell.center { border:2px solid #fff; }
.nav-buttons { margin-top:12px; }
.nav-row { display:flex; gap:12px; justify-content:center; }
.solved-section { display:flex; flex-direction:column; align-items:center; padding:30px 0; }
.solved-icon { font-size:52px; margin-bottom:12px; }
.solved-text { font-size:20px; font-weight:700; color:var(--text-dark); margin-bottom:24px; }
.toast { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(0,0,0,0.78); color:white; padding:12px 24px; border-radius:10px; font-size:14px; z-index:999; pointer-events:none; opacity:0; transition:opacity 0.3s; max-width:80%; text-align:center; }
.toast.show { opacity:1; }
.modal-overlay { position:fixed; top:0; left:0; right:0; bottom:0; background:rgba(0,0,0,0.5); display:flex; align-items:center; justify-content:center; z-index:100; opacity:0; pointer-events:none; transition:opacity 0.3s; }
.modal-overlay.show { opacity:1; pointer-events:auto; }
.modal-box { background:white; border-radius:16px; padding:28px 24px 20px; max-width:320px; width:90%; text-align:center; }
.modal-title { font-size:17px; font-weight:700; color:var(--text-dark); margin-bottom:10px; }
.modal-content { font-size:14px; color:var(--text-light); margin-bottom:20px; line-height:1.5; }
.modal-buttons { display:flex; gap:10px; }
.modal-buttons .btn-primary, .modal-buttons .btn-secondary { flex:1; font-size:14px; padding:10px 16px; }

/* ===== 3D 魔方 ===== */
.cube-scene { width:240px; height:240px; margin:10px auto 4px; perspective:700px; touch-action:none; user-select:none; }
.cube-scene.dragging { cursor:grabbing; }
.cube { position:relative; width:100%; height:100%; transform-style:preserve-3d; transform:rotateX(-25deg) rotateY(-35deg); transition:transform 0.05s linear; }
.cube-face { position:absolute; width:160px; height:160px; left:40px; top:40px; display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); background:#111; gap:3px; padding:3px; border-radius:6px; box-shadow:0 0 0 2px rgba(0,0,0,0.4); cursor:pointer; }
.cube-face .stk { border-radius:3px; background:#444; transition:background 0.15s; }
.cube-face.recorded { box-shadow:0 0 0 3px #667eea; }
.cube-face.active { box-shadow:0 0 0 4px #ffd500; }
.cube-face.f-U { transform:rotateX(90deg) translateZ(80px); }
.cube-face.f-D { transform:rotateX(-90deg) translateZ(80px); }
.cube-face.f-F { transform:translateZ(80px); }
.cube-face.f-B { transform:rotateY(180deg) translateZ(80px); }
.cube-face.f-R { transform:rotateY(90deg) translateZ(80px); }
.cube-face.f-L { transform:rotateY(-90deg) translateZ(80px); }
.cube-hint { text-align:center; font-size:13px; color:var(--text-light); margin-bottom:8px; }
.cube-progress { text-align:center; font-size:13px; color:var(--text-muted); margin:4px 0 12px; }

/* 编辑面板（点击某个面后弹出） */
.editor-panel { background:white; border-radius:var(--radius); padding:16px; margin:0 0 16px; box-shadow:var(--shadow); }
.editor-panel.hidden { display:none; }
.editor-title { font-size:15px; font-weight:700; color:var(--text-dark); text-align:center; margin-bottom:4px; }
.editor-sub { font-size:12px; color:var(--text-light); text-align:center; margin-bottom:12px; }
.editor-grid { width:210px; margin:0 auto 12px; background:#333; padding:4px; border-radius:10px; }
.editor-row { display:flex; }
.editor-cell { width:70px; height:70px; border:1.5px solid #444; display:flex; align-items:center; justify-content:center; cursor:pointer; }
.editor-cell.selected { border:3px solid var(--primary); transform:scale(1.05); z-index:1; }
.editor-actions { display:flex; flex-direction:column; gap:12px; }

/* 3D 解法查看器 */
.solve-scene { width:200px; height:200px; margin:8px auto; perspective:600px; touch-action:none; user-select:none; }
.solve-cube { position:relative; width:100%; height:100%; transform-style:preserve-3d; transform:rotateX(-25deg) rotateY(-35deg); }
.solve-face { position:absolute; width:130px; height:130px; left:35px; top:35px; display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); background:#111; gap:2px; padding:2px; border-radius:5px; }
.solve-face .stk { border-radius:2px; }
.solve-face.f-U { transform:rotateX(90deg) translateZ(65px); }
.solve-face.f-D { transform:rotateX(-90deg) translateZ(65px); }
.solve-face.f-F { transform:translateZ(65px); }
.solve-face.f-B { transform:rotateY(180deg) translateZ(65px); }
.solve-face.f-R { transform:rotateY(90deg) translateZ(65px); }
.solve-face.f-L { transform:rotateY(-90deg) translateZ(65px); }

