/* 크래시 테이블. 로비(First Step Games)와 같은 색 체계를 쓴다. */

:root {
  color-scheme: dark;
  --bg: #080b14;
  --panel: rgba(15, 21, 38, 0.92);
  --card: #121a2b;
  --line: #263652;
  --text: #f5f7ff;
  --muted: #95a2bb;
  --cyan: #53dcff;
  --amber: #ffbc3d;
  --red: #ff5470;
  --green: #5ce6a4;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 22px 16px 32px;
  background:
    radial-gradient(circle at 50% -12%, rgba(83, 220, 255, 0.14), transparent 34rem),
    linear-gradient(150deg, #090c15 0%, #0b1020 48%, #070910 100%);
  color: var(--text);
  font-family: "Pretendard", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.table {
  width: min(1180px, 100%);
  margin: 0 auto;
}

/* ───────────────────────────────────────────── 상단 바 */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid rgba(108, 137, 181, 0.25);
  border-radius: 16px;
}

.title { display: flex; align-items: center; gap: 12px; margin-right: auto; }

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(83, 220, 255, 0.5);
  border-radius: 11px;
  background:
    radial-gradient(circle at 30% 70%, rgba(255, 188, 61, .5), transparent 55%),
    linear-gradient(135deg, rgba(83, 220, 255, .28), rgba(83, 220, 255, 0));
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 8px; bottom: 9px;
  width: 21px; height: 2px;
  background: var(--cyan);
  border-radius: 2px;
  transform: rotate(-38deg);
  transform-origin: left center;
  box-shadow: 0 0 10px var(--cyan);
}

.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 17px; letter-spacing: .12em; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: .08em; }

.round-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  background: rgba(83, 220, 255, .08);
  border: 1px solid rgba(83, 220, 255, .3);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.state-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 9px var(--cyan);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.wallet { display: flex; gap: 10px; }

.wallet-item {
  display: grid;
  gap: 1px;
  min-width: 92px;
  padding: 7px 13px;
  background: rgba(8, 12, 22, .65);
  border: 1px solid var(--line);
  border-radius: 11px;
  text-align: right;
}

.wallet-item span { color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.wallet-item strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.wallet-item.staked strong { color: var(--amber); }

/* ───────────────────────────────────────────── 레이아웃 */

/* 라이브 목록을 왼쪽에 세우고, 오른쪽에 히스토리 → 그래프 → 베팅 패널을 쌓는다.
   패널을 오른쪽 열에 같이 두면 오른쪽만 길어져 왼쪽 아래가 크게 빈다. */
.layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 14px;
}

.stage {
  grid-area: 1 / 2;
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

/* ───────────────────────────────────────────── 히스토리 */

.history-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid rgba(108, 137, 181, 0.22);
  border-radius: 13px;
  scrollbar-width: thin;
}

.history-strip:empty::before {
  content: "아직 결과가 없습니다";
  color: #5c6880;
  font-size: 11px;
}

