/* ============================================================
   평택 물류 타이쿤 — 공용 스타일 (딥 네이비 + 시그널 오렌지)
   ============================================================ */
:root {
  --navy: #0d1b2a;
  --navy2: #16263c;
  --panel: #1e2f4a;
  --panel2: #27395a;
  --line: #35496e;
  --orange: #ff7a1a;
  --orange-soft: #ffb066;
  --board: #f2efe7;      /* 화이트보드 */
  --board-line: #d8d2c2;
  --card: #ffffff;
  --ink: #e9eef6;
  --ink-dim: #9fb0c8;
  --ink-dark: #14202f;
  --ok: #2fbf71;
  --warn: #ffcf3f;
  --bad: #ff4d5e;
  --cold: #3aa7ff;
  --haz: #c957ff;
  --urgent: #ff4d5e;
  --radius: 14px;
  --shadow: 0 4px 14px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  background: var(--navy);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; }

/* ---------- 공용 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; cursor: pointer;
  padding: 12px 22px; font-size: 16px; font-weight: 800;
  background: var(--panel2); color: var(--ink);
  transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: var(--orange); color: #1a0e00; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.big { font-size: 20px; padding: 16px 30px; border-radius: 16px; }
.btn.sm { font-size: 13px; padding: 8px 14px; border-radius: 10px; }

/* ---------- 헤더 ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--navy2), var(--navy));
  border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar .logo { font-weight: 900; font-size: 18px; letter-spacing: -.5px; white-space: nowrap; }
.topbar .logo .accent { color: var(--orange); }
.roundTag {
  background: var(--orange); color: #1a0e00; font-weight: 900;
  border-radius: 999px; padding: 4px 14px; font-size: 14px; white-space: nowrap;
}

/* ---------- 자원 게이지 ---------- */
.gauges { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gauge {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 12px; display: flex; align-items: center; gap: 8px; min-width: 96px;
}
.gauge .g-icon { font-size: 18px; }
.gauge .g-val { font-weight: 900; font-size: 15px; white-space: nowrap; }
.gauge .g-sub { font-size: 11px; color: var(--ink-dim); }
.gauge.over { border-color: var(--bad); background: #3a1420; animation: blink 1s infinite; }
.gauge.over .g-val { color: var(--bad); }
@keyframes blink { 50% { filter: brightness(1.35); } }
.gaugebar { width: 74px; height: 8px; background: #0b1524; border-radius: 6px; overflow: hidden; }
.gaugebar > i { display: block; height: 100%; background: var(--ok); border-radius: 6px; transition: width .25s; }
.gaugebar.warn > i { background: var(--warn); }
.gaugebar.over > i { background: var(--bad); }

.profitBox { margin-left: auto; text-align: right; }
.profitBox .p-label { font-size: 11px; color: var(--ink-dim); }
.profitBox .p-val { font-size: 30px; font-weight: 900; color: var(--orange); line-height: 1; font-variant-numeric: tabular-nums; }
.profitBox .p-val.minus { color: var(--bad); }

.timer { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); animation: blink 1s infinite; }

/* ---------- 배차판 레이아웃 ---------- */
.boardWrap { display: flex; gap: 12px; padding: 12px; align-items: flex-start; }
.cardPile {
  width: 250px; flex: none; background: var(--panel); border-radius: var(--radius);
  border: 1px solid var(--line); padding: 10px; min-height: 300px;
  display: flex; flex-direction: column; gap: 8px;
  max-height: calc(100vh - 130px); overflow-y: auto;
}
.cardPile h3, .slotArea h3 { margin: 0 0 4px; font-size: 13px; color: var(--ink-dim); font-weight: 800; letter-spacing: .06em; }

.slotArea {
  flex: 1; background: var(--board); border-radius: var(--radius); padding: 14px;
  color: var(--ink-dark); min-height: calc(100vh - 150px);
  background-image: radial-gradient(var(--board-line) 1.2px, transparent 1.2px);
  background-size: 26px 26px;
  border: 3px solid #cdc6b4;
}
.slotArea h3 { color: #6b6350; }
.slotGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

/* ---------- 주문 카드 ---------- */
.cargoCard {
  background: var(--card); color: var(--ink-dark);
  border-radius: 12px; padding: 9px 11px; box-shadow: var(--shadow);
  border-left: 6px solid #7d8aa5; cursor: grab; position: relative;
  transition: box-shadow .15s;
  touch-action: none;
}
.cargoCard.cold { border-left-color: var(--cold); }
.cargoCard.haz { border-left-color: var(--haz); }
.cargoCard.urgent { border-left-color: var(--urgent); }
.cargoCard .c-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.cargoCard .c-name { font-weight: 800; font-size: 14px; }
.cargoCard .c-fee { font-weight: 900; color: #d96200; font-size: 14px; white-space: nowrap; }
.cargoCard .c-sub { display: flex; gap: 7px; font-size: 12px; margin-top: 3px; color: #56637a; flex-wrap: wrap; align-items: center; }
.cargoCard .c-dest { font-weight: 900; color: #1c2c46; background: #edf1f7; padding: 1px 8px; border-radius: 6px; }
.cargoCard .badge { font-size: 11px; padding: 1px 6px; border-radius: 6px; font-weight: 800; }
.badge.b-cold { background: #e2f1ff; color: #0b6bbd; }
.badge.b-haz { background: #f5e4ff; color: #8a1fd1; }
.badge.b-urgent { background: #ffe3e6; color: #d31f30; }
.badge.b-bulk { background: #fff1dc; color: #a9640a; }
.badge.b-island { background: #e6f7ee; color: #147a45; }
.badge.b-carry { background: #fdf3c8; color: #8a6d00; }
.cargoCard.dragging { opacity: .35; }
.cargoCard.shake { animation: shake .4s; border-left-color: var(--bad) !important; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); }
}
.dragGhost {
  position: fixed; z-index: 100; pointer-events: none; width: 230px;
  transform: rotate(-2.5deg) scale(1.04); box-shadow: 0 14px 34px rgba(0,0,0,.45);
}

/* ---------- 슬롯 ---------- */
.slot {
  background: rgba(255, 255, 255, .68); border: 2.5px dashed #b9b09a; border-radius: 12px;
  padding: 9px; min-height: 108px; display: flex; flex-direction: column; gap: 7px;
  transition: border-color .15s, background .15s;
}
.slot .s-head { display: flex; align-items: center; gap: 7px; font-weight: 900; font-size: 14px; color: #3c455a; }
.slot .s-head .s-note { font-weight: 600; font-size: 11px; color: #857c66; margin-left: auto; text-align: right; }
.slot.dropOk { border-color: var(--ok); background: #e9f9f0; }
.slot.dropBad { border-color: var(--bad); background: #ffecee; }
.slot.truckSlot { background: rgba(255, 255, 255, .85); border-style: solid; border-color: #cfc7b2; }
.slot.truckSlot.coldTruck .s-head { color: #0b6bbd; }
.slot.dropZone { background: rgba(255, 230, 232, .55); }
.slot.storeZone { background: rgba(255, 248, 224, .6); }
.loadbar { display: flex; gap: 2.5px; }
.loadbar i { flex: 1; height: 9px; border-radius: 3px; background: #ddd6c4; }
.loadbar i.on { background: var(--orange); }
.loadbar i.overload { background: var(--bad); }
.slot .miniCargo {
  background: var(--card); border-radius: 9px; padding: 5px 9px; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,.13); display: flex; justify-content: space-between; gap: 6px;
  border-left: 4px solid #7d8aa5; cursor: grab; color: var(--ink-dark);
  touch-action: none; align-items: center;
}
.slot .miniCargo .m-cost { color: #8a7d5c; font-weight: 800; white-space: nowrap; font-size: 11.5px; }
.slot .miniCargo.cold { border-left-color: var(--cold); }
.slot .miniCargo.haz { border-left-color: var(--haz); }
.slot .miniCargo.urgent { border-left-color: var(--urgent); }
.slotFoot { font-size: 11.5px; color: #756c55; font-weight: 700; margin-top: auto; }

/* ---------- 토스트 ---------- */
#toastWrap { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bad); color: #fff; font-weight: 800; font-size: 15px;
  padding: 11px 22px; border-radius: 999px; box-shadow: var(--shadow);
  animation: toastIn .25s, toastOut .3s 2.2s forwards;
}
.toast.info { background: var(--panel2); }
.toast.good { background: var(--ok); color: #06331c; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

/* ---------- 모달 ---------- */
.modalBack {
  position: fixed; inset: 0; background: rgba(5, 10, 18, .72); z-index: 150;
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal {
  background: var(--navy2); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; width: min(520px, 94vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .m-sub { color: var(--ink-dim); font-size: 13px; margin-bottom: 14px; }
.optRow {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); margin-bottom: 7px;
}
.optRow.no { opacity: .5; }
.optRow .o-label { font-weight: 800; font-size: 14.5px; }
.optRow .o-detail { margin-left: auto; font-size: 13px; color: var(--ink-dim); font-variant-numeric: tabular-nums; text-align: right; }
.optRow .o-detail b { color: var(--orange-soft); }
.optRow .o-detail .no-reason { color: var(--bad); font-weight: 700; }
.optRow .btn { flex: none; }
textarea.memoInput {
  width: 100%; min-height: 88px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink); font-size: 16px; padding: 12px; font-family: inherit;
  resize: vertical; user-select: text; -webkit-user-select: text;
}
textarea.memoInput:focus { outline: none; border-color: var(--orange); }

/* ---------- 하단 액션바 ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; gap: 10px; padding: 10px 16px;
  background: linear-gradient(0deg, var(--navy) 70%, transparent);
}
.actionbar .spacer { flex: 1; }

/* ---------- 전체 화면 안내(대기/결과) ---------- */
.centerScreen {
  min-height: calc(100vh - 60px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 24px;
}
.centerScreen h1 { font-size: 30px; margin: 0; }
.centerScreen .hint { color: var(--ink-dim); font-size: 15px; max-width: 460px; line-height: 1.6; }
.bigNum { font-size: 64px; font-weight: 900; color: var(--orange); font-variant-numeric: tabular-nums; }

/* ---------- 뉴스/돌발 배너 ---------- */
.newsBanner {
  background: linear-gradient(90deg, #7a1d1d, #a32b12); color: #fff;
  border-radius: 12px; padding: 10px 16px; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow);
  animation: newsIn .5s;
}
.newsBanner .tagLive { background: #fff; color: #a32b12; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 900; flex: none; }
@keyframes newsIn { from { transform: translateY(-16px); opacity: 0; } }

/* ---------- 교사: 미러 그리드 ---------- */
.mirrorGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mirror {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  min-height: 150px; display: flex; flex-direction: column; gap: 7px;
}
.mirror .mr-head { display: flex; align-items: baseline; gap: 8px; }
.mirror .mr-name { font-weight: 900; font-size: 15px; }
.mirror .mr-profit { margin-left: auto; font-weight: 900; color: var(--orange); font-variant-numeric: tabular-nums; }
.mirror .mr-profit.minus { color: var(--bad); }
.mirror .mr-slots { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11.5px; }
.mirror .mr-chip {
  background: var(--panel2); border-radius: 7px; padding: 3px 7px; font-weight: 700;
  border-left: 3px solid #7d8aa5;
}
.mirror .mr-chip.cold { border-left-color: var(--cold); }
.mirror .mr-chip.drop { border-left-color: var(--bad); opacity: .75; }
.mirror .mr-status { font-size: 11px; color: var(--ink-dim); margin-top: auto; }
.mirror.locked { outline: 2px solid var(--ok); }
.mirror.blurred .mr-slots { filter: blur(6px); }

/* ---------- 교사: 정산쇼 ---------- */
.settleBars { display: flex; flex-direction: column; gap: 10px; }
.sbRow { display: flex; align-items: center; gap: 10px; }
.sbRow .sb-name { width: 130px; font-weight: 800; text-align: right; font-size: 14px; }
.sbRow .sb-track { flex: 1; background: var(--panel); border-radius: 10px; height: 34px; position: relative; overflow: hidden; }
.sbRow .sb-fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 10px;
  background: linear-gradient(90deg, var(--orange), var(--orange-soft));
  width: 0; transition: width 1.1s cubic-bezier(.2, .8, .2, 1);
}
.sbRow .sb-fill.minus { background: linear-gradient(90deg, #8a1c28, var(--bad)); }
.sbRow .sb-val { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-weight: 900; font-variant-numeric: tabular-nums; z-index: 2; }
.sbRow .sb-optline { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ok); z-index: 3; border-radius: 2px; }

.gapCard {
  background: var(--panel); border-left: 5px solid var(--orange); border-radius: 10px;
  padding: 8px 12px; margin: 5px 0; font-size: 13.5px;
}
.gapCard b { color: var(--orange-soft); }

.leader { display: flex; flex-direction: column; gap: 6px; }
.leader .ld-row {
  display: flex; align-items: center; gap: 10px; background: var(--panel);
  border-radius: 10px; padding: 8px 14px;
}
.leader .ld-rank { font-weight: 900; font-size: 18px; width: 30px; }
.leader .ld-row.first { background: linear-gradient(90deg, #4a3410, var(--panel)); outline: 1px solid var(--orange); }
.leader .ld-name { font-weight: 800; }
.leader .ld-badges { font-size: 15px; }
.leader .ld-val { margin-left: auto; font-weight: 900; color: var(--orange); font-variant-numeric: tabular-nums; }

/* ---------- 치트시트 ---------- */
.cheat { font-size: 12px; }
.cheat table { border-collapse: collapse; width: 100%; }
.cheat th, .cheat td { border: 1px solid var(--line); padding: 3.5px 7px; text-align: center; }
.cheat th { background: var(--panel2); }
.cheat caption { font-weight: 900; padding: 4px; color: var(--orange-soft); caption-side: top; text-align: left; }

/* ---------- 최적 배차 공개 연출 ---------- */
.flyCard {
  position: fixed; z-index: 300; background: var(--card); color: var(--ink-dark);
  border-radius: 10px; padding: 7px 12px; font-weight: 800; font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); border-left: 5px solid var(--orange);
  transition: all .9s cubic-bezier(.3, .9, .3, 1); pointer-events: none;
}

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .boardWrap { flex-direction: column; }
  .cardPile { width: 100%; max-height: 200px; flex-direction: row; flex-wrap: wrap; }
  .cardPile .cargoCard { width: calc(50% - 6px); }
  .mirrorGrid { grid-template-columns: repeat(2, 1fr); }
}
