/* 机器人半马 — visual system
   Brand: 亦庄蓝 #0256A6, 亦庄绿 #0CB25B; deep sea background #061A33/#0B2A4F;
   one accent (霓虹青 #2EE6FF); feedback orange #FF8A3D, alert red #FF3B5C, paper #F4F7FB.
   One radius (14px), one shadow, two weights (400 / 800). */
:root {
  --blue: #0256a6;
  --green: #0cb25b;
  --deep: #061a33;
  --deep2: #0b2a4f;
  --cyan: #2ee6ff;
  --orange: #ff8a3d;
  --red: #ff3b5c;
  --paper: #f4f7fb;
  --gold: #ffc938;
  --silver: #c9d3e0;
  --bronze: #d08b5b;
  --r: 14px;
  --shadow: 0 6px 18px rgba(0, 8, 24, 0.45);
  --font: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; height: 100dvh; overflow: hidden;
  background: var(--deep); color: var(--paper);
  font-family: var(--font); font-weight: 400;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
[hidden] { display: none !important; }
small { font-weight: 400; }

/* ---------- controls ---------- */
.btn {
  flex: 0 0 auto; min-height: 48px; min-width: 44px; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid rgba(46, 230, 255, 0.28); border-radius: var(--r);
  background: rgba(11, 42, 79, 0.86); color: var(--paper);
  font: 800 17px/1 var(--font); letter-spacing: 0.04em;
  box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; white-space: nowrap;
  transition: transform 0.12s cubic-bezier(.3, 1.6, .5, 1), background 0.15s;
}
.btn small { font-size: 14px; opacity: 0.7; letter-spacing: 0.08em; margin-left: 2px; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; }
.btn.primary { background: linear-gradient(180deg, #19c96f, var(--green)); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn.big { min-height: 60px; font-size: 22px; width: 100%; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 14px; box-shadow: none; background: rgba(255, 255, 255, 0.06); }
.btn .ic { width: 22px; height: 22px; }
.btn.big .ic { width: 26px; height: 26px; }
.btn-row { display: flex; gap: 10px; width: 100%; }
.btn-row .btn { flex: 1 1 0; min-width: 0; }
.icon-btn {
  width: 48px; height: 48px; flex: 0 0 auto; padding: 0; border-radius: var(--r);
  border: 1px solid rgba(46, 230, 255, 0.28); background: rgba(6, 26, 51, 0.72);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; box-shadow: var(--shadow);
}
.icon-btn .ic { width: 24px; height: 24px; }
.icon-btn.off .ic { opacity: 0.35; }
.ic { display: inline-block; opacity: 0; transition: opacity 0.25s; }
.ic.loaded { opacity: 1; }
.hud-btn { position: fixed; top: calc(var(--sat) + 10px); right: calc(var(--sar) + 10px); }

/* ---------- title ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.title-screen {
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 18px) calc(var(--sab) + 14px) calc(var(--sal) + 18px);
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(6, 26, 51, 0.55) 0%, rgba(6, 26, 51, 0) 34%, rgba(6, 26, 51, 0) 52%, rgba(6, 26, 51, 0.82) 74%, rgba(6, 26, 51, 0.96) 100%);
}
.title-top { display: flex; justify-content: space-between; align-items: flex-start; }
.brand-plate {
  background: #fff; border-radius: var(--r); padding: 9px 12px; box-shadow: var(--shadow);
  width: 104px; height: 104px; display: grid; place-items: center;
}
.brand-plate img { width: 72px; height: 72px; object-fit: contain; opacity: 0; transition: opacity 0.3s; }
.brand-plate img.loaded { opacity: 1; }
.title-block { text-align: center; margin-top: 4px; flex: 1 1 auto; }
.kicker {
  display: inline-block; padding: 6px 12px; border-radius: var(--r);
  background: rgba(6, 26, 51, 0.7); border: 1px solid rgba(46, 230, 255, 0.35);
  font-size: 14px; letter-spacing: 0.04em; color: var(--cyan);
}
.title {
  margin: 10px 0 2px; font-weight: 800; font-size: clamp(52px, 15.5vw, 70px); line-height: 1.02; letter-spacing: 0.02em;
  color: #fff; text-shadow: 0 4px 0 var(--blue), 0 8px 24px rgba(0, 0, 0, 0.55);
}
.title em {
  font-style: normal; display: inline-block; color: #fff;
  background: linear-gradient(180deg, #38f08f, var(--green)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: none; filter: drop-shadow(0 4px 0 #075a31) drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
}
.subtitle { font-size: 14px; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(244, 247, 251, 0.86); text-shadow: 0 2px 8px #000; }
.title-bottom { display: flex; flex-direction: column; gap: 10px; align-items: stretch; position: relative; z-index: 2; }
.pb-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r);
  background: rgba(11, 42, 79, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: var(--shadow);
  margin-right: 88px;
}
.pb-card .ic { width: 28px; height: 28px; }
.pb-card b { display: block; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pb-label { font-size: 14px; color: rgba(244, 247, 251, 0.65); }
.pb-day { margin-left: auto; text-align: right; }
.pb-day b { font-size: 15px; }
.credit { margin: 2px 0 0; text-align: center; font-size: 14px; color: rgba(244, 247, 251, 0.62); }
.title-xiaoyi {
  position: absolute; right: calc(var(--sar) + 2px); bottom: calc(var(--sab) + 190px); width: 118px; height: 118px;
  object-fit: contain; z-index: 3; pointer-events: none; opacity: 0; transform-origin: 50% 100%;
}
.title-xiaoyi.loaded { opacity: 1; animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-4px) scale(1.02, 0.98); } }

/* ---------- result ---------- */
.result-screen { background: rgba(4, 16, 34, 0.9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: rise 0.42s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.result-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 18px) calc(var(--sal) + 16px);
  display: flex; flex-direction: column; gap: 12px;
}
.result-head { text-align: center; padding-top: 6px; }
.result-kicker { display: inline-block; padding: 6px 12px; border-radius: var(--r); background: var(--green); font-weight: 800; font-size: 14px; letter-spacing: 0.12em; }
.result-time { font-weight: 800; font-size: clamp(54px, 16vw, 68px); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; line-height: 1.1; text-shadow: 0 4px 0 var(--blue); }
.result-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 8px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--r); font-size: 14px; font-weight: 800; background: rgba(255, 201, 56, 0.16); color: var(--gold); border: 1px solid rgba(255, 201, 56, 0.5); }
.badge .ic { width: 16px; height: 16px; }
.badge.green { background: rgba(12, 178, 91, 0.16); color: #4be393; border-color: rgba(12, 178, 91, 0.6); }
.result-rank { margin-top: 8px; font-size: 16px; color: rgba(244, 247, 251, 0.9); min-height: 22px; }
.result-rank b { color: var(--cyan); font-weight: 800; }
.result-rank .up { color: #4be393; font-weight: 800; }
.caster { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 84px 10px 12px; border-radius: var(--r); background: rgba(11, 42, 79, 0.85); border: 1px solid rgba(255, 255, 255, 0.1); min-height: 72px; }
.caster-face { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--green); flex: 0 0 auto; opacity: 0; }
.caster-face.loaded { opacity: 1; }
.caster p { margin: 0; font-size: 14px; line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { padding: 10px 2px 8px; border-radius: var(--r); background: rgba(11, 42, 79, 0.85); border: 1px solid rgba(255, 255, 255, 0.08); text-align: center; }
.stat .ic { width: 24px; height: 24px; }
.stat b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat span { font-size: 14px; color: rgba(244, 247, 251, 0.65); }
.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-xiaoyi { position: absolute; right: 2px; bottom: 0; width: 88px; height: 88px; object-fit: contain; pointer-events: none; opacity: 0; transform: scaleX(-1); }
.result-xiaoyi.loaded { opacity: 1; animation: hop 1.6s ease-in-out infinite; }
@keyframes hop { 0%, 100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-6px); } }

/* ---------- boards ---------- */
.board-card { border-radius: var(--r); background: rgba(11, 42, 79, 0.85); border: 1px solid rgba(255, 255, 255, 0.08); padding: 10px; }
.tabs { display: flex; gap: 6px; }
.tab {
  flex: 1 1 0; min-height: 44px; border-radius: var(--r); border: 1px solid transparent; background: rgba(255, 255, 255, 0.05);
  color: rgba(244, 247, 251, 0.7); font: 800 15px/1 var(--font); cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--blue); color: #fff; border-color: rgba(46, 230, 255, 0.45); }
.subtabs { display: flex; gap: 6px; margin-top: 8px; }
.subtabs .tab { min-height: 44px; font-size: 14px; }
.board-list { list-style: none; margin: 8px 0 0; padding: 0; min-height: 120px; }
.board-list li { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; border-radius: var(--r); font-size: 15px; }
.board-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.board-list li.me { background: rgba(12, 178, 91, 0.2); outline: 1px solid rgba(12, 178, 91, 0.6); }
.board-list .rk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: rgba(255, 255, 255, 0.08); }
.board-list .rk.g { background: var(--gold); color: #3b2b00; }
.board-list .rk.s { background: var(--silver); color: #26313d; }
.board-list .rk.b { background: var(--bronze); color: #3a1d08; }
.board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.board-list .empty { display: block; text-align: center; color: rgba(244, 247, 251, 0.6); padding: 28px 0; background: none; }
.board-note { font-size: 14px; color: rgba(244, 247, 251, 0.6); text-align: center; margin-top: 8px; min-height: 16px; }

.sheet-wrap, .modal-wrap { position: fixed; inset: 0; background: rgba(2, 10, 22, 0.66); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade 0.2s; }
.modal-wrap { align-items: center; padding: 16px; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-height: 88dvh; overflow-y: auto; touch-action: pan-y;
  background: linear-gradient(180deg, var(--deep2), var(--deep)); border-radius: var(--r) var(--r) 0 0;
  border-top: 1px solid rgba(46, 230, 255, 0.3); padding: 14px 16px calc(var(--sab) + 18px); box-shadow: var(--shadow);
  animation: rise 0.32s cubic-bezier(.2, 1.2, .4, 1);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2, .modal h2 { margin: 0; font-size: 22px; font-weight: 800; }
.sheet-head h2 small, .modal h2 small { font-size: 14px; letter-spacing: 0.14em; opacity: 0.6; margin-left: 4px; }
.sheet-lead, .modal-lead { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: rgba(244, 247, 251, 0.8); }
.me-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 14px; color: rgba(244, 247, 251, 0.8); }
.arena-card { border-radius: var(--r); background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); padding: 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.arena-card h3 { margin: 0; font-size: 16px; font-weight: 800; }
.code-show { font: 800 34px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.22em; text-align: center; color: var(--cyan); padding: 6px 0; }
.code-input {
  width: 100%; min-height: 54px; border-radius: var(--r); border: 1px solid rgba(46, 230, 255, 0.4); background: rgba(6, 26, 51, 0.9);
  color: #fff; text-align: center; font: 800 26px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.24em; text-transform: uppercase;
  -webkit-user-select: text; user-select: text; touch-action: manipulation;
}
.arena-err { min-height: 18px; font-size: 14px; color: var(--red); text-align: center; }

.modal {
  width: min(360px, 100%); background: linear-gradient(180deg, var(--deep2), var(--deep)); border-radius: var(--r);
  border: 1px solid rgba(46, 230, 255, 0.3); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow);
  animation: pop 0.3s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
.poster-modal { width: min(380px, 100%); max-height: calc(100dvh - 32px); }
.poster-modal img { width: 100%; max-height: 62dvh; object-fit: contain; border-radius: var(--r); background: #0b2a4f; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.poster-modal .modal-lead { text-align: center; margin: 0; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--sab) + 120px); transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 16px; border-radius: var(--r); background: rgba(6, 26, 51, 0.94); border: 1px solid rgba(46, 230, 255, 0.4);
  font-size: 14px; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 40; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#rotate { position: fixed; inset: 0; z-index: 100; background: var(--deep); display: grid; place-items: center; }
.rotate-card { text-align: center; font-size: 18px; font-weight: 800; }
.rotate-card small { font-weight: 400; opacity: 0.7; }
.rotate-phone { width: 46px; height: 78px; margin: 0 auto 16px; border: 4px solid var(--cyan); border-radius: var(--r); animation: turn 1.8s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
@media (max-width: 380px) {
  .btn-row .btn small { display: none; }
  .subtitle { font-size: 14px; letter-spacing: 0.06em; }
}
@media (max-height: 680px) {
  .title { font-size: clamp(44px, 13vw, 56px); }
  .brand-plate { width: 84px; height: 84px; }
  .brand-plate img { width: 58px; height: 58px; }
  .btn.big { min-height: 54px; font-size: 20px; }
  .btn { min-height: 46px; }
  .title-xiaoyi { width: 96px; height: 96px; bottom: calc(var(--sab) + 170px); }
  .stat b { font-size: 17px; }
  .result-time { font-size: 50px; }
}
