/* ============================================================
   SCREEN STOCKS · 暖金像素主题
   规则：所有字号 12 的整数倍；无圆角；硬边；红涨绿跌
   ============================================================ */

@font-face {
  font-family: 'FP';
  src: url('/fonts/fp.woff2') format('woff2');
  font-display: block;
}

:root {
  --bg: #140d05;
  --panel: #1f1409;
  --panel2: #26190b;
  --ink: #ffc24b;
  --ink-soft: #e0a83c;
  --dim: #b3821f;
  --line: #3a2710;
  --up: #ff5a3c;
  --down: #4fd66b;
  --accent: #ff8c1a;
  --shadow: 0 0 0 rgba(0,0,0,0);
}

* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'FP', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: .5px;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.16) 0 2px, transparent 2px 4px);
}

button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; letter-spacing: inherit; }
.hidden { display: none !important; }
.u { color: var(--up) !important; }
.d { color: var(--down) !important; }
.fine { color: var(--dim); font-size: 12px; margin-top: 8px; }

/* ---------------- 入场 ---------------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.gate::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,140,26,.10), transparent 60%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.2) 0 2px, transparent 2px 4px);
  pointer-events: none;
}
.gate-box {
  position: relative;
  width: 100%; max-width: 400px;
  border: 4px solid var(--ink);
  background: var(--panel);
  padding: 32px 24px 24px;
  text-align: center;
  box-shadow: 8px 8px 0 #000;
}
.gate-hex {
  width: 48px; height: 48px; margin: 0 auto 20px;
  background: var(--ink);
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}
.gate-title { font-size: 24px; line-height: 1.6; margin-bottom: 8px; }
.gate-sub { font-size: 12px; color: var(--dim); margin-bottom: 24px; line-height: 1.6; }
.gate-input {
  width: 100%; padding: 12px;
  background: #0d0803;
  border: 4px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  text-align: center;
  outline: none;
}
.gate-input:focus { border-color: var(--ink); }
.gate-input::placeholder { color: #5c4310; }
.gate-btn {
  width: 100%; margin-top: 12px; padding: 12px;
  background: var(--accent);
  color: #1a0f00;
  font-size: 24px;
  border: 4px solid #ffb04f;
  box-shadow: 4px 4px 0 #000;
  transition: transform .06s steps(2), box-shadow .06s steps(2);
}
.gate-btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #000; }
.gate-btn:disabled { background: #3a2710; color: #6b5119; border-color: #4a3416; }
.gate-fine { margin-top: 20px; font-size: 12px; color: #5c4310; }

/* ---------------- 主框架 ---------------- */
.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  height: 100%;
  height: 100dvh;
  max-width: 1600px;
  margin: 0 auto;
}

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 16px;
  border-bottom: 4px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); font-size: 24px; line-height: 1; }
.brand-txt { font-size: 24px; line-height: 1; letter-spacing: 1px; }
.brand-txt em { color: var(--accent); font-style: normal; }

