/* 计时器独立页由外层页面滚动，导航随内容离开视口。房间计时器不受影响。 */
html:has(app-timer-sample > iframe[data-testid="timer-sample-frame"]) {
  scrollbar-gutter: stable;
}
body:has(app-timer-sample > iframe[data-testid="timer-sample-frame"]) .debater-global-nav {
  position: relative !important;
  top: auto !important;
  padding-block: 12px !important;
  transition-property: background-color, border-color, color !important;
}
body:has(app-timer-sample > iframe[data-testid="timer-sample-frame"]) .container:has(> app-breadcrumb) {
  padding-top: 16px !important;
}
html:has(app-timer-sample > iframe[data-timer-settings-open]) {
  overflow: hidden;
}

/* 去除随 iframe 高度增长的 100dvh 下限，避免高度反馈与第二根滚动条。 */
html[data-timer-embedded] {
  overflow: clip;
}
html[data-timer-embedded] .timer-tool:not(:fullscreen) {
  min-height: 0;
}
/* 设置打开时只滚动弹窗；位置与高度使用外层可见视口，而非整个长 iframe。 */
html[data-timer-embedded]:not(:has(:fullscreen)) .timer-dialog {
  position: fixed;
  top: var(--timer-host-dialog-top, 16px);
  max-height: min(820px, var(--timer-host-dialog-height, calc(100dvh - 32px)));
  margin-block: 0;
}
.timer-tool:fullscreen:has(.timer-dialog[open]) {
  overflow: hidden;
}

/* 队名完整换行；普通页面给计时数字保留实际高度，长队名可撑高卡片。 */
.timer-tool .timer-team-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
.timer-tool:not(:fullscreen) .timer-team-body {
  grid-template-rows: auto minmax(min-content, 1fr) auto;
  row-gap: 12px;
}

