:root {
  color-scheme: light;
  --ink: #20201d;
  --paper: #f4eddf;
  --card: #fffaf0;
  --red: #c84b3c;
  --muted: #756f65;
  --line: #cbc0ad;
  --p1: #c84b3c;
  --p2: #3b7cb8;
  --p3: #6d9b3a;
  --p4: #b07c3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #fff9e9 0 12%, transparent 32%),
    linear-gradient(135deg, var(--paper), #e6d8c2);
  font-family: ui-serif, "Songti SC", "Noto Serif SC", Georgia, serif;
}

button, input, textarea, select { font: inherit; }
button, select, input { min-height: 44px; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }

#app { width: min(720px, 100%); margin: auto; padding: 24px; }
.shell { min-height: calc(100vh - 48px); display: grid; align-content: center; gap: 24px; }
.eyebrow { margin: 0; color: var(--red); font: 700 .78rem/1.2 ui-sans-serif, system-ui; letter-spacing: .18em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2.7rem, 11vw, 5.8rem); line-height: .9; letter-spacing: -.06em; }
h2 { font-size: clamp(1.7rem, 6vw, 2.8rem); line-height: 1.1; }
h3 { font-size: 1.1rem; color: var(--muted); }
.subtitle, .hint { color: var(--muted); }
.panel { padding: clamp(20px, 5vw, 40px); border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 92%, transparent); box-shadow: 0 22px 55px #604d3422; }
.fields { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 11px 13px; color: var(--ink); background: #fffdf8; }
textarea { min-height: 88px; resize: vertical; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.primary, .secondary, .icon-button { border: 1px solid var(--ink); padding: 10px 18px; }
.primary { color: white; background: var(--ink); }
.secondary, .icon-button { color: var(--ink); background: transparent; }
.primary:hover { background: var(--red); border-color: var(--red); }
.secondary:hover:not(:disabled) { background: var(--ink); color: white; }
.small { padding: 6px 12px; min-height: 32px; font-size: .85rem; }

/* ── 自己的数字（顶部常驻） ── */
.own-numbers {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.my-numbers-display {
  font: 700 .9rem ui-sans-serif, system-ui;
  color: var(--ink);
}
.my-numbers-display strong {
  font-size: 1.2rem;
  color: var(--red);
}

/* ── 题目区块 ── */
.question { padding-block: 30px; border-block: 1px solid var(--line); text-align: center; }
.category { margin-bottom: 10px; color: var(--red); font: 700 .78rem ui-sans-serif, system-ui; letter-spacing: .08em; }
.scale { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; color: var(--muted); font: 700 .82rem/1.4 ui-sans-serif, system-ui; text-align: left; }
.scale span:last-child { text-align: right; }

/* ── 数字卡 ── */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.number-card { display: grid; min-height: 190px; place-content: center; border: 1px solid var(--ink); background: var(--card); text-align: center; }
.number-card strong { font-size: clamp(3.5rem, 15vw, 6rem); line-height: 1; }
.number-card span { color: var(--muted); font: .8rem ui-sans-serif, system-ui; letter-spacing: .1em; }

/* ── 玩家翻页导航 ── */
.turn-nav { display: flex; gap: 6px; margin: 20px 0 16px; }
.turn-tab {
  flex: 1;
  padding: 10px 8px;
  border: 2px solid var(--line);
  background: transparent;
  font-weight: 700;
  font-size: .9rem;
  text-align: center;
  transition: all .15s;
}
.turn-tab.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.turn-tab:hover:not(.active) {
  background: var(--card);
}

/* ── 翻页内容 ── */
.turn-content { margin-bottom: 16px; }
.turn-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}
.turn-indicator {
  font: 700 .85rem ui-sans-serif, system-ui;
  color: var(--muted);
  min-width: 48px;
  text-align: center;
}

/* ── 坑位邀请行 ── */
.invite-list { display: grid; gap: 10px; }
.invite-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--card);
}
.invite-badge {
  font: 700 .85rem ui-sans-serif, system-ui;
  white-space: nowrap;
  min-width: 60px;
}
.invite-name { flex: 1; min-width: 0; }
.invite-row .small { white-space: nowrap; flex-shrink: 0; }

/* ── 题库选择器 ── */
.category-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  user-select: none;
  font-weight: 400;
  font-size: .9rem;
  transition: all .15s;
}
.category-chip.active { border-color: var(--ink); background: var(--ink); color: white; }
.category-chip input[type="checkbox"] { display: none; }

/* ── 排序列表 ── */
.story-list { display: grid; gap: 10px; }

.story {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  touch-action: none;
}
.story.dragging { opacity: .45; }
.grip { color: var(--muted); font-size: 1.2rem; }

.story-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.3;
}
.story-label strong { font-size: 1rem; }
.card-memo {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.3;
}

/* ── 排序对照轴 ── */
.sort-axis { margin-bottom: 16px; padding: 8px 0; }
.axis-line {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
  padding-left: 16px;
  border-left: 2px dashed var(--line);
  gap: 8px;
}
.axis-marker { display: flex; align-items: baseline; gap: 10px; }
.axis-value { font-size: 1.4rem; font-weight: 700; color: var(--ink); min-width: 36px; }
.axis-label { font-size: .8rem; color: var(--muted); font-family: ui-sans-serif, system-ui; }

/* ── 移动按钮 ── */
.move { display: flex; gap: 4px; }
.icon-button { min-width: 38px; min-height: 38px; padding: 4px; }
.icon-button:hover { background: var(--ink); color: white; }

/* ── 揭晓结果 ── */
.result { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.result strong { font-size: 1.5rem; }
.correct { color: #44734a; }
.wrong { color: var(--red); }
.score { font-size: clamp(3rem, 15vw, 6rem); line-height: 1; }
.toast { min-height: 1.4em; margin: 12px 0 0; color: var(--red); }

@media (max-width: 500px) {
  #app { padding: 14px; }
  .shell { min-height: calc(100vh - 28px); }
  .panel { padding: 20px; }
  .cards { gap: 8px; }
  .number-card { min-height: 150px; }
  .category-picker { gap: 5px; }
  .category-chip { padding: 6px 10px; font-size: .8rem; }
  .invite-row { flex-wrap: wrap; }
  .turn-tab { font-size: .8rem; padding: 8px 4px; }
}

@media (prefers-reduced-motion: no-preference) {
  .panel { animation: arrive .35s ease-out; }
  @keyframes arrive { from { opacity: 0; transform: translateY(8px); } }
}
