:root {
  --bg: #000000;
  --bg2: #131516;
  --bg3: #1f2023;
  --panel: #131516;
  --border: #2a2d31;
  --text: #fafafa;
  --muted: #84888c;
  --green: #0ecb81;
  --green-dim: rgba(14,203,129,.15);
  --red: #f6465d;
  --red-dim: rgba(246,70,93,.15);
  --yellow: #f68f15;
  --blue: #f68f15;
  --accent: #f68f15;
  --font: "IBM Plex Sans", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

/* 스크롤바 숨김 (스크롤 동작은 유지) */
html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar { width: 0; height: 0; display: none; }

.hide-scroll,
.market-bar,
.nav,
.ticker-stats,
.feed-list,
.hist-list,
.table-scroll,
.recent-bets {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hide-scroll::-webkit-scrollbar,
.market-bar::-webkit-scrollbar,
.nav::-webkit-scrollbar,
.ticker-stats::-webkit-scrollbar,
.feed-list::-webkit-scrollbar,
.hist-list::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar,
.recent-bets::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
img { display: block; max-width: 100%; }

.topbar {
  min-height: 56px;
  height: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: #000000;
  position: sticky; top: 0; z-index: 50;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: .02em;
}
.bp-logo {
  display: block;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 10px rgba(246,143,21,.45));
}
.brand span.en {
  color: var(--yellow);
  margin-left: 4px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .08em;
}
.nav { display: flex; gap: 18px; color: var(--muted); font-size: 14px; }
.nav a:hover, .nav a.active { color: var(--text); }
.userchip {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; color: var(--muted);
}
.userchip strong { color: var(--yellow); font-family: var(--mono); }

/* ===== Landing ===== */
.hero {
  position: relative;
  min-height: calc(100vh - 56px);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 32px;
  padding: 48px 40px 64px;
  align-items: center;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(246,143,21,.12), transparent 60%),
    radial-gradient(700px 400px at 90% 80%, rgba(14,203,129,.08), transparent 55%),
    linear-gradient(180deg, #000000 0%, #0f141b 100%);
  z-index: 0;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.1;
  letter-spacing: -.02em;
}
.hero h1 em { font-style: normal; color: var(--yellow); }
.hero p.lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 16px;
  max-width: 520px;
  line-height: 1.6;
}
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 6px; cursor: pointer;
  padding: 12px 20px; font-weight: 600; font-size: 14px;
  transition: transform .15s, opacity .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: #f68f15; color: #000; }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.stat-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 36px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat-card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.stat-card .price { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.stat-card .chg { font-size: 13px; margin-top: 6px; font-family: var(--mono); }
.up { color: var(--green); }
.down { color: var(--red); }

