/* ==========================================================================
   EasyRenpy · 试玩预览（Player）
   16:9 舞台 + 视觉小说式对白 / 选项 / 输入 / 结束层。
   舞台内部按「设计分辨率」像素排版，整体通过 transform: scale() 适配容器。
   ========================================================================== */

.player-workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.player-workspace [hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   顶部工具栏
   -------------------------------------------------------------------------- */

.player-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.player-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-toolbar-left {
  flex: 1 1 0;
  min-width: 0;
}

.player-toolbar-center {
  flex: 0 1 auto;
  justify-content: center;
}

.player-toolbar-right {
  flex: 1 1 0;
  justify-content: flex-end;
}

.player-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex: none;
}

.player-project-name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 12px;
}

.player-node-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  max-width: 440px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 12px;
  min-width: 0;
}

.player-node-chip svg {
  flex: none;
  opacity: 0.75;
}

.player-node-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-step {
  flex: none;
  color: var(--text-faint);
  font-family: var(--font-code);
  font-size: 11px;
}

.player-status-chip {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.player-status-chip.status-running {
  background: var(--warn-weak);
  color: #fcd34d;
}

.player-status-chip.status-waiting {
  background: var(--accent-weak);
  color: var(--accent-text);
}

.player-status-chip.status-ended {
  background: var(--success-weak);
  color: #86efac;
}

.player-status-chip.status-error {
  background: var(--danger-weak);
  color: #fca5a5;
}

.player-audio-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  max-width: 190px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: 11px;
  overflow: hidden;
}

.player-audio-chip svg {
  flex: none;
}

.player-audio-chip.is-muted {
  background: var(--bg-elev);
  color: var(--text-faint);
}

.player-audio-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-toggle.active {
  background: var(--accent-weak);
  border-color: transparent;
  color: var(--accent-text);
}

.player-back {
  flex: none;
}

/* --------------------------------------------------------------------------
   主体：舞台 + 侧栏
   -------------------------------------------------------------------------- */

.player-main {
  position: relative;
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.player-stage-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.12), transparent 62%),
    radial-gradient(ellipse at 50% 110%, rgba(15, 23, 42, 0.9), transparent 70%),
    var(--bg-inset);
}

html[data-theme="light"] .player-stage-area {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.12), transparent 62%),
    radial-gradient(ellipse at 50% 110%, rgba(148, 163, 184, 0.4), transparent 70%),
    #dfe4ee;
}

/* --------------------------------------------------------------------------
   舞台（设计分辨率像素坐标，整体缩放）
   -------------------------------------------------------------------------- */

.player-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(0.5);
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(158deg, #0b1020 0%, #121a2d 46%, #1a1428 100%);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(148, 163, 184, 0.12);
  color: #eef1fa;
  font-family: var(--font-ui);
  outline: none;
  cursor: default;
  isolation: isolate;
}

.player-stage.is-advanceable {
  cursor: pointer;
}

.player-stage:focus {
  outline: none;
}

/* 暗角 */
.player-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, transparent 52%, rgba(0, 0, 0, 0.38) 100%);
}

/* ------------------------------- 背景 ------------------------------- */

.player-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.player-bg-layer {
  position: absolute;
  inset: 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.42s ease;
  will-change: opacity;
}

.player-bg-layer.is-visible {
  opacity: 1;
}

/* ------------------------------- 立绘 ------------------------------- */

.player-sprites {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.player-sprite {
  position: absolute;
  bottom: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s ease;
  will-change: opacity;
}

.player-sprite.is-in {
  opacity: 1;
}

.player-sprite.is-out {
  opacity: 0;
}

.player-sprite-img {
  max-height: 100%;
  max-width: none;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 18px 38px rgba(0, 0, 0, 0.5));
}

.player-sprite.is-placeholder .player-sprite-img {
  opacity: 0.92;
}

.player-sprite.at-left {
  left: 3%;
}

.player-sprite.at-right {
  right: 3%;
}

.player-sprite.at-center {
  left: 50%;
  transform: translateX(-50%);
}

.player-sprite.at-truecenter {
  left: 50%;
  top: 50%;
  bottom: auto;
  height: 74%;
  transform: translate(-50%, -50%);
}

