* { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --bg: #0b1219;
  --panel: #111a22;
  --panel-hi: #17232d;
  --line: #263743;
  --text: #edf5f8;
  --muted: #a0b1bd;
  --mint: #92efd0;
  --red: #fc8d99;
  --amber: #f4cd82;
  --numbers: "Cascadia Mono", Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
.toy-container { --safe-top: max(env(safe-area-inset-top, 0px), var(--toy-top, 54px)); }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 70% 12%, #142229 0, transparent 54%), var(--bg);
  color: var(--text);
  font: 15px/1.5 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  padding: var(--safe-top) max(var(--safe-right), var(--toy-right, 0px))
    max(var(--safe-bottom), var(--toy-bottom, 0px)) max(var(--safe-left), var(--toy-left, 0px));
}
button, input { font: inherit; }
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: var(--panel-hi);
  font-weight: 650;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
button:hover:enabled { background: #223440; border-color: #57707d; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.frame { width: min(1180px, calc(100% - 56px)); margin-inline: auto; }
.site-head { border-bottom: 1px solid #23313c; background: #0c151b; }
.mast { display: flex; justify-content: space-between; align-items: center; min-height: 68px; gap: 12px; }
.brand, .brand > span, nav { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 16px; font-weight: 750; white-space: nowrap; }
.brand > span { gap: 12px; }
.brand small { color: var(--muted); font-size: 12px; font-weight: 550; }
.brand-divider { display: block; height: 16px; width: 1px; background: var(--line); }
nav { gap: 6px; }
nav button { border-color: transparent; background: transparent; min-height: 40px; color: #d4e0e6; font-size: 14px; }
main { padding-top: clamp(24px, 4.3vw, 56px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.primary { background: var(--mint); border-color: var(--mint); color: #0d2921; min-height: 46px; }
.primary:hover:enabled { background: #b3f7de; border-color: #b3f7de; }
.primary span { font-size: 1.25em; line-height: 1; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--mint); font-size: 13px; font-weight: 750; letter-spacing: .12em; }
.eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 13px #92efd074; }
.gain { color: var(--mint) !important; }
.loss { color: var(--red) !important; }
.amber { color: var(--amber); }
.foot { display: flex; justify-content: space-between; gap: 12px; padding: 20px 0 24px; font-size: 12px; color: var(--muted); }
.loading { min-height: 55vh; display: grid; place-content: center; gap: 16px; }

.hero {
  min-height: 464px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  align-items: center;
  gap: clamp(25px, 4vw, 60px);
  padding: clamp(26px, 4.8vw, 64px);
  background: radial-gradient(ellipse at 88% 0%, #1b3434, transparent 58%), var(--panel);
}
.hero h1 { margin: 16px 0 18px; font-size: clamp(44px, 6.15vw, 86px); line-height: 1.09; letter-spacing: -.065em; font-weight: 900; }
.hero h1 em { font-style: normal; color: var(--mint); }
.hero-line { color: #c1cfd7; line-height: 1.85; font-size: clamp(14px, 1.4vw, 17px); }
.start { display: inline-flex; gap: 35px; justify-content: space-between; align-items: center; padding: 0 18px; min-height: 51px; margin-top: 27px; }
.hero-chart { overflow: hidden; background: var(--panel); border: 1px solid #38505c; border-radius: 12px; }
.hero-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.hero-chart-head div { display: grid; gap: 2px; }
.hero-chart-head div span { color: var(--muted); font-size: 12px; }
.hero-chart-head strong { font-size: 17px; }
.preview-unit { border: 1px solid var(--line); padding: 3px 8px; border-radius: 5px; color: var(--muted); font-size: 12px; }
#heroCandles { height: clamp(172px, 23vw, 290px); width: 100%; }
.hero-chart-foot { display: flex; gap: 18px; padding: 10px 16px; color: var(--muted); font-size: 12px; }
.entry-metrics, .score-strip { display: grid; margin-top: 14px; }
.entry-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entry-metrics div, .score-strip div { display: grid; gap: 4px; padding: 16px clamp(12px, 3vw, 28px); }
.entry-metrics div + div, .score-strip div + div { border-left: 1px solid var(--line); }
.entry-metrics strong, .score-strip strong { font-family: var(--numbers); font-size: clamp(18px, 2.35vw, 30px); overflow-wrap: anywhere; }
.entry-metrics span, .score-strip span { color: var(--muted); font-size: 13px; }

.play-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.play-heading h1 { margin-top: 2px; font-size: clamp(23px, 3.1vw, 36px); font-weight: 800; }
.progress-box { display: grid; width: min(25%, 240px); min-width: 115px; gap: 6px; color: var(--muted); font-size: 12px; }
.progress-box > span { display: flex; justify-content: space-between; gap: 5px; }
.progress-box b { color: var(--text); white-space: nowrap; }
progress { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 40px; overflow: hidden; background: #253540; }
progress::-webkit-progress-bar { background: #253540; }
progress::-webkit-progress-value { background: var(--mint); }
progress::-moz-progress-bar { background: var(--mint); }
.score-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.play-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(285px, 345px); align-items: start; gap: 14px; margin-top: 14px; }
.market-panel { overflow: hidden; }
.panel-head, .trade-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px 8px; }
.panel-head h2, .trade-head h2 { font-size: 18px; font-weight: 800; }
.panel-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.price-block { display: grid; justify-items: end; }
.price-block span { color: var(--muted); font-size: 11px; }
.price-block strong { font-family: var(--numbers); font-size: 23px; line-height: 1.2; }
.ohlc { display: flex; gap: clamp(7px, 2vw, 18px); flex-wrap: wrap; padding: 6px 18px 8px; min-height: 33px; font-size: 11px; color: var(--muted); }
.ohlc b { color: #d9e7eb; font: 12px var(--numbers); }
.candles { height: clamp(235px, 28vw, 348px); width: 100%; }
.chart-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 18px 11px; font-size: 11px; color: var(--muted); }
.chart-foot a { margin-left: auto; }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { display: inline-block; width: 18px; border-bottom: 1px dashed #a0b1bd; }
.markers { display: inline-flex; gap: 8px; }
.markers b { font-weight: 550; }

.trading { padding: 15px; }
.trade-head { padding: 0; }
.trade-head span { color: var(--muted); font-size: 12px; }
.position { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 14px; padding: 10px 11px; background: #17242b; border-radius: 8px; }
.position div { display: grid; gap: 2px; }
.position div + div { text-align: right; }
.position span { color: var(--muted); font-size: 11px; }
.position strong { font-size: 14px; overflow-wrap: anywhere; }
.directions, .presets { display: grid; gap: 5px; }
.directions { grid-template-columns: repeat(3, 1fr); }
.presets { grid-template-columns: repeat(4, 1fr); margin-top: 7px; }
.directions button, .presets button { min-height: 36px; background: #141e26; font-size: 13px; padding-inline: 4px; }
.directions button[aria-pressed="true"], .presets button[aria-pressed="true"] { background: #233a39; color: var(--mint); border-color: #4d786e; }
.directions button[data-side="short"][aria-pressed="true"], .order[data-order-side="short"] { background: #382830; color: var(--red); border-color: #794c59; }
.directions button[data-side="reduce"][aria-pressed="true"], .order[data-order-side="reduce"] { background: #36312a; color: var(--amber); border-color: #6f5e44; }
.size-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; color: #d4e0e6; font-size: 13px; }
.size-label input { width: 52px; min-height: 30px; border: 1px solid var(--line); border-radius: 5px; background: #0d171e; color: var(--text); font: 14px var(--numbers); text-align: center; appearance: textfield; }
.size-label input::-webkit-inner-spin-button { appearance: none; }
.quote { margin: 8px 0 7px; min-height: 18px; color: var(--muted); font-size: 12px; }
.order-buttons { display: flex; gap: 6px; }
.order { flex: 1; background: #224037; border-color: #4d786e; color: var(--mint); }
.order:hover:enabled { filter: brightness(1.16); background: #285143; }
.order[data-order-side="short"]:hover:enabled { background: #49333d; }
.order[data-order-side="reduce"]:hover:enabled { background: #453b2d; }
.advance { border-top: 1px solid var(--line); margin-top: 13px; padding-top: 12px; }
.advance button { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.advance p { margin-top: 5px; color: var(--muted); font-size: 11px; text-align: center; }

.result-head { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: center; padding: clamp(19px, 4vw, 38px); background: linear-gradient(120deg, #172a2b, var(--panel) 66%); }
.result-copy h1 { font-weight: 900; font-size: clamp(39px, 6vw, 66px); letter-spacing: -.05em; line-height: 1.1; margin: 8px 0; }
.result-copy > p:not(.eyebrow) { color: #bfced6; }
.result-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.result-buttons button { min-height: 44px; }
.comparison { background: #0f181e; border: 1px solid var(--line); padding: 16px 19px; border-radius: 10px; }
.comparison > div:first-child { display: grid; }
.comparison span { color: var(--muted); font-size: 13px; }
.comparison strong { font: 750 clamp(36px, 5.2vw, 63px)/1.08 var(--numbers); overflow-wrap: anywhere; padding: 3px 0 12px; }
.benchmark { border-top: 1px solid var(--line); padding-top: 9px; display: flex; justify-content: space-between; gap: 5px; }
.benchmark b { font: 700 16px var(--numbers); overflow-wrap: anywhere; }
.comparison p { margin-top: 6px; font-size: 12px; color: var(--muted); }
.result-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reveal { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin: 14px 0; padding: 12px 18px; }
.reveal > div { display: grid; }
.reveal span, .reveal small { color: var(--muted); font-size: 12px; }
.reveal h2 { font-size: 25px; }
.reveal h2 small { font-weight: 550; white-space: normal; }
.reveal strong { font-size: 15px; }

dialog { width: min(520px, calc(100% - 28px)); max-height: min(78vh, 670px); padding: 0; border: 1px solid #39515e; border-radius: 14px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: #050b10bb; }
.dialog-body { padding: 18px; }
.dialog-body header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-body h2 { font-size: 22px; }
.close-dialog { font-size: 24px; padding: 0 11px; line-height: 1; }
.dialog-note, .empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.dialog-body h3 { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 8px; font-size: 15px; }
.dialog-body h3 span { color: var(--muted); font-size: 12px; }
.dialog-body h3 button { min-height: 34px; font-size: 12px; }
.rank-list { padding: 0; margin: 6px 0; list-style: none; }
.rank-list li { border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 0; }
.rank-list li span { color: var(--muted); font-family: var(--numbers); }
.rank-list li b { overflow-wrap: anywhere; }
.rank-list li strong { font-family: var(--numbers); }
.rules { margin: 12px 0; padding-left: 23px; color: #d0dce2; }
.rules li { padding: 4px 0 4px 2px; }
.dialog-ok { width: 100%; }
#status {
  padding: 10px 14px; position: fixed; z-index: 10; inset: auto 12px calc(14px + max(var(--safe-bottom), var(--toy-bottom, 0px)));
  width: fit-content; max-width: calc(100% - 24px); margin: auto; border: 1px solid #4a6573; border-radius: 8px;
  background: #1b2d37; color: var(--text); font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .16s ease;
}
#status.show { opacity: 1; }

@media (max-width: 790px) {
  .frame { width: calc(100% - 28px); }
  .hero { min-height: 0; gap: 18px; }
  .hero h1 { font-size: clamp(36px, 7.15vw, 61px); }
  .play-grid { grid-template-columns: minmax(0, 1fr) minmax(248px, 290px); }
  .trading { padding: 12px; }
}
@media (max-width: 620px) {
  .frame { width: calc(100% - 22px); }
  .mast { min-height: 54px; }
  .brand img { width: 28px; height: 28px; }
  nav button { padding-inline: 7px; font-size: 13px; }
  .brand > span { gap: 6px; }
  .brand small { font-size: 11px; }
  main { padding-top: 13px; }
  .hero { grid-template-columns: 1fr; padding: 17px; }
  .hero h1 { font-size: clamp(40px, 9.8vw, 58px); margin: 10px 0; }
  .start { margin-top: 15px; }
  .hero-chart-head { padding-block: 7px; }
  .hero-chart-foot { padding-block: 6px; }
  .entry-metrics, .score-strip { margin-top: 9px; }
  .entry-metrics div, .score-strip div { gap: 3px; padding: 8px 7px; }
  .entry-metrics strong, .score-strip strong { font-size: clamp(13px, 4.25vw, 21px); }
  .entry-metrics span, .score-strip span { font-size: 11px; }
  .play-grid { grid-template-columns: 1fr; gap: 9px; margin-top: 9px; }
  .progress-box { min-width: 115px; }
  .trading { padding: 10px; }
  .playing .foot { padding-bottom: 69px; }
  .playing #status { bottom: calc(67px + max(var(--safe-bottom), var(--toy-bottom, 0px))); }
  .candles { height: clamp(141px, 18vh, 198px); }
  .panel-head { padding: 8px 10px 3px; }
  .panel-head h2, .trade-head h2 { font-size: 16px; }
  .price-block strong { font-size: 19px; }
  .ohlc { min-height: 23px; padding: 2px 10px 4px; }
  .chart-foot { padding: 5px 10px 6px; gap: 4px 8px; font-size: 10px; }
  .position { margin: 6px 0; padding: 5px 8px; }
  .size-label { margin-top: 7px; }
  .presets { margin-top: 5px; }
  .directions button, .presets button { min-height: 36px; }
  .quote { margin: 3px 0; }
  .advance {
    position: fixed;
    z-index: 5;
    inset: auto var(--toy-right, 0px) max(var(--safe-bottom), var(--toy-bottom, 0px)) var(--toy-left, 0px);
    margin: 0;
    padding: 8px 11px;
    background: #101a21;
  }
  .advance p { display: none; }
  .result-head { grid-template-columns: 1fr; gap: 12px; }
  .result-buttons { margin-top: 11px; }
  .comparison { padding: 9px 12px; }
  .replay-candles { height: clamp(210px, 37vh, 320px); }
}
@media (max-width: 345px) {
  .brand-divider, .brand small { display: none; }
  .hero h1 { font-size: 37px; }
  .chart-foot .chart-key + span:not(.markers) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