.wallet { line-height: 1.2; }
.wallet.right { margin-left: auto; text-align: right; }
.w-label { font-size: 12px; color: var(--dim); }
.w-value { font-size: 36px; line-height: 1.1; text-shadow: 0 0 10px rgba(255,194,75,.35); }
.w-pct { font-size: 12px; }
.w-sub { font-size: 12px; color: var(--dim); margin-top: 2px; }
.topbar-meta { font-size: 12px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.topbar-meta .lv { color: var(--accent); }
.topbar-meta .nick { color: var(--ink-soft); }
.dot { color: var(--line); }

.main {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  min-width: 0;
  gap: 0;
  min-height: 0;
}

.panel {
  border-right: 4px solid var(--line);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
}
.panel:last-child { border-right: none; }
.panel-head {
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  font-size: 12px; color: var(--dim);
  border-bottom: 2px solid var(--line);
  flex: none;
}

/* 股票列表 */
.stock-list { flex: 1; overflow-y: auto; min-height: 0; }
.stock-row {
  display: grid;
  grid-template-columns: 1fr 84px 64px;
  gap: 8px; align-items: center;
  padding: 9px 12px;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
}
.stock-row:hover { background: var(--panel2); }
.stock-row.on { background: var(--ink); color: #1a0f00; }
.stock-row.on .s-code, .stock-row.on .s-pct, .stock-row.on .u, .stock-row.on .d { color: #1a0f00 !important; opacity: .9; }
.s-name { font-size: 12px; line-height: 1.3; }
.s-code { font-size: 12px; color: var(--dim); }
.s-price { text-align: right; font-size: 12px; }
.s-pct { text-align: right; font-size: 12px; }

.xpbar { padding: 10px 12px; border-top: 2px solid var(--line); flex: none; }
.xp-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.xp-track { height: 8px; background: #0d0803; border: 2px solid var(--line); }
.xp-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s steps(8); }

/* 行情 */
.quote { padding: 0; }
.quote-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px 0;
}
.q-name { display: flex; align-items: baseline; gap: 8px; font-size: 24px; line-height: 1.2; }
.q-code { font-size: 12px; color: var(--dim); }
.q-price { text-align: right; }
.q-price > span:first-child { font-size: 48px; line-height: 1; text-shadow: 0 0 14px rgba(255,194,75,.35); }
.chg { font-size: 24px; margin-left: 8px; }
.q-joke { padding: 4px 16px 0; color: var(--accent); font-size: 12px; }
.q-stat { padding: 2px 16px 8px; color: var(--dim); font-size: 12px; }

.chart-wrap { flex: 1; min-height: 140px; padding: 0 12px; position: relative; }
#chart { position: absolute; inset: 0 12px; width: calc(100% - 24px); height: 100%; }
canvas#chart { display: block; image-rendering: pixelated; }
.chart-tip {
  position: absolute; left: 16px; top: 4px;
  font-size: 12px; color: var(--dim); text-align: left; line-height: 1.5;
  background: var(--bg);
  padding: 0 4px;
}

.tabs { display: flex; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); flex: none; }
.tab {
  flex: 1; padding: 8px 0; font-size: 12px; color: var(--dim);
  border-right: 2px solid var(--line);
}
.tab:last-child { border-right: none; }
.tab.on { color: #1a0f00; background: var(--ink); }

.tab-body { min-height: 220px; max-height: 258px; overflow-y: auto; padding: 6px 12px; flex: none; }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

/* 盘口 */
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.book-col { min-width: 0; }
.book-row { display: grid; grid-template-columns: 42px 1fr 64px; gap: 6px; padding: 1px 0; font-size: 12px; line-height: 1.5; }
.book-row .lbl { color: var(--dim); }
.book-row .amt { text-align: right; color: var(--dim); }
.book-sep { height: 2px; background: var(--line); margin: 6px 0; }
.book-head { color: var(--dim); border-bottom: 2px solid var(--line); margin-bottom: 2px; }

/* 明细 */
.tape-row { display: grid; grid-template-columns: 72px 1fr 64px; gap: 8px; padding: 2px 0; font-size: 12px; }
.tape-row .t { color: var(--dim); }
.tape-row .q { text-align: right; color: var(--dim); }

/* 任务 */
.task { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 2px solid var(--line); }
.task:last-child { border-bottom: none; }
.task-name { font-size: 12px; }
.task-sub { font-size: 12px; color: var(--dim); }
.task-xp { font-size: 12px; color: var(--accent); white-space: nowrap; }
.task.done .task-name { color: var(--down); }

/* 喊单墙 */
.call-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 4px 0; font-size: 12px; border-bottom: 1px solid #2a1a0c; }
.call-who { color: var(--ink-soft); }
.call-side.b { color: var(--up); }
.call-side.s { color: var(--down); }
.call-amt { color: var(--dim); }

/* 持仓 */
.pos-list { flex: 1; overflow-y: auto; min-height: 0; }
.pos-row { padding: 8px 12px; border-bottom: 2px solid var(--line); font-size: 12px; }
.pos-row .n { display: flex; justify-content: space-between; }
.pos-row .m { display: flex; justify-content: space-between; color: var(--dim); }
.pos-row .n .code { color: var(--dim); font-size: 12px; }
.pos-row .v { color: var(--dim); font-size: 12px; margin-top: 2px; }
.pos-row .v b { color: var(--ink); font-weight: normal; }
.pos-total.strong { border-top: 4px solid var(--ink); }
.pos-total.strong span { color: var(--ink); font-size: 12px; }
.pos-empty { padding: 20px 12px; color: var(--dim); font-size: 12px; text-align: center; }
.pos-total { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 2px solid var(--line); font-size: 12px; color: var(--dim); flex: none; }
.pos-total span:last-child { color: var(--ink); }

/* 底部 */
.actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 12px 16px;
  border-top: 4px solid var(--line);
  background: var(--panel);
}
.btn {
  padding: 14px 0; font-size: 24px; line-height: 1.1;
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 #000;
  transition: transform .06s steps(2), box-shadow .06s steps(2);
  color: var(--ink);
}
.btn small { display: block; font-size: 12px; color: var(--dim); margin-top: 4px; }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 #000; }
.btn.buy { color: var(--up); border-color: var(--up); }
.btn.sell { color: var(--down); border-color: var(--down); }
.btn.confirm { width: 100%; color: #1a0f00; background: var(--accent); border-color: #ffb04f; }

/* 抽屉 */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 95; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 96;
  background: var(--panel);
  border-top: 4px solid var(--ink);
  padding: 12px 16px 16px;
  transform: translateY(110%);
  transition: transform .18s steps(6);
  max-height: 80vh; overflow-y: auto;
}
.sheet.open { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 24px; margin-bottom: 12px; }
.sheet-close { font-size: 24px; color: var(--dim); }
.sheet-body { display: flex; flex-direction: column; gap: 10px; }
.sheet-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 6px 0; border-bottom: 2px solid var(--line); }
.sheet-row b { color: var(--ink-soft); }
.qty-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qty-grid button {
  padding: 10px 0; font-size: 12px;
  border: 2px solid var(--line); color: var(--ink-soft);
}
.qty-grid button.on { background: var(--ink); color: #1a0f00; border-color: var(--ink); }
.num-input {
  width: 120px; padding: 6px 8px; text-align: right;
  background: #0d0803; border: 2px solid var(--line); color: var(--ink);
  font-size: 12px; outline: none;
}
.num-input:focus { border-color: var(--ink); }
.sheet-msg { min-height: 18px; font-size: 12px; color: var(--accent); }
.sheet-msg.err { color: var(--up); }

/* 飘字 */
.float-layer { position: fixed; inset: 0; pointer-events: none; z-index: 97; }
.float-txt {
  position: absolute;
  font-size: 24px;
  text-shadow: 2px 2px 0 #000;
  animation: floatUp .9s steps(9) forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0%   { transform: translateY(0);    opacity: 1; }
  100% { transform: translateY(-64px); opacity: 0; }
}
@keyframes flashUp { 0% { color: var(--up); transform: scale(1.08); } 100% { color: var(--ink); transform: scale(1); } }
@keyframes flashDown { 0% { color: var(--down); transform: scale(1.08); } 100% { color: var(--ink); transform: scale(1); } }
.flash-up { animation: flashUp .25s steps(3); }
.flash-down { animation: flashDown .25s steps(3); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .main { grid-template-columns: 260px minmax(0, 1fr); }
  .positions { grid-column: 1 / -1; border-top: 4px solid var(--line); max-height: 200px; }
  .w-value { font-size: 24px; }
  .q-price > span:first-child { font-size: 36px; }
}

@media (max-width: 760px) {
  html, body { overflow-y: auto; overflow-x: hidden; }
  .app { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .stock-list { min-width: 0; }
  .actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .topbar {
    position: sticky; top: 0; z-index: 50;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 8px 12px;
    border-bottom-width: 4px;
  }
  .brand { grid-column: 1; }
  .brand-txt { font-size: 12px; letter-spacing: 1px; }
  .brand-mark { font-size: 12px; }
  .topbar-meta {
    grid-column: 1 / -1; grid-row: 3;
    font-size: 12px; white-space: nowrap; overflow: hidden;
    justify-content: flex-start;
  }
  .wallet { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
  .wallet.right { grid-column: 2; grid-row: 3; margin-left: 0; }
  .w-value { font-size: 24px; }
  .w-label { font-size: 12px; }

  .main { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 0; }

  .panel { border-right: none; }
  .stocks { border-bottom: 4px solid var(--line); }
  .panel-head { display: none; }
  .stock-list {
    display: flex; overflow-x: auto; overflow-y: hidden;
    gap: 8px; padding: 8px 12px;
    scrollbar-width: none;
  }
  .stock-list::-webkit-scrollbar { display: none; }
  .stock-row {
    flex: none;
    display: block;
    width: 132px;
    padding: 8px;
    border: 2px solid var(--line);
    text-align: left;
  }
  .stock-row.on { border-color: var(--ink); background: var(--ink); }
  .s-price, .s-pct { text-align: left; }
  .stock-row:only-child { flex: 1; }
  .s-price { margin-top: 4px; font-size: 24px; line-height: 1.1; white-space: nowrap; }
  .s-price.long { font-size: 12px; }
  .xpbar { padding: 8px 12px; }

  .quote { border-bottom: 4px solid var(--line); }
  .quote-head { padding: 10px 12px 0; flex-direction: column; align-items: flex-start; gap: 2px; }
  .q-name { font-size: 12px; }
  .q-price { text-align: left; }
  .q-price > span:first-child { font-size: 36px; }
  .chg { font-size: 12px; margin-left: 4px; }
  .q-joke, .q-stat { padding-left: 12px; padding-right: 12px; }
  .chart-wrap { height: 180px; flex: none; padding: 0 8px; }
  .tab-body { min-height: 190px; max-height: none; height: auto; overflow-y: visible; padding-top: 4px; }

  .positions { border-top: none; }
  .pos-list { max-height: 200px; }

  .actions {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 4px solid var(--ink);
  }
  .btn { padding: 12px 0; font-size: 24px; box-shadow: 3px 3px 0 #000; }
  .btn small { font-size: 12px; }

  .sheet { max-height: 86vh; }
  .gate-box { padding: 24px 16px 16px; }
  .gate-title { font-size: 24px; }
}

/* 指数卡片 */
.idx-info { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.idx-info > div { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }
.idx-info b { color: var(--ink); font-weight: normal; }
.idx-info .fine { margin-top: 6px; color: var(--dim); }
.btn.disabled { opacity: .35; border-color: var(--line); color: var(--dim); }
.btn.disabled small { color: var(--dim); }

/* 退出登录 */
.logout {
  margin-left: 8px;
  padding: 2px 8px;
  border: 2px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.4;
}
.logout:active { background: var(--line); color: var(--ink); }
.call-who.me { color: var(--accent); }

/* 股票说明 */
.q-desc {
  margin: 2px 16px 8px;
  padding: 6px 10px;
  border-left: 4px solid var(--accent);
  background: rgba(255,140,26,.06);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.7;
}
.q-desc:empty { display: none; }
@media (max-width: 760px) {
  .q-desc { margin: 2px 12px 8px; }
}
