/* FX Trade Sim — style.css
 * Inherits :root token system from fx-price-action/style.css.
 * Adds trade-sim specific variables and components.
 */

/* ===== Design Tokens (PA quiz :root + sim additions) ===== */
:root {
  /* --- Base palette (PA quiz) --- */
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #6b7785;
  --muted-aa: #5a6573;
  --line: #e2e8f0;
  --brand: #0c1933;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --up: #1c8c5a;
  --down: #d23b48;
  --timer-warn: #e07b10;
  --chip-bg: #f0f5ff;

  /* --- Radius --- */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* --- Shadow --- */
  --shadow: 0 6px 24px rgba(20, 35, 60, 0.08);
  --shadow-sm: 0 2px 8px rgba(20, 35, 60, 0.06);
  --shadow-md: 0 6px 24px rgba(20, 35, 60, 0.08);
  --shadow-lg: 0 12px 40px rgba(20, 35, 60, 0.13);

  /* --- Spacing --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* --- Layout rhythm (cycle-1 additions) --- */
  /* Section gap: major visual breaks between HUD / chart / panel */
  --gap-section: var(--sp-5);
  /* Element gap: within a card/panel between grouped items */
  --gap-element: var(--sp-3);
  /* Fine gap: tight coupling inside a component */
  --gap-fine: var(--sp-2);

  /* --- Transition --- */
  --dur-fast: 100ms;
  --dur-base: 180ms;
  --dur-slow: 300ms;
  --dur-xslow: 500ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* --- Type scale --- */
  --text-xs: 0.78rem;
  --text-sm: 0.88rem;
  --text-base: 1rem;
  --text-md: 1.05rem;
  --text-lg: 1.12rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.6rem;
  --text-3xl: 2rem;

  /* --- Sim-specific additions --- */
  --hud-bg: rgba(12, 25, 51, 0.04);
  --pos-buy-bg: rgba(28, 140, 90, 0.08);
  --pos-sell-bg: rgba(210, 59, 72, 0.08);
  /* Divider inside op-panel zones */
  --zone-divider: 1px solid var(--line);

  /* --- Cycle-3: color / depth additions --- */
  /* HUD subtle brand-navy gradient */
  --hud-grad: linear-gradient(135deg, rgba(12,25,51,0.055) 0%, rgba(12,25,51,0.02) 100%);
  /* Chart frame: brand left-accent */
  --chart-accent: 3px solid rgba(12,25,51,0.65);
  /* Card surface hierarchy: level-0=bg, level-1=card(white), level-2=inset/sub */
  --surface-sub: #f8fafc;
  /* Semantic up/down — slightly desaturated for consistency */
  --up: #1a8754;
  --down: #cc3847;
  /* Position display — richer tint when active */
  --pos-buy-bg: rgba(26, 135, 84, 0.09);
  --pos-sell-bg: rgba(204, 56, 71, 0.09);
  /* Subtle brand ink for hero asset number */
  --brand-ink: #0f2040;

  /* --- Cycle-2: typography additions --- */
  /* Financial figure weight: heavier than body, lighter feel for labels */
  --fw-label: 400;
  --fw-value: 700;
  --fw-value-hero: 800;
  /* Line-height for single-line figures (no descenders needed) */
  --lh-numeric: 1.15;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ===== Site Header / Footer ===== */
.site-header {
  background: var(--brand);
  text-align: center;
  padding: 8px 16px;
}
.site-header__link { display: inline-block; line-height: 0; }
.site-header__logo {
  width: min(460px, 84%);
  height: auto;
  max-width: 100%;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
  text-align: center;
  padding: 22px 16px 28px;
  margin-top: 8px;
}
.site-footer__lead { margin: 0 0 6px; font-size: var(--text-sm); color: var(--muted); }
.site-footer__lead a { color: var(--brand); font-weight: 700; text-decoration: none; }
.site-footer__lead a:hover { text-decoration: underline; }
.site-footer__copy { margin: 0; font-size: 0.78rem; color: #9aa5b1; }

/* ===== App Container ===== */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-5) var(--sp-10);
}

/* ===== Screen System ===== */
.screen { display: none; }
.screen.is-active {
  display: block;
  animation: screen-in var(--dur-slow) var(--ease-out) both;
}
/* showScreen() moves focus to the screen heading (tabindex=-1) for screen-reader
   announcement. That focus is programmatic (not keyboard-reachable), so suppress
   the visible outline — the SR announcement is preserved. (backlog ④) */
.screen h1[tabindex="-1"]:focus,
.screen h2[tabindex="-1"]:focus { outline: none; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Accessibility Helpers ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Typography ===== */
.title {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin: 0 0 var(--sp-4);
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--ink);
}

.lead {
  font-size: var(--text-md);
  line-height: 1.85;
  margin: 0 0 var(--sp-6);
  color: var(--ink);
}
/* 強調行（毎日1回チャレンジ）はインク色でさらに際立たせる */
.lead strong {
  font-weight: 800;
  color: var(--ink);
}

.note {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--sp-6);
  line-height: 1.65;
  letter-spacing: 0.01em;
}

/* ===== How-to List ===== */
.how {
  list-style: none;
  padding: var(--sp-5) var(--sp-5) var(--sp-5);
  margin: 0 0 var(--sp-6);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.how li {
  margin: 0;
  padding: var(--sp-2) 0;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.7;
  border-bottom: 1px solid var(--line);
  letter-spacing: 0.01em;
}
.how li:last-child { border-bottom: none; }

/* ===== Buttons (base) ===== */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 32px;
  /* Ensure minimum tap target height */
  min-height: 44px;
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  /* Unified transition set — covers lift, shadow, color, opacity */
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
  font-family: inherit;
  line-height: 1.2;
}
/* Lift on hover */
.btn:hover:not(:disabled) { transform: translateY(-1px); }
/* Press-down: sink + flatten shadow */
.btn:active:not(:disabled) {
  transform: translateY(2px) scale(0.985);
  box-shadow: none !important;
  transition-duration: 60ms;
}
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
/* Disabled: dimmer + visually "flat" to signal un-pressable */
.btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: saturate(0.5);
}

/* Primary button */
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: #1d4fd0;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.42);
}

/* Start screen CTA: fixed width, left-aligned */
.btn-start-main {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* Reset button — subtle ghost with danger-hover */
.btn-reset {
  background: var(--card);
  border: 1.5px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 11px 24px;
}
.btn-reset:hover:not(:disabled) {
  border-color: var(--down);
  color: var(--down);
  background: rgba(204, 56, 71, 0.04);
}

/* ===== Mute button ===== */
.btn-mute {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  outline: none;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
  flex-shrink: 0;
}
.btn-mute:hover { color: var(--ink); border-color: var(--primary); background: var(--chip-bg); }
.btn-mute:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-mute[aria-pressed="true"] { color: var(--line); border-color: var(--line); background: var(--bg); }

/* ===== Game HUD (header bar inside trade screen) ===== */
.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--gap-section);
  background: var(--hud-grad);
  border: 1px solid rgba(12,25,51,0.14);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* HUD right-side controls group (mute + abort) */
