/* src/toy.css — Mobile touch ergonomics, landscape/portrait adaptation, and Bilibili Toy tactical UI. */

html, body, #app {
  overscroll-behavior: none;
  touch-action: manipulation;
}

/* ---- Extra mobile tactical touch controls ---- */
.t-sprint-tag {
  position: absolute;
  left: 0;
  top: -80px;
  transform: translateX(-50%);
  padding: 2px 7px;
  background: var(--signal);
  color: var(--ink);
  font: 700 10px/1.2 var(--f-label);
  letter-spacing: .08em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.t-stick.sprinting .t-sprint-tag {
  opacity: 1;
}
.t-stick.sprinting .t-ring {
  border-color: var(--signal);
  background: rgba(255, 179, 71, .16);
}
.t-stick.sprinting .t-nub {
  border-color: var(--signal);
  background: rgba(255, 179, 71, .42);
}

.t-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.t-lfire {
  width: 60px;
  height: 60px;
  left: calc(24px + var(--sal));
  bottom: calc(176px + var(--sab));
  font-size: 12px;
  border-color: rgba(255, 179, 71, .62);
}
.t-fire {
  width: 84px;
  height: 84px;
  right: calc(20px + var(--sar));
  bottom: calc(58px + var(--sab));
  border-color: rgba(255, 179, 71, .75);
}
.t-jump {
  width: 58px;
  height: 58px;
  right: calc(20px + var(--sar));
  bottom: calc(156px + var(--sab));
}
.t-ads {
  width: 58px;
  height: 58px;
  right: calc(118px + var(--sar));
  bottom: calc(28px + var(--sab));
}
.t-reload {
  width: 54px;
  height: 54px;
  right: calc(108px + var(--sar));
  bottom: calc(118px + var(--sab));
}
.t-crouch {
  width: 54px;
  height: 54px;
  right: calc(190px + var(--sar));
  bottom: calc(26px + var(--sab));
}
.t-interact {
  width: 64px;
  height: 64px;
  right: calc(182px + var(--sar));
  bottom: calc(96px + var(--sab));
  background: rgba(255, 179, 71, .18);
}
.t-interact.on {
  display: flex;
}
.t-pause {
  width: 46px;
  height: 38px;
  right: calc(12px + var(--sar));
  top: calc(12px + var(--sat));
  font-size: 11px;
  letter-spacing: .08em;
}

/* ---- UP主栏 & 云状态徽标 ---- */
#toy-author {
  position: absolute;
  top: calc(clamp(14px, 5.5vh, 52px) + var(--sat) + 12px);
  left: max(var(--gl), 5.5vw);
  right: max(var(--gr), 4.5vw);
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  pointer-events: none;
}
#toy-author[hidden] {
  display: none;
}
#toy-author.has-quick-follow {
  justify-content: flex-start;
  padding-right: 112px;
}

/* ---- Persistent quality controls ---- */
#toy-quality {
  position: absolute;
  top: calc(14px + var(--sat));
  right: max(var(--gr), 4.5vw);
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(11, 13, 15, .82);
  border: 1px solid var(--line);
  border-right: 2px solid var(--steel);
  pointer-events: auto;
}
#toy-quality[hidden] { display: none; }
.toy-quality-note {
  padding: 0 5px;
  font: 500 10px/1 var(--f-mono);
  color: var(--bone-dim);
  white-space: nowrap;
}
.toy-quality-btn {
  min-width: 30px;
  min-height: 25px;
  padding: 0 5px;
  color: var(--bone-dim);
  background: transparent;
  border: 1px solid rgba(232, 228, 218, .28);
  border-radius: 0;
  font: 600 10px/1 var(--f-label);
  cursor: pointer;
}
.toy-quality-btn:hover { color: var(--bone); border-color: var(--bone); }
.toy-quality-btn[aria-pressed="true"] { color: var(--ink); background: var(--signal); border-color: var(--signal); }
.toy-quality-btn:disabled { opacity: .42; cursor: not-allowed; filter: grayscale(.45); }
#toy-quality.locked .toy-quality-note { color: var(--signal); }
@media (max-width: 760px) {
  #toy-quality { top: calc(56px + var(--sat)); right: var(--gr); max-width: calc(100vw - var(--gr) - 8px); }
  .toy-quality-note { display: none; }
  .toy-quality-btn { min-width: 27px; padding: 0 4px; }
}
html.is-touch #toy-quality { top: calc(56px + var(--sat)); right: calc(64px + var(--sar)); }

