/* =========================================================================
   宾客手机 · 适配层：矮屏收紧、键盘、平板、横过来怎么画、老系统兼容
   .fit1 / .fit2 / .fit3 由 js/mobile.js 按“放不放得下”逐级加在 #main 上（会叠加），
   所以题目多长、屏幕多矮，选项和按钮都在屏幕里。
   ========================================================================= */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body.player {
  /* 微信 iOS 会把用户调的字号写在 body 的行内样式上，必须 !important 才压得住 */
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}
.stage-box,
#join {
  overscroll-behavior: contain;
}
.measuring,
.measuring * {
  animation: none !important;
  transition: none !important;
}

/* ---------- 平板 / 电脑：内容居中，不铺满 ---------- */
.page {
  padding-left: max(var(--safe-l), calc((100 * var(--vw) - 560px) / 2));
  padding-right: max(var(--safe-r), calc((100 * var(--vw) - 560px) / 2));
}

@media (min-width: 560px) {
  .avatar-pick button {
    height: 76px;
  }
}

/* ---------- 断线提示放上面，不挡底下的按钮 ---------- */
body.player .conn-badge {
  top: calc(var(--safe-t) + 8px);
  bottom: auto;
}
.toast-item {
  max-width: calc(100 * var(--vw) - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 加载页：等久了给个出口 ---------- */
.loading-help {
  margin-top: -4px;
  padding: 0 36px;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}
.loading-help .btn {
  margin-top: 14px;
}

/* ---------- 名字永远一行 ---------- */
.names {
  white-space: nowrap;
}

/* ---------- 加入页 ---------- */
/* 按钮吸在屏幕底部：屏幕再矮也看得到下一步该点哪。外圈同色，盖住滑到底下的头像 */
#join-btn {
  flex: none;
  position: sticky;
  bottom: calc(10px + var(--safe-b));
  z-index: 3;
  box-shadow: 0 8px 18px rgba(160, 40, 60, 0.28), var(--clay), 0 0 0 8px var(--paper);
}
.kb #join-btn {
  position: static;
}
.label-btn {
  min-height: 44px;
  margin: -12px -8px;
  padding: 0 14px;
}
.field.miss .input,
.field.miss .side-btn {
  box-shadow: 0 0 0 3px var(--accent), inset 0 2px 5px rgba(122, 62, 38, 0.1);
}
.field.miss {
  animation: shake 0.28s 2;
}
.avatar-pick button {
  width: 100%;
}

/* ---------- 规则 / 结果 / 小字 ---------- */
/* 折行均衡一点，别让最后一行只剩一两个字（老浏览器忽略） */
.sub,
.title,
.reward-text,
.result-card .foot {
  text-wrap: balance;
}
.q-text,
.rules li {
  text-wrap: pretty;
}
.tip,
.foot-tip {
  font-size: 14px;
}
.stack > .top-row,
.stack > .q-text,
.stack > .btn,
.stack > .q-foot,
.stack > .tip {
  flex: none;
}
.charge-play {
  touch-action: none;
}
.gs-keys {
  flex: 1 0 auto;
  min-height: 190px;
}
.gs-keys button {
  min-height: 42px;
}
/* 上下滑、左右甩的区域：手指起点靠边也算 */
.ticket {
  width: min(324px, 86 * var(--vw));
}

/* ---------- 中奖记录 ---------- */
#prize-btn {
  margin-right: -6px;
}
#prize-btn .itile {
  width: 30px;
  height: 30px;
  animation: pulse 1.6s ease-in-out infinite;
}
.prize-card {
  max-height: 100%;
  overflow-y: auto;
}
/* 奖品名再长也别把按钮挤扁 */
.prize-card > * {
  flex: none;
}
@media (max-height: 640px) {
  .prize-card {
    padding: 22px 20px 18px;
  }
  .prize-card .mark {
    margin-bottom: 14px;
  }
  .prize-card .mark .itile {
    width: 62px;
    height: 62px;
  }
  .prize-card .prize-name {
    font-size: 30px;
  }
  .prize-card .btn {
    margin-top: 14px;
  }
}

/* ---------- 窄屏：昵称和名次优先 ---------- */
@media (max-width: 374px) {
  #me-bar {
    gap: 8px;
  }
  #me-side {
    display: none;
  }
  .me-meta #me-rank:not(:empty)::before {
    content: none;
  }
}