.hud-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-shrink: 0;
}

/* Abort button variant inside HUD — compact, secondary */
.btn-abort--hud {
  padding: 6px 12px;
  min-height: 34px;
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.hud-asset,
.hud-pnl,
.hud-limits {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.hud-limits { gap: var(--sp-1); }

.hud-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-label);
  color: var(--muted-aa);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.hud-sep { color: var(--muted); margin: 0 var(--sp-1); }

.hud-value {
  font-size: var(--text-lg);
  font-weight: var(--fw-value-hero);
  color: var(--ink);
  line-height: var(--lh-numeric);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur-base);
}
/* 資産フィールドは最重要 — さらに大きく + ブランド紺で差別化 */
.hud-asset .hud-value {
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  color: var(--brand-ink);
}
.hud-value--muted { color: var(--muted-aa); font-weight: var(--fw-value); }
.hud-value--up    { color: var(--up); }
.hud-value--down  { color: var(--down); }

.is-depleted { color: var(--down) !important; font-weight: 800 !important; }

/* HUD bump animation for unrealized PnL changes */
@keyframes score-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.14); }
  65%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.is-bump { animation: score-bump var(--dur-slow) var(--ease-out) both; }

/* ===== Chart Area ===== */
.chart-wrap {
  border-radius: var(--radius-md);
  overflow: hidden;
  /* Main visual hero: stronger shadow + brand-navy left accent */
  box-shadow:
    var(--shadow-lg),
    inset 3px 0 0 rgba(12,25,51,0.55);
  margin-bottom: var(--gap-element);
  background: var(--card);
  /* Subtle top border for crispness */
  border-top: 1px solid rgba(12,25,51,0.1);
}

.chart {
  width: 100%;
  height: 360px;
}

/* ===== Progress Bar ===== */
.bar-progress-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.bar-progress-track {
  flex: 1;
  height: 5px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.bar-progress-fill {
  height: 100%;
  /* Brand-navy gradient for progress to tie into overall color story */
  background: linear-gradient(90deg, var(--brand) 0%, #2a4a8a 100%);
  border-radius: 99px;
  transition: width 80ms linear, background var(--dur-base);
  width: 0%;
}

.bar-progress-label {
  font-size: var(--text-sm);
  color: var(--muted-aa);
  white-space: nowrap;
  min-width: 72px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ===== Operations Panel ===== */
.op-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  /* Slightly stronger than shadow-sm, weaker than chart-wrap */
  box-shadow: 0 3px 14px rgba(20,35,60,0.09);
  margin-bottom: var(--gap-section);
  overflow: hidden;
}

/* Each zone inside op-panel gets its own padding + top divider */
.op-section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-fine);
  padding: var(--sp-4) var(--sp-4);
}
/* The hidden attribute must win over display:flex above — otherwise feature-gated
   sections (lot / pending) stay visible despite hidden=true (backlog ⑥/⑦). */
.op-section[hidden] { display: none !important; }

/* Dividers between zones */
.op-section + .op-section {
  border-top: var(--zone-divider);
}

/* Advance zone */
.advance-controls {
  display: flex;
  gap: var(--sp-3);
  align-items: stretch;
}

/* Left group: auto toggle + speed select stacked */
.advance-left {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex-shrink: 0;
  min-width: 0;
}

.btn-advance {
  background: var(--surface-sub);
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  /* Comfortable tap target */
  padding: 10px 22px;
  min-height: 44px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  /* Subtle shadow to distinguish from flat auto/speed */
  box-shadow: 0 1px 4px rgba(20,35,60,0.08);
}
.btn-advance:hover:not(:disabled) {
  background: var(--chip-bg);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}
.btn-advance:disabled { opacity: 0.32; border-color: var(--line); color: var(--muted); box-shadow: none; filter: saturate(0.5); }

/* Large "next" button: takes remaining width, tall for easy tap */
.btn-advance--large {
  flex: 1;
  min-height: 56px;
  font-size: var(--text-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Speed combo (select) — matches auto-toggle width */
.speed-combo {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 7px 28px 7px 10px;
  min-height: 36px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  /* Custom dropdown arrow */
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7785' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color var(--dur-fast), color var(--dur-fast), background-color var(--dur-fast);
}
.speed-combo:hover {
  border-color: var(--primary);
  color: var(--ink);
}
.speed-combo:focus {
  border-color: var(--primary);
  outline: none;
}
.speed-combo:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Auto toggle button */
.btn-auto-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 10px 16px;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition:
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  font-family: inherit;
}
.btn-auto-toggle:hover {
  background: var(--chip-bg);
  border-color: var(--primary);
}
.btn-auto-toggle:active {
  transform: translateY(1px) scale(0.985);
  transition-duration: 60ms;
}
.btn-auto-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
/* ON state: filled primary — clearly "active" */
.btn-auto-toggle[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(37,99,235,0.28);
}
.btn-auto-toggle[aria-pressed="true"]:hover {
  background: #1d4fd0;
}
.auto-toggle__label { line-height: 1; }

/* Speed segment */
.speed-select {
  display: flex;
  gap: var(--sp-1);
}

.speed-btn {
  flex: 1;
  /* Adequate tap target */
  padding: 8px 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  font-family: inherit;
  letter-spacing: 0.02em;
}
/* Active speed: filled primary + subtle inner highlight */
.speed-btn[aria-pressed="true"],
.speed-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 2px 8px rgba(37,99,235,0.22);
}
.speed-btn:hover:not([aria-pressed="true"]):not(.is-active) {
  background: var(--chip-bg);
  border-color: var(--primary);
  color: var(--primary);
}
/* Press feel */
.speed-btn:active:not([aria-pressed="true"]):not(.is-active) {
  transform: scale(0.96);
  transition-duration: 60ms;
}
.speed-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Trade zone */
.op-section--trade {
  display: flex;
  flex-direction: row;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4);
}

.btn-buy, .btn-sell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  /* Larger tap target — primary action deserves more height */
  padding: 18px 16px;
  min-height: 58px;
  font-size: var(--text-xl);
  font-weight: 800;
  border-radius: var(--radius-md);
  border: none;
  letter-spacing: 0.03em;
  /* Inner top highlight for "raised slab" feel */
  position: relative;
}

