:root {
  color-scheme: dark;
  --ink: #ecf8fc;
  --muted: #839ca8;
  --cyan: #1ee6ff;
  --cyan-dim: #008c9d;
  --red: #ff4058;
  --paper: #07111c;
  font-family: "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-width: 320px;
  background: radial-gradient(circle at 50% 15%, #0b2530 0, #050b12 26rem, #010305 70%);
  color: var(--ink);
  display: grid;
  place-items: center;
  overflow: visible;
}

button { font: inherit; }

.app-shell {
  position: relative;
  width: min(100vw, 430px);
  height: min(100dvh, 900px);
  min-height: 580px;
  isolation: isolate;
  overflow: hidden;
  background: #02070c;
  border-inline: 1px solid rgba(160,120,220, .16);
  box-shadow: 0 0 70px rgba(168,85,247, .10);
}

.side-panel { position: fixed; z-index: 4; top: 0; bottom: 0; width: 280px; padding: 34px 12px; color: #3f8794; font: 9px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none; }
.side-panel-left { left: calc(50% - 520px); }
.side-panel-right { right: calc(50% - 520px); }
.side-heading { color: #b478ff; font-size: 12px; letter-spacing: .12em; border-left: 2px solid #b478ff; padding-left: 10px; }
.side-heading.amber { color: #d5a400; border-color: #d5a400; }
.side-meta { margin: 4px 0; color: #36545b; font-size: 8px; }
.side-row { display: flex; justify-content: space-between; border-top: 1px solid rgba(139,92,246, .28); padding-top: 6px; }
.side-meter { height: 2px; margin-top: 16px; background: #10252b; }
.side-meter span { display: block; width: 62%; height: 100%; background: #11cfe4; }
.side-block { margin-top: 26px; padding: 14px 12px; border: 1px solid rgba(139,92,246, .28); background: rgba(10,5,20, .58); display: grid; gap: 4px; }
.doc-block b { color: #26d8e8; font-weight: 500; margin-bottom: 2px; }
.stream-label { margin: 26px 0 10px; color: #385b62; letter-spacing: .18em; }
.stream-lines { display: grid; gap: 5px; color: #1b7988; }
.risk-block { margin-top: 30px; gap: 9px; color: #413061; }
.risk-block > span:first-child { display: flex; justify-content: space-between; color: #547177; }
.risk-block b { color: #16d9ec; font-weight: 500; }
.risk-block hr { width: 100%; border: 0; border-top: 1px solid rgba(70,45,110, .28); }
.risk-block small { color: #38275a; }
.risk { border-left: 4px solid; padding-left: 7px; }
.risk.safe { border-color: #16b66c; }.risk.blue { border-color: #4d72c7; }.risk.amber { border-color: #bf8800; }.risk.red { border-color: #d52e35; }.risk.cyan { border-color: #c084fc; color: #c084fc; }
.stat-block { gap: 5px; color: #3f555a; }
.side-alert { position: absolute; left: 12px; right: 12px; bottom: 38px; min-height: 108px; padding: 16px; border: 1px solid rgba(139,92,246, .45); display: grid; gap: 2px; color: #18c9d8; }
.side-alert i { display: block; height: 4px; margin-top: 8px; background: linear-gradient(90deg, #b478ff 0 55%, transparent 55%); }

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.panel {
  position: absolute;
  z-index: 2;
  left: 50%;
  width: min(calc(100% - 36px), 360px);
  transform: translateX(-50%);
  text-align: center;
}

.menu-panel { top: 17.5%; }

.brand-line {
  color: #7ba4af;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: .15em;
}

.brand-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.eyebrow {
  margin: 30px 0 9px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 14px;
  font-size: clamp(42px, 13vw, 58px);
  letter-spacing: .08em;
  line-height: .98;
  text-shadow: 0 0 30px rgba(192,132,252, .22);
}

h2 { margin-bottom: 10px; font-size: 30px; letter-spacing: .05em; }

.intro {
  margin: 0 auto;
  max-width: 300px;
  color: #9aadb7;
  font-size: 14px;
  line-height: 1.7;
}

.intro strong { color: var(--cyan); font-weight: 800; }

.rule-list {
  display: grid;
  gap: 8px;
  margin: 28px auto;
  color: #8ca4ae;
  font-size: 12px;
  text-align: left;
}

.rule-list span { display: flex; align-items: center; gap: 8px; }
.rule-list i { width: 7px; height: 7px; border-radius: 1px; transform: rotate(45deg); }
.rule-list .safe { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
.rule-list .danger { background: var(--red); box-shadow: 0 0 10px var(--red); }

/* 手机端（≤1040px）两侧面板会被隐藏，风险参数改为在菜单里展示，
   保证电脑与手机看到同一套说明文字。桌面端不显示这块，避免与右侧面板重复。 */
.mobile-risk { display: none; }

.action-stack { display: grid; gap: 11px; }
.action-stack.compact { margin-top: 22px; }

.button, .text-button, .pause-button {
  border: 0;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.button {
  min-height: 57px;
  padding: 11px 14px;
  border: 1px solid transparent;
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .06em;
}

.button small { display: block; margin-top: 3px; color: inherit; opacity: .65; font-size: 10px; letter-spacing: .1em; }
.button:hover, .button:focus-visible { transform: translateY(-2px); }
.button:active { transform: translateY(1px) scale(.99); }
.button:focus-visible, .pause-button:focus-visible, .text-button:focus-visible { outline: 2px solid white; outline-offset: 3px; }

.primary { background: linear-gradient(105deg, #a855f7, #c084fc); color: #001117; box-shadow: 0 9px 28px rgba(180,120,255, .26); }
.primary:hover, .primary:focus-visible { box-shadow: 0 12px 38px rgba(180,120,255, .42); }
.secondary { background: rgba(18,9,32, .91); border-color: rgba(150,110,200, .45); }
.secondary:hover, .secondary:focus-visible { background: rgba(30,14,52, .96); }
.button:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.control-tip { margin: 19px auto; color: #66808c; font-size: 10px; line-height: 1.5; }

.hud {
  position: absolute;
  z-index: 3;
  inset: max(16px, env(safe-area-inset-top)) 18px auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #a6c1ca;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
}

.pause-button { width: 34px; height: 30px; background: rgba(12,6,24, .78); border: 1px solid rgba(168,85,247, .6); color: var(--cyan); }
.pause-button:hover { background: rgba(60,28,105, .8); }

.mini-panel { top: 35%; padding: 28px 25px; background: rgba(10,5,20, .93); border: 1px solid rgba(192,132,252, .6); box-shadow: 0 0 40px rgba(168,85,247, .2); }
.mini-panel .eyebrow { margin-top: 0; }
.mini-panel h2 { font-size: 25px; }
.text-button { margin-top: 15px; padding: 8px; background: none; color: #8fabba; font-size: 12px; }
.text-button:hover { color: var(--cyan); }

.result-panel { top: 19%; }
.portrait { width: 124px; height: 124px; margin: 0 auto 15px; border: 3px solid var(--cyan); background: radial-gradient(circle at 50% 40%, #3be9e7 0 3%, #0e3140 4% 24%, #06101a 25%); box-shadow: 0 0 28px rgba(192,132,252, .22); }
.portrait.failure { border-color: var(--red); box-shadow: 0 0 28px rgba(255, 64, 88, .22); }
.result-panel .eyebrow { margin: 0 0 9px; }
.result-text { min-height: 44px; color: #8ca7b3; font-size: 13px; line-height: 1.6; }
.settlement { margin-top: 18px; padding: 18px; border: 1px solid rgba(192,132,252, .63); background: rgba(9,4,18, .76); }
.settlement span { display: block; color: #7e9aa5; font: 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }
.settlement strong { display: block; margin-top: 10px; color: white; font-size: 35px; letter-spacing: .03em; }
.result-panel.failure .settlement { border-color: rgba(255, 64, 88, .72); }
.result-panel.failure .settlement strong { color: #fff0f1; }

.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1040px) {
  .side-panel { display: none; }
  .app-shell { width: min(100vw, 430px); overflow: hidden; }
  .mobile-risk {
    display: grid;
    gap: 7px;
    margin: 16px auto 0;
    padding: 12px;
    border: 1px solid rgba(139,92,246, .28);
    background: rgba(10,5,20, .58);
    color: #413061;
    font: 9px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: left;
  }
  .mobile-risk small { color: #38275a; letter-spacing: .1em; }
}

@media (max-height: 690px) {
  .menu-panel { top: 8%; }
  .eyebrow { margin-top: 19px; }
  .rule-list { margin: 18px auto; }
  .control-tip { margin-top: 13px; }
  /* 横屏等高度紧张的机型：风险说明改为两列并压缩，尽量不让主按钮被挤出视口。 */
  .mobile-risk { grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 10px; padding: 9px; font-size: 8px; }
  .mobile-risk small { grid-column: 1 / -1; }
}

/* 横屏手机（高度很矮）：只压缩留白与标题字号，不隐藏任何说明文字，
   尽量让风险参数与「开始冲刺」按钮都留在首屏内。 */
@media (max-height: 480px) {
  .menu-panel { top: 2%; }
  .eyebrow { margin: 8px 0 5px; font-size: 10px; }
  h1 { margin-bottom: 7px; font-size: 30px; }
  .intro { font-size: 11.5px; line-height: 1.45; }
  .rule-list { margin: 8px auto; }
  .mobile-risk { margin-top: 8px; padding: 8px; }
  .action-stack { gap: 7px; }
  .control-tip { margin-top: 6px; }
}