/* ------------------------------- 对话框 ------------------------------- */

.player-dialog {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 4.6%;
  z-index: 4;
  min-height: 208px;
  padding: 30px 40px 34px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(180deg, rgba(12, 16, 27, 0.84) 0%, rgba(6, 8, 14, 0.94) 100%);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.58),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

.player-dialog.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.player-dialog-namebox {
  position: absolute;
  left: 32px;
  top: -25px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 70%;
  padding: 7px 24px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-left: 4px solid var(--speaker-color, #6366f1);
  background: linear-gradient(180deg, rgba(26, 31, 47, 0.98), rgba(14, 17, 27, 0.98));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.player-dialog-name {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--speaker-color, #c7d2fe);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-dialog-attr {
  font-size: 16px;
  color: rgba(148, 163, 184, 0.78);
  white-space: nowrap;
}

.player-dialog-body {
  position: relative;
}

.player-dialog-text {
  min-height: 132px;
  font-size: 30px;
  line-height: 1.72;
  letter-spacing: 0.02em;
  color: #f3f5fb;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
  white-space: pre-wrap;
  word-break: break-word;
}

.player-dialog.is-narration .player-dialog-text {
  color: #dbe2f0;
  font-style: italic;
}

.player-dialog-text i,
.player-dialog-text em {
  color: #c7d2fe;
}

.player-dialog-continue {
  position: absolute;
  right: 6px;
  bottom: -10px;
  font-size: 22px;
  line-height: 1;
  color: #a5b4fc;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.player-dialog-continue.is-ready {
  opacity: 0.95;
  animation: player-blink 1.15s ease-in-out infinite;
}

/* ------------------------------- 选项 ------------------------------- */

.player-choices {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6% 16%;
  background: radial-gradient(
    ellipse at 50% 50%,
    rgba(5, 7, 13, 0.72) 0%,
    rgba(5, 7, 13, 0.32) 60%,
    rgba(5, 7, 13, 0.18) 100%
  );
  animation: player-fade-in 0.22s ease both;
}

.player-menu-prompt {
  margin-bottom: 6px;
  max-width: 92%;
  font-size: 27px;
  line-height: 1.5;
  color: #c7d2fe;
  text-align: center;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7);
  animation: player-fade-up 0.26s ease both;
}

.player-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 1120px;
  padding: 20px 30px;
  border-radius: 14px;
  border: 1px solid rgba(129, 140, 248, 0.36);
  background: linear-gradient(180deg, rgba(24, 29, 46, 0.93) 0%, rgba(13, 16, 27, 0.95) 100%);
  color: #eef1fa;
  font-size: 28px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
  transition:
    transform 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    background 0.16s var(--ease);
  animation: player-fade-up 0.28s ease both;
}

.player-choice:nth-child(3) {
  animation-delay: 0.03s;
}
.player-choice:nth-child(4) {
  animation-delay: 0.06s;
}
.player-choice:nth-child(5) {
  animation-delay: 0.09s;
}
.player-choice:nth-child(6) {
  animation-delay: 0.12s;
}

.player-choice:hover:not(:disabled) {
  transform: translateX(10px);
  border-color: #818cf8;
  background: linear-gradient(180deg, rgba(36, 43, 68, 0.97) 0%, rgba(20, 24, 39, 0.97) 100%);
  box-shadow:
    0 16px 42px rgba(99, 102, 241, 0.28),
    0 0 0 1px rgba(129, 140, 248, 0.4);
}

.player-choice:active:not(:disabled) {
  transform: translateX(10px) translateY(1px);
}

.player-choice.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
  border-color: rgba(148, 163, 184, 0.22);
}

.player-choice-index {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(129, 140, 248, 0.42);
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
  font-family: var(--font-code);
  font-size: 20px;
  font-weight: 700;
}

.player-choice-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.player-choice-reason {
  flex: none;
  max-width: 340px;
  padding: 4px 11px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.32);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  font-size: 16px;
  line-height: 1.4;
}

/* ------------------------------- 输入 ------------------------------- */

.player-input-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8%;
  background: rgba(4, 6, 12, 0.66);
  backdrop-filter: blur(3px);
  animation: player-fade-in 0.2s ease both;
}