.btn-buy {
  background: linear-gradient(180deg, #23a06a 0%, var(--up) 100%);
  color: #fff;
  box-shadow:
    0 4px 16px rgba(26, 135, 84, 0.30),
    inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-buy:hover:not(:disabled) {
  background: linear-gradient(180deg, #1e9160 0%, #156e45 100%);
  box-shadow:
    0 6px 22px rgba(26, 135, 84, 0.42),
    inset 0 1px 0 rgba(255,255,255,0.18);
}
/* Disabled: clearly "locked" — not just dim */
.btn-buy:disabled {
  background: #c8ddd5;
  color: rgba(255,255,255,0.6);
  box-shadow: none;
  opacity: 1;
  filter: none;
}

.btn-sell {
  background: linear-gradient(180deg, #e04555 0%, var(--down) 100%);
  color: #fff;
  box-shadow:
    0 4px 16px rgba(204, 56, 71, 0.30),
    inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-sell:hover:not(:disabled) {
  background: linear-gradient(180deg, #ce3e4d 0%, #ad2d3b 100%);
  box-shadow:
    0 6px 22px rgba(204, 56, 71, 0.42),
    inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-sell:disabled {
  background: #ddc8cb;
  color: rgba(255,255,255,0.6);
  box-shadow: none;
  opacity: 1;
  filter: none;
}

/* Press-down override for buy/sell (stronger sink) */
.btn-buy:active:not(:disabled),
.btn-sell:active:not(:disabled) {
  transform: translateY(3px) scale(0.978);
  box-shadow: none !important;
  transition-duration: 60ms;
}

.trade-btn__arrow {
  font-size: var(--text-base);
  opacity: 0.85;
}

/* Exit zone */
.btn-exit {
  background: var(--card);
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
  /* Adequate tap target */
  padding: 13px 24px;
  min-height: 50px;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
  width: 100%;
  letter-spacing: 0.02em;
  /* Ghost button gets a subtle shadow so it reads as interactive */
  box-shadow: 0 1px 6px rgba(37,99,235,0.10);
  transition:
    background var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn-exit:hover:not(:disabled) {
  background: var(--chip-bg);
  box-shadow: 0 3px 12px rgba(37,99,235,0.18);
}
.btn-exit:active:not(:disabled) {
  transform: translateY(2px) scale(0.985);
  box-shadow: none;
  transition-duration: 60ms;
}
/* Disabled: visually dormant — position not held */
.btn-exit:disabled {
  border-color: var(--line);
  color: var(--muted);
  box-shadow: none;
  opacity: 0.32;
  filter: saturate(0.4);
}

/* Exit flash pulse */
@keyframes exit-flash {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.04); }
  60%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}
.exit-flash { animation: exit-flash 280ms var(--ease-out) both; }

/* ===== Position Display ===== */
.position-display {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  margin-bottom: var(--gap-element);
  transition: background var(--dur-base), border-color var(--dur-base), box-shadow var(--dur-base);
}
.position-display.has-buy {
  background: var(--pos-buy-bg);
  border-color: rgba(26,135,84,0.45);
  border-left: 3px solid var(--up);
  box-shadow: 0 2px 10px rgba(26,135,84,0.1);
}
.position-display.has-sell {
  background: var(--pos-sell-bg);
  border-color: rgba(204,56,71,0.45);
  border-left: 3px solid var(--down);
  box-shadow: 0 2px 10px rgba(204,56,71,0.1);
}

.pos-none { color: var(--muted); font-size: var(--text-sm); }

.pos-tag {
  padding: 2px 10px;
  border-radius: 4px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
}
.pos-tag--buy  { background: var(--up); }
.pos-tag--sell { background: var(--down); }

.pos-entry { color: var(--ink); font-size: var(--text-sm); }
.pos-entry strong {
  font-weight: var(--fw-value-hero);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.pos-pnl--up   {
  color: var(--up);
  font-weight: var(--fw-value-hero);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.pos-pnl--down {
  color: var(--down);
  font-weight: var(--fw-value-hero);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.pos-pnl--zero { color: var(--muted-aa); font-weight: var(--fw-value); font-size: var(--text-sm); }

/* ===== Result Screen ===== */

/* Card entrance animation (staggered fade-up) */
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--gap-section);
  /* Entrance animation — each card gets its own delay via nth-of-type */
  animation: card-in var(--dur-slow) var(--ease-out) both;
}
.result-card:nth-of-type(2) { animation-delay: 80ms; }

/* 本日成績カード: 左ボーダーでブランド紺を効かせ、最重要カードを視覚的に優先 */
#session-result-card {
  border-left: 4px solid var(--brand);
}

/* 通算成績カード: inset 背景で一段控えめな surface */
.result-card--cumulative {
  background: var(--surface-sub);
  border-color: rgba(20,35,60,0.1);
  box-shadow: var(--shadow-sm);
}

.result-card__heading {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: var(--zone-divider);
  opacity: 0.65;
}

.result-stat-list {
  margin: 0;
  padding: 0;
}

.result-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line);
  gap: var(--sp-3);
}
.result-stat:last-child { border-bottom: none; }
/* ラベル: 補助テキスト扱い */
.result-stat dt {
  font-size: var(--text-xs);
  font-weight: var(--fw-label);
  color: var(--muted-aa);
  letter-spacing: 0.025em;
  flex-shrink: 0;
}
/* 値: 明確に大きく・重く */
.result-stat dd {
  margin: 0;
  text-align: right;
  font-size: var(--text-base);
  font-weight: var(--fw-value);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.result-stat--bar dd {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* Session PnL big number — hero figure (サイクル5: さらに大きく達成感) */
.res-pnl {
  font-weight: var(--fw-value-hero);
  font-size: var(--text-3xl);
  line-height: var(--lh-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.res-pnl--up    { color: var(--up); }
.res-pnl--down  { color: var(--down); }
.res-pnl--zero  { color: var(--muted-aa); }

/* Cumulative stats figures */
.cum-big {
  font-weight: var(--fw-value-hero);
  font-size: var(--text-xl);
  line-height: var(--lh-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Winrate bar — wider, more visible (サイクル5: 視認性向上) */
.winrate-bar-track {
  width: 140px;
  height: 7px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.winrate-bar-fill {
  height: 100%;
  border-radius: 99px;
  /* Gradient fill for vitality */
  background: linear-gradient(90deg, #1a8754 0%, #22c984 100%);
  width: 0%;
  transition: width 600ms var(--ease-out), background var(--dur-base);
}
/* Low winrate: red gradient */
.winrate-bar-fill.is-losing {
  background: linear-gradient(90deg, var(--down) 0%, #f47484 100%);
}

.result-card__note {
  margin: var(--sp-4) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* Disclaimer — 上品な注意書きスタイル (サイクル5: 赤ベタを緩和) */
.disclaimer {
  color: var(--muted-aa);
  font-weight: 400;
  font-size: var(--text-xs);
  border-left: 2px solid var(--line);
  padding: var(--sp-2) var(--sp-3);
  margin: var(--gap-section) 0;
  background: var(--surface-sub);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  letter-spacing: 0.01em;
  line-height: 1.7;
}
/* ※ 先頭の記号は残し、重要性をさりげなく示す */
.disclaimer::before {
  content: '';
}

/* No-trade message */
.res-no-trade {
  margin: var(--sp-3) 0 0;
  font-size: var(--text-sm);
  color: var(--muted-aa);
  font-style: italic;
}

/* Result action buttons */
.result-actions {
  display: flex;
  flex-direction: column;
  gap: var(--gap-element);
  margin: var(--gap-section) auto;
  max-width: 480px;
  animation: card-in var(--dur-slow) var(--ease-out) 160ms both;
}
/* Full-width buttons in result actions */
.result-actions .btn {
  width: 100%;
  text-align: center;
}
/* Primary CTA in result: larger and more prominent */
.result-actions .btn-primary {
  padding: 18px 32px;
  min-height: 56px;
  font-size: var(--text-md);
  letter-spacing: 0.02em;
  /* Slightly stronger shadow for primary emphasis */
  box-shadow: 0 6px 22px rgba(37,99,235,0.35);
}

/* v13.2: divider between primary and reset group */
.result-actions__divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 4px 0;
}

/* v13.2: reset + capital select group */
.result-reset-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-sub);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* Blog CTA */
.cta {
  margin: var(--sp-5) 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
  padding-top: var(--sp-4);
  border-top: var(--zone-divider);
  text-align: center;
}
.cta a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}
.cta a:hover { text-decoration: underline; }

/* ===== H: Abort button ===== */
.btn-abort {
  padding: 8px 14px;
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  font-family: inherit;
}
/* Note: right-alignment handled by .hud-controls { margin-left: auto } */
.btn-abort:hover {
  color: var(--down);
  border-color: var(--down);
  background: rgba(204, 56, 71, 0.04);
}
.btn-abort:active {
  transform: translateY(1px) scale(0.97);
  transition-duration: 60ms;
}
.btn-abort:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-abort:disabled { opacity: 0.32; cursor: not-allowed; filter: saturate(0.4); }

/* ===== C: Bar + trades description block ===== */
.bar-and-trades-wrap {
  /* Tighter coupling to op-panel above: sp-3 instead of section gap */
  margin-bottom: var(--gap-element);
}
/* C: trades-remaining + remaining-bars on one row, close together */
.session-status {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.status-trades {
  font-size: var(--text-xs);
  color: var(--muted-aa);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
/* 数値部分は hud-value クラス経由で大きく・等幅 */
.status-trades .hud-value {
  font-size: var(--text-md);
  font-weight: var(--fw-value-hero);
  font-variant-numeric: tabular-nums;
}
.bar-and-trades-desc {
  font-size: var(--text-xs);
  color: var(--muted);
  margin: var(--sp-2) 0 0;
  line-height: 1.6;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-sub);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* ===== F: PF explanation link ===== */
.pf-link {
  font-size: var(--text-xs);
  color: var(--primary);
  text-decoration: none;
  font-weight: 400;
  margin-left: 4px;
}
.pf-link:hover { text-decoration: underline; }

/* ===== v11.0: Session P&L HUD slot ===== */
.hud-session-pnl {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ===== v11.0: Share Card Section ===== */
.share-card-section {
  margin: var(--gap-section) auto var(--gap-section);
  padding: var(--sp-5) var(--sp-4) var(--sp-5);
  /* No border-top — section has its own card surface */
  max-width: 600px;
  text-align: center;
  /* Subtle inset surface to separate share area */
  background: var(--surface-sub);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  /* Entrance: slightly delayed to let result cards appear first */
  animation: card-in var(--dur-slow) var(--ease-out) 120ms both;
}

.share-card-section__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted-aa);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 var(--sp-4);
}

.share-canvas {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin: 0 auto var(--sp-5);
  /* Thin border for canvas crispness on white screens */
  outline: 1px solid rgba(20,35,60,0.07);
}
.share-canvas[hidden] { display: none; }
.share-canvas.is-revealed {
  animation: share-reveal var(--dur-xslow) var(--ease-out) both;
}
@keyframes share-reveal {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.share-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
}

.btn-share-generate {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--brand);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-md);
  padding: 12px 28px;
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(12,25,51,0.25);
  transition:
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn-share-generate:hover:not(:disabled) {
  background: #152241;
  box-shadow: 0 6px 20px rgba(12,25,51,0.38);
  transform: translateY(-1px);
}
.btn-share-generate:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn-share-generate:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.btn-share-generate[hidden] { display: none; }

.share-post-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: center;
  flex-wrap: wrap;
}
.share-post-actions[hidden] { display: none; }

.btn-share-save,
.btn-share-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 22px;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn-share-save:hover:not(:disabled),
.btn-share-copy:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn-share-save:active:not(:disabled),
.btn-share-copy:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  box-shadow: none;
  transition-duration: 60ms;
}
.btn-share-save:focus-visible,
.btn-share-copy:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
/* Copied state: clear visual confirmation */
.btn-share-copy.is-copied {
  border-color: var(--up);
  color: var(--up);
  background: rgba(26,135,84,0.05);
  pointer-events: none;
}

/* X share button */
.btn-share-x {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: #0f1419;
  color: #fff;
  border: 1.5px solid #0f1419;
  border-radius: var(--radius-md);
  padding: 10px 22px;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition:
    background var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn-share-x:hover:not(:disabled) {
  background: #2a2f36;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn-share-x:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  box-shadow: none;
  transition-duration: 60ms;
}
.btn-share-x:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Fallback / iOS hint */
.card-fallback-msg {
  margin: var(--sp-3) auto 0;
  max-width: 460px;
  font-size: var(--text-sm);
  color: var(--down);
  font-weight: 700;
}
.card-fallback-msg[hidden] { display: none; }

.card-ios-hint {
  display: none;
  margin: var(--sp-2) auto 0;
  font-size: var(--text-xs);
  color: var(--muted-aa);
}
@media (pointer: coarse) { .card-ios-hint { display: block; } }

/* Toast */
.share-toast {
  display: inline-block;
  margin-top: var(--sp-3);
  padding: 6px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: 9999px;
  font-size: var(--text-sm);
  font-weight: 700;
  animation: toast-in var(--dur-slow) var(--ease-out) both;
}
.share-toast[hidden] { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(4px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}

/* ===== Mobile adjustments (≤480px) ===== */
@media (max-width: 480px) {
  /* Site header + app container */
  .site-header { padding: 6px 12px; }
  .site-header__logo { width: 88%; }
  .app { padding: var(--sp-6) var(--sp-4) var(--sp-8); }
  /* Chart height */
  .chart { height: 280px; }

  /* HUD: tighter spacing */
  .game-head {
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--gap-element);
  }
  /* HUD values: scale down but keep readable */
  .hud-value { font-size: var(--text-md); }
  .hud-asset .hud-value { font-size: var(--text-lg); }

  /* Op panel sections: slightly tighter padding */
  .op-section { padding: var(--sp-3); }

  /* Advance controls: left group + large next button */
  .advance-controls {
    gap: var(--sp-2);
  }
  .advance-left {
    gap: var(--sp-1);
  }
  .btn-advance--large {
    min-height: 50px;
    font-size: var(--text-base);
  }
  .btn-auto-toggle {
    min-height: 40px;
    padding: 8px 12px;
  }
  .speed-combo {
    min-height: 34px;
    font-size: var(--text-xs);
  }

  /* Speed buttons: slightly shorter on mobile, text stays legible */
  .speed-btn {
    min-height: 36px;
    font-size: var(--text-xs);
    padding: 6px 0;
  }

  /* Buy/Sell: keep large but adjust font */
  .btn-buy, .btn-sell {
    padding: 16px 12px;
    min-height: 54px;
    font-size: var(--text-lg);
  }

  /* Exit button: mobile comfortable */
  .btn-exit {
    min-height: 48px;
    font-size: var(--text-sm);
  }

  /* Result screen */
  .result-card { padding: var(--sp-4) var(--sp-4); }
  .res-pnl { font-size: var(--text-2xl); letter-spacing: -0.02em; }
  .winrate-bar-track { width: 90px; }

  /* Result action buttons: stack vertically */
  .result-actions { gap: var(--sp-2); }
  .result-actions .btn { min-height: 44px; }
  .result-actions .btn-primary { min-height: 56px; font-size: var(--text-md); }

  /* Share buttons: centered column layout */
  .btn-share-generate,
  .btn-share-save,
  .btn-share-copy,
  .btn-share-x { width: min(280px, 100%); justify-content: center; }
  .share-post-actions { flex-direction: column; align-items: center; gap: var(--sp-2); }

  /* Misc */
  .bar-and-trades-desc { padding: var(--sp-2); }

  /* Reset button smaller on mobile */
  .btn-reset {
    font-size: var(--text-xs);
    min-height: 44px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .speed-combo { transition: none !important; }
  /* Neutralize all transform-based press feedback */
  .btn:active,
  .btn-advance:active,
  .btn-auto-toggle:active,
  .btn-abort:active,
  .speed-btn:active,
  .btn-buy:active,
  .btn-sell:active,
  .btn-exit:active,
  .btn-share-generate:active,
  .btn-share-save:active,
  .btn-share-copy:active,
  .btn-share-x:active {
    transform: none !important;
  }
  /* Keep revealed / entrance states immediately visible */
  .share-canvas.is-revealed,
  .share-toast,
  .screen.is-active,
  .result-card,
  .result-actions,
  .share-card-section { opacity: 1 !important; transform: none !important; }
}

/* ===== v12 additions: hub back bar + lock notice ===== */
.hub-back-bar {
  padding: 6px 16px;
  background: var(--brand, #0c1933);
}
.hub-back-link {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.82rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.hub-back-link:hover {
  color: #ffffff;
  text-decoration: underline;
}
/* v146: back-to-top link shown only on the trade start screen (light bg) */
.trade-start-back {
  display: block;
  text-align: left;
  margin-bottom: var(--sp-3);
  color: var(--muted, #6b7684);
  font-size: 0.85rem;
  text-decoration: none;
}
.trade-start-back:hover { color: var(--ink, #14233c); text-decoration: underline; }

.lock-notice {
  margin: 12px auto 0;
  max-width: 520px;
  padding: 14px 18px;
  border-radius: var(--radius-sm, 8px);
  background: #fff8e6;
  border: 1px solid #f6c744;
  color: #7a5500;
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: center;
}
.lock-notice a {
  color: #1d5ec4;
  font-weight: 700;
  text-decoration: underline;
}
/* v13.9: X-share recovery button inside the limit notice */
.btn-recover-x {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 12px auto 2px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm, 8px);
  background: #0f1419;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
}
.btn-recover-x:hover { background: #2a2f36; }
.btn-recover-x:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ===== result nav (v12 UI調整) ===== */
.result-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px auto 0;
  max-width: 480px;
  width: 100%;
}
/* trade.html places new rx-btn links inside .result-actions (not .result-nav),
   so extend selectors to cover both containers. */
.result-nav .rx-btn,
.result-actions .rx-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  transition: background .15s, border-color .15s;
}
.result-nav .rx-btn--primary,
.result-actions .rx-btn--primary {
  background: #2563eb;
  color: #fff;
}
.result-nav .rx-btn--ghost,
.result-actions .rx-btn--ghost {
  background: #fff;
  color: #38465a;
  border-color: #e2e8f0;
}
.result-nav .rx-btn--ghost:hover,
.result-actions .rx-btn--ghost:hover { background: #f7f9fc; }
.result-nav .rx-btn--quiet,
.result-actions .rx-btn--quiet {
  background: transparent;
  color: #2563eb;
  font-size: 14px;
}
.result-nav .rx-btn--quiet:hover,
.result-actions .rx-btn--quiet:hover { background: #eaf1fe; }

/* ===== v13: Indicator Toolbar ===== */
.ind-toolbar {
  margin-bottom: var(--gap-element);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--sp-2) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  box-shadow: var(--shadow-sm);
}
.ind-toolbar[hidden] { display: none; }

.ind-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.ind-toggle-btn {
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 5px 10px;
  min-height: 32px;
  cursor: pointer;
  outline: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  letter-spacing: 0.02em;
}
.ind-toggle-btn[hidden] { display: none; }
.ind-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--chip-bg);
}
.ind-toggle-btn[aria-pressed="true"],
.ind-toggle-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.ind-toggle-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Horizontal line section */
.ind-hline-section[hidden] { display: none; }

.ind-hline-input-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.ind-hline-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted-aa);
  white-space: nowrap;
}

.ind-hline-input {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: var(--text-xs);
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  width: 110px;
  min-height: 32px;
  outline: none;
  -moz-appearance: textfield;
}
.ind-hline-input::-webkit-outer-spin-button,
.ind-hline-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.ind-hline-input:focus { border-color: var(--primary); }

.ind-hline-add-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 5px 10px;
  min-height: 32px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.ind-hline-add-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--chip-bg); }
.ind-hline-add-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.ind-hline-list {
  list-style: none;
  margin: var(--sp-1) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.ind-hline-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-sub);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--muted-aa);
}

.ind-hline-price {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink);
}

.ind-hline-del {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  outline: none;
  border-radius: 2px;
}
.ind-hline-del:hover { color: var(--down); }
.ind-hline-del:focus-visible { outline: 2px solid var(--primary); }

.ind-hline-clear-btn {
  margin-top: var(--sp-1);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted-aa);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: inherit;
  padding: 3px 10px;
  min-height: 28px;
  cursor: pointer;
  outline: none;
}
.ind-hline-clear-btn[hidden] { display: none; }
.ind-hline-clear-btn:hover { color: var(--down); border-color: var(--down); }
.ind-hline-clear-btn:focus-visible { outline: 2px solid var(--primary); }

/* === 別ペイン共通 === */
.ind-pane {
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--gap-element);
  border-left: 3px solid rgba(12,25,51,0.30);
}
.ind-pane[hidden] { display: none; }

.ind-pane--rsi  { height: 100px; }
.ind-pane--macd { height: 120px; }

/* ===== v13: Lot Selector ===== */
.lot-selector-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.lot-selector__label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted-aa);
  white-space: nowrap;
}
.lot-btns {
  display: flex;
  gap: var(--sp-1);
  flex: 1;
}
.lot-btn {
  flex: 1;
  padding: 8px 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: background var(--dur-fast), color var(--dur-fast),
              border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.lot-btn[aria-pressed="true"],
.lot-btn.is-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 2px 8px rgba(37,99,235,0.22);
}
.lot-btn:hover:not([aria-pressed="true"]):not(.is-active) {
  background: var(--chip-bg);
  border-color: var(--primary);
  color: var(--primary);
}
.lot-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ===== v13.1: Pending Order Form ===== */
.ord-details { width: 100%; }
.ord-summary {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  padding: var(--sp-1) 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  user-select: none;
}
.ord-summary::-webkit-details-marker { display: none; }
.ord-summary::before {
  content: "▶";
  font-size: 0.7em;
  transition: transform var(--dur-base);
}
.ord-details[open] .ord-summary::before { transform: rotate(90deg); }

.ord-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3) 0 var(--sp-2);
}
.ord-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.ord-label {
  font-size: var(--text-xs);
  color: var(--muted-aa);
  min-width: 72px;
  flex-shrink: 0;
}