/* ---- Top-right quick follow button ---- */
#toy-follow-quick {
  position: absolute;
  top: calc(14px + var(--sat));
  right: max(var(--gr), 4.5vw);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: rgba(11, 13, 15, .82);
  border: 1px solid var(--line);
  border-right: 2px solid var(--signal);
  pointer-events: auto;
}
#toy-follow-quick[hidden] {
  display: none;
}
#toy-follow-quick.with-quality {
  top: calc(54px + var(--sat));
}
.toy-follow-quick-btn {
  min-height: 25px;
  padding: 0 11px;
  font-size: 11px;
  letter-spacing: .08em;
}
.toy-follow-quick-btn.followed {
  background: rgba(46, 196, 166, .18);
  border-color: rgba(46, 196, 166, .68);
  color: var(--teal);
}
.toy-follow-quick-btn.followed:hover {
  background: rgba(46, 196, 166, .3);
  border-color: var(--teal);
}
html.is-touch #toy-follow-quick {
  top: calc(12px + var(--sat));
  right: calc(64px + var(--sar));
}
@media (max-height: 500px) {
  #toy-follow-quick {
    top: calc(12px + var(--sat));
    right: max(var(--gr), 3.5vw);
  }
  #toy-follow-quick.with-quality {
    top: calc(52px + var(--sat));
  }
  html.is-touch #toy-follow-quick,
  html.is-touch #toy-follow-quick.with-quality {
    top: calc(8px + var(--sat));
    right: calc(64px + var(--sar));
  }
}
@media (max-width: 760px) {
  #toy-follow-quick,
  #toy-follow-quick.with-quality {
    top: calc(14px + var(--sat));
    right: var(--gr);
  }
  html.is-touch #toy-follow-quick,
  html.is-touch #toy-follow-quick.with-quality {
    top: calc(12px + var(--sat));
    right: calc(64px + var(--sar));
  }
}

.toy-up-group,
.toy-meta-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  background: rgba(11, 13, 15, .78);
  border: 1px solid var(--line);
  border-left: 2px solid var(--signal);
  padding: 5px 10px;
}
.toy-meta-group {
  border-left: 1px solid var(--line);
  border-right: 2px solid var(--steel);
}
.toy-avatar {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border: 1px solid rgba(232, 228, 218, .45);
  flex: none;
}
.toy-up-name {
  font: 600 12px/1.2 var(--f-label);
  color: var(--bone);
  letter-spacing: .04em;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toy-chip-btn {
  font: 600 11px/1 var(--f-label);
  letter-spacing: .06em;
  color: var(--ink);
  background: var(--signal);
  border: 1px solid var(--signal);
  border-radius: 0;
  min-height: 26px;
  padding: 0 10px;
  cursor: pointer;
  white-space: nowrap;
}
.toy-chip-btn:hover {
  background: var(--signal-hot);
  border-color: var(--signal-hot);
}
.toy-chip-btn.ghost {
  background: transparent;
  color: var(--bone);
  border-color: rgba(232, 228, 218, .38);
}
.toy-chip-btn.ghost:hover {
  border-color: var(--bone);
  background: rgba(232, 228, 218, .1);
}
#toy-status {
  font: 500 11px/1.2 var(--f-mono);
  color: var(--bone-dim);
  letter-spacing: .02em;
  white-space: nowrap;
}

