:root {
  --bg: #0b1320;
  --bg-2: #0e1a2b;
  --panel: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #eaf2ff;
  --text-soft: #8aa0bd;
  --neon: #39e6a3; /* 由 JS 按单词循环覆盖 */
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -12%, #16243c, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #1a1330, transparent 55%),
    linear-gradient(160deg, #0b1320, #060b13 75%);
  min-height: 100vh;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 22px 26px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 顶栏 */
.topbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 30px; width: 52px; height: 52px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--neon), #4ec3ff);
  border-radius: 16px; box-shadow: 0 0 26px -4px var(--neon);
}
.brand-text h1 { font-size: 20px; letter-spacing: .5px; }
.brand-text p { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }

.selectors { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sel { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); }
.sel select {
  font: inherit; font-size: 14px; color: var(--text);
  padding: 8px 12px; border: 1.5px solid var(--panel-border);
  border-radius: 12px; background: var(--panel); cursor: pointer; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.sel select:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(57,230,163,.18); }
.word-count {
  font-size: 12.5px; color: var(--neon);
  background: rgba(57,230,163,.12); padding: 6px 10px; border-radius: 10px; font-weight: 600;
}

/* 主舞台 */
.stage {
  flex: 1; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(820px 520px at 50% 42%, rgba(57,230,163,.07), transparent 70%),
    linear-gradient(165deg, #0e1a2b, #090f1a);
  border-radius: var(--radius); border: 1.5px solid var(--panel-border);
  box-shadow: inset 0 0 80px -20px rgba(57,230,163,.15), 0 24px 60px -30px #000;
}
.stage::after {
  content: ""; position: absolute; inset: 0; background: var(--neon);
  opacity: 0; pointer-events: none; mix-blend-mode: screen; z-index: 1;
}
.stage.flash::after { animation: flash .5s ease-out; }
@keyframes flash { 0% { opacity: 0; } 16% { opacity: .28; } 100% { opacity: 0; } }

.progress-pill {
  position: absolute; top: 18px; left: 18px; z-index: 5;
  font-size: 13px; font-weight: 600; color: var(--text);
  background: rgba(10,18,30,.6); backdrop-filter: blur(6px);
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--panel-border);
}

/* 跟读模式：单字卡 */
.card { position: relative; z-index: 3; text-align: center; padding: 10px 30px; width: 100%; display: block; }
.word {
  font-size: clamp(56px, 16vw, 200px); font-weight: 900; line-height: 1; letter-spacing: 1px;
  color: var(--neon); text-shadow: 0 0 42px var(--neon), 0 0 14px var(--neon);
}
.phonetic {
  margin-top: 18px; font-size: clamp(16px, 2.6vw, 26px);
  color: var(--text); font-weight: 600; opacity: 0; transition: opacity .35s ease;
  text-shadow: 0 0 16px rgba(255,255,255,.25);
}
.meaning {
  margin-top: 14px; font-size: clamp(22px, 3.6vw, 40px);
  font-weight: 700; color: #fff; opacity: 0;
  transition: opacity .4s ease, transform .4s ease; transform: translateY(10px);
  text-shadow: 0 0 22px rgba(255,255,255,.3);
}
.pos-tag {
  margin-top: 14px; font-size: 13px; color: var(--text-soft);
  letter-spacing: 1px; opacity: 0; transition: opacity .4s ease;
}
.card.calm .word { animation: fade .5s ease both; }
.card.calm .phonetic, .card.calm .meaning, .card.calm .pos-tag { opacity: 1; }
.card.calm .meaning { transform: translateY(0); }
@keyframes fade { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* 喊麦模式：同一单词的多个错落副本 */
.shout-grid { display: none; position: absolute; inset: 0; z-index: 3; }
.stage.mode-shout .card { display: none; }
.stage.mode-shout .shout-grid { display: block; }
.stage.mode-read .shout-grid { display: none; }

.cell {
  position: absolute; transform: translate(-50%, -50%) scale(.82);
  padding: 14px 26px; border: 1.5px solid rgba(255,255,255,.14); border-radius: 16px;
  background: rgba(255,255,255,.04); color: var(--neon); font-weight: 900;
  font-size: clamp(22px, 3.4vw, 46px); line-height: 1.05; white-space: nowrap;
  opacity: .16; transition: opacity .35s ease, transform .35s ease, box-shadow .35s ease, border-color .35s ease;
}
.cell.long { font-size: clamp(30px, 5vw, 68px); }
.cell.lit {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  border-color: var(--neon);
  box-shadow: 0 0 30px -4px var(--neon), inset 0 0 20px -8px var(--neon);
}

/* 节奏条 */
.rhythm-bar { position: absolute; bottom: 0; left: 0; right: 0; height: 6px; background: rgba(255,255,255,.08); z-index: 5; }
.rhythm-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--neon), #fff);
  box-shadow: 0 0 14px var(--neon); transition: width .12s linear;
}

