:root {
  --bg-1: #14161c;
  --bg-2: #1d212b;
  --accent: #e8503a;
  --accent-dark: #b63a28;
  --gold: #e9c46a;
  --ink: #2b2d33;
  --paper: #f7f3e8;
  --muted: #9aa0ad;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a3140 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: #e8eaf0;
  overflow-x: hidden;
  user-select: none;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 24px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  width: 100%;
  max-width: 980px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 6px 16px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 34px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.brand-text h1 { font-size: 22px; letter-spacing: 2px; line-height: 1.1; }
.brand-en { font-size: 10px; letter-spacing: 4px; color: var(--muted); }

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #3a4150;
  background: #262b36;
  color: #e8eaf0;
  cursor: pointer;
  transition: transform .12s, background .2s, box-shadow .2s;
}
.btn:hover { background: #2f3643; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.97); }

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  border-color: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(232,80,58,.35);
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(180deg, #f05a44, var(--accent-dark)); }

.switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  background: #20242e;
  border: 1px solid #333a48;
  transition: color .2s, border-color .2s;
}
.switch:hover { color: #dfe3ec; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- 舞台与场记板 ---------- */
.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 0 30px;
  perspective: 1400px;
}

.board {
  position: relative;
  width: min(92vw, 660px);
  aspect-ratio: 8 / 6;
  transform: rotateX(6deg);
  transform-style: preserve-3d;
  cursor: pointer;
  outline: none;
  border-radius: 14px;
  box-shadow: 0 30px 60px rgba(0,0,0,.55);
}
.board:focus-visible { box-shadow: 0 0 0 3px rgba(232,80,58,.7), 0 30px 60px rgba(0,0,0,.55); }

/* 板身震动 */
.board.shaking { animation: boardShake .5s ease-out; }
@keyframes boardShake {
  0%, 100% { transform: rotateX(6deg) translateY(0); }
  15% { transform: rotateX(6deg) translateY(-6px) rotate(-.6deg); }
  35% { transform: rotateX(6deg) translateY(3px) rotate(.5deg); }
  55% { transform: rotateX(6deg) translateY(-2px); }
  75% { transform: rotateX(6deg) translateY(1px); }
}

/* 上半：记录板 */
.slate {
  position: absolute;
  inset: 0 0 34% 0;
  transform-origin: 50% 100%;
  background: var(--paper);
  border-radius: 14px 14px 6px 6px;
  overflow: hidden;
  z-index: 2;
  box-shadow: inset 0 -6px 12px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
}
.slate.clapping { animation: slateClap .55s ease-out; }
@keyframes slateClap {
  0%   { transform: rotateX(0); }
  30%  { transform: rotateX(68deg); }
  52%  { transform: rotateX(68deg); }
  100% { transform: rotateX(0); }
}

.slate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #2c2f38, #1e2128);
  color: #fff;
}
.slate-head .prod {
  font-size: clamp(16px, 3vw, 24px);
  font-weight: 700;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slate-logo { font-size: 22px; opacity: .9; }

.slate-fields {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px 8px;
  padding: 12px 16px;
  color: var(--ink);
  align-content: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.field .label {
  font-size: 10px;
  letter-spacing: 2px;
  color: #a09b8b;
  border-bottom: 1px dashed #d8d2bf;
  padding-bottom: 2px;
  text-align: center;
}
.field .value {
  font-family: "Ma Shan Zheng", "KaiTi", cursive;
  font-size: clamp(20px, 3.4vw, 30px);
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field .value.mono { font-family: "Consolas", monospace; font-size: clamp(14px, 2.2vw, 20px); padding-top: 4px; }
.field.wide { grid-column: span 5; }
.field.wide .value { text-align: left; }

/* 下半：打板条 */
.sticks {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34%;
  border-radius: 6px 6px 14px 14px;
  overflow: hidden;
  z-index: 1;
  transform-style: preserve-3d;
}

.stick-top {
  position: absolute;
  inset: 0 0 50% 0;
  transform-origin: 50% 0%;
  background: repeating-linear-gradient(135deg, #14161c 0 16px, #f2efe4 16px 32px);
  border-bottom: 3px solid #000;
  box-shadow: 0 -4px 8px rgba(0,0,0,.4) inset;
}
.stick-top.clapping { animation: stickClap .55s ease-out; }
@keyframes stickClap {
  0%   { transform: rotateX(0); }
  30%  { transform: rotateX(-75deg); }
  52%  { transform: rotateX(-75deg); }
  100% { transform: rotateX(0); }
}

.stick-bottom {
  position: absolute;
  inset: 50% 0 0 0;
  background: linear-gradient(180deg, #1b1e25, #0f1116);
  box-shadow: inset 0 4px 8px rgba(0,0,0,.5);
}

/* 打板闪光 */
.clap-flash {
  position: absolute;
  left: 50%;
  bottom: 33.5%;
  transform: translate(-50%, 50%);
  font-size: 26px;
  color: var(--gold);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  text-shadow: 0 0 12px rgba(233,196,106,.9);
}
.clap-flash.flash { animation: flashPop .5s ease-out; }
@keyframes flashPop {
  0%   { opacity: 0; transform: translate(-50%, 50%) scale(.3); }
  25%  { opacity: 1; transform: translate(-50%, 50%) scale(1.35); }
  100% { opacity: 0; transform: translate(-50%, 50%) scale(.9); }
}

/* 板下阴影 */
.board-shadow {
  width: min(88vw, 620px);
  height: 34px;
  margin-top: -18px;
  background: radial-gradient(50% 100% at 50% 50%, rgba(0,0,0,.5), transparent 70%);
  filter: blur(6px);
}

/* ---------- 底部提示 ---------- */
.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding-top: 6px;
}
kbd {
  font-family: inherit;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 5px;
  background: #262b36;
  border: 1px solid #3a4150;
  border-bottom-width: 2px;
  color: #dfe3ec;
}

/* ---------- 编辑弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: fadeIn .18s ease-out;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(94vw, 560px);
  background: #1f242e;
  border: 1px solid #343c4b;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: popIn .22s ease-out;
}
@keyframes popIn {
  from { transform: translateY(14px) scale(.97); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal h2 { font-size: 18px; margin-bottom: 16px; letter-spacing: 1px; }

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: span 2; }
.form-item span { font-size: 12px; color: var(--muted); }
.form-item input,
.form-item select,
.form-item textarea {
  font-family: inherit;
  font-size: 14px;
  color: #eef0f5;
  background: #161a22;
  border: 1px solid #343c4b;
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color .2s;
}
.form-item input:focus,
.form-item select:focus,
.form-item textarea:focus { border-color: var(--accent); }
.form-item textarea { resize: vertical; }

.tip { font-size: 12px; color: var(--muted); margin: 14px 0 0; line-height: 1.6; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { justify-content: center; }
  .slate-fields { grid-template-columns: repeat(3, 1fr); padding: 10px; }
  .field.wide { grid-column: span 3; }
  .form { grid-template-columns: 1fr; }
  .form-item.full { grid-column: span 1; }
}