/* ---- Debrief tactical score & share ---- */
.toy-debrief-extra {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(20, 24, 27, .88);
  border: 1px solid var(--line);
  border-left: 2px solid var(--signal);
}
.toy-score-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.toy-score-line span {
  font: 600 12px/1.2 var(--f-label);
  letter-spacing: .08em;
  color: var(--steel);
}
.toy-score-line b {
  font: 800 24px/1 var(--f-mono);
  color: var(--signal);
  letter-spacing: .04em;
}
.toy-score-sub {
  margin-top: 6px !important;
  font: 400 11px/1.4 var(--f-mono);
  color: var(--bone-dim);
}
.toy-qr-wrap {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.toy-qr-wrap[hidden] {
  display: none;
}
.toy-qr-wrap img {
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
  flex: none;
}
.toy-qr-wrap p {
  font: 400 11px/1.5 var(--f-mono);
  color: var(--bone-dim);
}

/* ---- Tactical Modal (Leaderboards / Cloud Career / Follow Prompt) ---- */
#toy-modal {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--sat)) max(14px, var(--sar)) calc(12px + var(--sab)) max(14px, var(--sal));
  background: rgba(6, 8, 10, .78);
  pointer-events: auto;
}
#toy-modal[hidden] {
  display: none;
}
.toy-dialog {
  width: min(520px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: #101417;
  border: 1px solid var(--line);
  border-top: 3px solid var(--signal);
  color: var(--bone);
  overflow: hidden;
}
.toy-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.toy-dialog-head h2 {
  margin: 0;
  font: 700 18px/1.2 var(--f-display);
  letter-spacing: .08em;
}
.toy-dialog-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 18px 18px;
  -webkit-overflow-scrolling: touch;
}
.toy-dialog-note {
  margin: 0 0 12px;
  font: 400 12px/1.55 var(--f-mono);
  color: var(--bone-dim);
}
.toy-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.toy-seg {
  display: inline-flex;
}
.toy-seg button {
  min-height: 32px;
  padding: 0 12px;
  font: 600 12px/1 var(--f-label);
  letter-spacing: .06em;
  color: var(--bone-dim);
  background: transparent;
  border: 1px solid rgba(232, 228, 218, .35);
  border-radius: 0;
  margin-left: -1px;
  cursor: pointer;
}
.toy-seg button:first-child {
  margin-left: 0;
}
.toy-seg button[aria-pressed="true"] {
  background: var(--bone);
  border-color: var(--bone);
  color: var(--ink);
}
.toy-my-rank {
  padding: 9px 12px;
  margin-bottom: 10px;
  background: rgba(255, 179, 71, .1);
  border: 1px solid rgba(255, 179, 71, .35);
  font: 500 12px/1.4 var(--f-mono);
  color: var(--bone);
}
.toy-rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.toy-rank-list li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font: 500 13px/1.3 var(--f-label);
}
.toy-rank-no {
  font: 700 13px/1 var(--f-mono);
  color: var(--steel);
}
.toy-rank-list li.top .toy-rank-no {
  color: var(--signal);
}
.toy-rank-nick {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bone);
}
.toy-rank-val {
  font: 600 13px/1 var(--f-mono);
  color: var(--signal);
}
.toy-career-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.toy-stat-box {
  padding: 10px 12px;
  background: rgba(20, 24, 27, .9);
  border: 1px solid var(--line);
}
.toy-stat-box span {
  display: block;
  font: 500 11px/1.2 var(--f-label);
  color: var(--steel);
  letter-spacing: .06em;
}
.toy-stat-box b {
  display: block;
  margin-top: 6px;
  font: 700 18px/1.1 var(--f-mono);
  color: var(--bone);
}
.toy-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ---- Toast message ---- */
#toy-toast {
  position: fixed;
  left: 50%;
  top: calc(14px + var(--sat));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(460px, calc(100vw - 28px));
  padding: 8px 14px;
  background: rgba(11, 13, 15, .94);
  border: 1px solid var(--signal);
  color: var(--bone);
  font: 500 12px/1.4 var(--f-label);
  letter-spacing: .04em;
  text-align: center;
  pointer-events: none;
  box-shadow: var(--shadow);
}
#toy-toast[hidden] {
  display: none;
}