@media (max-width: 340px) {
  /* 十个字的名字也要一行放得下 */
  .tops,
  .fit1 .tops,
  .fit2 .tops {
    padding-left: 12px;
    padding-right: 12px;
  }
  .tops li,
  .fit2 .tops li {
    gap: 6px;
    font-size: 14px;
  }
  .tops li em {
    font-size: 12.5px;
  }
  .cut-btn {
    gap: 6px;
    padding: 0 14px 0 8px;
    font-size: 13px;
    white-space: nowrap;
  }
}

/* ---------- 矮屏：顶部和底部的固定栏先让出高度 ---------- */
@media (max-height: 640px) {
  #me-bar {
    margin-top: 6px;
    padding: 4px 4px 4px 6px;
    border-radius: 26px;
  }
  .me-av {
    width: 40px;
    height: 40px;
  }
  .me-name {
    font-size: 15px;
    line-height: 1.25;
  }
  .me-score b {
    font-size: 22px;
  }
  .stage-box {
    padding-top: 10px;
    padding-bottom: 12px;
  }
  .has-cheer .stage-box {
    padding-bottom: 2px;
  }
  #cheer {
    padding: 6px var(--gutter) 8px;
  }
  #cheer button {
    height: 46px;
    border-radius: 19px;
    font-size: 28px;
  }
  #join .peek-crew {
    --crew-w: min(206px, 58%);
  }
  .join-card {
    gap: 14px;
    padding: 16px 14px 14px;
  }
  .join-card .field {
    gap: 7px;
  }
  .side-btn {
    min-height: 58px;
    padding: 8px 14px;
  }
}

/* =========================================================================
   自动收紧
   ========================================================================= */
/* ---------- 第 1 级：间距和大图 ---------- */
.fit1 .stack {
  gap: 10px;
}
.fit1 .q-text {
  padding: 14px 18px;
  font-size: 19px;
  line-height: 1.4;
}
.fit1 .opts {
  gap: 8px;
}
.fit1 .opt {
  min-height: 54px;
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 16px;
}
.fit1 .opts.duo .opt {
  min-height: 132px;
  padding: 10px 8px;
  font-size: 21px;
}
.fit1 .opts.duo .opt .duo-face {
  font-size: 54px;
}
.fit1 .q-foot {
  gap: 4px;
}
.fit1 .cut-btn {
  height: 44px;
}
.fit1 .intro {
  gap: 10px;
}
.fit1 .intro .demo {
  font-size: 8.5px;
  margin-bottom: 2px;
}
.fit1 .intro-head {
  gap: 5px;
}
.fit1 .rules li {
  padding: 7px 0;
  font-size: 14px;
  line-height: 1.4;
}
.fit1 .reward-card {
  padding: 16px 18px;
}
.fit1 .reward-card .reward-text {
  font-size: 25px;
}
.fit1 .result-wrap {
  gap: 12px;
}
.fit1 .result-card {
  padding: 18px 20px 16px;
  gap: 5px;
}
.fit1 .result-card .title {
  font-size: 24px;
}
.fit1 .result-wrap.has-tops {
  gap: 10px;
}
.fit1 .result-wrap.has-tops .result-card {
  padding: 14px 20px 12px;
}
.fit1 .has-tops .result-card .mark .itile {
  width: 52px;
  height: 52px;
}
.fit1 .has-tops .result-card .mark.pic,
.fit1 .has-tops .result-card .mark.emoji {
  font-size: 58px;
}
.fit1 .tops {
  padding: 8px 16px 6px;
}
.fit1 .tops li {
  height: 30px;
}
.fit1 .tops li i {
  font-size: 20px;
}
.fit1 .ph-full {
  width: min(100%, 46 * var(--vh));
}
.fit1 .result-card .mark {
  margin-bottom: 4px;
}
.fit1 .result-card .mark .itile {
  width: 64px;
  height: 64px;
}
.fit1 .result-card .mark.pic,
.fit1 .result-card .mark.emoji {
  font-size: 72px;
}
.fit1 .p-title {
  margin: 0 0 4px;
  padding: 5px 18px 5px 8px;
  font-size: 16px;
}
.fit1 .gain {
  margin-top: 2px;
}
.fit1 .gain b {
  font-size: 40px;
}
.fit1 .result-card .foot {
  margin-top: 6px;
  padding-top: 10px;
}
.fit1 .dw-mine {
  width: 84px;
  height: 84px;
  margin-bottom: 4px;
}
.fit1 .clash {
  margin: 0 0 6px;
}
.fit1 .clash i {
  font-size: 66px;
}
.fit1 .charge-head .title {
  font-size: 26px;
}
.fit1 .charge-heart {
  --size: min(210px, 56 * var(--vw), 30 * var(--vh));
  margin: 8px auto;
}
.fit1 .my-tally b {
  font-size: 34px;
}
.fit1 .lobby {
  gap: 10px;
}
.fit1 .lobby .hero {
  padding-top: 10px;
}
.fit1 .lobby .peek-crew {
  --crew-w: min(240px, 66%);
  margin-bottom: calc(var(--crew-w) * -0.02 - 10px);
}
.fit1 .bless-card {
  gap: 10px;
  padding: 14px 16px;
}
.fit1 .lobby .foot-tip {
  padding-top: 0;
}
.fit1 .gs-show b {
  font-size: 36px;
}
.fit1 .gs-keys {
  min-height: 182px;
  gap: 6px;
}
.fit1 .tm-target b {
  font-size: 48px;
}
.fit1 .tm-pad,
.fit1 .st-pad,
.fit1 .dw-area,
.fit1 .reflex-pad,
.fit1 .fl-pad,
.fit1 .money-area {
  min-height: 180px;
}