.player-input-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: min(1000px, 74%);
  padding: 42px 48px;
  border-radius: 20px;
  border: 1px solid rgba(129, 140, 248, 0.35);
  background: linear-gradient(180deg, rgba(21, 26, 41, 0.98) 0%, rgba(10, 13, 23, 0.99) 100%);
  box-shadow: var(--shadow-2);
}

.player-input-prompt {
  font-size: 30px;
  line-height: 1.5;
  color: #eef1fa;
}

.player-input-row {
  display: flex;
  gap: 14px;
}

.player-input-field.input {
  flex: 1;
  height: 66px;
  padding: 0 22px;
  border-radius: 12px;
  border-color: rgba(129, 140, 248, 0.45);
  background: rgba(9, 12, 20, 0.92);
  color: #f3f5fb;
  font-size: 28px;
}

.player-input-submit.btn {
  flex: none;
  height: 66px;
  padding: 0 34px;
  border-radius: 12px;
  font-size: 24px;
}

.player-input-hint {
  font-size: 17px;
  color: rgba(148, 163, 184, 0.7);
}

/* ------------------------------- 等待 ------------------------------- */

.player-pause-chip {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 46%;
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translate(-50%, -50%);
  padding: 16px 32px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(8, 11, 18, 0.84);
  color: #dbe2f0;
  font-size: 24px;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(5px);
}

.player-pause-chip::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid rgba(165, 180, 252, 0.28);
  border-top-color: #a5b4fc;
  animation: player-spin 0.9s linear infinite;
}

/* ------------------------------- 转场特效 ------------------------------- */

.player-fx {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
}

.fx-dissolve {
  background: #000;
  animation: player-fx-dissolve 0.52s ease both;
}

.fx-fade {
  background: #000;
  animation: player-fx-fade 0.52s ease both;
}

.fx-fadeblack {
  background: #000;
  animation: player-fx-black 0.9s ease both;
}

.fx-fadewhite {
  background: #fff;
  animation: player-fx-black 0.9s ease both;
}

.fx-move-in {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.62), transparent 42%);
  animation: player-fx-slide-in 0.48s ease both;
}

.fx-move-out {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.62), transparent 42%);
  animation: player-fx-slide-out 0.48s ease both;
}

.fx-wipe-left,
.fx-wipe-right,
.fx-wipe-up,
.fx-wipe-down {
  background: #05070d;
  animation: player-fx-wipe 0.54s ease both;
}

.fx-wipe-left {
  animation-name: player-fx-wipe-left;
}
.fx-wipe-right {
  animation-name: player-fx-wipe-right;
}
.fx-wipe-up {
  animation-name: player-fx-wipe-up;
}
.fx-wipe-down {
  animation-name: player-fx-wipe-down;
}

.fx-iris {
  background: #05070d;
  animation: player-fx-iris 0.56s ease both;
}

.player-stage.is-shake-h {
  animation: player-shake-h 0.42s ease;
}

.player-stage.is-shake-v {
  animation: player-shake-v 0.42s ease;
}

/* ------------------------------- 结束 / 错误 ------------------------------- */

.player-end-layer,
.player-error-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6% 8%;
  background: radial-gradient(circle at 50% 38%, rgba(12, 17, 30, 0.92), rgba(3, 4, 8, 0.97));
  backdrop-filter: blur(3px);
  animation: player-fade-in 0.3s ease both;
}

.player-end-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 76%;
  text-align: center;
}

.player-end-glyph {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(129, 140, 248, 0.4);
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  box-shadow: 0 0 46px rgba(99, 102, 241, 0.32);
}

.player-end-title {
  font-size: 62px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #f3f5fb;
  text-shadow: 0 6px 30px rgba(99, 102, 241, 0.35);
}

.player-end-sub {
  font-size: 22px;
  line-height: 1.6;
  color: #9aa3b8;
}

.player-end-actions,
.player-error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.player-end-actions .btn,
.player-error-actions .btn {
  height: 52px;
  padding: 0 26px;
  border-radius: 12px;
  font-size: 20px;
}

.player-error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 74%;
  padding: 44px 54px;
  border-radius: 20px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: linear-gradient(180deg, rgba(30, 17, 22, 0.96) 0%, rgba(13, 9, 13, 0.98) 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  text-align: center;
}