/* v13.1: 方向/種別トグルボタン */
.ord-side-btns,
.ord-type-btns {
  display: flex;
  gap: var(--sp-2);
  flex: 1;
}
.btn-ord-side,
.btn-ord-kind {
  flex: 1;
  padding: 7px 12px;
  min-height: 36px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.btn-ord-side.is-active[data-side="buy"],
.btn-ord-side[aria-pressed="true"][data-side="buy"] {
  background: var(--up);
  color: #fff;
  border-color: var(--up);
}
.btn-ord-side.is-active[data-side="sell"],
.btn-ord-side[aria-pressed="true"][data-side="sell"] {
  background: var(--down);
  color: #fff;
  border-color: var(--down);
}
.btn-ord-kind.is-active,
.btn-ord-kind[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-ord-side:focus-visible,
.btn-ord-kind:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* hint テキスト（種別ボタン内の補足） */
.ord-kind-hint {
  font-size: var(--text-xs);
  font-weight: 400;
  opacity: 0.82;
  display: block;
  margin-top: 1px;
}

/* v13.1: pips 入力 */
.ord-pips-input {
  width: 90px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-base);
}
.ord-pips-input:focus { border-color: var(--primary); }
.ord-pips-unit {
  font-size: var(--text-xs);
  color: var(--muted-aa);
  margin-left: 2px;
}

/* v13.1: preview テキスト */
.ord-preview {
  font-size: var(--text-xs);
  color: var(--muted-aa);
  min-height: 1.4em;
  padding: var(--sp-1) 0;
  line-height: 1.5;
}
.ord-preview:not(:empty) {
  color: var(--ink);
}

/* pending チャートライン凡例 */
.ord-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--muted-aa);
  margin-top: var(--sp-1);
}
.ord-legend__line {
  display: inline-block;
  width: 24px;
  height: 0;
  border-top: 2px dashed rgba(37, 99, 235, 0.55);
  vertical-align: middle;
}

