:root {
  --bg: #0a0e1a;
  --panel-bg: rgba(18, 25, 44, 0.92);
  --panel-border: #283352;
  --text: #e3e9f7;
  --muted: #8b96b3;
  --gold: #e8c15a;
  --cyan: #6fc3df;
  --purple: #b58cff;
  --green: #6fd98a;
  --red: #ff6f6f;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1px 1px at 24px 32px, rgba(255,255,255,.5), transparent 100%),
    radial-gradient(1.5px 1.5px at 130px 90px, rgba(255,255,255,.35), transparent 100%),
    radial-gradient(1px 1px at 300px 150px, rgba(255,255,255,.45), transparent 100%),
    radial-gradient(1px 1px at 60px 260px, rgba(255,255,255,.3), transparent 100%),
    radial-gradient(1.5px 1.5px at 380px 320px, rgba(255,255,255,.3), transparent 100%),
    radial-gradient(ellipse at 50% -20%, rgba(111,195,223,.14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header { text-align: center; padding: 32px 16px 16px; }
.eyebrow { margin: 0 0 6px; letter-spacing: .18em; font-size: 13px; color: var(--gold); }
.site-header h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 36px); letter-spacing: .04em; }
.subtitle { margin: 0 auto; max-width: 620px; color: var(--muted); font-size: 15px; }

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: start;
}

.left-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.panel h2 { margin: 0; font-size: 19px; }
.panel h3 { margin: 16px 0 8px; font-size: 15px; color: var(--gold); }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.hint { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* ---------- 罗盘主屏 ---------- */
.play-panel { padding: 22px 20px 18px; }
.compass-stage { position: relative; }
.compass-stage #compass { display: block; width: 100%; max-width: 620px; margin: 0 auto; height: auto; }
.compass-stage.success #compass { filter: drop-shadow(0 0 10px rgba(111,217,138,.35)); }

.ring { fill: none; stroke-width: 2.4; opacity: .9; }
.ring-inner { stroke: var(--cyan); }
.ring-middle { stroke: var(--gold); }
.ring-outer { stroke: var(--purple); }
.tick-line { stroke: rgba(255,255,255,.3); stroke-width: 1.5; }
.target-marker { fill: #e8c15a; opacity: .9; filter: url(#glow); }
.pointer-arrow { filter: url(#glow); }
.pointer {
  transform-box: view-box;
  transform-origin: 200px 200px;
}

.play-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.op-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 108px;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(111,195,223,.12);
  border: 1px solid rgba(111,195,223,.45);
  color: var(--cyan);
}
.op-btn .op-name { font-size: 15px; font-weight: 700; }
.op-btn[data-op="1"] { background: rgba(232,193,90,.12); color: var(--gold); border-color: rgba(232,193,90,.45); }
.op-btn[data-op="2"] { background: rgba(181,140,255,.12); color: var(--purple); border-color: rgba(181,140,255,.45); }

.play-status { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 12px; }
.status { margin: 0; text-align: center; color: var(--muted); font-size: 14px; min-height: 1.4em; }
.reveal-btn { min-width: 180px; padding: 10px 30px; font-size: 15px; }
.win-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(111,217,138,.08);
  border: 1px solid rgba(111,217,138,.35);
  color: var(--green);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  animation: win-fade .4s ease;
}
.win-banner[hidden] { display: none; }
.win-icon { font-size: 15px; }
@keyframes win-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.random-bar {
  margin-top: 16px;
  border-top: 1px dashed #2a3552;
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.random-label { font-size: 14px; color: var(--muted); }
.difficulty-row { display: flex; gap: 12px; flex-wrap: wrap; }
.difficulty-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; cursor: pointer; }
.difficulty-row input { accent-color: var(--gold); }
.random-bar .note { width: 100%; text-align: center; }

/* ---------- 出题设置 ---------- */
.setup-panel h2 { line-height: 1.6; }
.rings-grid { display: grid; gap: 10px; }
.ring-row { display: grid; grid-template-columns: 56px 1fr 1fr; align-items: center; gap: 8px; }
.ring-row label { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); }
.ring-name { font-weight: 700; font-size: 14px; }
.ring-name.inner { color: var(--cyan); }
.ring-name.middle { color: var(--gold); }
.ring-name.outer { color: var(--purple); }

.ops-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ops-table th, .ops-table td { padding: 6px 4px; text-align: center; }
.ops-table thead th { color: var(--muted); font-weight: 500; border-bottom: 1px solid #2a3552; }
.ops-table .op-name { font-weight: 700; }

/* ---------- 步进组件 ---------- */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #33405f;
  border-radius: 8px;
  overflow: hidden;
  background: #0e1424;
  vertical-align: middle;
}
.stepper button {
  border: none;
  background: #1a2238;
  color: var(--text);
  width: 28px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  border-radius: 0;
}
.stepper button:hover:not(:disabled) { background: #263252; color: var(--gold); }
.stepper input {
  border: none;
  background: transparent;
  color: var(--text);
  width: 52px;
  text-align: center;
  padding: 6px 2px;
  border-radius: 0;
  font-size: 14px;
}
.stepper input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--cyan); }