.player-error-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

/* 空工程 / 尚未设置开始节点等「引导类」错误：用中性色而非报错红 */
.player-error-card.is-gentle {
  border-color: rgba(129, 140, 248, 0.34);
  background: linear-gradient(180deg, rgba(20, 25, 42, 0.97) 0%, rgba(9, 12, 20, 0.98) 100%);
}

.player-error-card.is-gentle .player-error-icon {
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
}

.player-error-card.is-gentle .player-error-title {
  color: #dbe2f0;
}

.player-error-title {
  font-size: 38px;
  font-weight: 700;
  color: #fecdd3;
}

.player-error-message {
  font-size: 24px;
  line-height: 1.6;
  color: #e7eaf3;
}

.player-error-hint {
  max-width: 90%;
  font-size: 18px;
  line-height: 1.6;
  color: #9aa3b8;
}

/* ------------------------------- 浮动提示 ------------------------------- */

.player-notices {
  position: absolute;
  top: 2.6%;
  left: 50%;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 74%;
  transform: translateX(-50%);
  pointer-events: none;
}

.player-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  padding: 9px 20px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(10, 13, 22, 0.92);
  color: #dbe2f0;
  font-size: 17px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.player-notice.is-in {
  opacity: 1;
  transform: translateY(0);
}

.player-notice svg {
  flex: none;
}

.player-notice.notice-warn {
  border-color: rgba(245, 158, 11, 0.42);
  color: #fcd34d;
}

.player-notice.notice-error {
  border-color: rgba(239, 68, 68, 0.48);
  color: #fca5a5;
}

/* ------------------------------- 快捷键提示 ------------------------------- */

