/* 천하제일 주식대회 - 스타일 */
:root {
  --bg: #0d1117;
  --bg2: #131922;
  --panel: #171e29;
  --panel2: #1d2634;
  --line: #263041;
  --line2: #33405480;
  --tx: #e6edf3;
  --tx2: #9aa7b8;
  --tx3: #6b7889;
  --up: #ff4d5a;
  --down: #3d8bff;
  --gold: #f5c451;
  --acc: #4f8cff;
  --ok: #2ecc8f;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --r: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  /* 거래 화면이라 움직이진 않고, 은은한 빛으로 깊이만 준다 */
  background:
    radial-gradient(920px 500px at 6% -8%, #17243d 0%, transparent 58%),
    radial-gradient(800px 440px at 100% 2%, #2c2211 0%, transparent 56%),
    var(--bg);
  background-attachment: fixed;
  color: var(--tx);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
               "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 14px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc); text-decoration: none; }
.hide { display: none !important; }

/* 숫자는 폭이 고정된 글꼴로 */
.num, td.num, .mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--tx2); }
.muted { color: var(--tx2); }
.dim { color: var(--tx3); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.bold { font-weight: 700; }

/* ================================================= 로그인 (대회 입장 화면) */
#gate {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px; overflow: hidden;
  background:
    radial-gradient(1100px 620px at 12% -12%, #1a2b52 0%, transparent 62%),
    radial-gradient(900px 520px at 92% 108%, #43300f 0%, transparent 62%),
    linear-gradient(178deg, #0b1018 0%, #0d1117 55%, #10131c 100%);
}

/* ---- 배경 연출 ---- */
.fx { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.orb.o1 { width: 460px; height: 460px; left: -120px; top: -140px;
          background: radial-gradient(circle, #2f6bd8, transparent 70%);
          animation: drift1 19s ease-in-out infinite; }
.orb.o2 { width: 400px; height: 400px; right: -110px; bottom: -90px;
          background: radial-gradient(circle, #d8a12f, transparent 70%);
          animation: drift2 23s ease-in-out infinite; }
.orb.o3 { width: 320px; height: 320px; left: 55%; top: 8%;
          background: radial-gradient(circle, #8d4fd8, transparent 70%);
          opacity: .3; animation: drift1 27s ease-in-out infinite reverse; }
@keyframes drift1 { 50% { transform: translate(70px, 55px) scale(1.15); } }
@keyframes drift2 { 50% { transform: translate(-60px, -45px) scale(1.1); } }

/* 아케이드 게임 느낌의 원근 격자 바닥 */
.floor {
  position: absolute; left: -60%; right: -60%; bottom: 0; height: 70%;
  background-image:
    linear-gradient(#f5c4517a 1px, transparent 1px),
    linear-gradient(90deg, #f5c4515c 1px, transparent 1px);
  background-size: 64px 64px;
  transform: perspective(700px) rotateX(64deg); transform-origin: bottom center;
  animation: floorRun 5.5s linear infinite;
  -webkit-mask-image: linear-gradient(to top, #000 2%, #000c 22%, transparent 72%);
  mask-image: linear-gradient(to top, #000 2%, #000c 22%, transparent 72%);
}
@keyframes floorRun { to { background-position: 0 64px, 0 0; } }

/* 떠오르는 캔들(봉) */
.candles { position: absolute; inset: 0; }
.cd {
  position: absolute; bottom: -90px; width: var(--w); height: var(--h);
  border-radius: 2px; opacity: .34;
  animation: cdRise var(--dur) linear infinite;
}
.cd.u { background: var(--up); }
.cd.d { background: var(--down); }
.cd::before, .cd::after {
  content: ''; position: absolute; left: 50%; width: 2px;
  margin-left: -1px; background: inherit;
}
.cd::before { top: -10px; height: 10px; }
.cd::after { bottom: -10px; height: 10px; }
@keyframes cdRise {
  from { transform: translateY(0); }
  to   { transform: translateY(-118vh); }
}

/* ---- 카드 ---- */
.gate-card {
  position: relative; z-index: 2;
  width: 100%; max-width: 410px; padding: 34px 28px 26px;
  border-radius: 22px; border: 1px solid #f5c4512e;
  background: linear-gradient(168deg, #1b2434f2, #121926fa);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 26px 70px #000a, 0 0 70px -18px #f5c45140, inset 0 1px 0 #ffffff12;
}

.ribbon {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  padding: 5px 15px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 800; color: #2a1c00;
  background: linear-gradient(96deg, #ffd76e, #f0b02a);
  box-shadow: 0 5px 18px #f5c4515c;
}

.gate-logo { position: relative; text-align: center; margin-bottom: 24px; }
.gate-logo .rays {
  position: absolute; top: -26px; left: 50%; width: 210px; height: 210px;
  margin-left: -105px; pointer-events: none; opacity: .5;
  background: conic-gradient(from 0deg, transparent 0 8deg, #f5c45130 8deg 11deg,
              transparent 11deg 30deg);
  -webkit-mask-image: radial-gradient(circle, #000 18%, transparent 66%);
  mask-image: radial-gradient(circle, #000 18%, transparent 66%);
  animation: spin 24s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gate-logo .cup {
  position: relative; font-size: 52px; line-height: 1;
  filter: drop-shadow(0 0 20px #f5c45185);
  animation: bob 3.6s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-9px); } }

.gate-logo h1 {
  position: relative; margin: 12px 0 5px; font-size: 27px;
  font-weight: 900; letter-spacing: -.8px;
  background: linear-gradient(100deg, #b8862a 0%, #f5c451 26%, #fff6d0 44%,
                              #f5c451 62%, #b8862a 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 5.5s linear infinite;
}
@keyframes shine { to { background-position: -250% 0; } }

.gate-logo p { margin: 0; color: var(--tx2); font-size: 13px; word-break: keep-all; }
.gate-logo p b { color: var(--gold); }

/* ---- 카드 하단 ---- */
.gate-foot { margin-top: 20px; padding-top: 15px; border-top: 1px solid #ffffff10; }
.gate-foot p {
  margin: 9px 0 0; text-align: center; font-size: 11px;
  color: var(--tx3); word-break: keep-all;
}
.gate-ticker { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.gate-ticker span {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: #ffffff0a; border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.gate-ticker b { color: var(--tx2); font-weight: 600; margin-right: 4px; }

/* 버튼 위로 지나가는 광택 */
.btn.gold { position: relative; overflow: hidden; }
.btn.gold::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 45%;
  left: -60%; transform: skewX(-22deg); pointer-events: none;
  background: linear-gradient(90deg, transparent, #ffffff5c, transparent);
  animation: sweep 4.5s ease-in-out infinite;
}
@keyframes sweep { 0%, 62% { left: -60%; } 100% { left: 130%; } }

@media (prefers-reduced-motion: reduce) {
  .orb, .floor, .cd, .gate-logo .cup, .gate-logo h1,
  .gate-logo .rays, .btn.gold::after { animation: none !important; }
}

.tabs2 { display: flex; background: var(--bg2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs2 button {
  flex: 1; padding: 9px; border: 0; background: transparent; color: var(--tx2);
  border-radius: 7px; font-weight: 600;
}
.tabs2 button.on { background: var(--panel2); color: var(--tx); box-shadow: 0 1px 4px #0006; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--tx2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--acc); }

.btn {
  width: 100%; padding: 12px; border: 0; border-radius: 11px;
  background: var(--acc); color: #fff; font-weight: 700; font-size: 15px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.gold { background: linear-gradient(95deg, #e0a92c, var(--gold)); color: #2a1e00; }
.btn.ghost { background: var(--panel2); color: var(--tx); border: 1px solid var(--line); }
.btn.buy { background: var(--up); }
.btn.sell { background: var(--down); }
.btn.sm { width: auto; padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.xs { width: auto; padding: 4px 9px; font-size: 12px; border-radius: 7px; font-weight: 600; }
.btn.danger { background: #c0392b; }

.msg { margin-top: 12px; padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.msg.err { background: #3a1b1e; color: #ff9aa2; border: 1px solid #5c2429; }
.msg.ok { background: #12332a; color: #7ee2b8; border: 1px solid #1d5344; }

/* ================================================= 헤더 */
header {
  position: sticky; top: 0; z-index: 50;
  background: #10161fee; backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hbar { display: flex; align-items: center; gap: 14px; padding: 11px 18px; max-width: 1400px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; white-space: nowrap; }
.brand .cup { font-size: 21px; }
.brand span.t {
  background: linear-gradient(92deg, var(--gold), #ffeab0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spacer { flex: 1; }
.whoami { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #3c5a92, #2b3d63); font-weight: 700; font-size: 13px;
}

/* 지수 스트립 */
.ticker { display: flex; gap: 8px; overflow-x: auto; padding: 7px 18px; border-top: 1px solid var(--line);
          max-width: 1400px; margin: 0 auto; scrollbar-width: none; }
.ticker::-webkit-scrollbar { display: none; }
.tk { display: flex; align-items: baseline; gap: 7px; padding: 4px 11px; background: var(--bg2);
      border: 1px solid var(--line); border-radius: 8px; white-space: nowrap; font-size: 12px; }
.tk b { font-weight: 600; color: var(--tx2); }

/* 탭 */
nav.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px; max-width: 1400px;
           margin: 0 auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  padding: 11px 15px; background: transparent; border: 0; border-bottom: 2px solid transparent;
  color: var(--tx2); font-weight: 600; white-space: nowrap;
}
nav.tabs button.on { color: var(--tx); border-bottom-color: var(--gold); }

main { max-width: 1400px; margin: 0 auto; padding: 18px; }

/* ================================================= 패널 */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px; margin-bottom: 16px;
}
.panel > h3 {
  margin: 0 0 13px; font-size: 14px; display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap;
}
.panel > h3 .spacer { flex: 1; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 980px) {
  .g2, .g3, .g4, .g-side { grid-template-columns: 1fr; }
}

/* 요약 카드 */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--tx2); margin-bottom: 6px; font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.stat .s { font-size: 12px; color: var(--tx3); margin-top: 3px; }
.stat.hero { background: linear-gradient(150deg, #1c2740, var(--panel) 65%); }

/* ================================================= 테이블 */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: right; padding: 9px 10px; color: var(--tx3); font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
  background: var(--panel);
}
th:first-child, td:first-child { text-align: left; }
td { padding: 10px; border-bottom: 1px solid var(--line2); text-align: right; white-space: nowrap; }
tbody tr:hover { background: #ffffff06; }
tbody tr.me { background: #f5c4510f; }
tbody tr.me td { border-bottom-color: #f5c45133; }
.empty { padding: 34px 10px; text-align: center; color: var(--tx3); }

.badge {
  display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px;
  font-weight: 700; background: var(--panel2); color: var(--tx2); border: 1px solid var(--line);
}
.badge.kr { background: #16304d; color: #7fb6ff; border-color: #23486e; }
.badge.us { background: #3d2c14; color: #f0c274; border-color: #5c4520; }
.badge.buy { background: #40161b; color: #ff8f98; border-color: #63242b; }
.badge.sell { background: #14284a; color: #86b6ff; border-color: #1f3d6b; }
.rk { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
      background: var(--panel2); font-weight: 800; font-size: 12px; }
.rk.r1 { background: linear-gradient(140deg, #f6c953, #c98f16); color: #241a00; }
.rk.r2 { background: linear-gradient(140deg, #d6dde6, #9aa5b1); color: #1c2129; }
.rk.r3 { background: linear-gradient(140deg, #d59158, #a3672f); color: #241300; }

/* ================================================= 검색 */
.search-box { position: relative; }
.search-box input { width: 100%; padding: 13px 15px; font-size: 15px; background: var(--bg2);
                    border: 1px solid var(--line); border-radius: 12px; outline: none; }
.search-box input:focus { border-color: var(--acc); }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px;
  max-height: 340px; overflow-y: auto; box-shadow: var(--shadow);
}
.results div.it { padding: 11px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer;
                  border-bottom: 1px solid var(--line2); }
.results div.it:last-child { border-bottom: 0; }
.results div.it:hover, .results div.it.sel { background: #ffffff0d; }
.results .nm { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* 주문 패널 */
.side-toggle { display: flex; gap: 6px; background: var(--bg2); padding: 4px; border-radius: 11px; margin-bottom: 14px; }
.side-toggle button { flex: 1; padding: 10px; border: 0; background: transparent; color: var(--tx2);
                      border-radius: 8px; font-weight: 700; }
.side-toggle button.on.b { background: var(--up); color: #fff; }
.side-toggle button.on.s { background: var(--down); color: #fff; }
.qty-row { display: flex; gap: 6px; margin-bottom: 10px; }
.qty-row button { flex: 1; padding: 7px; background: var(--panel2); border: 1px solid var(--line);
                  border-radius: 8px; color: var(--tx2); font-size: 12px; font-weight: 600; }
.qty-row button:hover { border-color: var(--acc); color: var(--tx); }
.kv { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.kv .k { color: var(--tx2); }
.kv.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 15px; }

/* 차트 */
.chart-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head .px { font-size: 27px; font-weight: 800; letter-spacing: -1px; }
.rngs { display: flex; gap: 4px; }
.rngs button { padding: 5px 11px; background: var(--bg2); border: 1px solid var(--line);
               border-radius: 8px; color: var(--tx2); font-size: 12px; font-weight: 600; }
.rngs button.on { background: var(--acc); border-color: var(--acc); color: #fff; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; }
.legend i { display: inline-block; width: 11px; height: 3px; border-radius: 2px; margin-right: 5px;
            vertical-align: middle; }

/* 게시판 */
.post { padding: 10px 0; border-bottom: 1px solid var(--line2); }
.post:last-child { border-bottom: 0; }
.post .h { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--tx3); margin-bottom: 3px; }
.post .h b { color: var(--gold); font-size: 13px; }
.post .c { white-space: pre-wrap; word-break: break-word; }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: #000a; z-index: 200; display: grid;
            place-items: center; padding: 18px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
         padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--shadow);
         max-height: 90vh; overflow-y: auto; }
.modal h3 { margin: 0 0 15px; font-size: 16px; }
.modal .row { display: flex; gap: 8px; margin-top: 16px; }

/* 토스트 */
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 500;
         display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 11px; background: #222c3c; border: 1px solid var(--line);
         box-shadow: var(--shadow); font-size: 13px; font-weight: 600; max-width: 90vw; }
.toast.ok { background: #143a2c; border-color: #1e5b45; color: #93ecc5; }
.toast.err { background: #3d1a1e; border-color: #63272d; color: #ffa3aa; }

/* 대회 배너 */
.contest {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(100deg, #241d0d, var(--panel) 62%);
  border: 1px solid #4a3c17; border-radius: var(--r); padding: 13px 17px; margin-bottom: 16px;
}
.contest .dday { font-size: 21px; font-weight: 800; color: var(--gold); }

@media (max-width: 640px) {
  main { padding: 12px; }
  .panel { padding: 13px; }

  /* 요약 카드는 2줄x2칸으로 — 세로로 길게 늘어지지 않게 */
  .grid.g4, .grid.g3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 11px 12px; }
  .stat .v { font-size: 17px; letter-spacing: -.7px; }
  .stat .k, .stat .s { font-size: 11px; }
  .hbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 13px; gap: 6px; }
  .brand .cup { font-size: 18px; }
  .stat .v { font-size: 19px; }
  td, th { padding: 8px 7px; }

  /* 헤더가 줄바꿈으로 무너지지 않도록 */
  .whoami { gap: 7px; }
  .whoami .unm { min-width: 0; }
  .whoami .unm .bold {
    max-width: 72px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-size: 13px;
  }
  .whoami .unm .small { display: none; }
  .btn.xs, .btn.sm { white-space: nowrap; }
  nav.tabs button { padding: 10px 12px; font-size: 13px; }
}

@media (max-width: 430px) {
  .whoami .unm { display: none; }       /* 이름은 아바타로 대신 */
}

@media (max-width: 340px) {
  .brand .t { display: none; }          /* 아주 좁으면 트로피만 */
}
