/* ============================================================
 * v1.8 第三批续做 03：时间线 drawer + 简单居中 dock
 * ============================================================ */

@media (min-width: 1024px) {
  body.tactical-v77.match-started {
    display: block;
    max-width: min(1200px, calc(100vw - 32px));
  }

  body.tactical-v77.match-started .col-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
  }

  body.tactical-v77.match-started .col-side-top {
    display: contents;
  }
}

.col-side-bottom {
  position: fixed;
  top: 0;
  right: 0;
  width: 220px;
  height: 100vh;
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  overflow: visible;
  background: var(--bg-base, #0f1115);
  padding: 14px;
  box-shadow: -8px 0 0 rgba(0, 0, 0, 0.5);
  margin: 0;
  box-sizing: border-box;
}

body.timeline-wide .col-side-bottom {
  width: 360px;
}

body.timeline-open .col-side-bottom {
  transform: translateX(0);
}

/* 时间线打开时，主内容让出右侧抽屉宽度（220 + 16 间隙），重新在可见区居中，
   避免比分 / 球场 / 牌堆 / 结束回合等被固定浮层盖住、整体偏右（错位修复）。
   仅宽屏（抽屉为右侧固定浮层）生效；窄屏抽屉走另一套布局，不在此让位。 */
@media (min-width: 1024px) {
  body.tactical-v77.match-started.timeline-open {
    padding-right: 236px;
  }
  body.tactical-v77.match-started.timeline-open.timeline-wide {
    padding-right: 376px;
  }
}

/* C 线信息层开关 step1：时间线默认关 = 不显示（覆盖所有视口）。
   窄屏（< 1024px）.col-side-bottom 是 display:contents，抽屉位移盖不住，时间线会常驻在页底；
   这里把整块时间线在"未开启"时收掉，让设置里的开关在任何视口都真正控制显示。 */
body:not(.timeline-open) #bottom-log {
  display: none;
}

/* C 线信息层开关 step1：原 #timeline-toggle 改成 #settings-toggle（沿用原位置 + 样式）+ 设置面板 */
#settings-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 70;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  background: rgba(15, 17, 21, .85);
  color: var(--gold-primary, #f0d99b);
  border: 1px solid rgba(212, 166, 74, .45);
  border-radius: 0;
  cursor: pointer;
  transition: all 160ms ease, right 200ms ease;
  letter-spacing: .4px;
}

#settings-toggle:hover {
  background: rgba(212, 166, 74, .12);
  border-color: rgba(212, 166, 74, .75);
}

body.timeline-open #settings-toggle {
  display: none;
}

.settings-panel {
  position: fixed;
  top: 52px;
  right: 16px;
  z-index: 71;
  width: 240px;
  padding: 12px 14px;
  background: rgba(15, 17, 21, .96);
  border: 1px solid rgba(212, 166, 74, .45);
  border-radius: 0;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: right 200ms ease;
}

.settings-panel.hidden {
  display: none;
}

/* 赛季更新 / 下一场预告仍属于可停留页面，设置是它的全局子视图。
   只在这类模态页把设置控件提到遮罩上方；球场赛后奖励仍按原规则隐藏设置。 */
body.post-match-modal-open:not(.postmatch-onpitch) #settings-toggle {
  z-index: 1002;
}

body.post-match-modal-open:not(.postmatch-onpitch) .settings-panel {
  z-index: 1003;
}

.settings-panel.is-opening {
  animation: settings-panel-in 180ms cubic-bezier(.16, 1, .3, 1) both;
}

.settings-panel.is-closing {
  pointer-events: none;
  animation: settings-panel-out 160ms cubic-bezier(.4, 0, .2, 1) both;
}

@keyframes settings-panel-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes settings-panel-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

body.timeline-open .settings-panel {
  display: none;
}

.settings-panel .settings-title {
  font-size: 13px;
  color: var(--gold-primary, #f0d99b);
  letter-spacing: .4px;
  border-bottom: 1px solid rgba(212, 166, 74, .25);
  padding-bottom: 6px;
}

.settings-panel .settings-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}

.settings-panel .settings-row input {
  margin-top: 2px;
  accent-color: var(--gold-primary, #f0d99b);
  cursor: pointer;
}

.settings-panel .settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-panel .settings-row-text b {
  font-size: 13px;
  color: #e8ecf3;
}

.settings-panel .settings-row-text small {
  font-size: 11px;
  color: rgba(232, 236, 243, .55);
}

.settings-panel .settings-section {
  border-top: 1px solid rgba(212, 166, 74, .18);
  padding-top: 10px;
}

.settings-panel .settings-section-title {
  margin-bottom: 8px;
  color: var(--gold-primary, #f0d99b);
  font-size: 12px;
  font-weight: 800;
}

.settings-panel .settings-danger-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-panel .settings-danger-btn {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #ffd7d7;
  background: rgba(118, 33, 31, .34);
  border: 1px solid rgba(239, 83, 80, .62);
  border-radius: 0;
  cursor: pointer;
}

.settings-panel .settings-danger-btn:hover:not(:disabled) {
  background: rgba(151, 43, 40, .46);
  border-color: rgba(239, 83, 80, .9);
}

.settings-panel .settings-danger-btn:disabled {
  opacity: .52;
  cursor: not-allowed;
}

.settings-panel .settings-danger-btn.is-loading {
  color: rgba(232, 236, 243, .72);
  background: rgba(90, 90, 90, .28);
  border-color: rgba(232, 236, 243, .22);
}

.settings-panel .settings-danger-note {
  font-size: 11px;
  line-height: 1.45;
  color: rgba(232, 236, 243, .58);
}

@media (max-width: 420px) {
  body.timeline-open #settings-toggle {
    right: 16px;
    top: 56px;
  }
  body.timeline-open .settings-panel {
    right: 16px;
    top: 92px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-panel.is-opening,
  .settings-panel.is-closing {
    animation: none;
  }
}

.timeline-width-btn {
  position: absolute;
  left: 0;
  top: 78px;
  z-index: 2;
  width: 28px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(15, 17, 21, .86);
  color: var(--gold-primary, #f0d99b);
  border: 1px solid rgba(212, 166, 74, .45);
  border-left: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .2px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .45);
}

.timeline-width-btn:hover,
.timeline-width-btn:focus-visible {
  background: rgba(212, 166, 74, .16);
  border-color: rgba(212, 166, 74, .75);
  outline: none;
}

.col-side-bottom #log {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

#hand-bar {
  position: fixed;
  bottom: calc(16px + 268px + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 49;
  margin: 0;
  box-sizing: border-box;
}