.btn-place-order {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 22px;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  align-self: flex-end;
}
.btn-place-order:hover:not(:disabled) { background: #152241; }
.btn-place-order:disabled { opacity: 0.32; cursor: not-allowed; }
.btn-place-order:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* 注文一覧 */
.ord-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.ord-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-sub);
  font-size: var(--text-xs);
}
.ord-item__tag {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: var(--text-xs);
  color: #fff;
}
.ord-item__tag--limit-buy,
.ord-item__tag--stop-buy   { background: var(--up); }
.ord-item__tag--limit-sell,
.ord-item__tag--stop-sell  { background: var(--down); }

.ord-item__price {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  flex: 1;
}
.btn-ord-cancel {
  padding: 3px 10px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--muted-aa);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.btn-ord-cancel:hover { color: var(--down); border-color: var(--down); }
.btn-ord-cancel:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ===== v13: 複数建玉リスト ===== */
.pos-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
}
.pos-list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-2);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--line);
  font-size: var(--text-xs);
}
.pos-list-item.is-buy { border-left: 3px solid var(--up); }
.pos-list-item.is-sell { border-left: 3px solid var(--down); }

.btn-exit-pos {
  margin-left: auto;
  padding: 3px 12px;
  min-height: 28px;
  border: 1.5px solid var(--primary);
  border-radius: 4px;
  background: var(--card);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.btn-exit-pos:hover { background: var(--chip-bg); }
.btn-exit-pos:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* 全決済ボタン */
.btn-exit-all {
  background: var(--card);
  border: 2px solid var(--down);
  color: var(--down);
  font-weight: 700;
  padding: 10px 20px;
  min-height: 44px;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  width: 100%;
  margin-top: var(--sp-2);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur-base), box-shadow var(--dur-base);
}
.btn-exit-all:hover:not(:disabled) {
  background: rgba(204,56,71,0.05);
  box-shadow: 0 2px 10px rgba(204,56,71,0.15);
}
.btn-exit-all:disabled { opacity: 0.32; cursor: not-allowed; }
.btn-exit-all[hidden] { display: none; }
.btn-exit-all:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* position-display 複数建玉時のスクロール制限 */
.position-display.has-multi {
  max-height: 120px;
  overflow-y: auto;
}

