/* 2026-12-03 · Exchange terminal, market replay cover and arcade overlays. */
:root {
  --mast-height: 54px;
  --banner-height: 0px;
  --top-height: calc(var(--mast-height) + var(--banner-height));
  color-scheme: light;
  --bg: #f6f7fa;
  --surface: #ffffff;
  --inset: #e8edf4;
  --line: #c9d1dc;
  --muted: #505e70;
  --white: #151e2c;
  --accent: #c73516;
  --up: #ca082d;
  --blue: #074cca;
  --chart-volume: #eaf0f7;
  font-family: "Inter","Malgun Gothic",system-ui,sans-serif;
  color: var(--white);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10131a;
  --surface: #191e28;
  --inset: #252c39;
  --line: #333e50;
  --muted: #aab4c4;
  --white: #f3f4f7;
  --accent: #ff704e;
  --up: #ff3047;
  --blue: #4580ff;
  --chart-volume: #212838;
}
* {
  box-sizing: border-box;
}
body {
  max-width: 430px;
  margin: 0 auto;
  container-type: inline-size;
}
#topbar {
  background: var(--bg);
}
.mast, main {
  padding: 0 16px max(24px,env(safe-area-inset-bottom));
}
button,
select {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 10px 15px;
  cursor: pointer;
}
button {
  touch-action: manipulation;
}
button:hover:enabled {
  filter: brightness(1.15);
  border-color: #747d90;
}
button:disabled {
  opacity: .43;
  cursor: default;
}
button:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] {
  display: none!important;
}
.mast,
.row,
.actions,
.metrics,
.market-tabs {
  display: flex;
  align-items: center;
}
.mast,
.row {
  justify-content: space-between;
}
.mast {
  height: var(--mast-height);
  padding-block: 0;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .2em;
  color: inherit;
  text-decoration: none;
  font-size: 30px;
}
.brand img { width: 1em; height: 1em; object-fit: contain; }
.brand .wordmark { display: block; width: 3.76em; height: auto; }
.up {
  color: var(--up);
}
#head-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.theme-btn, .language-btn, .flag-options button, .slot-icon {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  font-size: 22px;
  line-height: 1;
}
.theme-btn, .language-btn { border: 0; background: transparent; }
.flag-options { display: flex; }
.flag-emoji {
  width: 30px;
  height: 30px;
  display: inline-block;
  font-size: 0;
  background: url("./flag-emoji.png") 0 0 / 400% 100% no-repeat;
}
.flag-emoji[data-language="en"] { background-position-x: 33.3333%; }
.flag-emoji[data-language="ja"] { background-position-x: 66.6667%; }
.flag-emoji[data-language="zh"] { background-position-x: 100%; }
.flag-options [aria-pressed=true] { box-shadow: inset 0 -2px var(--accent); }
.popover {
  position: absolute;
  right: 0;
  top: 42px;
  z-index: 10;
  display: grid;
  background: var(--surface);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  min-width: 140px;
}
.popover button {
  text-align: left;
  background: transparent;
  border: 0;
}
.popover [aria-pressed=true] {
  color: var(--accent);
}
small, .metric-label {
  font: 600 11px/1.45 "IBM Plex Mono",ui-monospace,monospace;
  color: var(--muted);
  letter-spacing: .035em;
}
p {
  color: var(--muted);
  line-height: 1.55;
}
h1,
h2,
p {
  margin: 0;
}
h2 {
  font-size: 18px;
  letter-spacing: -.055em;
}
.down {
  color: var(--blue);
}
/* Match the native full-width anchored slot in CSS pixels in the device simulator. */
#ad-banner {
  display: grid;
  place-items: center;
  width: 100%;
  height: var(--banner-height);
  background: var(--inset);
  border-bottom: 1px solid var(--line);
}
.market-tabs {
  justify-content: space-between;
  gap: 4px;
  min-height: 50px;
}
.market-tabs button {
  display: inline-flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  white-space: nowrap;
  min-height: 46px;
  min-width: 44px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 9px 1px 7px;
  font-weight: 650;
  font-size: 12px;
  color: var(--muted);
}
.market-tabs [aria-pressed=true] {
  color: var(--white);
  box-shadow: inset 0 -2px var(--accent);
}
.market-tabs .flag-emoji { width: 21px; height: 21px; flex: none; }
.account-heading { display: flex; align-items: center; justify-content: space-between; }
.account-reset { display: grid; place-items: center; width: 40px; height: 40px; margin: -40px -24px -8px 0;
  padding: 0; border: 0; background: transparent; color: var(--up); font: 600 18px/1 system-ui; }
