* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1226;
  --panel: #1a1f3c;
  --accent: #5b8cff;
  --ok: #36d399;
  --err: #f87272;
  --text: #e8ecff;
  --muted: #9aa3c7;
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sound-toggle {
  background: #232a4d; color: var(--text); border: 1px solid #2a3157;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.sound-toggle.off { color: var(--muted); opacity: .7; }
.sound-test {
  background: #1f2547; color: var(--text); border: 1px solid #2a3157;
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.sound-test:active { background: #2a3157; }
.btn.small { padding: 6px 12px; font-size: 13px; margin-top: 8px; }
.nav a {
  color: var(--muted); text-decoration: none; margin-left: 16px; font-size: 15px;
}
.nav a.active { color: var(--accent); font-weight: 600; }
.app { max-width: 720px; margin: 0 auto; padding: 20px; }
@media (max-width: 560px) {
  .topbar { flex-direction: column; gap: 8px; }
  .nav a { margin: 0 8px; }
}

.card { background: var(--panel); border-radius: 14px; padding: 20px; margin-top: 16px; }
.card h2 { font-size: 20px; margin-bottom: 6px; }
.hint { color: var(--muted); margin: 8px 0 14px; font-size: 14px; }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; cursor: pointer; margin-top: 8px; display: inline-block; }
.btn.primary { background: linear-gradient(135deg, #5b8cff, #7b5bff); }
.area { margin-top: 16px; }
.grid { display: grid; gap: 8px; margin-top: 12px; }
.cell {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  background: #232a4d; color: var(--text); border: 2px solid transparent;
  border-radius: 10px; font-size: clamp(16px, 5vw, 26px); cursor: pointer;
  transition: transform .08s, background .15s; user-select: none; padding: 0;
}
.cell:active { transform: scale(.94); }
.cell.done { background: #1c3a2a; color: var(--ok); border-color: var(--ok); cursor: default; }
.cell.wrong { background: #3a1c1c; border-color: var(--err); animation: flash .3s; }
@keyframes flash { 0%,100%{opacity:1} 50%{opacity:.3} }
.status { font-size: 15px; color: var(--accent); margin-bottom: 6px; }
.toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%);
  background: var(--err); color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 14px; z-index: 50;
}
.toast.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(-50%)} 25%{transform:translateX(-58%)} 75%{transform:translateX(-42%)} }
.result { margin-top: 14px; font-size: 16px; }
.result .best { color: var(--ok); font-weight: 700; }
.fake-rank { background: #20264a; padding: 10px 14px; border-radius: 10px;
  color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.poem-head { background: #20264a; padding: 14px; border-radius: 10px; margin-bottom: 12px; }
.poem-head h3 { font-size: 15px; margin-bottom: 6px; }
.poem-text { font-size: 16px; line-height: 1.7; letter-spacing: 1px; }
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tab { background: #232a4d; color: var(--muted); border: none; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 14px; }
.tab.active { background: var(--accent); color: #fff; }
.rank-list { list-style: none; margin-top: 8px; }
.rank-list li { padding: 8px 0; border-bottom: 1px solid #2a3157; font-size: 15px; }
.type-best { color: var(--ok); margin: 8px 0; }
.empty { color: var(--muted); margin-top: 12px; }
.size-pick { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.pick-label { color: var(--muted); font-size: 14px; }
.size-btn { background: #232a4d; color: var(--muted); border: 1px solid transparent;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.size-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.mode-pick { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.mode-btn { background: #232a4d; color: var(--muted); border: 1px solid transparent;
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.poem-select { width: 100%; margin: 10px 0; padding: 8px; border-radius: 8px;
  background: #232a4d; color: var(--text); border: 1px solid #2a3157; font-size: 14px; }
.type-pick { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.type-btn { background: #232a4d; color: var(--muted); border: 1px solid transparent;
  border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px;
  display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
.type-btn small { color: #6b73a0; font-size: 11px; margin-top: 2px; }
.type-btn.active { background: linear-gradient(135deg, #5b8cff, #7b5bff); color: #fff; border-color: transparent; }
.type-btn.active small { color: #dde3ff; }
.fireworks {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 80px; pointer-events: none; z-index: 100; animation: pop 2s ease-out forwards;
}
@keyframes pop {
  0% { transform: scale(.2); opacity: 0; }
  20% { transform: scale(1.2); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}
@media (max-width: 560px) {
  .topbar { position: static; }
  .nav { display: flex; justify-content: space-around; width: 100%; }
  .nav a { margin: 0; }
  .app { padding: 12px; }
}