/* 全屏使用视口内的剩余高度，不能沿用普通页面的固定卡片下限。 */
html:has(iframe[data-testid="timer-sample-frame"]:fullscreen) {
  scrollbar-gutter: auto;
  overflow: clip;
}
.timer-tool:fullscreen {
  --timer-full-arena-gap: clamp(6px, 1dvh, 14px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, .8dvh, 10px);
  padding: clamp(8px, 2vmin, 24px);
  overflow: clip;
  border-radius: 0;
}
/* 印章画在视口内的背景盒子中，避免白天模式的负 right 扩大滚动宽度。 */
.timer-tool:is([data-background-preset="dark"], [data-background-preset="light"]):fullscreen::after {
  inset: 12dvh auto auto 0;
  width: min(400px, 100%);
  height: min(520px, 65dvh);
  background-position: calc(50% - 174px) center;
}
.timer-tool[data-background-preset="light"]:fullscreen::after {
  left: auto;
  right: 0;
  background-position: calc(50% + 174px) center;
}
.timer-tool:fullscreen > :not(.timer-dialog, .timer-settings-mini) {
  min-width: 0;
  flex-shrink: 0;
  margin-block: 0;
}
.timer-tool:fullscreen .timer-page-title {
  font-size: clamp(18px, min(4vw, 5dvh), 52px);
}
.timer-tool:fullscreen .timer-stage-list {
  flex-wrap: nowrap;
  justify-content: safe center;
  overflow: auto hidden;
  scrollbar-width: none;
}
.timer-tool:fullscreen .timer-stage-list button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px;
}
.timer-tool:fullscreen .timer-motion {
  --timer-motion-unit: var(--timer-full-motion-unit, 1px);
  width: var(--timer-full-motion-width, 100%);
  max-width: none;
  min-height: 0;
  gap: calc(7 * var(--timer-motion-unit));
  padding: calc(16 * var(--timer-motion-unit)) calc(24 * var(--timer-motion-unit)) calc(18 * var(--timer-motion-unit));
  border-width: var(--timer-motion-unit);
  border-radius: calc(16 * var(--timer-motion-unit));
}
.timer-tool:fullscreen .timer-motion span {
  font-size: calc(11 * var(--timer-motion-unit));
  line-height: 1.4;
}
.timer-tool:fullscreen .timer-motion p {
  font-size: calc(32 * var(--timer-motion-unit));
  line-height: 1.42;
}
.timer-tool:fullscreen .timer-arena {
  display: flex;
  flex: 1;
  min-height: 0;
  max-width: none;
  align-items: center;
  justify-content: center;
  gap: var(--timer-full-arena-gap);
  container-type: size;
}
/* 以普通桌面卡片 553×480 为基准；宽高共用一个比例，不能单独拉伸卡片高度。 */
.timer-tool:fullscreen .timer-team {
  --timer-full-card-unit: calc((100cqw + 2px) / 553);
  flex: none;
  width: var(--timer-full-card-width, min(calc((100cqw - var(--timer-full-arena-gap)) / 2), calc(100cqh * 553 / 480)));
  aspect-ratio: 553 / 480;
  min-height: 0;
  padding: 0;
  container-type: inline-size;
}
.timer-tool:fullscreen .timer-stance-banner {
  flex: none;
  width: 100%;
  height: calc(120 * var(--timer-full-card-unit));
  min-height: 0;
  margin: 0;
  padding: calc(12 * var(--timer-full-card-unit)) calc(24 * var(--timer-full-card-unit));
  gap: calc(8 * var(--timer-full-card-unit));
}
.timer-tool:fullscreen .timer-stance-banner > span {
  font-size: calc(14 * var(--timer-full-card-unit));
  line-height: 1.2;
}
.timer-tool:fullscreen .timer-stance {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: calc(26 * var(--timer-full-card-unit));
  line-height: 1.35;
}
/* 文字、数字、按钮与留白均来自卡片宽度，避免剩余高度挤压计时数字。 */
.timer-tool:fullscreen .timer-team-body {
  min-height: 0;
  container-type: normal;
  grid-template-rows: var(--timer-full-name-row, auto) minmax(0, 1fr) auto;
  padding: calc(24 * var(--timer-full-card-unit)) calc(28 * var(--timer-full-card-unit));
  row-gap: calc(12 * var(--timer-full-card-unit));
}
.timer-tool:fullscreen .timer-team-name {
  margin: 0;
  align-self: start;
  font-size: var(--timer-full-name-font, calc(31 * var(--timer-full-card-unit)));
  line-height: 1.2;
}
.timer-tool:fullscreen .timer-value {
  font-size: calc(140 * var(--timer-full-card-unit));
  line-height: 1.05;
}
.timer-tool:fullscreen .timer-adjustments { gap: calc(12 * var(--timer-full-card-unit)); }
.timer-tool:fullscreen .timer-adjustments button {
  width: calc(46 * var(--timer-full-card-unit));
  min-width: 0;
  min-height: calc(44 * var(--timer-full-card-unit));
  font-size: calc(12 * var(--timer-full-card-unit));
}
@media (max-width: 700px) {
  .timer-tool:fullscreen .timer-arena { flex-direction: column; }
  .timer-tool:fullscreen .timer-team {
    width: var(--timer-full-card-width, min(100cqw, calc((100cqh - var(--timer-full-arena-gap)) * 553 / 960)));
  }
}
.timer-tool:fullscreen .timer-controls { gap: 6px; }
.timer-tool:fullscreen .timer-controls button { min-height: 36px; padding-inline: 8px; }
.timer-tool:fullscreen .timer-records {
  min-height: 24px;
  max-height: 22dvh;
  flex-shrink: 1;
  overflow: auto;
  scrollbar-width: none;
}
.timer-tool:fullscreen .timer-records summary { min-height: 24px; padding-block: 3px; font-size: 12px; }
.timer-tool:fullscreen .timer-shortcuts { font-size: 8px; line-height: 1.4; }
.timer-tool:fullscreen .timer-dialog { scrollbar-width: none; }
.timer-tool:fullscreen :is(.timer-stage-list, .timer-records, .timer-dialog)::-webkit-scrollbar { display: none; }