#account-dialog .erase-account { color: var(--up); }
#privacy-tools button { font-size: 12px; padding: 6px 9px; }
#privacy-tools a { padding: 8px 0; font-size: 12px; color: var(--muted); }
.privacy-page { padding: 20px; line-height: 1.6; overflow-wrap: anywhere; }
.privacy-page h1 { font-size: 24px; }
.privacy-page h2 { margin: 22px 0 4px; font-size: 17px; }
.privacy-page p { margin: 4px 0 12px; }
.privacy-page a { color: var(--blue); }
.privacy-page label { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 650; }
#privacy-tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;}
.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 12px;
}
.stock-selection, .account, .machine, .receipt, .investment-history {
  border: 1px solid var(--line);
  border-radius: 11px;
}
.stock-selection {
  padding: 16px;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 6px;
}
#stock-search, #stock-list {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--white);
  border-radius: 7px;
}
#stock-search { font: inherit; font-size: 14px; padding: 9px 12px; }
.stock-picker { height: 340px; display: flex; flex-direction: column; min-width: 0; }
#stock-list { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#stock-list p { margin: 10px; font-size: 13px; }
.stock-option {
  display: grid;
  position: relative;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 13px;
}
.stock-option:has(:checked) { background: var(--inset); box-shadow: inset 3px 0 var(--accent); }
.sr-only, .stock-option input {
  position: absolute;
  width: 1px; height: 1px;
  margin: 0; padding: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.stock-option:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.stock-identity { min-width: 0; display: flex; align-items: baseline; gap: 5px; }
.stock-identity b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.stock-identity small { flex-shrink: 0; }
.stock-chord { justify-self: end; display: grid; grid-template-columns: auto 5ch; gap: 3px; align-items: center; text-align: right; font: 600 11px ui-monospace,monospace; }
.stock-chord i { font-style: normal; }
#launch { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
#launch span { font-size: 1.55em; line-height: 1; }
.launch,
.primary {
  border: 0;
  color: white;
  background: #b53216;
  font-weight: 850;
  min-height: 45px;
  padding: 12px 22px;
}
.launch { padding: 8px 10px; }
.account {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
}
.balance-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; }
.balance-row strong { font-size: 27px; letter-spacing: -.055em; overflow-wrap: anywhere; }
.account > :not(.wallet-arrows) { position: relative; z-index: 1; }
.wallet-gain { --wallet-ink: var(--up); --drift: -36px; }
.wallet-loss { --wallet-ink: var(--blue); --drift: 36px; }
.wallet-amount { color: var(--wallet-ink, inherit); font-variant-numeric: tabular-nums; }
.wallet-arrows { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--wallet-ink); }
.wallet-arrows span { position: absolute; top: 45%; opacity: 0; font: bold 26px/1 system-ui;
  animation: wallet-drift 1.1s ease-out both; }
@keyframes wallet-drift {
  0% { opacity: 0; transform: translateY(calc(-1 * var(--drift))); }
  22% { opacity: .6; }
  100% { opacity: 0; transform: translateY(var(--drift)); }
}
.slot-icon { gap: 3px; padding: 6px 10px; border-radius: 10px; background: var(--inset); }
.slot-label { font-size: 12px; line-height: 1.2; font-weight: 700; white-space: nowrap; }
.slot-icon > [aria-hidden] { font-size: 33px; line-height: 1; }
.investment-history { margin: 12px 0 18px; padding: 16px; background: var(--surface); }
.status {
  max-height: 56px;
  overflow: auto;
  font-size: 13px;
  margin: 8px 0;
  overflow-wrap: anywhere;
}
.receipt h2 { font-size: 18px; margin: 0 0 12px; }
.empty {
  margin: 28px 0;
}
.back {
  padding: 7px 12px;
  background: transparent;
  font-size: 13px;
}
.investment-history ol { list-style: none; padding: 0; margin: 8px 0 0; }
.investment-history li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px;
  align-items: center; border-top: 1px solid var(--line); padding: 9px 0; font-size: 13px; }