/* ===== v13: 初期資金選択 ===== */
.cap-select-wrap { margin-top: 12px; }
.cap-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted-aa);
  margin-bottom: var(--sp-2);
}
.cap-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cap-btn {
  flex: 1;
  min-width: 100px;
  padding: 8px 16px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  touch-action: manipulation;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.cap-btn[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}
.cap-btn:hover:not([aria-pressed="true"]) { background: var(--chip-bg); }
.cap-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ===== v13: rank-up overlay (self-contained for trade page) ===== */
.rankup-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(7,14,30,.62);
  display: grid; place-items: center; padding: 20px;
  animation: ru-fade var(--dur-base) var(--ease-out);
}
.rankup-box {
  width: 100%; max-width: 340px;
  background: linear-gradient(150deg, #15294f, #0c1933);
  color: #fff; border-radius: var(--radius-md); padding: 28px 24px 22px;
  text-align: center; box-shadow: 0 18px 48px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.12);
  animation: ru-pop var(--dur-base) var(--ease-out);
}
.ru-kicker { font-weight: 700; letter-spacing: .14em; font-size: 14px; color: #f4c64b; }
.ru-emblem { width: 116px; height: 116px; object-fit: contain; margin: 8px auto 4px; display: block; }
.ru-rank { font-size: 19px; font-weight: 800; margin-top: 4px; }
.ru-unlocked { font-size: 12px; color: rgba(255,255,255,.66); margin-top: 16px; }
.ru-list { list-style: none; margin: 8px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.ru-list li { font-size: 13.5px; font-weight: 700; color: #fff; }
.ru-close { margin-top: 6px; }
@keyframes ru-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ru-pop  { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }

/* ===== Mobile ≤480px: v13 additions ===== */
@media (max-width: 480px) {
  .ind-pane--rsi  { height: 80px; }
  .ind-pane--macd { height: 100px; }
  .ind-toggle-btn { min-height: 30px; padding: 4px 8px; }
  .ind-hline-input { width: 90px; }
  .btn-exit-pos { min-height: 32px; padding: 4px 10px; }
  .ord-row { flex-direction: column; align-items: flex-start; }
  .ord-side-btns, .ord-type-btns { width: 100%; }
  .ord-pips-input { width: 100%; }
  .btn-place-order { align-self: stretch; }
  .position-display.has-multi { max-height: 96px; }
}

/* ===== Reduced motion: v13 additions ===== */
@media (prefers-reduced-motion: reduce) {
  .ind-toggle-btn,
  .ind-hline-add-btn,
  .ind-hline-del,
  .ind-hline-clear-btn,
  .lot-btn,
  .btn-exit-pos,
  .btn-exit-all,
  .btn-place-order,
  .btn-ord-cancel,
  .cap-btn,
  .btn-ord-side,
  .btn-ord-kind,
  .ord-pips-input {
    transition: none !important;
  }
  .rankup-overlay, .rankup-box { animation: none; }
}

/* ===== v14: Locked features info panel ===== */
.op-section--locked {
  padding: var(--sp-3) var(--sp-4);
}

.locked-features__title {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted-aa);
  letter-spacing: 0.04em;
  margin: 0 0 var(--sp-2);
}

.locked-features__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
}

.locked-features__item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.01em;
}