.preview-panel {
  background: linear-gradient(180deg, #161b24, #10141a);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.preview-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.preview-body { height: 360px; }
.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 40px 72px;
}
.feature {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}
.feature h3 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

/* ===== Trade layout ===== */
.trade-shell {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr auto;
  height: calc(100vh - 56px);
  gap: 0;
}
.market-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.market-bar::-webkit-scrollbar { display: none; }
.coin-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.coin-tab.active {
  background: var(--bg3);
  border-color: var(--border);
  color: var(--text);
}
.coin-ico {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  position: relative; overflow: hidden;
}
/* 실제 거래소 로고를 덮어 씌운다 (없으면 아래 글자 원형이 그대로 보인다) */
.coin-ico > img.ci-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover; display: block;
}
.coin-ico.has-ico { color: transparent; }
.coin-ico.btc { background: #f7931a; color: #111; }
.coin-ico.eth { background: #627eea; color: #fff; }
.coin-ico.xrp { background: #23292f; color: #fff; }
.coin-ico.sol { background: #9945ff; color: #fff; }
.coin-ico.doge { background: #c2a633; color: #111; }
.coin-ico.ada { background: #0033ad; color: #fff; }
.coin-ico.trx { background: #ff0013; color: #fff; }
.coin-ico.link { background: #2a5ada; color: #fff; }
.coin-ico.avax { background: #e84142; color: #fff; }
.coin-ico.dot { background: #e6007a; color: #fff; }
.coin-ico.bch { background: #0ac18e; color: #111; }
.coin-ico.etc { background: #328332; color: #fff; }
.coin-ico.atom { background: #2e3148; color: #fff; }
.coin-ico.near { background: #000; color: #fff; }
.coin-ico.xlm { background: #14b6e7; color: #111; }
.coin-ico.usdt { background: #26a17b; color: #fff; }
.coin-ico.krw { background: #1a5fb4; color: #fff; }
.interval-group { display: flex; gap: 6px; margin-left: 8px; }
.iv-btn {
  padding: 7px 12px; border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
}
.iv-btn.active { background: rgba(246,143,21,.12); color: var(--yellow); border-color: rgba(246,143,21,.45); }

.ticker-stats {
  margin-left: auto;
  display: flex; gap: 18px; font-size: 12px; color: var(--muted);
  font-family: var(--mono);
}
.ticker-stats b { color: var(--text); font-weight: 600; }

.chart-wrap {
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}
.chart-meta {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.chart-meta .pair { font-weight: 700; font-size: 16px; }
.chart-meta .live { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.round-timer {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted);
}
.round-timer .clock {
  font-family: var(--mono); font-size: 18px; color: var(--yellow); font-weight: 700;
}
.round-timer .dim { opacity: .75; }
.round-badge {
  background: rgba(246,143,21,.14);
  color: var(--yellow);
  border: 1px solid rgba(246,143,21,.35);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-family: var(--mono);
}
.round-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: #10141b;
}
.rb-item {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.rb-item:last-child { border-right: 0; }
.rb-k { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.rb-v { display: block; font-size: 13px; font-weight: 600; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-v.accent { color: var(--yellow); font-size: 16px; }
.bet-status {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(246,143,21,.08);
  color: var(--yellow);
  border: 1px solid rgba(246,143,21,.2);
}
.bet-status.locked {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(246,70,93,.25);
}
.bet-status.ok {
  background: var(--green-dim);
  color: var(--green);
  border-color: rgba(14,203,129,.25);
}
.hint-pill {
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.hint-pill.LONG { background: var(--green-dim); color: var(--green); }
.hint-pill.SHORT { background: var(--red-dim); color: var(--red); }
.hint-pill.FLAT { background: rgba(132,142,156,.2); color: var(--muted); }

#tv_chart { flex: 1; min-height: 420px; background: #131722; }

.side-panel {
  display: flex; flex-direction: column;
  background: var(--bg2);
  min-height: 0;
}
.order-box {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.order-box h4 {
  margin: 0 0 12px; font-size: 13px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}
.field input:focus { border-color: var(--yellow); }
.quick-amounts { display: flex; gap: 6px; margin-bottom: 12px; }
.quick-amounts button {
  flex: 1; padding: 7px 0; border-radius: 5px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--muted); cursor: pointer; font-size: 11px;
}
.pos-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-btn {
  padding: 14px 8px; border: 0; border-radius: 6px;
  font-weight: 700; cursor: pointer; font-size: 15px;
}
.pos-btn.long { background: var(--green); color: #04140c; }
.pos-btn.short { background: var(--red); color: #fff; }
.pos-btn:disabled { opacity: .45; cursor: not-allowed; }
.payout-note { margin-top: 10px; font-size: 12px; color: var(--muted); }
.payout-note b { color: var(--yellow); }
.clock-line {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.clock-line .clock {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: .02em;
}
.toast {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px;
  font-size: 12px; display: none;
}
.toast.show { display: block; }
.toast.ok { background: var(--green-dim); color: var(--green); }
.toast.err { background: var(--red-dim); color: var(--red); }

.feed-box, .hist-box {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border);
}
.feed-box h4, .hist-box h4 {
  margin: 0; padding: 10px 14px;
  font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.feed-list, .hist-list {
  flex: 1; overflow: auto;
  overscroll-behavior: contain;
  font-family: var(--mono); font-size: 11px;
  -webkit-overflow-scrolling: touch;
}
.feed-row, .hist-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(42,49,64,.5);
}
.feed-row.head, .hist-row.head {
  color: var(--muted); font-family: var(--font); position: sticky; top: 0;
  background: var(--bg2);
}
.bottom-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 220px 1fr;
  border-top: 1px solid var(--border);
  background: var(--panel);
  min-height: 160px;
}
.winrate-card {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
}
.winrate-card .big {
  font-size: 36px; font-weight: 700; font-family: var(--mono);
  color: var(--yellow); margin: 8px 0;
}
.winrate-card .sub { color: var(--muted); font-size: 12px; }
.recent-bets { padding: 10px 0; overflow: hidden; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.recent-bets table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 12px; }
.recent-bets th, .recent-bets td {
  padding: 8px 14px; text-align: left; border-bottom: 1px solid rgba(42,49,64,.6);
  white-space: nowrap;
}
.recent-bets th { color: var(--muted); font-weight: 500; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.badge.LONG, .badge.won { background: var(--green-dim); color: var(--green); }
.badge.SHORT, .badge.lost { background: var(--red-dim); color: var(--red); }
.badge.pending { background: rgba(246,143,21,.15); color: var(--yellow); }
.badge.draw { background: rgba(132,142,156,.2); color: var(--muted); }

.footer-note {
  padding: 20px 40px 40px;
  color: var(--muted); font-size: 12px; line-height: 1.5;
}

.ticker-stats .ts-item { white-space: nowrap; }

/* ===== Tablet ===== */
@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 28px 20px 36px;
    gap: 22px;
  }
  .preview-body { height: 300px; }
  .feature-row { grid-template-columns: 1fr; padding: 0 20px 40px; }
  .footer-note { padding: 16px 20px 32px; }
  .trade-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: calc(100dvh - 56px);
  }
  .chart-wrap { border-right: 0; }
  .side-panel { border-top: 1px solid var(--border); }
  .bottom-stats { grid-template-columns: 1fr; }
  .winrate-card { border-right: 0; border-bottom: 1px solid var(--border); }
  .round-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rb-item { border-bottom: 1px solid var(--border); }
  .ticker-stats {
    margin-left: 0;
    width: 100%;
    flex: 1 0 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    gap: 14px;
    padding: 4px 0 2px;
    scrollbar-width: none;
  }
  .ticker-stats::-webkit-scrollbar { display: none; }
  .market-bar { flex-wrap: wrap; }
  #tv_chart { min-height: 320px; height: 42vh; }
}

/* ===== Phone ===== */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px;
    row-gap: 8px;
  }
  .brand { gap: 8px; min-width: 0; }
  .brand span.en { font-size: 14px; display: inline; }
  .nav {
    order: 3;
    flex: 1 0 100%;
    gap: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    flex: 0 0 auto;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    background: var(--bg3);
    margin-right: 6px;
  }
  .nav a.active {
    background: rgba(246,143,21,.16);
    color: var(--yellow);
  }
  .userchip {
    margin-left: auto;
    font-size: 12px;
    gap: 8px;
  }
  .userchip #nick { display: none; }

  .hero { padding: 20px 14px 28px; }
  .hero h1 { font-size: clamp(26px, 8vw, 34px); }
  .hero p.lead { font-size: 14px; margin-bottom: 18px; }
  .cta-row { gap: 8px; }
  .btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 12px 14px;
    font-size: 13px;
  }
  .stat-strip {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 22px;
  }
  .stat-card { padding: 14px; }
  .stat-card .price { font-size: 20px; }
  .stat-card .chg { font-size: 12px; word-break: break-word; }
  .preview-panel { border-radius: 10px; }
  .preview-body { height: 240px; }
  .feature { padding: 16px; }

  .market-bar {
    padding: 8px 10px;
    gap: 6px;
  }
  .coin-tab { padding: 7px 10px; font-size: 13px; }
  .interval-group { margin-left: 0; }
  .iv-btn { padding: 7px 10px; min-width: 44px; }

  .chart-meta {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 10px 12px;
    align-items: flex-start;
  }
  .chart-meta .pair { font-size: 14px; }
  .chart-meta .live { font-size: 18px; width: 100%; }
  .round-timer {
    margin-left: 0;
    width: 100%;
    gap: 8px 10px;
    font-size: 11px;
  }
  .round-timer .clock { font-size: 16px; }
  .hint-pill { font-size: 10px; }

  .round-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rb-item { padding: 8px 10px; }
  .rb-k { font-size: 10px; }
  .rb-v { font-size: 12px; }
  .rb-v.accent { font-size: 15px; }

  #tv_chart {
    min-height: 260px;
    height: 38vh;
    max-height: 360px;
  }

  /* 모바일: 배팅 패널을 차트 바로 아래(가독·터치) */
  .trade-shell .side-panel { order: 3; }
  .trade-shell .chart-wrap { order: 2; }
  .trade-shell .market-bar { order: 1; }
  .trade-shell .bottom-stats { order: 4; }

  .order-box {
    position: static;
    background: var(--bg2);
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    box-shadow: none;
  }
  .pos-btn {
    padding: 16px 8px;
    font-size: 16px;
    min-height: 52px;
  }
  .quick-amounts button {
    padding: 10px 0;
    font-size: 12px;
    min-height: 40px;
  }
  .field input {
    font-size: 16px;
    padding: 12px;
  }
  .bet-status { font-size: 11px; line-height: 1.4; }

  /* 중첩 스크롤 제거 → 페이지 스크롤만 */
  .feed-box {
    max-height: none;
  }
  .feed-list {
    max-height: none;
    overflow: visible;
  }
  .feed-list .feed-row:nth-child(n+16) { display: none; }

  .bottom-stats { min-height: 0; }
  .winrate-card { padding: 14px; }
  .winrate-card .big { font-size: 28px; margin: 4px 0; }
  .recent-bets { padding: 6px 0 12px; }
  .table-scroll {
    overscroll-behavior-x: contain;
  }
  .recent-bets table { font-size: 11px; min-width: 520px; }
  .recent-bets th, .recent-bets td { padding: 7px 10px; }

  /* sticky topbar도 모바일에서 풀어 스크롤 걸림 완화 */
  .topbar { position: static; }
}

@media (max-width: 400px) {
  .stat-strip { grid-template-columns: 1fr; }
  .round-board { grid-template-columns: 1fr 1fr; }
  .coin-tab { padding: 6px 8px; }
  #tv_chart { height: 34vh; min-height: 220px; }
}