.investment-history li > div { display: grid; gap: 3px; overflow-wrap: anywhere; }
.investment-history .movement { text-align: right; }
/* Enamel cabinet, inset reel drums, and illuminated control deck. */
#slot-dialog { padding: 0; width: min(404px, calc(100% - 20px)); border: 0; border-radius: 18px;
  background: var(--surface); color: var(--white); box-shadow: 0 18px 55px #101a3655; }
.machine { container-type: inline-size; position: relative; }
.slot-marquee { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 6px; }
.slot-marquee h2 { margin: 0; font: italic 900 clamp(28px,9cqi,38px)/1 system-ui,sans-serif; letter-spacing: -.06em; }
.slot-close { width: 40px; height: 40px; font-size: 24px; background: transparent; color: inherit; border: 0; }
.slot-body { padding: 6px 16px 16px; }
.wheel-stage { container-type: inline-size; position: relative; display: grid; place-items: center; margin: 5px auto 12px;
  width: min(80%,36dvh,286px); aspect-ratio: 1; }
.note-disc { display: block; width: 100%; border-radius: 50%; box-shadow: 0 3px 10px #14244c44; }
.wheel-pointer { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); width: 18px; height: 19px;
  background: #16243d; clip-path: polygon(0 0,100% 0,50% 100%); }
.wheel-key { display:grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.wheel-tier { display:flex; align-items:center; gap: 4px; padding: 5px; border-radius: 7px; background: var(--inset);
  font: 700 clamp(10px,3.1cqi,13px)/1.2 system-ui,sans-serif; font-variant-numeric: tabular-nums; }
.wheel-tier svg { width: 15px; height: 22px; flex: none; color: #d63249; }
.wheel-tier[data-miss=true] svg { color: #347adb; }
.wheel-tier small { display:block; margin-top:2px; opacity:.72; font-size:10px; }
.slot-deck { display:grid; margin-top:12px; }
.slot-deck button { min-height:50px; padding:6px; border:0; border-radius:10px; background:#214eaa; color:white;
  font: 800 clamp(14px,5cqi,22px)/1.15 system-ui,sans-serif; }
.slot-reveal { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(ellipse at center,#23101cd9,transparent 72%); }
.slot-reveal strong { position: relative; max-width: 98%; padding: 0 4px; text-align: center; color: #ffeb93;
  font: 950 clamp(30px,10cqi,46px)/1.05 system-ui,sans-serif; letter-spacing: -.045em;
  -webkit-text-stroke: 2px #502238; paint-order: stroke fill;
  text-shadow: 0 2px #e58d42, 1px 4px #b44b34, 2px 6px #58223a, 0 8px 16px #160b15;
  animation: slot-reveal-hit .55s both; }
.slot-reveal[data-outcome=miss] strong { color: #e5efff;
  text-shadow: 0 2px #74aac7, 1px 4px #435682, 2px 6px #252d59, 0 8px 16px #160b15; }
.slot-result-text { display: block; font-weight: 1000; line-height: 1; letter-spacing: normal; white-space: nowrap;
  -webkit-text-stroke: .026em currentColor; }
.slot-burst, .slot-burst i { position: absolute; }
.slot-burst i { width: 5px; height: 11px; border-radius: 50%; background: var(--spark); box-shadow: 0 0 6px var(--spark);
  animation: slot-firework .85s var(--delay) ease-out 2 both; }
@keyframes slot-firework {
  from { opacity: 0; transform: rotate(var(--angle)) translateY(0) scale(.3); }
  12% { opacity: 1; }
  to { opacity: 0; transform: rotate(var(--angle)) translateY(calc(-1 * var(--reach))) scale(.65); }
}
@keyframes slot-reveal-hit {
  0% { opacity: .95; transform: translateY(-18px) scale(4.44); animation-timing-function: cubic-bezier(.64,0,.92,.55); }
  40% { opacity: 1; transform: translateY(7px) scale(.92); }
  59% { transform: translateY(-5px) scale(1.07); }
  77% { transform: translateY(2px) scale(.99); }
  100% { transform: none; }
}
.slot-reveal::before { content: ""; position: absolute; width: 66%; aspect-ratio: 1; border-radius: 50%;
  border: 6px solid #ffdb81; box-shadow: 0 0 16px #ffc65c; opacity: 0; animation: slot-impact-ring .36s .22s ease-out; }
.slot-reveal[data-outcome=miss]::before { border-color: #deeeff; box-shadow: 0 0 16px #87b6ef; }
@keyframes slot-impact-ring { from { opacity: .9; transform: scale(.35); } to { opacity: 0; transform: scale(1.8); } }
.machine > p { padding: 5px 12px; color: #ffe6d0; }
@media (prefers-reduced-motion:reduce) {
  .slot-burst, .slot-reveal::before { display: none; }
  .slot-reveal strong { animation: none; }
}
dialog {
  width: min(390px, calc(100% - 28px));
  max-height: calc(100dvh - 22px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--white);
}
dialog::backdrop { background: #080a1199; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dialog-heading { margin-bottom: 12px; }
.dialog-heading button { font-size: 20px; padding: 6px 12px; }
.dialog-actions { margin-top: 20px; justify-content: end; }
.dialog { display: grid; gap: 12px; }
#play {
  min-height: calc(100dvh - var(--top-height));
  display: flex;
  flex-direction: column;
}
#controls {
  display: flex;
  flex: 1;
  flex-direction: column;
}
.quote {
  gap: 10px;
  margin: 17px 0 8px;
}
.quote strong {
  font-size: 29px;
  letter-spacing: -.055em;
}
.quote-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.percent {
  font: 600 13px ui-monospace,monospace;
}
.issuer { display: grid; gap: 1px; }
.issuer small { color: var(--muted); font-size: 10px; }
.quote-chord { font-size: 11px; color: var(--muted); }
#chart[data-cue] :is(#day-tag,#price-axis,#volume-label,#market-fx) { visibility: hidden; }
#chart {
  position: relative;
  isolation: isolate;
  height: clamp(200px,38dvh,390px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
canvas {
  display: block;
}
#chart-tools {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  margin-top: 8px;
}
#chart-tools button {
  background: transparent;
  border: 0;
  font-size: 12px;
  min-width: 38px;
  min-height: 40px;
  padding: 5px;
}
#chart-tools .ma[aria-pressed=true] {
  color: var(--white);
  text-decoration: underline 3px var(--ma);
  text-underline-offset: 5px;
}
#chart-tools .ma[aria-pressed=false] {
  color: var(--muted);
}
#chart-tools .ma + .zoom {
  margin-left: auto;
}
#chart-tools .zoom {
  font-size: 22px;
}
#day-tag,
#price-axis span,
#average-tag,
#volume-label {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  font: 11px/1.35 monospace;
}
#day-tag {
  top: 2px;
  transform: translateX(-50%);
  color: #141720;
  background: #dbdfeb;
  border-radius: 3px;
  padding: 2px 5px;
}
#price-axis {
  position: absolute;
  inset-block: 0;
  right: 5px;
  z-index: 1;
  display: grid;
  pointer-events: none;
}
#price-axis span,
#average-tag {
  transform: translateY(-50%);
}
#price-axis span {
  position: relative;
  grid-area: 1 / 1;
  place-self: start end;
  color: var(--muted);
}
#average-tag {
  right: 0;
  white-space: nowrap;
  background: #ffdc93;
  color: #362813;
  padding: 2px;
}
#average-tag { z-index: 2; }
#average-tag::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 100cqi;
  height: 1px;
  background: #db9b2f;
}
#volume-label {
  bottom: 3px;
  right: 4px;
  white-space: pre-line;
  text-align: right;
}
.track {
  height: 3px;
  background: var(--line);
  margin: 8px 0;
}
#clock {
  height: 100%;
  background: var(--accent);
  transform-origin: left;
}
.metrics {
  display: grid;
  grid-template-columns: min(var(--portrait-size, 100px), 34%) minmax(0, 1fr);
  column-gap: 6px;
  align-items: start;
  margin: 12px 0 20px;
}
.investor-face {
  align-self: start; aspect-ratio: 1; width: 100%; display: grid; place-items: center;
  overflow: hidden; border-radius: 8px; border: 1px solid var(--line);
  background: linear-gradient(150deg,var(--surface),var(--inset));
}
.investor-face img { width: 100%; height: 100%; object-fit: contain; }
.investor-face span { display: none; font-size: calc(var(--portrait-size, 85px) * .78); line-height: 1; }
.metrics .equity b { display: block; font-size: clamp(18px,5.6cqi,24px); line-height: 1.1; letter-spacing: -.04em; }
.metrics .percent { font-size: 11px; }
.metrics > div { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.portfolio-values { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 3px 6px; }
#replay-loading { width: min(270px, 80vw); }
#replay-progress { display: block; width: 100%; height: 8px; margin-top: 12px; accent-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .investor-face img { display: none; }
  .investor-face span { display: block; }
}
.metrics small {
  display: block;
  font-size: clamp(10px,2.7cqi,11px);
  margin: 2px 0;
}
.actions {
  display: grid;
  grid-template-columns: minmax(44px,1fr) repeat(2,minmax(0,4fr)) minmax(44px,1fr);
  gap: 4px;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding: 10px 0 max(10px,env(safe-area-inset-bottom));
  background: var(--bg);
  z-index: 2;
}
.actions button {
  min-height: 54px;
  padding-inline: 2px;
  font-weight: 800;
  border: 0;
}
.sell {
  background: #074ccc;
  color: white;
}
.buy {
  background: #c9082d;
  color: white;
}
.receipt {
  margin: 10px 0;
  padding: 22px;
  background: var(--surface);
  scroll-margin: 16px;
}
.receipt dl > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.receipt dd {
  margin: 0;
  text-align: right;
}
.receipt .primary {
  width: 100%;
}
#market-fx {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.fx {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.fx b {
  position: relative;
  z-index: 1;
  font: 900 italic clamp(30px,8cqi,36px)/1 Impact,"Arial Narrow",sans-serif;
  letter-spacing: -.04em;
}
.fx-loss {
  background: linear-gradient(125deg,#647eb540,transparent);
}
.fx-loss::before {
  content: "";
  position: absolute;
  inset: -10% 30%;
  background: #b7d8ff;
  clip-path: polygon(67% 0,30% 54%,48% 52%,27% 100%,75% 38%,55% 42%);
}
.fx-loss::before, .fx-loss b { animation: fadeFx .8s both; }
.fx-loss b {
  color: #aaccff;
}
.fx-gain b {
  color: #ffd291;
  animation: fadeFx .8s both;
}
.fx-gain i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 10px;
  background: var(--ink);
  animation: burst .82s ease-out both;
}
/* All app-owned overlays enter from above. Keep native dialog focus and backdrop handling. */
dialog[open], .popover, .fx, .receipt {
  animation: drop-in 240ms cubic-bezier(.22,1,.36,1) both;
}
@keyframes drop-in {
  from { translate: 0 var(--drop-start, -36px); opacity: 0; }
  to { translate: 0 0; opacity: 1; }
}
dialog { --drop-start: -42vh; }
.popover { --drop-start: -18px; max-height: calc(100dvh - var(--top-height)); overflow-y: auto; }
@keyframes fadeFx {
  0%,
  100% {
    opacity: 0;
  }
  14%,
  70% {
    opacity: 1;
  }
}
@keyframes burst {
  from {
    transform: translate(0,0);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx),var(--dy)) rotate(var(--rot));
    opacity: 0;
  }
}
@media (prefers-reduced-motion:reduce) {
  dialog[open], .popover, .receipt,
  .fx,
  .fx b,
  .fx-loss::before,
  .fx i {
    animation: none!important;
  }
  .fx-gain i {
    display: none;
  }
}