.locked-features__lock {
  display: flex;
  align-items: center;
  color: var(--muted);
  opacity: 0.65;
  flex-shrink: 0;
}

/* =====================================================================
   v150: 注文操作バーを画面下に固定（sticky bottom action bar）
   メインチャート＋RSI/MACD＋インジ設定＋補助操作は上でスクロールし、
   次へ/ロット/Buy/Sell/決済 は常に画面下端で操作できる。
   ===================================================================== */
.op-panel.op-actions {
  position: sticky;
  bottom: 0;
  z-index: 30;
  margin-bottom: 0;
  /* 上向きの影で「浮いた固定バー」であることを示す */
  box-shadow: 0 -6px 18px rgba(20, 35, 60, 0.16);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
/* 固定バー内は縦を詰めてチャートの表示領域を確保 */
.op-actions > .op-section {
  padding-top: var(--sp-3);
  padding-bottom: var(--sp-3);
}
/* 補助カード（ロック情報・指値/逆指値）は中身が無いとき空カードを出さない */
.op-panel.op-extras {
  margin-bottom: var(--gap-element);
}
.op-panel.op-extras:not(:has(.op-section:not([hidden]))) {
  display: none;
}

/* =====================================================================
   v151: チャート可視領域の最大化（モバイル中心）
   1) 毎フレーム同じ説明文を削除（説明は開始画面の how にある）
   2) チャート高さをビューポート高に連動（ResizeObserver が追従）。
      固定操作バー＋上部要素の概算を差し引き、clamp で下限/上限を確保。
      → 下部固定バーがチャートを覆わず、画面サイズに応じて最大化される。
   3) モバイルは操作バーを圧縮し、その分チャートを広く取る。
   ===================================================================== */
.bar-and-trades-desc { display: none; }

/* チャート高 = 100dvh - (ヘッダ+HUD+進捗+固定操作バー の概算) */
.chart { height: clamp(260px, calc(100dvh - 560px), 520px); }

@media (max-width: 480px) {
  /* モバイル: 操作バーを圧縮した分、差し引きを小さくしてチャートを広く
     （ヘッダ84+HUD91+ポジ37+進捗30+固定バー259 ≒ 501 を差し引く） */
  .chart { height: clamp(240px, calc(100dvh - 506px), 440px); }

  /* 操作バー圧縮: advance-left を横並びにして1段分の高さを削る */
  .advance-left { flex-direction: row; align-items: center; gap: var(--sp-2); }
  .speed-combo { width: auto; min-width: 62px; }
  .btn-auto-toggle { min-height: 38px; }

  /* 固定バー内のセクション縦paddingを詰める */
  .op-actions > .op-section { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
  .btn-advance--large { min-height: 44px; }
  .btn-buy, .btn-sell { min-height: 50px; }
  .btn-exit { min-height: 44px; }

  /* HUD/ポジション/進捗の上下マージンを圧縮してチャート開始位置を上げる */
  #screen-trade > .position-display { margin: var(--sp-1) 0; }
  #screen-trade > .bar-and-trades-wrap { margin-bottom: var(--sp-2); }
}

/* =====================================================================
   v152: PC（広い画面）でのUX最適化 — 横幅活用 + スリム操作バー
   1) トレード画面のみ最大幅を広げてチャートを大きく（start/result は従来幅）
   2) 縦積みの操作バーを横1列のスリムバーに（マウス操作で大ボタン不要）
      → 固定バーが薄くなりチャートが大幅に広がる
   ===================================================================== */
@media (min-width: 1000px) {
  /* 横1列バーが確実に収まる広い画面のみ適用（iPad横1024〜デスクトップ）。
     720〜999px はスタック型のまま（横バーが溢れるため）。 */
  /* トレード画面のみワイド化（:has で他画面を巻き込まない） */
  .app:has(#screen-trade.is-active) { max-width: 1080px; }

  /* 操作バーを横1列に */
  .op-panel.op-actions {
    flex-direction: row;
    align-items: stretch;
    flex-wrap: nowrap;
  }
  .op-actions > .op-section {
    flex: 0 0 auto;
    justify-content: center;
    padding: var(--sp-3) var(--sp-4);
  }
  /* 区切りは縦線に切り替え（横積み時の上罫線を打ち消す） */
  .op-actions > .op-section + .op-section {
    border-top: none;
    border-left: var(--zone-divider);
  }

  /* advance（自動/速度/次へ）を1行に収める */
  .op-actions .advance-controls { align-items: center; gap: var(--sp-2); }
  .op-actions .advance-left { flex-direction: row; align-items: center; gap: var(--sp-2); }
  .op-actions .speed-combo { width: auto; min-width: 64px; }
  .op-actions .btn-advance--large { min-height: 50px; min-width: 110px; flex: 0 0 auto; }

  /* trade（Buy/Sell）が余白を使って中央の主役に */
  .op-actions > .op-section--trade { flex: 1 1 auto; }
  .op-actions .btn-buy,
  .op-actions .btn-sell { min-height: 54px; font-size: var(--text-lg); }

  /* exit（決済）はコンパクトに */
  .op-actions .btn-exit { min-height: 54px; }

  /* デスクトップはチャートをさらに大きく（薄いバー分の余白を回収）。
     ヘッダ95+HUD70+ポジ47+進捗40+固定バー84 ≒ 400 を差し引き、固定バーに重ねない。 */
  .chart { height: clamp(340px, calc(100dvh - 400px), 640px); }

  /* 補助パネル（ロック案内・指値）は横幅が広いので最大幅を抑えて間延び防止 */
  #locked-features ul { max-width: 760px; }
}

/* =====================================================================
   v153: 仕上げ — iOS セーフエリア / 上部圧縮 / 横向きスマホ対応
   ===================================================================== */

/* (1) iOS ホームインジケータ対策: 固定バー下端にセーフエリア分の余白を確保。
   決済ボタンがホームバーに隠れない（非対応端末では env() が 0）。 */
.op-panel.op-actions {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 480px) {
  /* (2) ポジション行を1行固定（長い損益でも折返さずチャートを押し下げない） */
  #screen-trade > .position-display {
    flex-wrap: nowrap;
    min-height: 38px;
    overflow: hidden;
  }
  #screen-trade > .position-display .pos-entry { white-space: nowrap; }

  /* 進捗ラベルとバーの間隔を詰めて上部をさらに圧縮 */
  #screen-trade > .bar-and-trades-wrap { margin-top: 0; }
  .session-status { margin-bottom: 2px; }
}

/* (3) 横向きスマホ（低い画面）: 横幅を活かしてチャートを主役に。
   操作バーはコンパクトな横並び（必要なら2段に折返し）にして縦を節約。 */
@media (orientation: landscape) and (max-height: 540px) {
  /* ヘッダを薄く（ロゴは高さ基準で縮小）。
     トレード画面のみに限定（start/result 画面を巻き込まない / Codex Med-3）。 */
  body:has(#screen-trade.is-active) .site-header { padding: 3px 12px; }
  body:has(#screen-trade.is-active) .site-header__logo { width: auto; height: 26px; }
  .app:has(#screen-trade.is-active) { padding: var(--sp-3) var(--sp-4) var(--sp-4); }

  /* 上部要素を圧縮（.game-head はトレード画面専用要素だが明示スコープ） */
  #screen-trade.is-active .game-head { padding: var(--sp-1) var(--sp-3); margin-bottom: var(--sp-2); }
  #screen-trade > .position-display { min-height: 32px; margin: 2px 0; padding: 2px var(--sp-3); }
  #screen-trade > .bar-and-trades-wrap { margin-bottom: var(--sp-1); }

  /* 操作バー: 横並び（端末幅により1〜2段に折返し。見切れ防止で wrap） */
  .op-panel.op-actions { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .op-actions > .op-section { flex: 0 0 auto; padding: var(--sp-2); }
  .op-actions > .op-section + .op-section { border-top: none; border-left: var(--zone-divider); }
  .op-actions .advance-controls { align-items: center; gap: var(--sp-1); }
  .op-actions .advance-left { flex-direction: row; align-items: center; gap: var(--sp-1); }
  .op-actions .speed-combo { width: auto; min-width: 54px; }
  .op-actions .btn-advance--large { min-height: 40px; min-width: 70px; flex: 0 0 auto; padding: 8px 12px; }
  /* lot: ラベルを隠してボタンのみ（横幅節約） */
  .op-actions .lot-selector__label { display: none; }
  .op-actions .lot-btn { min-width: 40px; padding: 6px 8px; }
  /* trade（Buy/Sell）は余白を使う主役 */
  .op-actions > .op-section--trade { flex: 1 1 auto; }
  .op-actions .btn-buy, .op-actions .btn-sell { min-height: 42px; font-size: var(--text-base); padding: 8px 10px; }
  .op-actions .btn-exit { min-height: 42px; padding: 8px 14px; }

  /* チャートは残り高さに合わせて（最小160px・スクロール可 / Codex Med-4 微調整） */
  .chart { height: clamp(160px, calc(100dvh - 200px), 360px); }
}

/* =====================================================================
   v156: 説明画像（intro-trade.png）でタイトル＋遊び方を置換。
   残りチャレンジ回数（#daily-allowance）は画像の下に配置。
   ===================================================================== */
.game-intro-img {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--sp-1) 0 var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(12,25,51,0.12);
  box-shadow: var(--shadow-md);
  background: #fff;
}
.daily-allowance {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--brand-ink);
  text-align: center;
  margin: 0 0 var(--sp-5);
  line-height: 1.6;
}

.game-intro-pic { display: block; }

/* =====================================================================
   v160: 指値・逆指値のチャート指定（タップで価格指定）
   ===================================================================== */
.ord-row--pick { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.btn-ord-pick {
  padding: 8px 14px;
  min-height: 38px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ord-pick:hover { background: var(--chip-bg); }
.btn-ord-pick.is-active,
.btn-ord-pick[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37,99,235,0.28);
}
.btn-ord-pick:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ord-pick-hint {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary);
}

/* =====================================================================
   v164: 水平線のチャートタップ追加（ピックボタン）
   ===================================================================== */
.ind-hline-pick-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.btn-ord-pick--sm { min-height: 32px; padding: 6px 12px; font-size: var(--text-xs); }

/* =====================================================================
   v171: 結果画面の次セッションエリア3状態出し分け
   （残あり=次へボタン / 残0&回復可=Xシェア回復ボタン / 残0&回復不可=メッセージ）
   [hidden] が .result-actions .btn { width:100% } 等に負けないよう明示ガード
   ===================================================================== */
.result-actions .btn[hidden] { display: none !important; }
.btn-recover-x[hidden] { display: none !important; }
.next-session-note {
  margin: 4px auto 2px;
  max-width: 420px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--muted-aa);
  text-align: center;
  line-height: 1.6;
}
.next-session-note[hidden] { display: none !important; }