/* ---- Portrait orientation advisor for phones ---- */
#toy-rotate {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--sat)) 20px calc(20px + var(--sab));
  background: rgba(8, 10, 12, .94);
  pointer-events: auto;
}
.toy-rotate-box {
  width: min(340px, 100%);
  padding: 22px 20px;
  background: #121619;
  border: 1px solid var(--line);
  border-top: 3px solid var(--signal);
  text-align: left;
}
.toy-rotate-tag {
  display: inline-block;
  padding: 3px 7px;
  background: var(--signal);
  color: var(--ink);
  font: 800 11px/1 var(--f-label);
  letter-spacing: .08em;
}
.toy-rotate-box h2 {
  margin: 12px 0 8px;
  font: 800 22px/1.2 var(--f-display);
  color: var(--bone);
  letter-spacing: .06em;
}
.toy-rotate-box p {
  margin: 0 0 16px;
  font: 400 13px/1.6 var(--f-label);
  color: var(--bone-dim);
}
.toy-rotate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (orientation: portrait) and (max-width: 620px) {
  html.is-touch:not(.rotate-dismissed) #toy-rotate {
    display: flex;
  }
  /* If dismissed, ensure portrait HUD, title, and touch controls remain compact and collision-free */
  #toy-author {
    top: calc(18px + var(--sat));
    left: var(--gl);
    right: var(--gr);
  }
  .m-bars i {
    height: calc(10px + var(--sat));
  }
  .m-bars i + i {
    height: calc(10px + var(--sab));
  }
  .m-title {
    padding-top: calc(74px + var(--sat));
    padding-bottom: calc(22px + var(--sab));
  }
  .m-word {
    font-size: 52px !important;
    margin: 8px 0 12px !important;
  }
  .m-premise {
    font-size: 15px;
    padding-top: 10px !important;
  }
  .m-actions:not(.col) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .m-actions:not(.col) .btn.primary {
    grid-column: 1 / -1;
  }
  .t-lfire {
    width: 52px;
    height: 52px;
    left: calc(14px + var(--sal));
    bottom: calc(186px + var(--sab));
  }
  .t-fire {
    width: 68px;
    height: 68px;
    right: calc(14px + var(--sar));
    bottom: calc(56px + var(--sab));
    font-size: 13px;
  }
  .t-jump {
    width: 48px;
    height: 48px;
    right: calc(14px + var(--sar));
    bottom: calc(136px + var(--sab));
    font-size: 11px;
  }
  .t-ads {
    width: 48px;
    height: 48px;
    right: calc(92px + var(--sar));
    bottom: calc(24px + var(--sab));
    font-size: 11px;
  }
  .t-reload {
    width: 46px;
    height: 46px;
    right: calc(88px + var(--sar));
    bottom: calc(88px + var(--sab));
    font-size: 11px;
  }
  .t-crouch {
    width: 46px;
    height: 46px;
    right: calc(150px + var(--sar));
    bottom: calc(24px + var(--sab));
    font-size: 11px;
  }
  .t-interact {
    width: 54px;
    height: 54px;
    right: calc(146px + var(--sar));
    bottom: calc(84px + var(--sab));
    font-size: 11px;
  }
}