/* 控制条 */
.controls {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
  background: rgba(14,26,43,.82); border: 1.5px solid var(--panel-border); backdrop-filter: blur(10px);
  border-radius: var(--radius); padding: 16px 20px; box-shadow: 0 14px 36px -18px #000;
}
.transport { display: flex; align-items: center; gap: 12px; }
.ctrl-btn {
  font: inherit; font-size: 15px; cursor: pointer; border: 1.5px solid var(--panel-border);
  background: var(--panel); color: var(--text); padding: 10px 14px; border-radius: 14px; transition: all .18s;
}
.ctrl-btn:hover { border-color: var(--neon); transform: translateY(-1px); }
.ctrl-btn.play {
  background: linear-gradient(135deg, var(--neon), #4ec3ff); color: #04121a; border: none;
  font-weight: 800; padding: 12px 22px; min-width: 108px; text-align: center;
  box-shadow: 0 0 26px -4px var(--neon);
}
.ctrl-btn.play:hover { filter: brightness(1.08); }

.sliders { display: flex; gap: 22px; flex-wrap: wrap; }
.slider { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-soft); }
.slider b { color: var(--neon); }
.slider input[type=range] { width: 150px; accent-color: var(--neon); cursor: pointer; }

.toggles { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.toggle input { accent-color: var(--neon); width: 16px; height: 16px; }
.toggle.mode select {
  font: inherit; font-size: 13.5px; padding: 6px 10px; border: 1.5px solid var(--panel-border);
  border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer;
}

.hint { text-align: center; font-size: 12.5px; color: var(--text-soft); margin-top: -4px; }

@media (max-width: 600px) {
  .controls { flex-direction: column; align-items: stretch; }
  .sliders { justify-content: space-between; }
  .slider input[type=range] { width: 130px; }
}

/* ---------- 在线词典：生词补全面板 ---------- */
.dict-btn { /* 复用 .ctrl-btn，这里仅作占位以便未来微调 */ }

/* 喊麦模式底部字幕：音标 + 中文注释 */
.shout-caption { display: none; position: absolute; left: 0; right: 0; bottom: 22px; z-index: 4; text-align: center; padding: 0 18px; pointer-events: none; }
.stage.mode-shout .shout-caption { display: block; }
.shout-caption .cap-phon { font-size: clamp(16px, 2.4vw, 24px); color: var(--text); font-weight: 600; opacity: .9; text-shadow: 0 0 14px rgba(255,255,255,.22); }
.shout-caption .cap-mean { font-size: clamp(20px, 3.2vw, 34px); font-weight: 800; color: #fff; margin-left: 14px; text-shadow: 0 0 22px rgba(255,255,255,.3); }
.shout-caption .cap-sep { opacity: .35; margin: 0 10px; }

/* 全屏模式（类似视频）：主舞台占满屏，屏内浮出精简控制条 */
.fs-overlay {
  display: none; position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 6;
  align-items: center; gap: 14px; padding: 10px 16px; border-radius: 16px;
  background: rgba(10,18,30,.55); backdrop-filter: blur(8px); border: 1.5px solid var(--panel-border);
  box-shadow: 0 10px 30px -16px #000;
  opacity: 1; transition: opacity .35s ease;
}
.stage:fullscreen .fs-overlay { display: flex; }
.fs-overlay.fs-hidden { opacity: 0; pointer-events: none; }
.stage:fullscreen { border-radius: 0; }
.stage:fullscreen .shout-caption { bottom: 88px; }   /* 让位给浮层控制条 */
.fs-btn {
  font: inherit; font-size: 20px; cursor: pointer; width: 46px; height: 46px; border-radius: 12px;
  border: 1.5px solid var(--panel-border); background: var(--panel); color: var(--text);
  display: grid; place-items: center; transition: all .18s;
}
.fs-btn:hover { border-color: var(--neon); transform: translateY(-1px); }
.fs-btn.fs-play { background: linear-gradient(135deg, var(--neon), #4ec3ff); color: #04121a; border: none; font-weight: 800; box-shadow: 0 0 22px -4px var(--neon); }
.fs-btn.fs-exit { width: 46px; font-size: 18px; }
.dict-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(3,7,13,.55); backdrop-filter: blur(3px);
}
.dict-mask[hidden], .dict-panel[hidden] { display: none; }   /* 修复 [hidden] 被 display:flex 覆盖导致关不掉 */
.dict-panel {
  position: fixed; top: 0; right: 0; z-index: 50; height: 100vh; width: min(420px, 92vw);
  background: linear-gradient(160deg, #0e1a2b, #070d16); border-left: 1.5px solid var(--panel-border);
  box-shadow: -20px 0 60px -20px #000; padding: 22px 22px 26px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}
.dict-head { display: flex; align-items: center; justify-content: space-between; }
.dict-head h2 { font-size: 17px; font-weight: 800; letter-spacing: .5px; }
.dict-close {
  font: inherit; font-size: 16px; cursor: pointer; width: 34px; height: 34px; border-radius: 10px;
  border: 1.5px solid var(--panel-border); background: var(--panel); color: var(--text);
}
.dict-close:hover { border-color: var(--neon); }
.dict-search { display: flex; gap: 10px; }
.dict-search input {
  flex: 1; font: inherit; font-size: 14px; color: var(--text); padding: 11px 13px;
  border: 1.5px solid var(--panel-border); border-radius: 12px; background: var(--panel); outline: none;
}
.dict-search input:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(57,230,163,.16); }
.dict-result { flex: 1; min-height: 120px; }
.dict-tip { font-size: 12.5px; color: var(--text-soft); line-height: 1.6; }
.dict-card {
  background: var(--panel); border: 1.5px solid var(--panel-border); border-radius: 16px; padding: 16px 18px;
}
.dict-card .dc-word { font-size: 30px; font-weight: 900; color: var(--neon); text-shadow: 0 0 22px var(--neon); }
.dict-card .dc-phon { margin-top: 6px; color: var(--text); font-size: 15px; opacity: .9; }
.dict-card .dc-pos { color: var(--text-soft); font-size: 12px; margin-top: 4px; }
.dict-card .dc-mean { margin-top: 10px; color: #fff; font-size: 16px; line-height: 1.6; font-weight: 600; }
.dict-card .dc-src { margin-top: 10px; font-size: 11.5px; color: var(--text-soft); }
.dict-card .dc-actions { margin-top: 14px; display: flex; gap: 10px; }
.dict-card .dc-err { color: #ff8a8a; font-size: 13.5px; line-height: 1.6; }
.dict-card .dc-ok { color: var(--neon); font-size: 13px; margin-top: 8px; }
.dict-settings { border-top: 1.5px solid var(--panel-border); padding-top: 14px; }
.dict-settings summary { cursor: pointer; font-size: 13.5px; color: var(--text-soft); }
.dict-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.dict-row { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-soft); }
.dict-row select, .dict-row input {
  font: inherit; font-size: 13.5px; color: var(--text); padding: 9px 11px;
  border: 1.5px solid var(--panel-border); border-radius: 10px; background: var(--panel); outline: none;
}
.dict-row select:focus, .dict-row input:focus { border-color: var(--neon); }
.dict-note { font-size: 11.5px; color: var(--text-soft); line-height: 1.6; }

/* ---------- 用户区（顶栏右上） ---------- */
.user-area { display: flex; align-items: center; gap: 10px; }
.user-tag {
  font-size: 13px; font-weight: 700; color: #04121a;
  background: linear-gradient(135deg, var(--neon), #4ec3ff);
  padding: 7px 12px; border-radius: 999px; box-shadow: 0 0 18px -4px var(--neon);
}

/* ---------- 登录门禁（覆盖全屏，登录前挡住应用） ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 600px at 50% -10%, #16243c, transparent 60%),
    linear-gradient(160deg, #0b1320, #060b13 75%);
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(380px, 90vw); padding: 30px 28px 24px; border-radius: 22px;
  background: linear-gradient(160deg, #0e1a2b, #070d16); border: 1.5px solid var(--panel-border);
  box-shadow: 0 30px 80px -30px #000; display: flex; flex-direction: column; gap: 14px; text-align: center;
}
.auth-logo {
  font-size: 34px; width: 64px; height: 64px; margin: 0 auto;
  display: grid; place-items: center; border-radius: 18px;
  background: linear-gradient(135deg, var(--neon), #4ec3ff); box-shadow: 0 0 30px -4px var(--neon);
}
.auth-title { font-size: 21px; font-weight: 900; letter-spacing: .5px; }
.auth-sub { font-size: 13px; color: var(--text-soft); margin-top: -6px; }
.auth-row { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 12.5px; color: var(--text-soft); }
.auth-row input {
  font: inherit; font-size: 15px; color: var(--text); padding: 12px 14px;
  border: 1.5px solid var(--panel-border); border-radius: 12px; background: var(--panel); outline: none;
}
.auth-row input:focus { border-color: var(--neon); box-shadow: 0 0 0 3px rgba(57,230,163,.16); }
.auth-btn {
  margin-top: 4px; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
  border: none; border-radius: 14px; padding: 13px; color: #04121a;
  background: linear-gradient(135deg, var(--neon), #4ec3ff); box-shadow: 0 0 26px -4px var(--neon);
  transition: filter .18s, transform .18s;
}
.auth-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.auth-err { font-size: 12.5px; color: #ff8a8a; min-height: 16px; margin: 0; }
.auth-note { font-size: 11px; color: var(--text-soft); line-height: 1.6; margin: 2px 0 0; }
.auth-note b { color: var(--neon); }

/* ---------- 账号管理面板（管理员） ---------- */
.admin-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(3,7,13,.55); backdrop-filter: blur(3px);
}
.admin-mask[hidden], .admin-panel[hidden] { display: none; }
.admin-panel {
  position: fixed; top: 0; right: 0; z-index: 50; height: 100vh; width: min(440px, 92vw);
  background: linear-gradient(160deg, #0e1a2b, #070d16); border-left: 1.5px solid var(--panel-border);
  box-shadow: -20px 0 60px -20px #000; padding: 22px 22px 26px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-head h2 { font-size: 17px; font-weight: 800; letter-spacing: .5px; }
.admin-list {
  display: flex; flex-direction: column; gap: 8px; background: var(--panel);
  border: 1.5px solid var(--panel-border); border-radius: 16px; padding: 12px 14px;
}
.adm-row { display: grid; grid-template-columns: 1fr 90px 70px; align-items: center; gap: 8px; font-size: 14px; }
.adm-head { color: var(--text-soft); font-size: 12px; border-bottom: 1px solid var(--panel-border); padding-bottom: 8px; }
.adm-name { font-weight: 700; color: var(--neon); }
.adm-role { color: var(--text); font-size: 12.5px; }
.adm-actions { text-align: right; }
.adm-del {
  font: inherit; font-size: 12.5px; cursor: pointer; border: 1.5px solid var(--panel-border);
  background: rgba(255,138,138,.12); color: #ff8a8a; padding: 5px 10px; border-radius: 9px; transition: all .18s;
}
.adm-del:hover { border-color: #ff8a8a; }
.adm-disabled { color: var(--text-soft); opacity: .5; }
.admin-add { border-top: 1.5px solid var(--panel-border); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.admin-add h3 { font-size: 14px; font-weight: 800; color: var(--text); }
.admin-row { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-soft); }
.admin-row select, .admin-row input {
  font: inherit; font-size: 13.5px; color: var(--text); padding: 9px 11px;
  border: 1.5px solid var(--panel-border); border-radius: 10px; background: var(--panel); outline: none;
}
.admin-row select:focus, .admin-row input:focus { border-color: var(--neon); }
.admin-err { font-size: 12.5px; color: #ff8a8a; min-height: 16px; margin: 0; }
.admin-note { font-size: 11px; color: var(--text-soft); line-height: 1.6; margin: 0; }

/* ---------- 修改密码面板（所有登录用户） ---------- */
.pw-mask {
  position: fixed; inset: 0; z-index: 40; background: rgba(3,7,13,.55); backdrop-filter: blur(3px);
}
.pw-mask[hidden], .pw-panel[hidden] { display: none; }
.pw-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 50;
  width: min(420px, 92vw); background: linear-gradient(160deg, #0e1a2b, #070d16);
  border: 1.5px solid var(--panel-border); border-radius: 16px; padding: 22px 22px 24px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 60px -16px #000;
}
.pw-panel .ctrl-btn.play { margin-top: 4px; }