.player-hint {
  position: absolute;
  right: 22px;
  bottom: 16px;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(226, 232, 240, 0.42);
  font-size: 16px;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

.player-hint .kbd {
  height: 22px;
  font-size: 11px;
  border-color: rgba(148, 163, 184, 0.36);
  background: rgba(9, 12, 20, 0.8);
  color: rgba(226, 232, 240, 0.7);
}

.player-hint-sep {
  opacity: 0.6;
}

.player-stage.is-dialog-visible .player-hint {
  opacity: 0;
}

/* ------------------------------- screen 叠加层 ------------------------------- */

.player-screens {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.player-screen-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.player-screen-layer.is-in {
  opacity: 1;
}

.player-screen-layer.is-out {
  opacity: 0;
}

/* 只有真正可交互的控件接收点击，空白区域仍然可以点击舞台推进剧情 */
.player-screen-layer button,
.player-screen-layer a,
.player-screen-layer input,
.player-screen-layer textarea,
.player-screen-layer select,
.player-screen-layer [role="button"],
.player-screen-layer [data-widget-id] {
  pointer-events: auto;
}

.player-screen-layer.is-modal {
  pointer-events: auto;
}

/* 界面设计画布底色在试玩叠加层中透明化（保留背景图片资源） */
.player-screen-layer > * {
  background-color: transparent !important;
}

.player-screen-layer .er-screen {
  background-color: transparent !important;
}

.player-screen-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 62%;
  padding: 26px 40px;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background: rgba(8, 11, 18, 0.86);
  color: #9aa3b8;
  text-align: center;
  pointer-events: none;
}

.player-screen-fallback-title {
  color: #c7d2fe;
  font-size: 24px;
  font-weight: 600;
}

.player-screen-fallback-hint {
  font-size: 18px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   右侧面板（历史 / 变量）
   -------------------------------------------------------------------------- */

.player-side {
  flex: none;
  display: flex;
  flex-direction: column;
  width: 0;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  transition: width 0.18s var(--ease);
}

.player-side.is-open {
  width: 324px;
}

.player-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.player-panel + .player-panel {
  border-top: 1px solid var(--border);
}

.player-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.player-panel-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
}

.player-panel-empty {
  padding: 16px 10px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

.player-history-item {
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: var(--bg-elev);
  font-size: 12px;
  line-height: 1.55;
}

.player-history-item.type-choice {
  border-color: rgba(245, 158, 11, 0.34);
}

.player-history-item.type-input {
  border-color: rgba(16, 185, 129, 0.34);
}

.player-history-who {
  margin-bottom: 3px;
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
}

.player-history-item.type-narration .player-history-who {
  color: var(--text-dim);
}

.player-history-text {
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.player-var-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  background: var(--bg-inset);
  font-size: 12px;
}

.player-var-name {
  overflow: hidden;
  color: var(--accent-text);
  font-family: var(--font-code);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-var-value {
  max-width: 62%;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-code);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* v1.1：自定义函数只读展示（仅导出后执行） */
.player-var-section {
  margin: 10px 2px 2px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.player-var-row-fn {
  align-items: center;
  border: 1px dashed var(--border);
  background: transparent;
}

.player-var-row-fn .player-var-name {
  color: var(--text-dim);
}

.player-fn-badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-weak);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.player-fn-badge.is-disabled {
  background: var(--bg-elev);
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   动画
   -------------------------------------------------------------------------- */

@keyframes player-blink {
  0%,
  100% {
    opacity: 0.95;
    transform: translateY(0);
  }
  50% {
    opacity: 0.35;
    transform: translateY(3px);
  }
}

@keyframes player-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes player-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes player-fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes player-fx-dissolve {
  0% {
    opacity: 0;
  }
  38% {
    opacity: 0.42;
  }
  100% {
    opacity: 0;
  }
}

@keyframes player-fx-fade {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

@keyframes player-fx-black {
  0% {
    opacity: 0;
  }
  46% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes player-fx-slide-in {
  0% {
    opacity: 0.85;
    transform: translateX(-8%);
  }
  100% {
    opacity: 0;
    transform: translateX(0);
  }
}

@keyframes player-fx-slide-out {
  0% {
    opacity: 0.85;
    transform: translateX(8%);
  }
  100% {
    opacity: 0;
    transform: translateX(0);
  }
}

@keyframes player-fx-wipe-left {
  0% {
    opacity: 0.92;
    clip-path: inset(0 100% 0 0);
  }
  55% {
    opacity: 0.5;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes player-fx-wipe-right {
  0% {
    opacity: 0.92;
    clip-path: inset(0 0 0 100%);
  }
  55% {
    opacity: 0.5;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes player-fx-wipe-up {
  0% {
    opacity: 0.92;
    clip-path: inset(100% 0 0 0);
  }
  55% {
    opacity: 0.5;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes player-fx-wipe-down {
  0% {
    opacity: 0.92;
    clip-path: inset(0 0 100% 0);
  }
  55% {
    opacity: 0.5;
    clip-path: inset(0 0 0 0);
  }
  100% {
    opacity: 0;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes player-fx-iris {
  0% {
    opacity: 0.92;
    clip-path: circle(0% at 50% 50%);
  }
  55% {
    opacity: 0.5;
    clip-path: circle(72% at 50% 50%);
  }
  100% {
    opacity: 0;
    clip-path: circle(72% at 50% 50%);
  }
}

@keyframes player-shake-h {
  0%,
  100% {
    margin-left: 0;
  }
  20% {
    margin-left: -18px;
  }
  40% {
    margin-left: 16px;
  }
  60% {
    margin-left: -10px;
  }
  80% {
    margin-left: 7px;
  }
}

@keyframes player-shake-v {
  0%,
  100% {
    margin-top: 0;
  }
  20% {
    margin-top: -14px;
  }
  40% {
    margin-top: 12px;
  }
  60% {
    margin-top: -8px;
  }
  80% {
    margin-top: 5px;
  }
}

/* --------------------------------------------------------------------------
   响应式 / 无障碍
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .player-node-chip {
    max-width: 260px;
  }
  .player-project-name {
    display: none;
  }
  .player-toggle span {
    display: none;
  }
  .player-toggle {
    width: 32px;
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-dialog,
  .player-choice,
  .player-menu-prompt,
  .player-notice,
  .player-screen-layer,
  .player-sprite,
  .player-choices,
  .player-end-layer,
  .player-error-layer,
  .player-input-layer {
    animation: none !important;
    transition: none !important;
  }
  .player-dialog-continue.is-ready {
    animation: none !important;
  }
  .player-pause-chip::before {
    animation: none !important;
  }
  .player-fx {
    animation: none !important;
  }
}
