/* ============================================================
   로지스틱 익스체인지 — 공통 스타일 (다크 트레이딩 테마)
   ============================================================ */
:root {
  --bg: #0a0f1c;
  --panel: #121a2b;
  --panel2: #182238;
  --line: #24304a;
  --text: #e8eefb;
  --dim: #8b98af;
  --green: #16c784;
  --red: #ea3943;
  --amber: #f5a524;
  --accent: #3b82f6;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0 0 .5em; font-weight: 800; }
button { font-family: inherit; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 16px; }
.hidden { display: none !important; }

/* ---- 패널/카드 ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel + .panel { margin-top: 12px; }

/* ---- 버튼 ---- */
.btn {
  display: inline-block;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #04140d; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #201400; }
.btn-big { font-size: 22px; padding: 16px 28px; border-radius: 16px; }
.btn-huge { font-size: 30px; padding: 24px 40px; border-radius: 20px; }
.btn-ghost { background: transparent; }
.btn-sm { font-size: 13px; padding: 5px 10px; border-radius: 8px; }

/* ---- 입력 ---- */
input[type=text], input[type=number], input[type=tel], textarea, select {
  background: #0d1424;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
label { font-size: 13px; color: var(--dim); font-weight: 700; display: block; margin: 10px 0 4px; }

/* ---- 상단 바 ---- */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar .title { font-weight: 900; font-size: 18px; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.chip {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 700;
  white-space: nowrap;
}
.chip b { color: var(--amber); }

/* 연결 상태 표시등 */
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; }
.conn .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.conn.on .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ---- 오프라인 배너 ---- */
.offline-banner {
  background: #3a1418; border: 1px solid var(--red); color: #ffd7da;
  border-radius: var(--radius); padding: 12px 16px; margin: 12px 0;
  font-weight: 700;
}
.offline-banner .row { display: flex; gap: 8px; margin-top: 8px; }
.offline-banner input { max-width: 160px; font-size: 20px; text-align: center; letter-spacing: 2px; }

/* ---- 뉴스 카드 ---- */
.news-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 820px) { .news-grid { grid-template-columns: 1fr; } }
.news-card {
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  transition: opacity .5s, transform .4s, border-color .4s, box-shadow .4s;
  animation: popIn .35s ease both;
}
.news-card .tag {
  font-size: 12px; font-weight: 800; color: var(--amber);
  letter-spacing: 1px; margin-bottom: 4px;
}
.news-card h3 { font-size: 17px; margin: 0 0 6px; line-height: 1.35; }
.news-card p { font-size: 14px; color: var(--dim); margin: 0; }
.news-card.real {
  border-color: var(--amber);
  box-shadow: 0 0 24px rgba(245,165,36,.25);
  animation: shake .6s ease;
  transform: scale(1.03);
  z-index: 2;
}
.news-card.real .tag { color: var(--amber); }
.news-card.dummy { opacity: .38; filter: grayscale(.8); }
.news-card .noreact {
  margin-top: 8px; font-size: 13px; color: var(--dim);
  border-top: 1px dashed var(--line); padding-top: 6px;
}
.news-card.pickable { cursor: pointer; }
.news-card.picked { border-color: var(--accent); box-shadow: 0 0 16px rgba(59,130,246,.35); }
.news-card .pickmark {
  position: absolute; top: 10px; right: 12px; font-size: 20px;
}

/* ---- 해설 카드 ---- */
.note-card {
  background: #10233a; border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 14px 16px; margin-top: 12px;
  animation: popIn .4s .3s ease both;
}
.note-card .h { font-size: 13px; font-weight: 800; color: var(--accent); letter-spacing: 1px; margin-bottom: 4px; }

/* ---- 가격 바 차트 ---- */
.price-board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; }
@media (max-width: 700px) { .price-board { grid-template-columns: repeat(3, 1fr); } }
.price-col { text-align: center; }
.price-col .barbox {
  height: 140px; display: flex; align-items: flex-end; justify-content: center;
}
.price-col .bar {
  width: 70%; border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #35507e, #22314e);
  transition: height .8s cubic-bezier(.2,.8,.3,1), background .5s;
  min-height: 4px;
}
.price-col.up .bar { background: linear-gradient(180deg, var(--green), #0b5e40); }
.price-col.down .bar { background: linear-gradient(180deg, var(--red), #7b1d23); }
.price-col .emoji { font-size: 26px; }
.price-col .nm { font-size: 13px; color: var(--dim); font-weight: 700; }
.price-col .pr { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.price-col .delta { font-size: 14px; font-weight: 800; min-height: 20px; }
.price-col.up .delta { color: var(--green); }
.price-col.down .delta { color: var(--red); }
.price-col.flat .delta { color: var(--dim); }

/* ---- 리더보드 ---- */
.lb-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 8px;
  transition: transform .5s;
  animation: popIn .3s ease both;
}
.lb-row .rank { font-size: 22px; font-weight: 900; width: 44px; color: var(--amber); }
.lb-row .name { font-size: 18px; font-weight: 800; flex: 1; }
.lb-row .hold { font-size: 13px; color: var(--dim); }
.lb-row .asset { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.lb-row .move { width: 34px; text-align: center; font-weight: 900; }
.lb-row .move.up { color: var(--green); }
.lb-row .move.down { color: var(--red); }
.lb-row.first { border-color: var(--amber); box-shadow: 0 0 14px rgba(245,165,36,.2); }
.lb-row .ok { color: var(--green); font-size: 18px; }
.lb-row .wait { color: var(--dim); font-size: 13px; }

/* ---- 타이머 ---- */
.timer {
  font-size: 64px; font-weight: 900; text-align: center;
  font-variant-numeric: tabular-nums; letter-spacing: 2px;
  color: var(--green);
}
.timer.warn { color: var(--amber); }
.timer.danger { color: var(--red); animation: pulse 1s infinite; }
.timer-sm { font-size: 28px; }

/* ---- 종목 매매 카드 (학생) ---- */
.stock-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 900px) { .stock-grid { grid-template-columns: repeat(3, 1fr); } }
.stock-card {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
}
.stock-card .head { display: flex; align-items: center; gap: 8px; }
.stock-card .head .emoji { font-size: 26px; }
.stock-card .head .nm { font-weight: 800; font-size: 16px; flex: 1; }
.stock-card .head .pr { font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; }
.stock-card .sub { font-size: 13px; color: var(--dim); margin: 4px 0 8px; display: flex; justify-content: space-between; }
.stock-card .pend { font-weight: 800; }
.stock-card .pend.buy { color: var(--green); }
.stock-card .pend.sell { color: var(--red); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 52px; height: 46px; font-size: 24px; font-weight: 900;
  border-radius: 10px; border: 1px solid var(--line);
  background: #0d1424; color: var(--text); cursor: pointer;
}
.stepper button:active { transform: scale(.94); }
.stepper .val { flex: 1; text-align: center; font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stars-box { font-size: 12px; color: var(--amber); margin-top: 8px; line-height: 1.7; display: none; }
.stock-card.show-stars .stars-box { display: block; }
.stars-box .k { color: var(--dim); display: inline-block; width: 52px; }

/* ---- 결과/손익 ---- */
.pnl { font-size: 44px; font-weight: 900; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }
.pnl.plus { color: var(--green); }
.pnl.minus { color: var(--red); }
.judge { font-size: 26px; font-weight: 900; text-align: center; padding: 10px; border-radius: 12px; margin-bottom: 10px; }
.judge.ok { background: rgba(22,199,132,.12); color: var(--green); border: 1px solid var(--green); }
.judge.no { background: rgba(234,57,67,.12); color: var(--red); border: 1px solid var(--red); }

/* ---- 성적표 타임라인 ---- */
.report-item {
  border-left: 3px solid var(--line); padding: 8px 0 8px 14px; margin-left: 8px;
  position: relative;
}
.report-item::before {
  content: ""; position: absolute; left: -8px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel2); border: 2px solid var(--dim);
}
.report-item.ok::before { background: var(--green); border-color: var(--green); }
.report-item.no::before { background: var(--red); border-color: var(--red); }
.report-item .r-title { font-weight: 800; }
.report-item .r-line { font-size: 14px; color: var(--dim); margin: 2px 0; }
.report-item .r-line b { color: var(--text); }
.badge {
  display: inline-block; background: var(--panel2); border: 1px solid var(--amber);
  color: var(--amber); font-weight: 800; border-radius: 999px;
  padding: 6px 14px; margin: 4px 6px 4px 0; font-size: 14px;
}

/* ---- 교사 화면 큰 표시 ---- */
.room-code {
  font-size: 90px; font-weight: 900; letter-spacing: 14px; text-align: center;
  color: var(--amber); text-shadow: 0 0 30px rgba(245,165,36,.4);
  font-variant-numeric: tabular-nums;
}
.round-code {
  font-size: 26px; font-weight: 900; color: var(--amber);
  border: 2px dashed var(--amber); border-radius: 12px; padding: 4px 16px;
  display: inline-block;
}
.big-label { font-size: 22px; font-weight: 800; }
.joined-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }
.joined-card {
  background: var(--panel2); border: 1px solid var(--green);
  border-radius: 12px; padding: 12px 22px; font-size: 20px; font-weight: 800;
  animation: popIn .35s ease both;
}

/* ---- 조작 버튼 줄 ---- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---- 애니메이션 ---- */
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; } }
@keyframes shake {
  0%,100% { transform: scale(1.03) rotate(0); }
  20% { transform: scale(1.05) rotate(-1.2deg); }
  40% { transform: scale(1.05) rotate(1.2deg); }
  60% { transform: scale(1.04) rotate(-.8deg); }
  80% { transform: scale(1.04) rotate(.8deg); }
}
@keyframes pulse { 50% { opacity: .55; } }
.flash-green { animation: flashG .9s ease; }
.flash-red { animation: flashR .9s ease; }
@keyframes flashG { 0% { background: rgba(22,199,132,.35); } 100% { background: transparent; } }
@keyframes flashR { 0% { background: rgba(234,57,67,.35); } 100% { background: transparent; } }

/* ---- 인덱스(역할 선택) ---- */
.role-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px; padding: 24px; text-align: center;
}
.role-btns { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.role-btn {
  background: var(--panel); border: 2px solid var(--line); border-radius: 20px;
  padding: 36px 44px; cursor: pointer; color: var(--text);
  font-size: 24px; font-weight: 900; min-width: 240px;
  transition: border-color .2s, transform .1s;
  text-decoration: none; display: block;
}
.role-btn:hover { border-color: var(--accent); transform: translateY(-3px); }
.role-btn .big { font-size: 54px; display: block; margin-bottom: 10px; }
.role-btn .sub { display: block; font-size: 14px; color: var(--dim); font-weight: 600; margin-top: 6px; }

/* 학생 하단 고정 확정 버튼 영역 */
.confirm-bar {
  position: sticky; bottom: 0; background: linear-gradient(180deg, transparent, var(--bg) 30%);
  padding: 14px 0 10px; z-index: 30;
}
.confirm-bar .btn { width: 100%; }

.muted { color: var(--dim); font-size: 14px; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .row2 { grid-template-columns: 1fr; } }