.fit1 .bl-sky {
  min-height: 140px;
}
.fit1 .bl-pot b {
  font-size: 48px;
}
.fit1 .bl-take {
  height: 74px;
  font-size: 30px;
}
.fit1 .cp-table {
  padding: 6px 8px;
}
.fit1 .pr-pad {
  min-height: 220px;
}
.fit1 .pr-pad canvas {
  width: min(210px, 60 * var(--vw), 32 * var(--vh));
  height: min(210px, 60 * var(--vw), 32 * var(--vh));
}
.fit1 .pr-lbl {
  font-size: 23px;
}
.fit1 .un-show b {
  font-size: 38px;
}
.fit1 .un-grid {
  gap: 6px;
}
.fit1 .un-num {
  min-height: 40px;
  font-size: 20px;
}

/* ---------- 第 2 级：字号 ---------- */
.fit2 .stack {
  gap: 8px;
}
.fit2 .top-row {
  min-height: 32px;
}
.fit2 .timer-pill,
.fit2 .count-pill {
  height: 32px;
  line-height: 32px;
}
.fit2 .q-text {
  padding: 10px 16px;
  border-radius: 22px;
  font-size: 17px;
  line-height: 1.35;
}
.fit2 .opts {
  gap: 7px;
}
.fit2 .opt {
  min-height: 48px;
  padding: 5px 40px 5px 8px;
  gap: 10px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.25;
}
.fit2 .opt .shape {
  width: 34px;
  height: 34px;
  border-radius: 12px;
}
.fit2 .opts.duo .opt {
  min-height: 104px;
  gap: 3px;
  font-size: 18px;
}
.fit2 .opts.duo .opt .duo-face {
  font-size: 44px;
}
.fit2 .cut-btn {
  height: 40px;
  font-size: 14px;
}
.fit2 .cut-btn i {
  font-size: 24px;
}
.fit2 .intro {
  gap: 7px;
}
.fit2 .intro .demo {
  font-size: 6.6px;
}
.fit2 .game-title {
  font-size: 23px;
}
.fit2 .intro .sub {
  font-size: 14px;
  line-height: 1.45;
}
.fit2 .rules {
  padding: 2px 14px;
  border-radius: 22px;
}
.fit2 .rules li {
  gap: 9px;
  padding: 5px 0;
  font-size: 13.5px;
  line-height: 1.35;
}
.fit2 .rules li::before {
  width: 20px;
  height: 20px;
}
.fit2 .wait-pill {
  --px: 16px;
  padding: 7px var(--px);
  font-size: 13px;
}
.fit2 .reward-card {
  padding: 12px 14px;
}
.fit2 .reward-card .label {
  margin-bottom: 4px;
}
.fit2 .reward-card .reward-text {
  font-size: 21px;
}
.fit2 .result-wrap {
  gap: 9px;
}
.fit2 .result-card {
  padding: 13px 18px 12px;
  border-radius: 28px;
  gap: 3px;
}
.fit2 .result-card .title {
  font-size: 21px;
}
.fit2 .result-wrap.has-tops {
  gap: 8px;
}
.fit2 .result-wrap.has-tops .result-card {
  padding: 10px 18px;
}
.fit2 .has-tops .result-card .mark .itile {
  width: 40px;
  height: 40px;
}
.fit2 .has-tops .result-card .mark.pic,
.fit2 .has-tops .result-card .mark.emoji {
  font-size: 44px;
}
.fit2 .has-tops .result-card .foot {
  margin-top: 2px;
  padding-top: 6px;
}
.fit2 .tops {
  padding: 5px 14px;
  border-radius: 22px;
}
.fit2 .tops .label {
  display: none;
}
.fit2 .tops li {
  height: 28px;
  font-size: 14px;
}
.fit2 .tops li i {
  font-size: 18px;
}
.fit2 .ph-full {
  width: min(100%, 50 * var(--vh));
  border-radius: 18px;
}
.fit2 .result-card .mark .itile {
  width: 48px;
  height: 48px;
}
.fit2 .result-card .mark.pic,
.fit2 .result-card .mark.emoji {
  font-size: 54px;
}
.fit2 .result-card .sub {
  font-size: 14px;
  line-height: 1.45;
}
.fit2 .p-title {
  font-size: 15px;
}
.fit2 .p-title i {
  font-size: 20px;
}
.fit2 .gain b {
  font-size: 32px;
}
.fit2 .dw-mine {
  width: 62px;
  height: 62px;
}
.fit2 .clash i {
  font-size: 48px;
}
.fit2 .charge-heart {
  --size: min(180px, 50 * var(--vw), 27 * var(--vh));
}
.fit2 .my-tally b {
  display: inline;
  margin-right: 6px;
  font-size: 28px;
}
.fit2 .lobby .peek-crew {
  --crew-w: min(190px, 54%);
}
.fit2 .lobby .hero {
  padding: 4px 8px 0;
}
.fit2 .lobby .eyebrow {
  display: none;
}
.fit2 .lobby .hero-sub {
  margin-top: 2px;
}
.fit2 .lobby .names {
  font-size: 28px;
}
.fit2 .bless-card {
  gap: 8px;
}
.fit2 .chips {
  gap: 6px;
}
.fit2 .chip {
  height: 36px;
  padding: 0 11px;
  font-size: 13px;
}
.fit2 .bless-card .input {
  height: 44px;
}
.fit2 .btn-block {
  height: 46px;
}
.fit2 .gs-show {
  padding: 2px 0;
}
.fit2 .gs-show b {
  font-size: 30px;
}
.fit2 .gs-wrap .q-text {
  font-size: 16px;
}
.fit2 .gs-keys button {
  min-height: 40px;
  border-radius: 18px;
  font-size: 22px;
}
.fit2 .gs-keys {
  min-height: 178px;
}
.fit2 .tm-target b {
  font-size: 40px;
}

