:root {
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eef2f6;
  background: #090c10;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --bg: #090c10;
  --panel: #11161d;
  --panel-2: #151b23;
  --line: #28313d;
  --muted: #8993a2;
  --text: #eef2f6;
  --up: #ff5d64;
  --down: #4ca5ff;
  --safe: #53c7ac;
  --blue: #78a8ff;
  --growth: #d6a15c;
  --theme: #d86d8b;
  --accent: #f0f2f5;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,255,255,.05), transparent 24rem),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Mobile is the product. Desktop simply previews the same narrow playfield. */
.game-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px 12px calc(104px + env(safe-area-inset-bottom));
  background: rgba(9,12,16,.68);
}

.topbar {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.brand-lockup { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { width: 20px; height: 30px; position: relative; flex: 0 0 auto; }
.brand-mark::before { content: ""; position: absolute; width: 2px; height: 30px; left: 9px; top: 0; background: #6f7781; }
.brand-mark span { position: absolute; width: 10px; height: 18px; left: 5px; top: 6px; border-radius: 2px; background: var(--up); box-shadow: 0 0 14px rgba(255,93,100,.18); }
.brand-lockup h1 { margin: 2px 0 0; font-size: 17px; line-height: 1; letter-spacing: .025em; white-space: nowrap; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; line-height: 1.1; font-weight: 900; letter-spacing: .1em; }
.top-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.icon-btn {
  min-width: 50px;
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #10151b;
  color: #bac2cd;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0,1.2fr) minmax(118px,.8fr);
  gap: 12px;
  align-items: end;
  padding: 14px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.asset-block { min-width: 0; }
.asset-block .label { color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .07em; }
.asset-block strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(31px, 9.8vw, 43px);
  line-height: .98;
  letter-spacing: -.055em;
  white-space: nowrap;
}
.asset-delta { margin-top: 7px; font-size: 13px; font-weight: 750; }
.muted { color: var(--muted); }
.goal-block { min-width: 0; padding-bottom: 1px; }
.goal-row { display: flex; justify-content: space-between; gap: 6px; color: #c9d0d9; font-size: 11px; }
.goal-row b { white-space: nowrap; }
.goal-row.small { margin-top: 6px; color: var(--muted); font-size: 10px; }
.progress-track { height: 5px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: #242b35; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e8ebef, #818995); transition: width .35s ease; }

.portfolio-panel { margin-top: 18px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h2 { margin: 3px 0 0; font-size: 19px; line-height: 1.1; letter-spacing: -.025em; }
.market-head { align-items: center; }
.allocation-total { text-align: right; flex: 0 0 auto; }
.allocation-total span { display: block; color: var(--muted); font-size: 10px; }
.allocation-total strong { font-size: 21px; }

.market-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.market-card {
  --tone: #aaa;
  position: relative;
  min-width: 0;
  min-height: 172px;
  padding: 11px 10px 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(255,255,255,.017), transparent 52%), var(--panel);
}
.market-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--tone); opacity: .88; }
.market-card.safe { --tone: var(--safe); }
.market-card.blue { --tone: var(--blue); }
.market-card.growth { --tone: var(--growth); }
.market-card.theme { --tone: var(--theme); }
.market-top { display: flex; justify-content: space-between; gap: 5px; min-height: 57px; }
.ticker { color: var(--tone); font-size: 10px; font-weight: 950; letter-spacing: .09em; }
.market-card h3 { margin: 3px 0 2px; font-size: 16px; line-height: 1.15; }
.market-card p { margin: 0; }
.market-card .market-top p { color: var(--muted); font-size: 11px; line-height: 1.35; }
.risk-meter { display: flex; gap: 2px; padding-top: 3px; flex: 0 0 auto; }
.risk-dot { width: 3px; height: 10px; border-radius: 99px; background: #313945; }
.risk-dot.on { background: var(--tone); }
/* Long desktop copy is intentionally removed from the main mobile loop. */
.market-desc { display: none; }
.allocation-row { display: grid; grid-template-columns: 40px minmax(0,1fr) 40px; align-items: center; gap: 4px; margin-top: 9px; }
.step-btn {
  width: 40px;
  height: 44px;
  border: 1px solid #323b47;
  border-radius: 11px;
  background: #0d1218;
  font-size: 23px;
  line-height: 1;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.step-btn:active { transform: scale(.96); }
.allocation-value { min-width: 0; text-align: center; }
.allocation-value strong { display: block; font-size: 18px; line-height: 1.05; }
.allocation-value span { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.allocation-track { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 99px; background: #252d37; }
.allocation-track div { height: 100%; background: var(--tone); transition: width .18s ease; }
.market-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.market-foot b { color: var(--tone); font-size: 11px; }

.cash-strip {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 7px;
  padding: 8px 11px;
  border: 1px dashed #343d49;
  border-radius: 13px;
}
.cash-strip b { display: block; font-size: 12px; }
.cash-strip span { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.cash-strip strong { flex: 0 0 auto; color: #cfd5dd; font-size: 19px; }

/* Result is kept close to the controls so every tap gives immediate feedback. */
.result-panel { min-height: 92px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.empty-result h2 { margin: 4px 0 5px; font-size: 18px; }
.empty-result p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.result-head { align-items: center; margin-bottom: 8px; }
.result-head h2 { font-size: 18px; }
.positive { color: var(--up); }
.negative { color: var(--down); }
.result-total { font-size: 16px; white-space: nowrap; }
.result-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.result-chip { min-width: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.result-chip span, .result-chip em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-chip span { color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .07em; }
.result-chip b { display: block; margin: 2px 0; font-size: 15px; }
.result-chip em { color: #aeb6c1; font-size: 10px; font-style: normal; }
.result-chip.win b { color: var(--up); }
.result-chip.lose b { color: var(--down); }
.result-chip.cash b { color: #d4dae1; }

/* History is secondary on mobile: shorter and below the play controls. */
.chart-panel { margin-top: 18px; }
.chart-legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 800; }
.chart-legend i { width: 7px; height: 7px; display: inline-block; margin-left: 3px; border-radius: 2px; }
.chart-legend .up { background: var(--up); }
.chart-legend .down { background: var(--down); }
.chart {
  min-height: 100px;
  height: 100px;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow: hidden;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(rgba(255,255,255,.027) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px),
    #0e1319;
  background-size: 100% 25px, 35px 100%;
}
.candle-wrap { flex: 1 1 0; min-width: 4px; max-width: 16px; height: 72px; position: relative; display: flex; justify-content: center; }
.candle-stick { width: min(8px,72%); min-width: 4px; position: relative; border-radius: 2px; transition: height .25s ease; }
.candle-stick::before { content: ""; width: 1px; height: calc(100% + 10px); position: absolute; left: 50%; top: -5px; transform: translateX(-50%); background: inherit; opacity: .65; z-index: 0; }
.candle-stick::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; background: inherit; }
.candle-stick.up { background: var(--up); }
.candle-stick.down { background: var(--down); }
.chart-empty { width: 100%; height: 76px; display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.ghost-candles { height: 45px; display: flex; align-items: center; gap: 6px; opacity: .2; }
.ghost-candles i { width: 5px; border-radius: 2px; background: #aeb6c1; }
.chart-empty span { margin-top: -11px; }

.sticky-action {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(7px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 16px), 464px);
  display: grid;
  grid-template-columns: minmax(0,.8fr) minmax(172px,1.2fr);
  align-items: center;
  gap: 7px;
  padding: 7px 7px 7px 11px;
  border: 1px solid #343d48;
  border-radius: 16px;
  background: rgba(13,17,23,.96);
  backdrop-filter: blur(18px);
  box-shadow: 0 13px 36px rgba(0,0,0,.4);
}
.bet-summary { min-width: 0; }
.bet-summary span { display: block; color: var(--muted); font-size: 9px; }
.bet-summary b { display: block; margin-top: 2px; overflow: hidden; font-size: clamp(13px,4vw,17px); text-overflow: ellipsis; white-space: nowrap; }
.candle-btn {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: #edf0f3;
  color: #0b0f14;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .055em;
  cursor: pointer;
  touch-action: manipulation;
}
.candle-btn i { width: 7px; height: 23px; position: relative; border-radius: 1px; background: var(--up); }
.candle-btn i::before { content: ""; position: absolute; width: 1px; height: 31px; left: 3px; top: -4px; background: var(--up); }
.candle-btn:disabled { opacity: .48; cursor: default; }
.candle-btn.rolling i { animation: pulse-candle .32s infinite alternate; }
@keyframes pulse-candle { to { transform: scaleY(1.45); } }

footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 19px; padding-bottom: 2px; color: #515a66; font-size: 9px; letter-spacing: .06em; }

.toast {
  position: fixed;
  z-index: 60;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%,-10px);
  width: min(calc(100% - 24px), 440px);
  padding: 11px 12px;
  border: 1px solid #3a4450;
  border-radius: 12px;
  background: #151b22;
  color: #e5e9ee;
  text-align: center;
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%,0); }

.modal-backdrop { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 14px; background: rgba(4,6,8,.86); backdrop-filter: blur(12px); }
.modal-card { width: min(400px,100%); padding: 24px 20px; border: 1px solid #333c47; border-radius: 20px; background: #11161d; box-shadow: 0 25px 80px rgba(0,0,0,.42); }
.modal-card h2 { margin: 6px 0 9px; font-size: 29px; letter-spacing: -.04em; }
.modal-card p { color: #aab3bf; font-size: 13px; line-height: 1.6; }
.primary-modal-btn { width: 100%; min-height: 52px; margin-top: 18px; border: 0; border-radius: 12px; background: #edf0f3; color: #0c1015; font-size: 13px; font-weight: 900; cursor: pointer; }
.text-btn { width: 100%; min-height: 46px; border: 0; background: transparent; color: #949eab; font-size: 12px; cursor: pointer; }
.intro-card { text-align: center; }
.intro-candle { width: 48px; height: 68px; margin: 0 auto 16px; position: relative; }
.intro-candle i { position: absolute; width: 2px; height: 68px; left: 23px; top: 0; background: #59626e; }
.intro-candle span { position: absolute; width: 24px; height: 43px; left: 12px; top: 12px; border-radius: 3px; background: var(--up); box-shadow: 0 0 30px rgba(255,93,100,.18); }
.intro-rule { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; }
.intro-rule span { color: var(--muted); }

/* Mobile play order: total asset -> daily result -> asset candles -> portfolio. */
.game-shell { display: flex; flex-direction: column; }
.topbar { order: 1; }
.hero-panel { order: 2; }
.result-panel { order: 3; }
.chart-panel { order: 4; }
.portfolio-panel { order: 5; }
footer { order: 6; }
.sticky-action { order: 7; }

@media (max-width: 370px) {
  .game-shell { padding-left: 9px; padding-right: 9px; }
  .brand-lockup .eyebrow { display: none; }
  .brand-lockup h1 { font-size: 16px; }
  .icon-btn { min-width: 46px; padding-inline: 6px; font-size: 10px; }
  .hero-panel { grid-template-columns: minmax(0,1fr) 116px; gap: 8px; }
  .asset-block strong { font-size: clamp(29px,9.4vw,36px); }
  .market-grid { gap: 6px; }
  .market-card { padding-left: 9px; padding-right: 8px; }
  .market-card .market-top p { font-size: 10px; }
  .allocation-row { grid-template-columns: 38px minmax(0,1fr) 38px; }
  .step-btn { width: 38px; }
  .sticky-action { width: calc(100% - 12px); grid-template-columns: minmax(0,.72fr) minmax(165px,1.28fr); }
}

@media (min-width: 700px) {
  body::before,
  body::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255,255,255,.04);
    pointer-events: none;
  }
  body::before { left: calc(50% - 240px); }
  body::after { right: calc(50% - 240px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* v0.4 news signals: read the close, overnight shock, and morning flow before betting. */
.news-panel { margin-top: 18px; }
.news-head { align-items: center; }
.news-head h2 { font-size: 18px; }
.news-rule {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #333c47;
  border-radius: 999px;
  color: #9ca6b3;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .04em;
}
.news-timeline { display: grid; gap: 7px; }
.news-card {
  position: relative;
  overflow: hidden;
  padding: 11px 11px 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 60%), var(--panel);
}
.news-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #5c6673; }
.news-card.positive::before { background: var(--up); }
.news-card.negative::before { background: var(--down); }
.news-card.volatile::before { background: var(--growth); }
.news-card.neutral::before { background: #697483; }
.news-meta { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.news-meta span { color: #697483; font-size: 9px; font-weight: 850; letter-spacing: .06em; }
.news-meta b { color: #b9c1cb; font-size: 10px; letter-spacing: .04em; }
.news-card h3 { margin: 0; font-size: 14px; line-height: 1.35; letter-spacing: -.015em; }
.news-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.news-impacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.news-impact { padding: 4px 6px; border: 1px solid #303946; border-radius: 7px; background: #0d1218; color: #aab3bf; font-size: 9px; font-weight: 900; letter-spacing: .035em; }
.news-impact.up { color: var(--up); border-color: rgba(255,93,100,.27); }
.news-impact.down { color: var(--down); border-color: rgba(76,165,255,.27); }
.news-impact.volatile { color: var(--growth); border-color: rgba(214,161,92,.27); }
.news-impact.neutral { color: #87919f; }
.news-footnote { margin: 7px 2px 0; color: #697483; font-size: 10px; line-height: 1.45; }
.news-footnote b { color: #aeb6c1; }

/* Expansion card was already part of the game loop; keep it compact on mobile. */
.expansion-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.expansion-copy { min-width: 0; }
.expansion-title { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; }
.expansion-title strong { font-size: 20px; line-height: 1; }
.expansion-title span { font-size: 11px; font-weight: 800; }
.expansion-copy p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.milestone-track { flex: 0 0 101px; display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; }
.milestone-track i { height: 6px; border-radius: 99px; background: #28313b; }
.milestone-track i.done { background: #717b87; }
.milestone-track i.current { outline: 1px solid #c9d0d9; outline-offset: 1px; }

/* Mobile play order: total asset -> daily result -> candles -> news -> expansion -> portfolio. */
.topbar { order: 1; }
.hero-panel { order: 2; }
.result-panel { order: 3; }
.chart-panel { order: 4; }
.news-panel { order: 5; }
.expansion-panel { order: 6; }
.portfolio-panel { order: 7; }
footer { order: 8; }
.sticky-action { order: 9; }

/* v0.5 mobile readability: 14px is the normal reading floor.
   Only compact metadata/status labels intentionally go below it. */
:root { font-size: 14px; }
body { font-size: 14px; }

/* Single-line section hierarchy: when a real title exists, no kicker above it. */
.brand-lockup h1 { margin-top: 0; font-size: 18px; }
.section-head h2 { margin-top: 0; }
.asset-block .label,
.asset-delta,
.goal-row,
.allocation-total span,
.market-card .market-top p,
.allocation-value span,
.cash-strip b,
.cash-strip span,
.empty-result p,
.result-total,
.bet-summary span,
.candle-btn,
.toast,
.modal-card p,
.primary-modal-btn,
.text-btn,
.intro-rule,
.news-card p,
.expansion-title span,
.expansion-copy p {
  font-size: 14px;
}

/* Compact metadata may be smaller than the 14px reading baseline. */
.ticker,
.market-foot,
.result-chip-top span,
.result-chip-top small,
.chart-legend,
.news-meta span,
.news-meta b,
.news-impact,
.news-footnote,
.goal-row.small,
footer {
  font-size: 12px;
}
.market-foot b { font-size: 14px; }
.chart-empty { font-size: 14px; }
.news-card h3 { font-size: 16px; }
.news-rule { font-size: 12px; }

/* Bigger text needs a little more breathing room in market cards. */
.market-top { min-height: 66px; }
.cash-strip { min-height: 56px; }

/* Daily results: keep the 2-column board, but make each result a single horizontal strip. */
.result-panel { min-height: 0; }
.result-head { margin-bottom: 7px; }
.result-head h2 { margin: 0; font-size: 17px; line-height: 1.2; }
.result-grid { gap: 5px; }
.result-chip {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(42px,.72fr) auto minmax(0,1fr);
  align-items: center;
  column-gap: 6px;
  padding: 5px 7px;
}
.result-chip-top {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.05;
}
.result-chip-top span,
.result-chip-top small,
.result-chip em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-chip-top span { display: block; color: var(--muted); font-weight: 900; letter-spacing: .055em; }
.result-chip-top small { display: block; color: #6f7a88; font-weight: 800; letter-spacing: .02em; }
.result-chip b { display: block; margin: 0; font-size: 16px; line-height: 1; white-space: nowrap; }
.result-chip em { display: block; color: #aeb6c1; font-size: 13px; line-height: 1.1; font-style: normal; text-align: right; }

@media (max-width: 370px) {
  .brand-lockup h1 { font-size: 17px; }
  .icon-btn { font-size: 13px; }
  .market-card .market-top p { font-size: 14px; }
  .result-chip { grid-template-columns: minmax(38px,.68fr) auto minmax(0,.92fr); column-gap: 4px; padding-inline: 6px; }
  .result-chip em { font-size: 12px; }
}
.icon-btn { font-size: 14px; }

/* v0.7 market cards: replace the old LAST/BET row with compact cumulative candles. */
.market-candle-history {
  position: relative;
  height: 30px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  margin: 4px 0 2px;
  padding: 2px 1px;
  overflow: hidden;
  border-top: 1px solid rgba(255,255,255,.045);
  border-bottom: 1px solid rgba(255,255,255,.045);
}
.market-candle-history::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 50%;
  height: 1px;
  background: rgba(255,255,255,.07);
  pointer-events: none;
}
.market-candle-history.empty {
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.mini-market-candle {
  position: relative;
  flex: 1 1 0;
  min-width: 2px;
  max-width: 7px;
  height: 100%;
  z-index: 1;
}
.mini-market-candle::before,
.mini-market-candle::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}
.mini-market-candle::before {
  width: 1px;
  height: calc(var(--candle-h) + 4px);
  opacity: .55;
}
.mini-market-candle::after {
  width: min(4px, 82%);
  height: var(--candle-h);
  border-radius: 1px;
}
.mini-market-candle.up { color: var(--up); }
.mini-market-candle.down { color: var(--down); }
.mini-market-candle.flat { color: #7b8592; }
.mini-market-candle.up::before,
.mini-market-candle.up::after { bottom: 50%; }
.mini-market-candle.down::before,
.mini-market-candle.down::after { top: 50%; }
.mini-market-candle.flat::before,
.mini-market-candle.flat::after {
  top: 50%;
  transform: translate(-50%, -50%);
}
.mini-market-candle.flat::before { height: 7px; }
.mini-market-candle.flat::after { height: 3px; }

/* Keep the portfolio cards compact even with the per-market history strip. */
.market-card { min-height: 176px; }
.market-top { min-height: 62px; }

/* v0.8 tighter top flow: title -> total asset -> previous-day result. */
.topbar {
  margin-bottom: 0;
}

.hero-panel {
  margin-top: 4px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17,22,29,.48);
}

.result-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}


/* v0.8 layout cleanup: consistent 15px spacing between major sections. */
.topbar { margin-bottom: 0; }
.hero-panel { margin-top: 15px; }
.result-panel,
.chart-panel,
.news-panel,
.portfolio-panel { margin-top: 15px; }
.result-head { justify-content: flex-start; }

/* v0.10 result impact FX: Korean market convention = red up, blue down. */
.result-head h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  color: var(--text);
}
.result-day,
.result-money,
.result-divider { color: var(--text); }
.result-percent { display: inline-block; color: var(--text); }
.result-percent.positive { color: var(--up); }
.result-percent.negative { color: var(--down); }
.result-percent.neutral { color: #fff; }
.fomo-callout {
  position: relative;
  isolation: isolate;
  margin-bottom: 7px;
  color: #c5ccd5;
  font-size: 14px;
  line-height: 1.35;
}

/* Weak up: only the result percentage and market guide pop red. */
.result-percent.impact-up-weak,
.fomo-callout.impact-up-weak {
  animation: omc-up-text-pop .72s cubic-bezier(.18,.78,.2,1);
}
@keyframes omc-up-text-pop {
  0% { color: var(--up); text-shadow: 0 0 0 rgba(255,93,100,0); transform: scale(1); }
  22% { color: #fff; text-shadow: 0 0 18px rgba(255,93,100,.95), 0 0 34px rgba(255,93,100,.58); transform: scale(1.075); }
  48% { color: var(--up); text-shadow: 0 0 10px rgba(255,93,100,.65); transform: scale(1.018); }
  100% { text-shadow: 0 0 0 rgba(255,93,100,0); transform: scale(1); }
}

/* Weak down: a blue current runs through the result percentage and guide only. */
.result-percent.impact-down-weak,
.fomo-callout.impact-down-weak {
  color: transparent !important;
  background-image: linear-gradient(90deg, var(--down) 0%, #dff0ff 40%, var(--down) 72%);
  background-size: 240% 100%;
  background-position: 120% 0;
  -webkit-background-clip: text;
  background-clip: text;
  animation: omc-down-text-flow .88s ease-out;
}
@keyframes omc-down-text-flow {
  0% { background-position: 120% 0; filter: drop-shadow(0 0 0 rgba(76,165,255,0)); }
  35% { filter: drop-shadow(0 0 9px rgba(76,165,255,.72)); }
  100% { background-position: -120% 0; filter: drop-shadow(0 0 0 rgba(76,165,255,0)); }
}

/* Medium moves color across the whole previous-day result panel. */
.result-panel.impact-up-medium,
.result-panel.impact-down-medium {
  position: relative;
  isolation: isolate;
  border-radius: 14px;
}
.result-panel.impact-up-medium::after,
.result-panel.impact-down-medium::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: -4px;
  border-radius: 16px;
  pointer-events: none;
}
.result-panel.impact-up-medium::after {
  background: radial-gradient(circle at 50% 35%, rgba(255,93,100,.45), rgba(255,93,100,.12) 48%, transparent 78%);
  animation: omc-up-panel-pop .84s cubic-bezier(.15,.72,.18,1);
}
@keyframes omc-up-panel-pop {
  0% { opacity: 0; transform: scale(.94); box-shadow: 0 0 0 rgba(255,93,100,0); }
  24% { opacity: 1; transform: scale(1.018); box-shadow: 0 0 30px rgba(255,93,100,.5), inset 0 0 30px rgba(255,93,100,.16); }
  100% { opacity: 0; transform: scale(1.045); box-shadow: 0 0 0 rgba(255,93,100,0); }
}
.result-panel.impact-down-medium::after {
  background: linear-gradient(110deg, transparent 15%, rgba(76,165,255,.08) 30%, rgba(76,165,255,.42) 50%, rgba(190,225,255,.2) 58%, transparent 78%);
  background-size: 260% 100%;
  animation: omc-down-panel-flow .98s ease-out;
}
@keyframes omc-down-panel-flow {
  0% { opacity: 0; background-position: 120% 0; box-shadow: 0 0 0 rgba(76,165,255,0); }
  22% { opacity: 1; box-shadow: 0 0 24px rgba(76,165,255,.34); }
  100% { opacity: 0; background-position: -120% 0; box-shadow: 0 0 0 rgba(76,165,255,0); }
}

/* Strong result: cover the entire mobile playfield, not the desktop preview gutters. */
.result-effect-layer {
  position: fixed;
  z-index: 45;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(100%, 480px);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
}
.result-effect-layer.impact-up-strong {
  background:
    radial-gradient(circle at 50% 58%, rgba(255,255,255,.3) 0 4%, rgba(255,93,100,.55) 15%, rgba(255,93,100,.18) 52%, transparent 78%),
    rgba(255,38,48,.08);
  animation: omc-up-screen-burst 1.05s cubic-bezier(.16,.74,.2,1);
}
@keyframes omc-up-screen-burst {
  0% { opacity: 0; filter: saturate(1); }
  14% { opacity: .95; filter: saturate(1.4); }
  36% { opacity: .58; }
  100% { opacity: 0; filter: saturate(1); }
}
.result-effect-layer.impact-down-strong {
  background:
    linear-gradient(180deg, transparent 0%, rgba(76,165,255,.08) 18%, rgba(76,165,255,.5) 48%, rgba(195,228,255,.14) 58%, transparent 82%);
  background-size: 100% 260%;
  animation: omc-down-screen-flow 1.15s ease-out;
}
@keyframes omc-down-screen-flow {
  0% { opacity: 0; background-position: 0 -120%; }
  18% { opacity: .88; }
  100% { opacity: 0; background-position: 0 120%; }
}

@media (prefers-reduced-motion: reduce) {
  .result-percent.impact-up-weak,
  .fomo-callout.impact-up-weak,
  .result-percent.impact-down-weak,
  .fomo-callout.impact-down-weak,
  .result-panel.impact-up-medium::after,
  .result-panel.impact-down-medium::after,
  .result-effect-layer.impact-up-strong,
  .result-effect-layer.impact-down-strong {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* v0.11: result line colors + portfolio editor as a dedicated mobile sheet. */
.result-summary,
.result-summary .result-day,
.result-summary .result-percent,
.result-summary .result-money,
.result-summary .result-divider {
  color: #fff;
}
.result-summary.positive,
.result-summary.positive .result-day,
.result-summary.positive .result-percent,
.result-summary.positive .result-money,
.result-summary.positive .result-divider {
  color: var(--up);
}
.result-summary.negative,
.result-summary.negative .result-day,
.result-summary.negative .result-percent,
.result-summary.negative .result-money,
.result-summary.negative .result-divider {
  color: var(--down);
}
.result-summary.neutral,
.result-summary.neutral .result-day,
.result-summary.neutral .result-percent,
.result-summary.neutral .result-money,
.result-summary.neutral .result-divider {
  color: #fff;
}

/* Weak movement now affects DAY + percent + amount together, plus the guide line. */
.result-summary.impact-up-weak,
.fomo-callout.impact-up-weak {
  animation: omc-up-text-pop .72s cubic-bezier(.18,.78,.2,1);
}
.result-summary.impact-down-weak,
.fomo-callout.impact-down-weak {
  color: transparent !important;
  -webkit-text-fill-color: transparent;
  background-image: linear-gradient(90deg, var(--down) 0%, #dff0ff 40%, var(--down) 72%);
  background-size: 240% 100%;
  background-position: 120% 0;
  -webkit-background-clip: text;
  background-clip: text;
  animation: omc-down-text-flow .88s ease-out;
}
.result-summary.impact-down-weak > * {
  color: transparent !important;
  -webkit-text-fill-color: transparent;
}

body.portfolio-open { overflow: hidden; }
.portfolio-modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  justify-content: center;
  background: rgba(3,5,8,.86);
  backdrop-filter: blur(10px);
}
.portfolio-modal-sheet {
  width: min(100%, 480px);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0b0f14;
  border-left: 1px solid rgba(255,255,255,.05);
  border-right: 1px solid rgba(255,255,255,.05);
}
.portfolio-modal-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(17,22,29,.98);
}
.portfolio-modal-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
  letter-spacing: -.025em;
}
.portfolio-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
}
.portfolio-modal-head .allocation-total span { font-size: 12px; }
.portfolio-modal-head .allocation-total strong { font-size: 20px; }
.portfolio-close-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #343d48;
  border-radius: 12px;
  background: #0d1218;
  color: #dce2e9;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.portfolio-modal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 12px 18px;
  -webkit-overflow-scrolling: touch;
}
.portfolio-modal-scroll .market-grid { gap: 8px; }
.portfolio-modal-scroll .market-card { background-color: #11161d; }
.portfolio-modal-scroll .cash-strip { margin-top: 10px; }
.portfolio-modal-action {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0,.8fr) minmax(172px,1.2fr);
  align-items: center;
  gap: 7px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom)) 12px;
  border-top: 1px solid #343d48;
  background: rgba(13,17,23,.98);
  box-shadow: 0 -12px 28px rgba(0,0,0,.24);
}
.portfolio-modal-action .candle-btn { width: 100%; }
.toast { z-index: 130; }

/* Main screen no longer carries the tall portfolio board. */
.portfolio-panel { display: none; }

@media (max-width: 370px) {
  .portfolio-modal-scroll { padding-left: 9px; padding-right: 9px; }
  .portfolio-modal-action {
    grid-template-columns: minmax(0,.72fr) minmax(165px,1.28fr);
    padding-left: 9px;
    padding-right: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .result-summary.impact-up-weak,
  .result-summary.impact-down-weak {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* v0.12: portfolio editor is a single-screen compact board. */
.portfolio-modal-head {
  min-height: 52px;
  padding: max(6px, env(safe-area-inset-top)) 10px 6px;
}
.portfolio-modal-head h2 {
  font-size: 17px;
}
.portfolio-modal-head-actions { gap: 6px; }
.portfolio-modal-head .allocation-total span { font-size: 12px; }
.portfolio-modal-head .allocation-total strong { font-size: 18px; }
.portfolio-close-btn {
  width: 40px;
  height: 40px;
  border-radius: 9px;
}

.portfolio-modal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.portfolio-modal-scroll .market-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}
.portfolio-modal-scroll .market-card {
  min-height: 0;
  height: 100%;
  padding: 6px 7px 5px;
  border-radius: 0;
  background: #11161d;
}
.portfolio-modal-scroll .market-card:nth-child(odd) { border-right-width: 0; }
.portfolio-modal-scroll .market-card:nth-child(n+3) { border-top-width: 0; }
.portfolio-modal-scroll .market-card::before { width: 2px; }

.portfolio-modal-scroll .market-top {
  min-height: 38px;
  height: auto;
  align-items: flex-start;
}
.portfolio-modal-scroll .market-name-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 3px;
}
.portfolio-modal-scroll .ticker {
  font-size: 14px;
  line-height: 1;
  letter-spacing: .06em;
}
.portfolio-modal-scroll .market-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portfolio-modal-scroll .risk-meter {
  padding-top: 1px;
}
.portfolio-modal-scroll .risk-dot {
  height: 8px;
}
.portfolio-modal-scroll .market-candle-history {
  height: 24px;
  margin: 4px 0 5px;
  padding: 1px 0;
}
.portfolio-modal-scroll .allocation-row {
  grid-template-columns: 40px minmax(0,1fr) 40px;
  gap: 2px;
  margin-top: 3px;
}
.portfolio-modal-scroll .step-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}
.portfolio-modal-scroll .allocation-value {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.portfolio-modal-scroll .allocation-value strong {
  font-size: 17px;
  line-height: 1;
}
.portfolio-modal-scroll .allocation-value span {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1;
}
.portfolio-modal-scroll .allocation-track {
  height: 3px;
  margin-top: 3px;
}
.portfolio-modal-scroll .market-foot {
  margin-top: 5px;
  font-size: 11px;
  line-height: 1.1;
}
.portfolio-modal-scroll .market-foot b { font-size: 12px; }
.portfolio-modal-scroll .locked-row {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.portfolio-modal-scroll .locked-row b {
  color: #d2d8df;
  font-size: 14px;
}
.portfolio-modal-scroll .cash-strip {
  flex: 0 0 36px;
  min-height: 36px;
  margin: 0;
  padding: 4px 9px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-top: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.portfolio-modal-scroll .cash-strip b { font-size: 14px; }
.portfolio-modal-scroll .cash-strip span { display: none; }
.portfolio-modal-scroll .cash-strip strong { font-size: 17px; }

.portfolio-modal-action {
  min-height: 64px;
  gap: 5px;
  padding: 5px 6px max(5px, env(safe-area-inset-bottom)) 9px;
  border-top: 0;
  box-shadow: none;
}
.portfolio-modal-action .bet-summary span { font-size: 11px; }
.portfolio-modal-action .bet-summary b { font-size: 15px; }
.portfolio-modal-action .candle-btn { min-height: 50px; }

@media (max-height: 700px) {
  .portfolio-modal-head { min-height: 46px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .portfolio-close-btn { width: 38px; height: 38px; }
  .portfolio-modal-scroll .market-card { padding-top: 4px; padding-bottom: 3px; }
  .portfolio-modal-scroll .market-top { min-height: 34px; }
  .portfolio-modal-scroll .market-name-block { gap: 1px; }
  .portfolio-modal-scroll .market-subtitle { font-size: 13px; }
  .portfolio-modal-scroll .market-candle-history { height: 20px; margin-block: 1px; }
  .portfolio-modal-scroll .allocation-row { grid-template-columns: 38px minmax(0,1fr) 38px; }
  .portfolio-modal-scroll .step-btn { width: 38px; height: 38px; }
  .portfolio-modal-scroll .market-foot { margin-top: 2px; }
  .portfolio-modal-scroll .cash-strip { flex-basis: 32px; min-height: 32px; }
  .portfolio-modal-action { min-height: 58px; }
  .portfolio-modal-action .candle-btn { min-height: 46px; }
}


/* v0.14: separated rounded market cards, larger candle field, controls anchored low. */
.portfolio-modal-scroll {
  padding: 6px;
}
.portfolio-modal-scroll .market-grid {
  gap: 6px;
}
.portfolio-modal-scroll .market-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 7px 8px 6px;
  overflow: hidden;
  border: 1px solid #343d48;
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255,255,255,.018), transparent 55%), #11161d;
}
.portfolio-modal-scroll .market-card:nth-child(odd),
.portfolio-modal-scroll .market-card:nth-child(n+3) {
  border-width: 1px;
}
.portfolio-modal-scroll .market-card::before {
  width: 2px;
  border-radius: 13px 0 0 13px;
}
.portfolio-modal-scroll .market-top {
  order: 1;
  flex: 0 0 auto;
  min-height: 34px;
}
.portfolio-modal-scroll .market-candle-history {
  order: 2;
  flex: 1 1 auto;
  min-height: 36px;
  height: auto;
  margin: 3px 0;
  padding: 2px 0;
}
.portfolio-modal-scroll .market-foot {
  order: 3;
  flex: 0 0 auto;
  margin-top: 1px;
  margin-bottom: 2px;
}
.portfolio-modal-scroll .allocation-row {
  order: 4;
  flex: 0 0 auto;
  margin-top: auto;
}
.portfolio-modal-scroll .allocation-track {
  order: 5;
  flex: 0 0 auto;
  margin-top: 3px;
}
.portfolio-modal-scroll .locked-row {
  order: 4;
  flex: 0 0 auto;
  min-height: 36px;
  margin-top: auto;
}
.portfolio-modal-scroll .cash-strip {
  flex: 0 0 40px;
  min-height: 40px;
  margin: 6px 0 0;
  padding: 5px 10px;
  border: 1px solid #343d48;
  border-radius: 13px;
  background: #11161d;
}

@media (max-height: 700px) {
  .portfolio-modal-scroll { padding: 4px; }
  .portfolio-modal-scroll .market-grid { gap: 4px; }
  .portfolio-modal-scroll .market-card {
    padding: 4px 6px 4px;
    border-radius: 11px;
  }
  .portfolio-modal-scroll .market-card::before { border-radius: 11px 0 0 11px; }
  .portfolio-modal-scroll .market-top { min-height: 30px; }
  .portfolio-modal-scroll .market-candle-history {
    min-height: 28px;
    height: auto;
    margin: 1px 0;
  }
  .portfolio-modal-scroll .allocation-row {
    grid-template-columns: 36px minmax(0,1fr) 36px;
    margin-top: auto;
  }
  .portfolio-modal-scroll .step-btn { width: 36px; height: 36px; }
  .portfolio-modal-scroll .market-foot { margin-top: 0; margin-bottom: 1px; }
  .portfolio-modal-scroll .locked-row { min-height: 34px; }
  .portfolio-modal-scroll .cash-strip {
    flex-basis: 34px;
    min-height: 34px;
    margin-top: 4px;
    border-radius: 11px;
  }
}