/* ---------- 按钮 ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 9px 16px;
  font-size: 14px;
  transition: filter .15s, transform .05s, opacity .15s, color .15s, background .15s;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button:not(:disabled):active { transform: translateY(1px); }

.primary {
  background: linear-gradient(135deg, #f0cf6d, #d9a83f);
  color: #221a05;
  font-weight: 700;
  border: none;
  box-shadow: 0 4px 16px rgba(232,193,90,.28);
}
.primary:not(:disabled):hover { filter: brightness(1.08); }

.ghost { background: transparent; color: var(--muted); border-color: #33405f; }
.ghost:not(:disabled):hover { color: var(--text); border-color: var(--cyan); }

#btn-solve { width: 100%; margin-top: 16px; font-size: 16px; padding: 12px; }

/* ---------- 右侧解法面板 ---------- */
.solution-panel { position: sticky; top: 16px; }
.solution-placeholder {
  border: 1px dashed rgba(232,193,90,.4);
  background: rgba(232,193,90,.05);
  color: var(--gold);
  border-radius: 10px;
  padding: 16px 14px;
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
}
.solution-content {
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  margin-top: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,150,179,.35) transparent;
}
.solution-content::-webkit-scrollbar { width: 6px; }
.solution-content::-webkit-scrollbar-track { background: transparent; }
.solution-content::-webkit-scrollbar-thumb {
  background: rgba(139,150,179,.35);
  border-radius: 999px;
}
.solution-content::-webkit-scrollbar-thumb:hover { background: rgba(139,150,179,.6); }

/* ---------- 解法内容 ---------- */
.math-block { margin: 8px 0 12px; }
.math-inline { white-space: normal; }
.math-block .katex, .math-inline .katex { white-space: normal; }
.branch-list { list-style: none; margin: 6px 0 10px; padding: 0; display: grid; gap: 5px; }
.branch-list li { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.branch-list .math-inline { display: block; margin-left: 14px; }
.branch-no { color: var(--muted); font-size: 13px; white-space: nowrap; }
.minimal-box {
  border: 1px solid rgba(111,217,138,.45);
  background: rgba(111,217,138,.07);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 8px 0 12px;
}
.minimal-box h3 { color: var(--green); margin-top: 2px; }
.no-solution {
  border: 1px solid rgba(255,111,111,.5);
  background: rgba(255,111,111,.08);
  color: #ffc2c2;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0;
}
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-top: 6px; }
.diff-easy { background: rgba(111,217,138,.16); color: var(--green); border: 1px solid rgba(111,217,138,.45); }
.diff-normal { background: rgba(111,195,223,.16); color: var(--cyan); border: 1px solid rgba(111,195,223,.45); }
.diff-hard { background: rgba(232,193,90,.16); color: var(--gold); border: 1px solid rgba(232,193,90,.45); }
.diff-insane { background: rgba(255,111,111,.16); color: #ff9b9b; border: 1px solid rgba(255,111,111,.5); }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 30px; }

@media (max-width: 960px) {
  main { grid-template-columns: 1fr; }
  .solution-panel { position: static; }
  .solution-content { max-height: none; }
}

@media (max-width: 620px) {
  main { padding: 0 10px 30px; }
  .panel { padding: 14px 12px; }
  .ring-row { grid-template-columns: 48px 1fr 1fr; }
  .op-btn { min-width: 92px; padding: 10px 10px; }
}