.fit2 .bl-sky {
  min-height: 112px;
}
.fit2 .bl-ball {
  width: min(160px, 26 * var(--vh));
}
.fit2 .bl-pot b {
  font-size: 38px;
}
.fit2 .bl-take {
  height: 62px;
  font-size: 26px;
}
.fit2 .cp-table .cups {
  width: 84%;
  margin: 0 auto;
}
.fit2 .cp-say {
  font-size: 22px;
}
.fit2 .pr-pad {
  min-height: 190px;
}
.fit2 .pr-pad canvas {
  width: min(160px, 29 * var(--vh));
  height: min(160px, 29 * var(--vh));
}
.fit2 .un-show {
  padding: 2px 14px;
}
.fit2 .un-show b {
  font-size: 30px;
}
.fit2 .un-two {
  gap: 3px;
}
.fit2 .un-num {
  min-height: 36px;
  border-radius: 16px;
  font-size: 18px;
}

/* ---------- 第 3 级：只留必要的 ---------- */
.fit3 .intro .demo,
.fit3 .lobby .foot-tip,
.fit3 .reward-tag {
  display: none;
}
.fit3 .stack {
  gap: 6px;
}
.fit3 .q-text {
  padding: 8px 14px;
  font-size: 15.5px;
}
.fit3 .opt {
  min-height: 44px;
  font-size: 14.5px;
}
.fit3 .opts {
  gap: 5px;
}
.fit3 .q-foot .tip {
  font-size: 13px;
}
.fit3 .result-card .mark .itile {
  width: 38px;
  height: 38px;
}
.fit3 .result-card .mark.pic {
  font-size: 42px;
}
.fit3 .result-card .foot {
  margin-top: 2px;
  padding-top: 6px;
}
.fit3 .has-tops .result-card .mark {
  display: none;
}
.fit3 .has-tops .result-card .gain b {
  font-size: 26px;
}
.fit3 .ph-full {
  width: min(100%, 38 * var(--vh));
}
.fit3 .tops li {
  height: 25px;
}
.fit3 .tops li i {
  font-size: 17px;
}
.fit3 .dw-mine {
  width: 48px;
  height: 48px;
  margin: 0 auto 2px;
}
.fit3 .lobby .peek-crew {
  display: none;
}
.fit3 .stage-vote .sub {
  display: none;
}
.fit3 .gs-wrap .tip {
  font-size: 12px;
}

