:root {
  --bg: #07090f;
  --panel: #10131c;
  --panel2: #161a26;
  --text: #eef1f7;
  --muted: #9aa3b5;
  --line: rgba(255,255,255,.08);
  --accent: #7c9cff;
  --accent2: #5eead4;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --ease: cubic-bezier(.22,1,.36,1);
  --font: "Inter","Noto Sans SC",system-ui,sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
html { overflow-x: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active {
  display: block;
  animation: screen-in .38s var(--ease) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* boot */
.boot-wrap {
  max-width: 920px; margin: 0 auto;
  padding: calc(20px + var(--safe-t)) 16px calc(48px + var(--safe-b));
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 24px rgba(124,156,255,.35);
  animation: logo-pulse 2.4s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%,100% { box-shadow: 0 0 18px rgba(124,156,255,.3); transform: scale(1); }
  50% { box-shadow: 0 0 32px rgba(94,234,212,.55); transform: scale(1.06); }
}
.brand-row h1 { font-size: 1.15rem; letter-spacing: -.02em; }
.brand-row p { color: var(--muted); font-size: .85rem; }
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(124,156,255,.12), transparent 70%), var(--panel);
  border: 1px solid var(--line); border-radius: 24px; padding: 24px 18px; margin-bottom: 20px;
}
.hero::before {
  content: ""; position: absolute; inset: -40% -20% auto;
  height: 70%; pointer-events: none;
  background:
    radial-gradient(circle at 20% 40%, rgba(124,156,255,.22), transparent 42%),
    radial-gradient(circle at 80% 20%, rgba(94,234,212,.16), transparent 40%);
  animation: hero-shimmer 8s ease-in-out infinite alternate;
}
@keyframes hero-shimmer {
  from { transform: translate3d(-2%,0,0) scale(1); opacity: .85; }
  to { transform: translate3d(3%,4%,0) scale(1.05); opacity: 1; }
}
.hero > * { position: relative; z-index: 1; }
.hero-top {
  display: flex; align-items: flex-start; gap: 14px; margin-bottom: 10px;
}
.hero-avatar {
  flex-shrink: 0; width: 72px; height: 72px;
  border-radius: 18px; background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  image-rendering: pixelated; image-rendering: crisp-edges;
  box-shadow: 0 8px 24px rgba(124,156,255,.18);
}
.hero h2 { font-size: clamp(1.35rem, 4.5vw, 2rem); letter-spacing: -.03em; margin-bottom: 8px; }
.hero p { color: var(--muted); max-width: 36em; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  font-size: .78rem; color: var(--text); background: rgba(255,255,255,.05);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
  animation: panel-in .32s var(--ease) both;
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.panel h3 { font-size: .95rem; margin-bottom: 12px; }
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.card {
  text-align: left; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
  min-height: 44px;
}
.card:hover, .card.selected { border-color: rgba(124,156,255,.55); transform: translateY(-1px); }
.card.selected { box-shadow: 0 0 0 1px rgba(124,156,255,.35) inset; }
.card:active { transform: scale(.98); }
.card .title { font-weight: 650; margin-bottom: 4px; }
.card .desc { color: var(--muted); font-size: .86rem; }
.card .tag { display: inline-block; margin-top: 8px; font-size: .72rem; color: var(--accent2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), #6a7fff); color: #fff;
  border-radius: 12px; padding: 12px 18px; font-weight: 650; min-height: 44px;
  box-shadow: 0 8px 24px rgba(124,156,255,.25);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), opacity .18s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost {
  background: transparent; border: 1px solid var(--line); box-shadow: none; color: var(--text);
}
.btn.block { width: 100%; }
.btn.breathe {
  animation: btn-breathe 2.2s ease-in-out infinite;
}
@keyframes btn-breathe {
  0%,100% { box-shadow: 0 8px 22px rgba(124,156,255,.22); }
  50% { box-shadow: 0 9px 26px rgba(94,234,212,.3); }
}
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.muted { color: var(--muted); font-size: .86rem; }
.hidden { display: none !important; }

/* game HUD */
.game-shell {
  max-width: 1100px; margin: 0 auto;
  padding: calc(10px + var(--safe-t)) 12px calc(72px + var(--safe-b));
}
.topbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: rgba(16,19,28,.92); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; position: sticky; top: calc(6px + var(--safe-t)); z-index: 5;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar .left {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; min-width: 0; flex: 1 1 auto;
}
.topbar-avatar {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  background: rgba(255,255,255,.04); border: 1px solid var(--line);
  image-rendering: pixelated; image-rendering: crisp-edges;
}
.topbar .cal { font-weight: 700; }
.topbar .plat { color: var(--accent2); font-size: .86rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .controls {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0; flex: 1 1 auto; justify-content: flex-end;
}
.topbar .controls .btn {
  min-height: 44px; padding: 10px 12px; font-size: .86rem;
}
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .topbar .plat { font-size: .78rem; white-space: normal; }
  .topbar .controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topbar .controls .btn { width: 100%; }
}
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0;
}
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats-secondary { margin: 8px 0 0; gap: 6px; }
.stats-secondary .stat { padding: 8px 10px; }
.stats-secondary .stat .v { font-size: .95rem; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.stat .k { color: var(--muted); font-size: .75rem; }
.stat .v { font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em; }
.stat .v.good { color: var(--good); }
.stat .v.bad { color: var(--bad); }
.bars { display: grid; gap: 8px; margin-bottom: 12px; }
.bars-compact { gap: 6px; margin: 0 0 8px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.bar-row { display: grid; grid-template-columns: 46px 1fr 32px; gap: 8px; align-items: center; font-size: .78rem; color: var(--muted); }
.bars-compact .bar-row span:last-child { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 650; font-size: .75rem; }
.bar {
  height: 7px; background: rgba(255,255,255,.06); border-radius: 99px; overflow: hidden;
}
.bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px;
  transition: width .45s var(--ease);
}
.main-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-height: 220px;
}
.main-panel h3 { margin-bottom: 8px; }
.main-panel .body { color: var(--muted); margin-bottom: 14px; white-space: pre-wrap; }
.choices { display: grid; gap: 10px; }
.choice-cards {
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .choice-cards { grid-template-columns: 1fr 1fr; }
}
.choice {
  text-align: left; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; min-height: 44px;
  transition: transform .15s var(--ease), border-color .15s, box-shadow .15s;
}
.choice:hover { border-color: rgba(124,156,255,.5); }
.choice:active { transform: scale(.985); }
.choice .sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }

.choice-card {
  display: flex; flex-direction: row; align-items: stretch; gap: 0;
  padding: 0; overflow: hidden;
  border-radius: 14px; min-height: 0;
  background: var(--panel2);
  box-shadow: 0 6px 18px rgba(0,0,0,.14);
}
.choice-card:hover {
  border-color: rgba(94,234,212,.45);
  box-shadow: 0 8px 22px rgba(94,234,212,.1), 0 6px 18px rgba(0,0,0,.18);
}
.choice-card:active { transform: scale(.985); }
.choice-card.riskish { border-color: rgba(248,113,113,.28); }
.choice-card.safeish { border-color: rgba(52,211,153,.22); }
.choice-art {
  flex: 0 0 48px; width: 48px; min-width: 48px;
  display: grid; place-items: center;
  background: #0c1220;
  border-right: 1px solid var(--line);
}
.choice-art img {
  width: 40px; height: 40px; object-fit: cover; display: block;
  border-radius: 10px;
  transition: transform .28s var(--ease);
}
.choice-card:hover .choice-art img { transform: scale(1.04); }
.choice-body { padding: 10px 12px; flex: 1; min-width: 0; }
.choice-title {
  font-weight: 750; font-size: .92rem; letter-spacing: -.01em; line-height: 1.35;
}
.choice-lines { display: grid; gap: 3px; margin-top: 6px; }
.choice-cost, .choice-gain {
  font-size: .74rem; line-height: 1.35;
}
.choice-cost { color: #fca5a5; }
.choice-gain { color: #86efac; }
.choice-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.choice-tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: .66rem; font-weight: 650; letter-spacing: .02em;
  color: var(--accent2);
  background: rgba(94,234,212,.1);
  border: 1px solid rgba(94,234,212,.28);
}
.choice-tag.risk { color: #fecaca; background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); }
.choice-tag.safe { color: #bbf7d0; background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.28); }

/* afei.13 · 小追较优建议 */
.choice-advice {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(94,234,212,.1), rgba(124,156,255,.08));
  border: 1px solid rgba(94,234,212,.28);
  color: #d8fff6;
  font-size: .82rem;
  line-height: 1.45;
}
.choice-advice-ico { flex: 0 0 auto; line-height: 1.3; }
.choice-advice-text { flex: 1; min-width: 0; color: #cffaf0; }
.choice-card.advised {
  border-color: rgba(94,234,212,.42);
  box-shadow: 0 0 0 1px rgba(94,234,212,.18) inset, 0 8px 20px rgba(94,234,212,.08);
}
.choice-prefer-badge {
  display: inline-flex; align-items: center;
  margin-left: 8px; padding: 1px 7px;
  border-radius: 999px;
  font-size: .62rem; font-weight: 750; letter-spacing: .04em;
  vertical-align: middle;
  color: #042f2e;
  background: linear-gradient(135deg, #5eead4, #a5b4fc);
  box-shadow: 0 2px 8px rgba(94,234,212,.25);
}
.choice-tag.advised {
  color: #042f2e;
  background: linear-gradient(135deg, rgba(94,234,212,.85), rgba(165,180,252,.75));
  border-color: transparent;
}
@media (max-width: 560px) {
  .choice-advice {
    margin: 0 0 10px;
    padding: 7px 9px;
    font-size: .76rem;
    border-radius: 10px;
  }
  .choice-prefer-badge { margin-left: 6px; padding: 0 6px; font-size: .58rem; }
}

.chip.soft {
  background: rgba(124,156,255,.12);
  border-color: rgba(124,156,255,.28);
  color: #c7d2fe;
}

.focus-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .focus-grid { grid-template-columns: 1fr 1fr; } }
.focus-item {
  text-align: left; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0; min-height: 44px; overflow: hidden;
  display: flex; flex-direction: row; align-items: stretch; gap: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.focus-item:active { transform: scale(.985); }
.focus-item.on {
  border-color: rgba(94,234,212,.55);
  box-shadow: 0 0 0 1px rgba(94,234,212,.25) inset, 0 8px 22px rgba(94,234,212,.1);
}
.focus-art {
  width: 52px; min-width: 52px; height: auto; background: #0c1220; overflow: hidden; align-self: stretch;
}
.focus-art img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .95; min-height: 52px; }
.focus-body { padding: 8px 10px; flex: 1; min-width: 0; }
.focus-item .tip { color: var(--muted); font-size: .74rem; margin-top: 2px; line-height: 1.35; }

@media (max-width: 560px) {
  .choice-art { flex-basis: 44px; width: 44px; min-width: 44px; }
  .choice-art img { width: 36px; height: 36px; border-radius: 9px; }
  .choice-body { padding: 9px 10px; }
  .choice-title { font-size: .88rem; }
}

/* skills overview — 默认收起，不抢首屏 */
.skills-overview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  margin: 12px 0 0;
}
.skills-overview.is-collapsed { padding: 6px 10px; }
.skills-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; min-height: 44px; padding: 4px 0;
  border: 0; background: transparent; color: inherit; cursor: pointer;
}
.skills-overview:not(.is-collapsed) .skills-head { margin-bottom: 8px; }
.skills-head h3 {
  margin: 0; font-size: .9rem; letter-spacing: -.01em;
}
.skills-sub {
  margin: 2px 0 0; color: var(--muted); font-size: .7rem; line-height: 1.4;
}
.skills-selected {
  flex-shrink: 0;
  font-size: .72rem; font-weight: 700;
  color: var(--accent2);
  background: rgba(94,234,212,.1);
  border: 1px solid rgba(94,234,212,.28);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  align-self: center;
}
.skills-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.skills-overview.is-collapsed .skills-list { display: none; }
@media (min-width: 640px) {
  .skills-list { grid-template-columns: 1fr 1fr; max-height: 220px; }
}
.skill-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: left;
  min-height: 44px;
  transition: border-color .15s, background .15s, opacity .15s;
}
.skill-row .skill-ico {
  width: 32px; height: 32px; border-radius: 8px; overflow: hidden;
  background: #0c1220; flex-shrink: 0;
}
.skill-row .skill-ico img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.skill-row .skill-main { min-width: 0; }
.skill-row .skill-name {
  font-weight: 700; font-size: .8rem; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.skill-row .skill-tip {
  color: var(--muted); font-size: .66rem; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.skill-row .skill-fx {
  font-size: .64rem; font-weight: 650; color: #c7d2fe;
  text-align: right; max-width: 96px; line-height: 1.25;
}
.skill-row.on {
  border-color: rgba(94,234,212,.55);
  background: rgba(94,234,212,.08);
  box-shadow: 0 0 0 1px rgba(94,234,212,.18) inset;
}
.skill-row.on .skill-name { color: var(--accent2); }
.skill-row.locked { opacity: .48; }
.skill-row.locked .skill-fx { color: var(--muted); }
.skill-badge {
  display: inline-block; margin-left: 4px;
  font-size: .58rem; font-weight: 700; letter-spacing: .02em;
  padding: 1px 5px; border-radius: 999px;
  vertical-align: middle;
}
.skill-badge.on { color: #06251f; background: var(--accent2); }
.skill-badge.lock {
  color: #fde68a; background: rgba(251,191,36,.15); border: 1px solid rgba(251,191,36,.3);
}
.skills-overview.flash {
  animation: skills-flash .7s var(--ease);
}
@keyframes skills-flash {
  0% { box-shadow: 0 0 0 0 rgba(94,234,212,.0); }
  35% { box-shadow: 0 0 0 3px rgba(94,234,212,.35); }
  100% { box-shadow: 0 0 0 0 rgba(94,234,212,.0); }
}
@media (max-width: 560px) {
  .topbar .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .skills-list { max-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .choice-card:hover .choice-art img { transform: none; }
  .choice-card, .focus-item { transition: none; }
}

#btn-auto:disabled {
  opacity: .55; cursor: not-allowed;
}
.log-wrap, .more-stats {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 10px 8px;
}
.log-wrap > summary, .more-stats > summary {
  list-style: none; cursor: pointer; min-height: 40px;
  display: flex; align-items: center;
  font-size: .8rem; font-weight: 650; color: var(--muted);
  user-select: none;
}
.log-wrap > summary::-webkit-details-marker,
.more-stats > summary::-webkit-details-marker { display: none; }
.log-wrap > summary::after, .more-stats > summary::after {
  content: '▾'; margin-left: auto; opacity: .55; font-size: .75rem;
}
.log-wrap[open] > summary::after, .more-stats[open] > summary::after { content: '▴'; }
.log {
  margin-top: 4px; max-height: 140px; overflow: auto; font-size: .78rem; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 8px; -webkit-overflow-scrolling: touch;
}
.peers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; opacity: .9; }
.peer {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px 4px 4px; font-size: .78rem;
}
.peer canvas {
  width: 20px; height: 20px; border-radius: 50%;
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: rgba(0,0,0,.25);
}
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%) translateY(12px);
  background: #1c2230; border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 16px; font-size: .86rem; z-index: 20;
  opacity: 0; pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show {
  display: block; opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ending */
.ending {
  max-width: 720px; margin: 0 auto;
  padding: calc(24px + var(--safe-t)) 16px calc(48px + var(--safe-b));
}
.ending-card {
  background: linear-gradient(180deg, rgba(124,156,255,.14), transparent 50%), var(--panel);
  border: 1px solid var(--line); border-radius: 24px; padding: 24px 20px; text-align: center;
  animation: panel-in .4s var(--ease) both;
}
.grade {
  display: inline-block; font-size: 2rem; font-weight: 800; letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text;
  background-clip: text; color: transparent; margin: 8px 0;
  animation: grade-pop .55s var(--ease) both;
}
@keyframes grade-pop {
  0% { transform: scale(.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.ending canvas {
  display: block; margin: 12px auto; image-rendering: pixelated; image-rendering: crisp-edges;
  animation: avatar-pop .5s var(--ease) both;
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  box-shadow: 0 10px 30px rgba(124,156,255,.2);
}
@keyframes avatar-pop {
  from { transform: scale(.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; margin-top: 16px; }
.kv div { background: var(--panel2); border-radius: 12px; padding: 10px; border: 1px solid var(--line); }
.kv .k { color: var(--muted); font-size: .75rem; }
.step-hint { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }

/* wide primary button */
.btn-wide { width: 100%; max-width: 420px; }
.row-actions .btn-wide { max-width: none; }

/* countdown */
.countdown-box {
  margin-top: 18px; padding: 14px 16px; border-radius: 16px;
  background: rgba(124,156,255,.08); border: 1px dashed rgba(124,156,255,.35);
  text-align: center;
}
.countdown-label { color: var(--muted); font-size: .85rem; }
.countdown-num {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.1; margin: 4px 0; display: inline-block;
}
.countdown-num.pop {
  animation: num-pop .38s var(--ease);
}
@keyframes num-pop {
  0% { transform: scale(.7); opacity: .4; }
  55% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); }
}

/* story */
.story-banner, .narrative, .end-story {
  background: linear-gradient(135deg, rgba(94,234,212,.08), rgba(124,156,255,.08));
  border: 1px solid rgba(94,234,212,.22); border-radius: 14px;
  padding: 12px 14px; color: #d7e7e4; font-size: .92rem; line-height: 1.65;
  margin-bottom: 12px; white-space: pre-wrap;
  animation: fade-up .35s var(--ease) both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.story-banner .kicker, .narrative .kicker {
  display: block; font-size: .72rem; color: var(--accent2);
  letter-spacing: .06em; font-weight: 700; margin-bottom: 4px;
}
.narrative { margin: 0 0 12px; }
.end-story { text-align: left; margin: 12px 0; }

/* flip cards */
.card-stage {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
  perspective: 1000px;
}
@media (min-width: 640px) {
  .card-stage.cols-2 { grid-template-columns: 1fr 1fr; }
  .card-stage.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.flip-card {
  position: relative; height: 168px; cursor: pointer;
  transform-style: preserve-3d; transition: transform .55s var(--ease);
  border: 0; background: transparent; padding: 0; width: 100%;
  min-height: 168px;
}
@media (max-width: 420px) {
  .flip-card { height: 156px; min-height: 156px; }
}
.flip-card.flipped { transform: rotateY(180deg); animation: flip-land .55s var(--ease); }
@keyframes flip-land {
  0% { transform: rotateY(0); }
  70% { transform: rotateY(188deg); }
  100% { transform: rotateY(180deg); }
}
.flip-card.selected .face-front {
  border-color: rgba(94,234,212,.65);
  box-shadow: 0 0 0 1px rgba(94,234,212,.35) inset, 0 10px 28px rgba(94,234,212,.12);
  animation: selected-pulse 1.6s ease-in-out infinite;
}
@keyframes selected-pulse {
  0%,100% { box-shadow: 0 0 0 1px rgba(94,234,212,.35) inset, 0 8px 20px rgba(94,234,212,.1); }
  50% { box-shadow: 0 0 0 2px rgba(94,234,212,.55) inset, 0 12px 28px rgba(94,234,212,.22); }
}
.flip-card.rolling { animation: card-shake .18s linear infinite; }
@keyframes card-shake {
  0%,100% { transform: translateY(0) rotateY(0); }
  50% { transform: translateY(-2px) rotateY(8deg); }
}
.flip-card .face {
  position: absolute; inset: 0; border-radius: 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid var(--line); display: flex; flex-direction: column;
  justify-content: center; padding: 14px; text-align: left;
}
.face-back {
  background:
    radial-gradient(circle at 30% 20%, rgba(124,156,255,.28), transparent 50%),
    linear-gradient(160deg, #1a2030, #10131c);
}
.face-back .mark {
  font-size: 1.6rem; font-weight: 800; letter-spacing: .12em; color: var(--accent);
  text-align: center;
}
.face-back .hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 8px; }
.face-front {
  background: var(--panel2); transform: rotateY(180deg);
}
.face-front .tag { font-size: .72rem; color: var(--accent2); font-weight: 650; margin-bottom: 6px; }
.face-front .title { font-size: 1.05rem; font-weight: 750; letter-spacing: -.02em; margin-bottom: 6px; }
.face-front .desc { color: var(--muted); font-size: .82rem; }
.face-front .meta { margin-top: 10px; font-size: .78rem; color: #c9d2e4; }

/* draw trio locked view */
.draw-locked {
  display: grid; gap: 10px; margin-top: 8px;
}
.draw-locked .item {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.draw-locked .item .k { color: var(--accent2); font-size: .72rem; font-weight: 650; }
.draw-locked .item .v { font-weight: 750; margin-top: 2px; }
.draw-locked .item .s { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* reveal modal */
.reveal-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4,6,12,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 18px;
  padding-bottom: calc(18px + var(--safe-b));
}
.reveal-mask.hidden { display: none !important; }
.reveal {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(124,156,255,.16), transparent 42%), var(--panel);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 22px 18px 18px; position: relative; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.45); max-height: 90vh; overflow-y: auto;
  animation: panel-in .32s var(--ease) both;
}
.reveal-kicker {
  font-size: .78rem; color: var(--accent2); letter-spacing: .08em; font-weight: 650;
  margin-bottom: 6px;
}
.reveal-title {
  font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: 4px;
}
.reveal-sub { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.reveal-rows { display: grid; gap: 8px; margin-bottom: 14px; }
.rv-row {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; text-align: left;
}
.rv-k { color: var(--muted); font-size: .75rem; padding-top: 2px; }
.rv-v { font-weight: 700; }
.rv-s { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.reveal .btn { width: 100%; }
.reveal .btn + .btn { margin-top: 9px; }

.name-field {
  display: flex; gap: 8px; align-items: center; margin: 10px 0 4px; flex-wrap: wrap;
}
.name-field input {
  flex: 1; min-width: 140px;
  background: #161a26; border: 1px solid var(--line); border-radius: 10px;
  color: inherit; padding: 10px 12px; font: inherit; min-height: 44px;
}

/* leaderboard */
.board-panel {
  margin-top: 16px; text-align: left;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
}
.board-panel h4 { font-size: .95rem; margin-bottom: 10px; }
.board-list { display: grid; gap: 6px; }
.board-row {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03);
  font-size: .86rem;
}
.board-row.me { border: 1px solid rgba(94,234,212,.4); background: rgba(94,234,212,.08); }
.board-row .pos { color: var(--accent); font-weight: 800; }
.board-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .who small { color: var(--muted); display: block; font-size: .72rem; }
.board-row .nw { font-weight: 700; color: var(--good); }
.board-empty { color: var(--muted); font-size: .85rem; padding: 8px 0; }

.reveal.reveal-wide { width: min(520px, 100%); }
.reveal-hint { font-size: .75rem; margin: 2px 0 10px; }
.region-field {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 6px;
}
.region-field select,
.board-filter select {
  width: 100%;
  background: #161a26; border: 1px solid var(--line); border-radius: 10px;
  color: inherit; padding: 10px 12px; font: inherit; min-height: 44px;
}
.board-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px;
}
.board-tab {
  appearance: none; border: 1px solid var(--line); background: rgba(255,255,255,.04);
  color: var(--muted); border-radius: 999px; padding: 6px 12px; font: inherit;
  font-size: .78rem; font-weight: 650; cursor: pointer; min-height: 34px;
}
.board-tab.on {
  color: #041018; background: var(--accent2); border-color: transparent;
}
.board-filter {
  display: grid; gap: 4px; margin: 0 0 10px;
}
.board-filter label { font-size: .72rem; }
.board-footnote { margin-top: 8px; font-size: .75rem; }
@media (max-width: 520px) {
  .region-field { grid-template-columns: 1fr; }
}


/* contact */
.contact-box {
  margin-top: 16px; text-align: left;
  background: linear-gradient(160deg, rgba(124,156,255,.1), rgba(94,234,212,.06));
  border: 1px solid rgba(124,156,255,.28); border-radius: 16px; padding: 14px;
}
.contact-box.compact { margin-top: 18px; }
.contact-kicker {
  font-size: .78rem; color: var(--accent2); font-weight: 700; letter-spacing: .04em; margin-bottom: 6px;
}
.contact-box p { color: var(--muted); font-size: .86rem; margin-bottom: 8px; line-height: 1.55; }
.contact-lines { font-size: .9rem; display: grid; gap: 4px; }
.contact-qr {
  display: block; width: 120px; height: 120px; object-fit: contain; margin-top: 10px;
  border-radius: 8px; background: #fff; max-width: 100%;
}
.contact-qr.card { width: min(260px, 100%); height: auto; max-height: 280px; object-fit: contain; background: #fff; padding: 6px; }
.contact-box.compact .contact-qr { width: 96px; height: 96px; }
@media (max-width: 420px) {
  .contact-box.compact .contact-qr { width: 88px; height: 88px; }
  .contact-qr.card { max-height: 220px; }
}

/* floating particles on hero (CSS-only) */
.hero-particles {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.hero-particles span {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: rgba(124,156,255,.45);
  animation: float-up 7s linear infinite;
  opacity: 0;
}
.hero-particles span:nth-child(1) { left: 12%; animation-delay: 0s; background: rgba(94,234,212,.5); }
.hero-particles span:nth-child(2) { left: 28%; animation-delay: 1.2s; width: 4px; height: 4px; }
.hero-particles span:nth-child(3) { left: 46%; animation-delay: 2.4s; }
.hero-particles span:nth-child(4) { left: 62%; animation-delay: .6s; width: 5px; height: 5px; background: rgba(251,191,36,.4); }
.hero-particles span:nth-child(5) { left: 78%; animation-delay: 3.1s; }
.hero-particles span:nth-child(6) { left: 88%; animation-delay: 4.2s; width: 3px; height: 3px; }
@keyframes float-up {
  0% { transform: translateY(110%) scale(.6); opacity: 0; }
  15% { opacity: .7; }
  100% { transform: translateY(-20%) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .screen.active, .panel, .story-banner, .narrative, .end-story, .reveal, .ending-card {
    animation: none !important;
  }
}


/* month timeline */
.timeline {
  margin: 10px 0 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 12px;
}
.timeline-meta {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px; font-size: .82rem;
}
.timeline-title { color: var(--accent2); font-weight: 700; letter-spacing: .04em; }
.timeline-cal { font-weight: 750; }
.timeline-pct { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline-track {
  position: relative; height: 10px; border-radius: 999px;
  background: rgba(255,255,255,.06); overflow: hidden;
}
.timeline-life {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, rgba(124,156,255,.55), rgba(94,234,212,.7));
  border-radius: 999px;
  transition: width .45s var(--ease);
}
.timeline-month {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #fff6, transparent);
  box-shadow: 0 0 12px rgba(94,234,212,.45);
  border-radius: 999px;
  opacity: .9;
  pointer-events: none;
}
.timeline.advancing .timeline-month {
  transition: width linear;
}
.timeline-hint {
  margin-top: 6px; font-size: .72rem; color: var(--muted);
}
@media (max-width: 640px) {
  .timeline { padding: 9px 10px 10px; }
  .timeline-track { height: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .timeline-life, .timeline-month { transition: none !important; }
}


/* ---- afei.8 hierarchy: rail + stage ---- */
/* ---- afei.9 addiction / hand-feel ---- */
/* ---- afei.10 growth companion 小追 ---- */
/* ---- afei.11 desktop density ---- */
.game-layout {
  display: flex; flex-direction: column; gap: 10px; margin-top: 10px;
}
.game-rail { display: grid; gap: 8px; }
.game-stage { min-width: 0; }
.main-panel {
  min-height: 200px;
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}
.stat .k { letter-spacing: .02em; }
.stat .v {
  font-variant-numeric: tabular-nums;
  transition: color .25s var(--ease);
}
.timeline.flowing .timeline-track {
  box-shadow: 0 0 0 1px rgba(94,234,212,.12) inset;
}
.timeline.paused {
  opacity: .92;
}
.timeline.node-hold {
  border-color: rgba(251,191,36,.35);
}
.timeline.node-hold .timeline-title { color: var(--warn); }
.timeline-hint {
  min-height: 1.2em;
}

@media (min-width: 960px) {
  .game-shell { max-width: 1320px; padding-left: 18px; padding-right: 18px; }
  .game-layout {
    display: grid;
    grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }
  .game-rail {
    position: sticky;
    top: calc(68px + var(--safe-t));
  }
  .game-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    gap: 12px;
    align-items: start;
  }
  .game-side {
    position: sticky;
    top: calc(68px + var(--safe-t));
    display: grid;
    gap: 10px;
  }
  .game-stage .skills-overview { margin-top: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 559px) {
  .game-shell { padding-left: 10px; padding-right: 10px; }
  .topbar .left .chip { display: none; }
  .topbar-avatar { width: 34px; height: 34px; }
  .stats { margin: 0; }
  .main-panel { padding: 14px 12px; border-radius: 14px; min-height: 180px; }
  .focus-art { width: 44px; min-width: 44px; }
  .focus-art img { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn.breathe { animation: none !important; }
  .stat .v { transition: none; }
}


/* ========== afei.9 hand-feel / addiction ========== */
.pressable, .btn, .choice, .focus-item, .flip-card, .skill-row, .skills-head {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled),
.choice-card:active,
.focus-item:active,
.flip-card:active {
  transform: scale(.97);
}
.choice-card {
  min-height: 52px;
  position: relative;
  overflow: hidden;
}
.choice-card.picked {
  border-color: rgba(94,234,212,.7);
  box-shadow: 0 0 0 1px rgba(94,234,212,.4) inset, 0 10px 28px rgba(94,234,212,.18);
  transform: scale(.98);
}
.choice-card.dimmed {
  opacity: .38;
  filter: grayscale(.2);
  pointer-events: none;
}
.choice-card.ripple::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(94,234,212,.28), transparent 55%);
  animation: ripple-fade .55s var(--ease) both;
  pointer-events: none;
}
@keyframes ripple-fade {
  from { opacity: .9; }
  to { opacity: 0; }
}

.choice-result {
  margin-top: 10px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(94,234,212,.1), rgba(124,156,255,.1));
  border: 1px solid rgba(94,234,212,.35);
  animation: result-in .35s var(--ease) both;
}
.choice-result.hidden { display: none !important; }
.choice-result.show { display: block; }
.choice-result.rare {
  border-color: rgba(251,191,36,.55);
  box-shadow: 0 0 0 1px rgba(251,191,36,.25) inset, 0 12px 32px rgba(251,191,36,.12);
}
.choice-result.riskish { border-color: rgba(248,113,113,.45); }
.choice-result.safeish { border-color: rgba(52,211,153,.4); }
.cr-kicker {
  font-size: .72rem; font-weight: 750; letter-spacing: .06em;
  color: var(--accent2); margin-bottom: 6px;
}
.choice-result.rare .cr-kicker { color: var(--warn); }
.cr-text { font-size: .95rem; line-height: 1.55; margin-bottom: 12px; }
.cr-ok { width: 100%; }
@keyframes result-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.main-panel.choice-rare {
  border-color: rgba(251,191,36,.28);
}
.chip.rare-chip {
  color: #fde68a;
  background: rgba(251,191,36,.14);
  border-color: rgba(251,191,36,.35);
}

.stat { position: relative; overflow: hidden; }
.stat .delta {
  position: absolute; right: 10px; top: 8px;
  font-size: .72rem; font-weight: 750;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.stat .delta.up { color: var(--good); }
.stat .delta.down { color: var(--bad); }
.stat .delta.pop { animation: delta-pop .55s var(--ease) both; }
@keyframes delta-pop {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  30% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: .85; transform: translateY(-2px); }
}
.stat.flash-up { animation: flash-up .5s var(--ease); }
.stat.flash-down { animation: flash-down .5s var(--ease); }
@keyframes flash-up {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
  40% { box-shadow: 0 0 0 1px rgba(52,211,153,.45) inset; background: rgba(52,211,153,.08); }
  100% { box-shadow: none; }
}
@keyframes flash-down {
  0% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
  40% { box-shadow: 0 0 0 1px rgba(248,113,113,.45) inset; background: rgba(248,113,113,.08); }
  100% { box-shadow: none; }
}
.stat.pulse-bad, .bar-row.pulse-bad {
  animation: pulse-bad 1.2s ease-in-out infinite;
}
@keyframes pulse-bad {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
  50% { box-shadow: 0 0 0 1px rgba(248,113,113,.4) inset; }
}
.bar > i.danger {
  background: linear-gradient(90deg, #f87171, #fb923c);
}
.bar-row span.bad { color: var(--bad); }

.delta-fly {
  position: fixed; left: 50%; top: 28%;
  transform: translateX(-50%);
  z-index: 30; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.delta-fly-item {
  padding: 6px 12px; border-radius: 999px;
  font-size: .82rem; font-weight: 700;
  background: rgba(16,19,28,.92); border: 1px solid var(--line);
  animation: fly-up .85s var(--ease) both;
  white-space: nowrap; max-width: 90vw;
}
.delta-fly-item.up { color: var(--good); border-color: rgba(52,211,153,.35); }
.delta-fly-item.down { color: var(--bad); border-color: rgba(248,113,113,.35); }
@keyframes fly-up {
  0% { opacity: 0; transform: translateY(12px) scale(.94); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-36px) scale(1); }
}

.feel-banner {
  position: fixed; left: 50%; top: calc(72px + var(--safe-t));
  transform: translateX(-50%) translateY(-8px);
  z-index: 25; pointer-events: none;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(16,19,28,.94);
  border: 1px solid rgba(94,234,212,.4);
  font-weight: 750; font-size: .88rem;
  opacity: 0; max-width: calc(100vw - 24px); text-align: center;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.feel-banner.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}
.feel-banner.overtake { border-color: rgba(124,156,255,.5); color: #c7d2fe; }
.feel-banner.stage { border-color: rgba(251,191,36,.5); color: #fde68a; }

.peer.beaten {
  border-color: rgba(52,211,153,.4);
  background: rgba(52,211,153,.08);
  color: #bbf7d0;
}
.skill-badge.near {
  color: #06251f; background: #fde68a;
}
.skill-row.near {
  border-color: rgba(251,191,36,.35);
}
.chip.stage-glow {
  animation: selected-pulse 1.2s ease-in-out 2;
}

.hud-pop { animation: hud-pop .55s var(--ease) both; }
@keyframes hud-pop {
  0% { opacity: .2; transform: scale(.85); filter: blur(2px); }
  60% { opacity: 1; transform: scale(1.06); filter: none; }
  100% { transform: scale(1); }
}

.flip-card.draw-climax .face-front {
  animation: selected-pulse .7s ease-in-out 1;
  border-color: rgba(251,191,36,.7);
  box-shadow: 0 0 0 2px rgba(251,191,36,.45) inset, 0 14px 36px rgba(251,191,36,.2);
}

.sfx-row { margin-top: 10px; display: flex; justify-content: center; }
.btn-sfx { min-height: 40px; font-size: .82rem; padding: 8px 14px; }

.menu-sheet {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.55);
  display: grid; place-items: end center;
  padding: 16px 16px calc(20px + var(--safe-b));
}
.menu-sheet.hidden { display: none !important; }
.menu-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: grid; gap: 10px;
  animation: panel-in .28s var(--ease) both;
}
.menu-card h3 { margin: 0 0 4px; font-size: 1rem; }

.end-challenge {
  margin-top: 10px;
  font-size: .88rem;
}

@media (max-width: 560px) {
  .choice-card { min-height: 54px; }
  .feel-banner { top: calc(110px + var(--safe-t)); font-size: .82rem; }
  .stat .delta { font-size: .66rem; right: 8px; top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .choice-card.ripple::after,
  .stat.flash-up, .stat.flash-down,
  .stat.pulse-bad, .bar-row.pulse-bad,
  .delta-fly-item, .hud-pop, .choice-result,
  .feel-banner {
    animation: none !important;
    transition: none !important;
  }
  .feel-banner.show { opacity: 1; }
}


/* ========== afei.10 growth companion「小追」========== */
.companion-panel {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(167,139,250,.28);
  background: linear-gradient(145deg, rgba(167,139,250,.08), rgba(94,234,212,.05));
  box-shadow: 0 8px 22px rgba(0,0,0,.12);
}
.companion-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.companion-avatar {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: rgba(11,13,18,.45);
  border: 1px solid rgba(167,139,250,.25);
  image-rendering: pixelated;
  flex: 0 0 auto;
  transition: transform .18s var(--ease, ease);
}
.companion-avatar.bounce {
  animation: companion-bounce .45s var(--ease, ease) both;
}
.companion-avatar.concern-glow {
  box-shadow: 0 0 0 1px rgba(248,113,113,.35) inset;
}
.companion-avatar.cheer-glow {
  box-shadow: 0 0 0 1px rgba(94,234,212,.45) inset, 0 8px 20px rgba(94,234,212,.15);
}
@keyframes companion-bounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.06) translateY(-2px); }
  100% { transform: scale(1); }
}
.companion-meta { min-width: 0; flex: 1; }
.companion-name-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.companion-name-row strong { font-size: .95rem; }
.companion-role {
  font-size: .72rem;
  color: var(--muted, #94a3b8);
  margin-top: 2px;
}
.companion-look {
  font-size: .72rem;
  color: #c4b5fd;
  margin-top: 2px;
}
.companion-line {
  margin: 6px 0 0;
  font-size: .84rem;
  line-height: 1.35;
  color: var(--text, #e2e8f0);
  min-height: 2.4em;
}
.companion-line.pulse {
  animation: companion-line-in .35s var(--ease, ease) both;
}
@keyframes companion-line-in {
  from { opacity: .35; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

/* mobile strip: compact, don't steal thumb space from choices */
.companion-strip {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(167,139,250,.22);
  background: rgba(167,139,250,.07);
}
.companion-strip canvas {
  width: 40px; height: 40px;
  border-radius: 10px;
  image-rendering: pixelated;
  background: rgba(11,13,18,.4);
  flex: 0 0 auto;
}
.companion-strip-body {
  min-width: 0; flex: 1;
  display: grid; gap: 1px;
  font-size: .78rem;
}
.companion-strip-body strong { font-size: .8rem; }
.companion-strip-body span {
  color: var(--muted, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.companion-ending {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(251,191,36,.28);
  background: linear-gradient(135deg, rgba(251,191,36,.08), rgba(167,139,250,.08));
  text-align: left;
}
.companion-ending canvas {
  width: 88px; height: 88px;
  border-radius: 14px;
  image-rendering: pixelated;
  background: rgba(11,13,18,.4);
  flex: 0 0 auto;
}
.companion-end-line {
  margin: 4px 0 0;
  font-size: .9rem;
  line-height: 1.4;
}

@media (max-width: 959px) {
  .companion-panel { display: none; } /* rail buddy → strip on smaller */
  .companion-strip { display: flex; }
}
@media (min-width: 960px) {
  .companion-strip { display: none !important; }
  .companion-panel { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .companion-avatar.bounce,
  .companion-line.pulse {
    animation: none !important;
  }
}


/* ========== afei.11 desktop density ========== */
.stage-core { min-width: 0; display: grid; gap: 10px; }
.game-side { display: grid; gap: 10px; min-width: 0; }

.stage-ribbon {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(124,156,255,.1), rgba(94,234,212,.06));
  font-size: .82rem;
}
.stage-ribbon-k {
  font-size: .7rem; font-weight: 750; letter-spacing: .06em;
  color: var(--accent2); text-transform: uppercase;
}
.stage-ribbon strong { font-size: .92rem; }
.stage-ribbon-sep { opacity: .35; }
.stage-ribbon.node {
  border-color: rgba(251,191,36,.4);
  background: linear-gradient(90deg, rgba(251,191,36,.12), rgba(124,156,255,.06));
}

.side-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.1);
}
.side-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: .78rem; font-weight: 750; margin-bottom: 8px;
  letter-spacing: .02em;
}
.side-head-sub { font-weight: 500; color: var(--muted); font-size: .72rem; }

.month-flash { display: grid; gap: 6px; max-height: 168px; overflow: auto; }
.month-flash-empty { font-size: .78rem; padding: 4px 0 2px; }
.month-flash-item {
  display: grid; gap: 2px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  font-size: .78rem;
}
.month-flash-item.up { border-color: rgba(52,211,153,.28); background: rgba(52,211,153,.06); }
.month-flash-item.down { border-color: rgba(248,113,113,.28); background: rgba(248,113,113,.06); }
.mf-label { color: var(--muted); font-size: .7rem; font-variant-numeric: tabular-nums; }
.mf-text { font-weight: 650; line-height: 1.35; }

.peers-panel .peers { margin-top: 0; }
.peers-race { display: grid; gap: 8px; }
.peer-race-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  border-radius: 12px;
  padding: 7px 8px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  font-size: .78rem;
}
.peer-race-row canvas {
  width: 28px; height: 28px; border-radius: 8px;
}
.peer-race-meta { min-width: 0; display: grid; gap: 4px; }
.peer-race-name {
  font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.peer-race-name em {
  font-style: normal; margin-left: 6px;
  color: var(--good); font-size: .68rem; font-weight: 700;
}
.peer-race-bar {
  position: relative; height: 6px; border-radius: 99px;
  background: rgba(255,255,255,.06); overflow: hidden;
}
.peer-race-bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, rgba(124,156,255,.55), rgba(167,139,250,.7));
}
.peer-race-bar > b {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(94,234,212,.25), rgba(94,234,212,.55));
  box-shadow: 0 0 0 1px rgba(94,234,212,.25) inset;
  pointer-events: none;
}
.peer-race-worth {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: .74rem;
  color: var(--muted); white-space: nowrap;
}
.peer-race-row.beaten {
  border-color: rgba(52,211,153,.35);
  background: rgba(52,211,153,.07);
}
.peer-race-row.beaten .peer-race-worth { color: #bbf7d0; }

.skills-overview.side-panel { margin-top: 0; padding: 8px 10px; }
.log-wrap.side-panel { margin-top: 0; }

.run-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.run-head h3 { margin: 0; }
.run-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.run-metric {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 0;
}
.run-metric span {
  display: block; color: var(--muted); font-size: .7rem; margin-bottom: 2px;
}
.run-metric strong {
  display: block; font-size: .92rem; font-weight: 750;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.run-metric strong.good { color: var(--good); }
.run-metric strong.bad { color: var(--bad); }
.run-breath { margin-bottom: 8px; font-size: .82rem; }

.companion-growth {
  display: flex; gap: 5px; margin-top: 8px;
}
.companion-growth span {
  flex: 1; height: 5px; border-radius: 99px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(167,139,250,.15);
}
.companion-growth span.on {
  background: linear-gradient(90deg, rgba(167,139,250,.55), rgba(94,234,212,.55));
  border-color: transparent;
}
.companion-growth span.now {
  box-shadow: 0 0 0 1px rgba(251,191,36,.45);
}

.boot-dense {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.boot-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 10px;
}
.boot-card-k {
  font-size: .7rem; font-weight: 750; letter-spacing: .05em;
  color: var(--accent2); margin-bottom: 4px;
}
.boot-card-t { font-weight: 750; margin-bottom: 4px; }
.boot-card p { color: var(--muted); font-size: .8rem; margin: 0; line-height: 1.4; }

/* Mobile: keep side stack tidy; hide stage ribbon (topbar already has stage) */
@media (max-width: 959px) {
  .stage-ribbon { display: none !important; }
  .game-side { gap: 8px; }
  .month-flash-panel { display: none; } /* avoid stacking flash under thumb choices */
  .peers-panel {
    background: transparent; border: 0; box-shadow: none; padding: 0;
  }
  .peers-panel .side-head { display: none; }
  .peers-race {
    display: flex; flex-wrap: wrap; gap: 8px;
  }
  .peer-race-row {
    display: inline-flex;
    grid-template-columns: none;
    width: auto;
    border-radius: 999px;
    padding: 4px 10px 4px 4px;
    gap: 6px;
  }
  .peer-race-bar, .peer-race-worth { display: none; }
  .peer-race-row canvas { width: 20px; height: 20px; border-radius: 50%; }
  .peer-race-name em { display: none; }
  .skills-overview.side-panel,
  .log-wrap.side-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: none;
  }
  .run-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .boot-wrap { max-width: 1120px; }
  .boot-dense { display: grid; }
  .stage-ribbon { display: flex; }
  .hero { padding: 28px 24px; }
  .hero-avatar { width: 88px; height: 88px; }
  .main-panel {
    min-height: 280px;
    padding: 18px 18px 16px;
    box-shadow: 0 14px 36px rgba(0,0,0,.18);
  }
  .companion-panel {
    padding: 12px 14px;
  }
  .companion-avatar { width: 84px; height: 84px; }
  .timeline { padding: 12px 14px 14px; }
  .bars-compact { padding: 10px 12px; }
  .topbar { padding: 12px 14px; }
  .skills-list {
    grid-template-columns: 1fr;
    max-height: 280px;
  }
  .run-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ending { max-width: 860px; }
  .ending-card { padding: 28px 28px; }
}

@media (min-width: 1280px) {
  .game-shell { max-width: 1440px; }
  .game-layout {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 18px;
  }
  .game-stage {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
    gap: 14px;
  }
  .boot-wrap { max-width: 1240px; }
  .boot-dense { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main-panel { min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  .month-flash-item, .peer-race-bar > i, .peer-race-bar > b {
    transition: none !important;
  }
}


/* ========== afei.12 share card + contact lead / afei.16 mobile save ========== */
.share-card-block {
  margin: 18px auto 0;
  max-width: 420px;
  padding: 14px 12px 12px;
  border-radius: 18px;
  background: rgba(124,156,255,.07);
  border: 1px solid rgba(124,156,255,.22);
  text-align: center;
}
.share-card-kicker {
  margin-bottom: 10px;
  font-size: .78rem;
  letter-spacing: .04em;
}
.share-card-preview-wrap {
  position: relative;
  display: inline-block;
  width: min(100%, 360px);
  margin: 0 auto;
}
.share-card-preview {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 14px;
  background: #0b1020;
  box-shadow: 0 12px 28px rgba(0,0,0,.28);
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
  cursor: zoom-in;
}
.share-ready-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(70, 210, 140, .92);
  color: #062014;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .04em;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.share-ready-badge.show { opacity: 1; transform: none; }
.share-card-actions {
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.share-card-actions .btn {
  min-width: 132px;
  min-height: 44px;
}
.share-card-actions .btn.share-ready {
  box-shadow: 0 0 0 1px rgba(70, 210, 140, .45);
}
.share-card-hint {
  line-height: 1.45;
  margin-top: 8px;
  font-size: .75rem;
}

.share-save-mask {
  z-index: 60;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-b, 0px));
  align-content: center;
}
.share-save-sheet {
  width: min(440px, 100%);
  max-height: min(96vh, 920px);
  overflow: auto;
  background: linear-gradient(180deg, rgba(124,156,255,.14), transparent 36%), var(--panel, #121826);
  border: 1px solid var(--line, rgba(255,255,255,.12));
  border-radius: 20px;
  padding: 16px 14px 14px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.share-save-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -.02em;
}
.share-save-img {
  display: block;
  width: min(100%, 360px);
  max-height: min(68vh, 640px);
  height: auto;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 14px;
  background: #0b1020;
  -webkit-touch-callout: default; /* WeChat/iOS long-press menu */
  -webkit-user-select: auto;
  user-select: auto;
  /* critical for WeChat/iOS long-press save — never pointer-events:none */
  pointer-events: auto;
  touch-action: manipulation;
}
.share-save-hint {
  margin: 10px 0 12px;
  font-size: .78rem;
  line-height: 1.45;
}
.share-save-sheet .btn-wide { width: 100%; min-height: 44px; }

/* ========== afei.20 WeChat share-save long-press ========== */
/* ========== afei.18/19 home cumulative + online + slogan ========== */
.home-social {
  margin: 14px 0 4px;
  padding: 14px 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(124,156,255,.28);
  background:
    linear-gradient(135deg, rgba(124,156,255,.14), rgba(94,234,212,.08) 55%, rgba(251,191,36,.06));
  box-shadow: 0 10px 28px rgba(7,9,15,.22);
}
.home-live {
  font-size: clamp(1.05rem, 3.6vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -.02em;
  color: #e8ecf8;
  line-height: 1.35;
}
.home-online {
  margin-top: 4px;
  font-size: clamp(.95rem, 3.2vw, 1.12rem);
  font-weight: 750;
  letter-spacing: -.02em;
  color: #c9d2ea;
  line-height: 1.35;
}
.home-live .live-num,
.home-online .live-num {
  color: #5eead4;
  font-variant-numeric: tabular-nums;
}
.home-online .live-num { color: #7dd3fc; }
.home-slogan {
  margin: 8px 0 0;
  font-size: clamp(.9rem, 3.2vw, 1.05rem);
  font-weight: 700;
  line-height: 1.45;
  color: #ffd58a;
  letter-spacing: -.01em;
}
@media (max-width: 560px) {
  .home-social { padding: 12px 12px 10px; }
}

.contact-lead {
  margin-top: 16px;
  text-align: center;
}
.btn-contact-lead {
  width: 100%;
  max-width: 360px;
}
.contact-modal {
  max-width: 420px;
  text-align: center;
}
.contact-modal .contact-box {
  margin-top: 8px;
  text-align: left;
}
@media (max-width: 560px) {
  .share-card-block {
    margin-top: 14px;
    padding: 14px 10px 12px;
    max-width: none;
  }
  .share-card-preview-wrap,
  .share-card-preview {
    width: min(100%, 420px);
  }
  .share-card-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 140px;
  }
  .share-save-img {
    width: 100%;
    max-height: min(72vh, 720px);
  }
}


/* ========== afei.15 ending hero + lean chips ========== */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.ending-kicker { letter-spacing: .04em; font-size: .8rem; }
.ending-hero-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 14px auto 8px;
  max-width: 420px;
  text-align: left;
}
.ending-hero-row #end-hero {
  width: 148px; height: 148px;
  flex: 0 0 auto;
  margin: 0;
  border-radius: 20px;
  background: radial-gradient(circle at 50% 30%, rgba(124,156,255,.22), rgba(11,13,18,.35));
  box-shadow: 0 12px 36px rgba(124,156,255,.28);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: avatar-pop .55s var(--ease) both;
}
.ending-hero-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.ending-hero-copy .grade {
  display: block;
  font-size: 2.6rem;
  line-height: 1;
  margin: 0 0 4px;
}
.end-rank-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text, #e8ecf8);
}
.ending-hero-copy h2 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text, #e8ecf8);
}
.end-text-lean {
  margin: 8px auto 0;
  max-width: 36em;
  font-size: .82rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.end-story-lean { display: none !important; }
.end-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px auto 0;
  max-width: 420px;
  text-align: left;
}
.end-chip {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 52px;
}
.end-chip .k {
  color: var(--muted, #94a3b8);
  font-size: .68rem;
  letter-spacing: .04em;
  margin-bottom: 2px;
}
.end-chip .v {
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: -.02em;
  line-height: 1.25;
  word-break: break-word;
}
.end-profile-chip {
  margin: 10px auto 0;
  max-width: 420px;
  font-size: .8rem;
  font-weight: 700;
  color: rgba(232,236,248,.88);
  letter-spacing: .02em;
}
.end-taunt-lean {
  margin: 4px auto 0;
  max-width: 420px;
  font-size: .72rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.end-meta-lean {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 12px;
  text-align: left;
}
.end-meta-lean > div {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 8px 9px;
}
.end-meta-lean .k {
  color: var(--muted, #94a3b8);
  font-size: .65rem;
}
.end-meta-lean > div > div:last-child {
  font-size: .82rem;
  font-weight: 700;
  margin-top: 2px;
}
.companion-ending { margin-top: 12px; padding: 10px 12px; }
.companion-ending canvas { width: 72px; height: 72px; }
.companion-end-line { font-size: .85rem; }

@media (max-width: 520px) {
  .ending-hero-row {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  .ending-hero-copy { text-align: center; }
  .ending-hero-row #end-hero { width: 132px; height: 132px; }
  .ending-hero-copy .grade { font-size: 2.2rem; }
  .end-chips { gap: 6px; }
  .end-chip { padding: 8px 10px; min-height: 48px; }
  .end-meta-lean { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 960px) {
  .ending { max-width: 880px; }
  .ending-hero-row { max-width: 520px; gap: 22px; }
  .ending-hero-row #end-hero { width: 168px; height: 168px; }
  .end-chips, .end-profile-chip, .end-taunt-lean { max-width: 520px; }
}
@media (prefers-reduced-motion: reduce) {
  .ending-hero-row #end-hero { animation: none; }
}