/* ---- Phone landscape compact layout (e.g. 844x390, 667x375) ---- */
@media (max-height: 500px) {
  .m-bars i {
    height: calc(8px + var(--sat));
  }
  .m-bars i + i {
    height: calc(8px + var(--sab));
  }
  #toy-author {
    top: calc(14px + var(--sat));
    left: max(var(--gl), 3.5vw);
    right: max(var(--gr), 3.5vw);
  }
  .toy-up-group,
  .toy-meta-group {
    padding: 3px 8px;
  }
  .toy-avatar {
    width: 20px;
    height: 20px;
  }
  .toy-chip-btn {
    min-height: 24px;
    font-size: 11px;
    padding: 0 8px;
  }
  .m-title {
    padding: calc(50px + var(--sat)) max(var(--gr), 3.5vw) calc(16px + var(--sab)) max(var(--gl), 3.5vw);
    gap: 16px;
  }
  .m-eyebrow {
    font-size: 11px;
    gap: 4px 10px;
  }
  .m-tag {
    font-size: 12px;
    padding: 2px 6px;
  }
  .m-word {
    font-size: 46px !important;
    line-height: 1.04 !important;
    margin: 4px 0 8px !important;
  }
  .m-subtitle {
    display: inline-block;
    margin-left: 10px;
    font-size: .46em;
    vertical-align: baseline;
  }
  .m-premise {
    font-size: 14px;
    line-height: 1.4;
    padding-top: 8px !important;
  }
  .m-actions {
    margin-top: 10px;
    gap: 8px;
  }
  .m-actions .btn {
    min-height: 36px;
    font-size: 13px;
    padding: 1px 14px 0;
  }
  .m-actions .btn.primary {
    min-height: 38px;
    font-size: 14px;
    padding: 1px 22px 0;
    flex: 0 0 auto;
  }
  .m-note {
    margin-top: 6px !important;
    font-size: 10px;
    line-height: 1.35;
  }

  /* Compact HUD & touch cluster in 375~390px height */
  .h-compass {
    top: calc(6px + var(--sat));
    height: 46px;
  }
  .h-obj {
    top: calc(10px + var(--sat));
    max-width: 38vw;
  }
  .h-obj-t {
    font-size: 14px;
    margin: 4px 0 6px;
    min-height: 18px;
  }
  .is-touch .h-ammo {
    top: calc(48px + var(--sat));
    right: calc(14px + var(--sar));
  }
  .is-touch .h-ammo-n {
    font-size: 32px;
  }
  .is-touch .h-pips {
    margin: 4px 0 3px;
  }
  .is-touch .h-health {
    top: calc(74px + var(--sat));
  }
  .h-hp-n {
    font-size: 24px;
  }
  .is-touch .comms {
    top: calc(20% + var(--sat));
  }
  .comms-t {
    font-size: 14px;
  }

  .t-pause {
    width: 44px;
    height: 32px;
    top: calc(8px + var(--sat));
    right: calc(12px + var(--sar));
  }
  .t-lfire {
    width: 52px;
    height: 52px;
    left: calc(20px + var(--sal));
    bottom: calc(148px + var(--sab));
    font-size: 11px;
  }
  .t-fire {
    width: 70px;
    height: 70px;
    right: calc(16px + var(--sar));
    bottom: calc(44px + var(--sab));
    font-size: 13px;
  }
  .t-jump {
    width: 48px;
    height: 48px;
    right: calc(18px + var(--sar));
    bottom: calc(124px + var(--sab));
    font-size: 11px;
  }
  .t-ads {
    width: 48px;
    height: 48px;
    right: calc(98px + var(--sar));
    bottom: calc(18px + var(--sab));
    font-size: 11px;
  }
  .t-reload {
    width: 46px;
    height: 46px;
    right: calc(94px + var(--sar));
    bottom: calc(90px + var(--sab));
    font-size: 11px;
  }
  .t-crouch {
    width: 46px;
    height: 46px;
    right: calc(160px + var(--sar));
    bottom: calc(18px + var(--sab));
    font-size: 11px;
  }
  .t-interact {
    width: 54px;
    height: 54px;
    right: calc(156px + var(--sar));
    bottom: calc(78px + var(--sab));
    font-size: 11px;
  }

  /* Compact cards & modals */
  .m-card {
    width: min(460px, calc(100vw - var(--gl) - var(--gr)));
    padding: 12px 18px 12px;
  }
  .m-h {
    font-size: 26px !important;
    margin: 4px 0 6px !important;
  }
  .m-debrief .m-h {
    font-size: 24px !important;
  }
  .m-rating {
    margin: 2px 0 6px;
  }
  .m-rating b {
    font-size: 26px;
  }
  .m-stats > div {
    padding: 4px 0;
  }
  .m-stats dt {
    font-size: 12px;
  }
  .m-stats dd {
    font-size: 14px;
  }
  .toy-debrief-extra {
    margin-top: 8px;
    padding: 6px 10px;
  }
  .toy-score-line b {
    font-size: 19px;
  }
  .m-actions.col {
    margin-top: 8px;
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .m-actions.col .btn.primary {
    grid-column: 1 / -1;
  }
  .m-actions.col .btn {
    min-height: 34px;
    font-size: 12px;
    padding: 1px 12px 0;
    text-align: center;
  }
  .toy-dialog-head {
    padding: 10px 14px 8px;
  }
  .toy-dialog-body {
    padding: 10px 14px 12px;
  }
}