/* ---------- 键盘弹出时：不相干的让开 ---------- */
.kb .lobby .peek-crew,
.kb .lobby .foot-tip {
  display: none;
}

/* ---------- 手机横过来：整页转着画，画面一直贴着机身（js/turn.js） ---------- */
html.turned body.player {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--page-w);
  height: var(--page-h);
  transform-origin: 0 0;
}
html.turn90 {
  --safe-t: calc(env(safe-area-inset-left) / var(--zoom));
  --safe-r: calc(env(safe-area-inset-top) / var(--zoom));
  --safe-b: calc(env(safe-area-inset-right) / var(--zoom));
  --safe-l: calc(env(safe-area-inset-bottom) / var(--zoom));
}
html.turn90 body.player {
  transform: translateY(calc(var(--page-w) * var(--zoom))) rotate(-90deg) scale(var(--zoom));
}
html.turn270 {
  --safe-t: calc(env(safe-area-inset-right) / var(--zoom));
  --safe-r: calc(env(safe-area-inset-bottom) / var(--zoom));
  --safe-b: calc(env(safe-area-inset-left) / var(--zoom));
  --safe-l: calc(env(safe-area-inset-top) / var(--zoom));
}
html.turn270 body.player {
  transform: translateX(calc(var(--page-h) * var(--zoom))) rotate(90deg) scale(var(--zoom));
}
/* WebKit 在转过的页面里把 sticky 的宽高算反，按钮会跑到上面盖住昵称：改成钉在卡片底下 */
html.turned .join-card {
  flex: 1 0 auto;
  padding-bottom: 84px;
}
html.turned #join-btn {
  position: fixed;
  left: calc(var(--safe-l) + var(--gutter) + 16px);
  right: calc(var(--safe-r) + var(--gutter) + 16px);
  bottom: calc(var(--safe-b) + 38px);
  width: auto;
}
html.turned .join-tip {
  display: none;
}
/* 横着打字时键盘占掉大半，只留输入框那一块 */
.lying.kb #me-bar,
.lying.kb #cheer,
.lying.kb .hero,
.lying.kb .peek-crew {
  display: none;
}
.lying.kb .input {
  height: 36px;
}

/* ---------- 老系统兼容 ---------- */
/* iOS 14 / 安卓 WebView 87 以前没有 aspect-ratio，人物横幅会塌成 0 高 */
@supports not (aspect-ratio: 1) {
  .peek-crew {
    height: 0;
    padding-bottom: calc(var(--crew-w) * 0.3575);
  }
}
/* iOS 26 的 Safari 从贴边的 fixed 元素取状态栏和工具栏的颜色，取一次就不再更新，换游戏会断成两截。
   页面本来就不滚动，用 absolute 效果一样，它就改用 body 的背景色，能跟着主题变 */
@supports (-webkit-touch-callout: none) {
  .page,
  .ph-view,
  .overlay {
    position: absolute;
  }
}
.mesh {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