.hist {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hist[data-tier="bust"] { background: rgba(255, 84, 112, .13); border-color: rgba(255, 84, 112, .4); color: #ff8098; }
.hist[data-tier="low"]  { background: rgba(149, 162, 187, .12); border-color: rgba(149, 162, 187, .32); color: #b3c0d6; }
.hist[data-tier="mid"]  { background: rgba(83, 220, 255, .12); border-color: rgba(83, 220, 255, .36); color: var(--cyan); }
.hist[data-tier="high"] { background: rgba(92, 230, 164, .13); border-color: rgba(92, 230, 164, .4); color: var(--green); }
.hist[data-tier="epic"] { background: rgba(255, 188, 61, .15); border-color: rgba(255, 188, 61, .5); color: var(--amber); }

/* ───────────────────────────────────────────── 무대 */

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 88%, rgba(83, 220, 255, .09), transparent 46%),
    linear-gradient(160deg, #0d1424, #080c16);
  border: 1px solid rgba(108, 137, 181, 0.25);
  border-radius: 18px;
}

.screen[data-phase="crashed"] {
  border-color: rgba(255, 84, 112, .45);
  box-shadow: inset 0 0 90px rgba(255, 84, 112, .1);
}

#graph { position: absolute; inset: 0; width: 100%; height: 100%; }

.readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  pointer-events: none;
  text-align: center;
}

.mult {
  font-size: clamp(44px, 8vw, 76px);
  font-weight: 900;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 34px rgba(0, 0, 0, .8);
  transition: color .12s ease;
}

.mult span { font-size: .45em; margin-left: .06em; opacity: .65; }

.screen[data-phase="betting"] .mult { color: var(--muted); }
.screen[data-phase="flying"] .mult { color: #fff; }
.screen[data-phase="crashed"] .mult { color: var(--red); }

.stage-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.screen[data-phase="crashed"] .stage-note { color: #ff8098; }

.toasts {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: grid;
  gap: 6px;
  justify-items: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 6px 14px;
  background: rgba(8, 12, 22, .92);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  animation: rise .3s ease both;
}

.toast[data-kind="win"] { border-color: rgba(92, 230, 164, .55); color: var(--green); }
.toast[data-kind="warn"] { border-color: rgba(255, 188, 61, .55); color: var(--amber); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ───────────────────────────────────────────── 사이드 */

.side { grid-area: 1 / 1; display: grid; min-width: 0; min-height: 0; }
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.panel {
  display: grid;
  gap: 9px;
  padding: 13px;
  background: var(--panel);
  border: 1px solid rgba(108, 137, 181, 0.25);
  border-radius: 15px;
}

.panel[data-status="active"] { border-color: rgba(83, 220, 255, .5); }
.panel[data-status="cashed"] { border-color: rgba(92, 230, 164, .45); }
.panel[data-status="bust"] { border-color: rgba(255, 84, 112, .4); }

.panel-head { display: flex; align-items: center; gap: 8px; }

.panel-name {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.panel-flag {
  margin-left: auto;
  padding: 2px 8px;
  background: rgba(83, 220, 255, .12);
  border: 1px solid rgba(83, 220, 255, .38);
  border-radius: 999px;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
}

.field { display: grid; gap: 4px; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 700; }

input[type="number"] {
  width: 100%;
  padding: 9px 11px;
  background: rgba(8, 12, 22, .7);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: 700 15px/1 "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

input[type="number"]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
input[type="number"]:disabled { opacity: .5; }

.chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }

.chips button {
  padding: 6px 0;
  background: rgba(30, 43, 68, .8);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #c4cfe3;
  font: 800 11px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.chips button:hover:not(:disabled) { background: #2c3e60; color: #fff; }
.chips button:disabled { opacity: .35; cursor: default; }

.auto { display: grid; gap: 6px; }

.switch { display: flex; align-items: center; gap: 7px; color: #c4cfe3; font-size: 12px; font-weight: 700; cursor: pointer; }
.switch.small { color: var(--muted); font-size: 11px; }
.switch input { width: 15px; height: 15px; accent-color: var(--cyan); cursor: pointer; }

.auto-target { position: relative; display: flex; align-items: center; gap: 8px; }
.auto-target input { flex: 0 0 96px; padding-right: 22px; }
.auto-target .suffix { position: absolute; left: 78px; color: var(--muted); font-size: 12px; font-weight: 700; pointer-events: none; }
.auto-target .odds { color: var(--muted); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.act {
  padding: 13px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: 900 14px/1.15 "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}

.act:active:not(:disabled) { transform: translateY(1px); }
.act:hover:not(:disabled) { filter: brightness(1.12); }
.act:disabled { opacity: .45; cursor: default; }

.act.bet { background: linear-gradient(135deg, #2fb87f, #1d8f5f); color: #04150e; }
.act.cancel { background: rgba(30, 43, 68, .9); border-color: var(--line); color: #c4cfe3; }
.act.cash { background: linear-gradient(135deg, #ffcf66, #ff9d37); color: #2a1700; }

.panel-result { margin: 0; font-size: 11px; font-weight: 700; min-height: 14px; }
.panel-result[data-kind="cashed"] { color: var(--green); }
.panel-result[data-kind="bust"] { color: #ff8098; }

/* ───────────────────────────────────────────── 라이브 목록 */

.live {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid rgba(108, 137, 181, 0.25);
  border-radius: 15px;
}

.live header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.live-count { margin-left: auto; color: var(--cyan); letter-spacing: .02em; }

.live-list {
  display: grid;
  align-content: start;
  gap: 2px;
  flex: 1;
  min-height: 160px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
}

.live-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 58px;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.live-list li[data-state="in"] { background: rgba(30, 43, 68, .42); color: #aab6cc; }
.live-list li[data-state="out"] { background: rgba(92, 230, 164, .1); color: var(--green); }
.live-list li[data-state="bust"] { background: rgba(255, 84, 112, .08); color: #94788a; }

.bot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.bot-stake { color: inherit; opacity: .7; }
.bot-out { text-align: right; font-weight: 800; }

/* ───────────────────────────────────────────── 공정성 */

.fair {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid rgba(108, 137, 181, 0.22);
  border-radius: 15px;
  overflow: hidden;
}

.fair-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: 0;
  color: #c4cfe3;
  font: 800 12px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: .06em;
  text-align: left;
  cursor: pointer;
}

.fair-toggle .chev { margin-left: auto; transition: transform .18s ease; }
.fair-toggle.open .chev { transform: rotate(180deg); }

.fair-body { padding: 0 16px 16px; }

.fair-lead, .fair-formula {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.fair-lead b { color: #d8e1f2; }

.fair-grid {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0 0 12px;
  font-size: 11.5px;
}

.fair-grid dt { color: var(--muted); font-weight: 700; }
.fair-grid dd { margin: 0; overflow-wrap: anywhere; }

.mono { font-family: "Cascadia Mono", Consolas, monospace; color: #9fb3d4; font-size: 10.5px; }

#fairVerdict[data-ok="true"] { color: var(--green); font-weight: 800; }
#fairVerdict[data-ok="false"] { color: var(--red); font-weight: 800; }

.fair-formula code {
  padding: 1px 6px;
  background: rgba(8, 12, 22, .7);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  color: #bcd3f0;
}

footer {
  margin-top: 18px;
  color: #65718a;
  font-size: 11px;
  line-height: 1.7;
  text-align: center;
}

footer b { color: #8e9bb4; }

/* ───────────────────────────────────────────── 좁은 화면 */

@media (max-width: 940px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .stage { grid-area: auto; }
  .side { grid-area: auto; }
  .live-list { flex: none; max-height: 210px; }
}

@media (max-width: 640px) {
  body { padding: 14px 10px 26px; }
  .topbar { gap: 10px; padding: 11px 13px; }
  .title { width: 100%; }
  .round-state { order: 3; }
  .wallet { flex: 1; }
  .wallet-item { min-width: 0; flex: 1; }
  .screen { aspect-ratio: 4 / 3; min-height: 240px; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .fair-grid { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .fair-grid dt { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .state-dot, .toast { animation: none; }
}
