/* ============================================================
   세계로 무역 게임 — 디자인 시스템
   컨셉: "항구의 무역상". 짙은 바다빛 화면 위에 양피지 같은 카드가 떠 있고,
   자원은 등급별로 색이 다른 수집 카드처럼 보인다.
   외부 이미지 없이 CSS와 인라인 SVG만 사용한다.
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard-dynamic-subset.css');
/* 제목용 디스플레이 폰트 — 포스터 같은 한글 볼드체. 게임다운 에너지 + 프로젝터 원거리 가독성 */
@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&display=swap');

:root {
  /* 바다 (화면 바탕) */
  --sea-900: #0d1628;
  --sea-800: #14203a;
  --sea-700: #1e2f52;
  --sea-600: #2b4272;

  /* 종이 (카드) */
  --card: #fffdf7;
  --card-2: #f7f4ea;
  --line: #e4ddca;
  --line-soft: #efe9d9;

  /* 잉크 (글자) */
  --ink: #1b2540;
  --ink-2: #4a5570;
  --muted: #626d8a;

  /* 강조 */
  --gold: #f0b429;
  --gold-deep: #b8860b;
  --gold-soft: #fdf3d6;
  --brand: #3d6ef5;
  --brand-deep: #2a51c8;
  --brand-soft: #e8efff;
  --good: #16a06d;
  --good-soft: #e0f5ec;
  --bad: #dd4f47;
  --bad-soft: #fdeceb;
  --warn: #e0900f;
  --warn-soft: #fdf1d9;

  /* 자원 등급 */
  --tier-raw: #4f9d69;
  --tier-raw-soft: #eaf6ee;
  --tier-mid: #3d6ef5;
  --tier-mid-soft: #e9effe;
  --tier-final: #9333ea;
  --tier-final-soft: #f5ebfe;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 1px 2px rgba(13, 22, 40, .06), 0 8px 24px -12px rgba(13, 22, 40, .22);
  --shadow-pop: 0 8px 30px -8px rgba(13, 22, 40, .35);

  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
          'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --font-display: 'Black Han Sans', 'Pretendard Variable', Pretendard, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.55;
  letter-spacing: -.01em;
  background-color: var(--sea-900);
  /* 항해도 텍스처 = 바다 위에서 게임하는 느낌. 이미지가 없으면 점 패턴으로 대체 */
  background-image:
    radial-gradient(1200px 600px at 50% -10%, rgba(61, 110, 245, .28), transparent 70%),
    url("../assets/bg-map.png"),
    url("data:image/svg+xml,%3Csvg width='48' height='48' viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='24' cy='24' r='1.2' fill='%23ffffff' fill-opacity='.07'/%3E%3C/svg%3E");
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.28; letter-spacing: -.01em; font-weight: 800; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
p { margin: 0 0 .8em; }
a { color: var(--brand); }
code {
  background: var(--card-2); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 6px; font-size: .88em;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 16px 70px; }
.wrap-narrow { max-width: 700px; margin: 0 auto; padding: 22px 16px 70px; }

/* ============================================================
   버튼
   ============================================================ */

button, .btn {
  font: inherit; font-weight: 700; letter-spacing: -.01em;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--brand), var(--brand-deep));
  color: #fff;
  padding: 10px 18px;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 2px 6px -1px rgba(42, 81, 200, .45);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 3px -1px rgba(42, 81, 200, .5); }
button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
button:focus-visible, .btn:focus-visible, .pick:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

button.ghost {
  background: var(--card); color: var(--ink); border-color: var(--line);
  box-shadow: 0 1px 2px rgba(13, 22, 40, .06);
}
button.ghost:hover:not(:disabled) { background: var(--card-2); filter: none; }
button.danger { background: linear-gradient(180deg, #ea5c54, #c93f38); box-shadow: 0 2px 6px -1px rgba(201, 63, 56, .45); }
button.success { background: linear-gradient(180deg, #1cb87c, #0f8a5c); box-shadow: 0 2px 6px -1px rgba(15, 138, 92, .45); }
button.warn { background: linear-gradient(180deg, #efa424, #c97f0b); box-shadow: 0 2px 6px -1px rgba(201, 127, 11, .45); }
button.gold {
  background: linear-gradient(180deg, #f7c948, #d99e0b);
  color: #3d2c00; box-shadow: 0 2px 8px -1px rgba(217, 158, 11, .5);
}
button.sm { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
button.lg { padding: 14px 26px; font-size: 1.08rem; border-radius: 13px; }
button.block { width: 100%; }

/* 중요한 버튼(턴 진행 등)에 은은한 빛 흐름 */
button.shine { position: relative; overflow: hidden; }
button.shine::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .5) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: shine 6s ease-in-out infinite;
}
@keyframes shine { 0%, 82% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

/* ============================================================
   입력
   ============================================================ */

input, select, textarea {
  font: inherit; width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--brand-soft);
}
input::placeholder { color: #b4bccd; }
label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 15px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* 방 코드 입력 */
.code-input {
  text-align: center; font-size: 1.85rem; letter-spacing: .3em;
  font-weight: 800; text-transform: uppercase;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  padding: 14px 10px 14px 22px;
}

/* ============================================================
   카드 · 레이아웃
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
/* 교사 대시보드: 넓은 화면은 본문+사이드, 태블릿 이하는 단일 컬럼으로 붕괴 */
.dash-grid { display: grid; gap: 14px; grid-template-columns: 1fr 320px; align-items: start; }
.dash-grid > div > .card:first-child h2 { font-size: 1.55rem; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

/* ============================================================
   상단 바
   ============================================================ */

.topbar {
  background: rgba(20, 32, 58, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  color: #fff;
  padding: 11px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.topbar .title { font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em; }
.topbar .spacer { flex: 1; }
.topbar .muted, .topbar .small { color: #a9b6d4; }
.topbar b { color: var(--gold); }

.dev-credit {
  text-align: center; padding: 18px 12px 26px;
  font-size: .78rem; color: var(--muted);
}
.dev-credit b { font-weight: 700; }
.topbar button.ghost, .topbar .btn.ghost {
  background: rgba(255, 255, 255, .12); color: #fff;
  border-color: rgba(255, 255, 255, .2); box-shadow: none;
}
.topbar button.ghost:hover { background: rgba(255, 255, 255, .2); }

/* ============================================================
   배지 · 칩
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 800; line-height: 1.5;
  padding: 3px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge.brand { background: var(--brand-soft); color: var(--brand-deep); border-color: #c8d8ff; }
.badge.good  { background: var(--good-soft); color: var(--good); border-color: #b6e7d1; }
.badge.bad   { background: var(--bad-soft); color: var(--bad); border-color: #f6c4c1; }
.badge.warn  { background: var(--warn-soft); color: #a86c07; border-color: #f2d9a4; }
.badge.gold  { background: var(--gold-soft); color: var(--gold-deep); border-color: #f0dca4; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: .86rem; font-weight: 700;
}
.chip b { color: var(--ink); }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny  { font-size: .78rem; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.up   { color: var(--bad); font-weight: 800; }   /* 시세 상승 = 빨강 */
.down { color: var(--brand); font-weight: 800; } /* 시세 하락 = 파랑 */
.hidden { display: none !important; }

/* ============================================================
   국가 문장 (크레스트)
   ============================================================ */

.crest {
  --nation-h: 220;
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  /* 나라마다 다른 색 = 국기 이모지가 안 보이는 PC에서도 구분된다 */
  background:
    radial-gradient(circle at 35% 28%, #fff, hsl(var(--nation-h) 62% 93%));
  border: 2.5px solid hsl(var(--nation-h) 58% 55%);
  box-shadow: 0 2px 6px -2px hsl(var(--nation-h) 45% 35% / .45);
  flex-shrink: 0;
  font-weight: 800;
  color: hsl(var(--nation-h) 55% 32%);
}
/* 국기가 "KR" 두 글자로 대체돼도 원 밖으로 넘치지 않게 */
.crest-face {
  line-height: 1; max-width: 84%; text-align: center;
  overflow: hidden; letter-spacing: -.04em; white-space: nowrap;
}
/* 직접 만든 문장 이미지는 원을 꽉 채운다 */
.crest-img {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; display: block;
}
.crest:has(.crest-img) { background: #fff; }
.crest-sm { width: 30px; height: 30px; font-size: .92rem; }
.crest-md { width: 44px; height: 44px; font-size: 1.35rem; }
.crest-lg { width: 62px; height: 62px; font-size: 1.95rem; }
.crest-rank1 { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft), 0 3px 10px -3px rgba(240, 180, 41, .7); }
.crest-rank2 { border-color: #b6bfd0; box-shadow: 0 0 0 3px #eef1f6; }
.crest-rank3 { border-color: #cd9b6a; box-shadow: 0 0 0 3px #f8efe6; }
.crest-medal { position: absolute; bottom: -6px; right: -6px; font-size: .8em; }

/* ============================================================
   요약 타일
   ============================================================ */

.stat-tile {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 13px;
  min-width: 0;
}
.stat-icon { font-size: 1.3rem; flex-shrink: 0; }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: .74rem; font-weight: 700; color: var(--muted); }
.stat-value { font-size: 1.16rem; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .74rem; color: var(--muted); }
/* 히어로 타일 — 총자산처럼 "이 화면에서 가장 중요한 숫자" 하나에만 */
.stat-tile.is-hero { padding: 12px 16px; }
.stat-tile.is-hero .stat-icon { font-size: 1.6rem; }
.stat-tile.is-hero .stat-value { font-size: 1.75rem; }
.stat-tile.is-hero .stat-label { font-size: .8rem; }
/* 보조 타일 — 현금·빚 등 참고 수치는 한 단계 낮춘다 */
.stat-tile.is-sub .stat-value { font-size: 1rem; font-weight: 700; }
.stat-tile.tone-gold { background: var(--gold-soft); border-color: #f0dca4; }
.stat-tile.tone-gold .stat-value { color: var(--gold-deep); }
.stat-tile.tone-good { background: var(--good-soft); border-color: #b6e7d1; }
.stat-tile.tone-good .stat-value { color: var(--good); }
.stat-tile.tone-bad { background: var(--bad-soft); border-color: #f6c4c1; }
.stat-tile.tone-bad .stat-value { color: var(--bad); }

/* 값이 바뀔 때 살짝 튀어오르며 색으로 알려준다 */
@keyframes bumpUp {
  0% { transform: none; }
  35% { transform: translateY(-4px) scale(1.06); color: var(--good); }
  100% { transform: none; }
}
@keyframes bumpDown {
  0% { transform: none; }
  35% { transform: translateY(3px) scale(.96); color: var(--bad); }
  100% { transform: none; }
}
.bump-up { animation: bumpUp .7s ease; }
.bump-down { animation: bumpDown .7s ease; }

/* ============================================================
   자원 카드 (등급별 색 = 수집 카드 느낌)
   ============================================================ */

.res-card {
  display: flex; align-items: center; gap: 9px;
  background: #fff;
  border: 1.5px solid var(--line-soft);
  border-left-width: 5px;
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-width: 0;
  transition: transform .12s ease, box-shadow .12s ease;
}
.res-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px -8px rgba(13, 22, 40, .4); }
.res-face { font-size: 1.35rem; flex-shrink: 0; line-height: 1; }
.res-face-img { width: 30px; height: 30px; flex-shrink: 0; object-fit: contain; display: block; }
.res-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.res-name { font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-sub { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.res-unit { opacity: .7; }
.res-qty {
  font-weight: 800; font-size: 1.05rem; flex-shrink: 0;
  padding: 1px 8px; border-radius: 8px; background: var(--card-2);
}
.res-card.is-dim { opacity: .42; }
.res-card.tier-raw   { border-left-color: var(--tier-raw); }
.res-card.tier-mid   { border-left-color: var(--tier-mid); }
.res-card.tier-final { border-left-color: var(--tier-final); background: linear-gradient(100deg, #fff, var(--tier-final-soft)); }
.res-card.tier-raw   .res-qty { background: var(--tier-raw-soft); color: #2f6b43; }
.res-card.tier-mid   .res-qty { background: var(--tier-mid-soft); color: var(--brand-deep); }
.res-card.tier-final .res-qty { background: #ede0fb; color: #7226bd; }

/* 등급 프레임 = 카드 위에 얹는 장식 테두리 (원자재→완제품으로 화려해짐).
   레이아웃에 영향을 주지 않도록 오버레이로만 얹고, 이미지가 없으면 그냥 안 보인다. */
.res-card { position: relative; }
.res-card.has-frame { border-left-width: 1.5px; }
.res-card.has-frame::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-size: 100% 100%; background-repeat: no-repeat; border-radius: var(--radius-sm);
}
.res-card.tier-raw.has-frame::after   { background-image: url('../assets/frames/tier-raw.png'); }
.res-card.tier-mid.has-frame::after   { background-image: url('../assets/frames/tier-mid.png'); }
.res-card.tier-final.has-frame::after { background-image: url('../assets/frames/tier-final.png'); }

/* 옛 이름 호환 */
.stock-item {
  background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.stock-item .qty { font-weight: 800; font-variant-numeric: tabular-nums; }
.stock-item.zero { opacity: .45; }

/* ============================================================
   선택 카드 (나라 · 역할 · 난이도)
   ============================================================ */

.pick {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 15px; cursor: pointer; text-align: left; color: var(--ink);
  font-weight: 500; display: block; width: 100%;
  box-shadow: var(--shadow-card);
  transition: transform .13s ease, border-color .13s, box-shadow .13s, background .13s;
}
.pick:hover:not(:disabled) {
  border-color: var(--brand); background: #fff;
  transform: translateY(-3px); box-shadow: var(--shadow-pop); filter: none;
}
.pick.selected {
  border-color: var(--brand); background: var(--brand-soft);
  box-shadow: 0 0 0 4px rgba(61, 110, 245, .18), var(--shadow-card);
}
.pick.selected::after {
  content: '✓'; float: right; margin-top: -26px;
  color: #fff; background: var(--brand);
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 900;
}
.pick:disabled { opacity: .5; cursor: not-allowed; }
.pick .pick-title { font-weight: 800; font-size: 1.06rem; display: flex; align-items: center; gap: 8px; }
.pick .pick-desc { font-size: .83rem; color: var(--ink-2); margin-top: 6px; line-height: 1.5; }

/* 역할 아바타 */
.role-avatar { object-fit: contain; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.role-avatar.role-lg { width: 52px; height: 52px; }
.role-avatar.role-sm { width: 34px; height: 34px; }
.role-emoji.role-lg { font-size: 1.9rem; }
.role-emoji.role-sm { font-size: 1.3rem; }
.role-pick .pick-title { gap: 10px; }

/* ============================================================
   탭
   ============================================================ */

.tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  overflow-x: auto; padding: 5px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  scrollbar-width: thin;
}
.tabs button {
  background: none; color: #c3cee6; border: none; box-shadow: none;
  border-radius: 10px; padding: 9px 14px; white-space: nowrap; font-weight: 700;
  font-size: .92rem;
}
.tabs button:hover:not(.active) { background: rgba(255, 255, 255, .1); color: #fff; filter: none; }
.tabs button.active {
  background: var(--card); color: var(--ink);
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, .35);
}
.tabs .badge { margin-left: 5px; }

/* 탭이 넘칠 때: 더 있다는 걸 옅은 그림자로 알려준다 (실제로 보이는 스크롤바가 없는
   모바일 브라우저에서 특히 중요 — 시/군/구처럼 탭이 많아지는 방에서 잘 드러남) */
.tabs.scrollable:not(.at-end) {
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
}
.tabs.scrollable:not(.at-start) {
  mask-image: linear-gradient(to left, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to left, black calc(100% - 28px), transparent);
}
.tabs.scrollable:not(.at-start):not(.at-end) {
  mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent);
}

/* ============================================================
   알림 배너 · 속보
   ============================================================ */

.banner {
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow-card);
  animation: slideDown .4s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}
.banner h3 { margin: 0 0 4px; }
.banner.info { background: var(--brand-soft); border-color: #c3d5ff; }

/* 일반 이벤트 = 뉴스 속보 */
.banner.event {
  background: linear-gradient(105deg, #fff8e6, #ffeecd);
  border-color: var(--gold); border-left: 6px solid var(--gold);
}
/* 희귀 이벤트 = 반짝이는 보라 */
.banner.rare {
  background: linear-gradient(105deg, #f7ecff, #ffe9f7, #eef0ff);
  background-size: 200% 100%;
  border-color: #c98bf5; border-left: 6px solid #a855f7;
  animation: slideDown .4s cubic-bezier(.2, .9, .3, 1.2), rareGlow 4s ease-in-out infinite;
}
@keyframes rareGlow {
  0%, 100% { background-position: 0% 50%; box-shadow: var(--shadow-card); }
  50% { background-position: 100% 50%; box-shadow: 0 0 26px -6px rgba(168, 85, 247, .55); }
}
/* 이벤트 배너에 카테고리별 테마 그림을 아주 옅게 깔아 분위기만 살린다.
   글자 가독성을 위해 opacity를 낮게 유지하고, 이미지가 없으면 그냥 안 보인다. */
.banner.has-ev-bg { position: relative; overflow: hidden; }
.banner.has-ev-bg::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--ev-img); background-size: cover; background-position: center;
  opacity: .17;
}
.banner.has-ev-bg > * { position: relative; z-index: 1; }

.banner .live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); margin-right: 6px; vertical-align: middle;
  animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(221, 79, 71, .6); }
  50% { opacity: .55; box-shadow: 0 0 0 6px rgba(221, 79, 71, 0); }
}

/* ============================================================
   리스트 아이템 (거래 제안 등)
   ============================================================ */

.item {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 13px; margin-bottom: 10px; background: #fff;
  transition: box-shadow .15s;
}
.item:hover { box-shadow: 0 4px 14px -8px rgba(13, 22, 40, .35); }
.item.pending { border-left: 4px solid var(--warn); }
.item.ok { border-left: 4px solid var(--good); }
.item.no { border-left: 4px solid var(--bad); }
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }

/* 새 제안이 도착하면 시선을 끈다 */
@keyframes attention {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 144, 15, 0); }
  50% { box-shadow: 0 0 0 5px rgba(224, 144, 15, .22); }
}
.item.calls { animation: attention 1.8s ease-in-out 3; }

/* ============================================================
   진행 막대 · 투표
   ============================================================ */

.meter, .vote-track {
  display: block; flex: 1; min-width: 70px; height: 9px;
  background: var(--line-soft); border-radius: 999px; overflow: hidden;
}
.meter-fill, .vote-fill {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #1cb87c, #16a06d);
  transition: width .35s cubic-bezier(.3, .9, .3, 1);
}
.meter-fill.tone-brand { background: linear-gradient(90deg, #5b87f8, var(--brand)); }
.meter-fill.tone-gold { background: linear-gradient(90deg, #f7c948, var(--gold)); }
.vote-bar { display: flex; align-items: center; gap: 9px; font-size: .82rem; margin-top: 9px; flex-wrap: wrap; }

/* ============================================================
   순위 · 시상대
   ============================================================ */

.rank-row {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 8px; border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--line-soft);
}
.rank-row:last-child { border-bottom: none; }
.rank-no { width: 30px; font-weight: 900; color: var(--muted); text-align: center; flex-shrink: 0; }
.rank-row:nth-child(1) .rank-no { color: var(--gold-deep); font-size: 1.2rem; }
.rank-row:nth-child(2) .rank-no { color: #97a1b5; }
.rank-row:nth-child(3) .rank-no { color: #c08457; }
.rank-name { flex: 1; font-weight: 700; min-width: 0; font-size: 1rem; }
.rank-val { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.06rem; }
.rank-row.is-me { background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px #c3d5ff; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 6px 0 4px; }
.podium-col { flex: 1; max-width: 130px; text-align: center; }
.podium-crest { margin-bottom: 5px; }
.podium-trophy { width: 40px; height: 40px; object-fit: contain; display: block; margin: 0 auto -2px;
  filter: drop-shadow(0 3px 6px rgba(217, 158, 11, .5)); animation: bob 3.5s ease-in-out infinite; }
.result-trophy { width: 120px; height: 120px; object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(217, 158, 11, .55)); animation: bob 3.5s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.podium-name { font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-val { font-size: .76rem; color: var(--muted); margin-bottom: 6px; }
.podium-block {
  border-radius: 10px 10px 0 0; display: grid; place-items: center;
  font-weight: 900; font-size: 1.15rem; color: #fff;
  background: linear-gradient(180deg, #7c88a5, #5d6883);
}
.podium-1 .podium-block { height: 74px; background: linear-gradient(180deg, #f7c948, #d99e0b); color: #3d2c00; }
.podium-2 .podium-block { height: 54px; }
.podium-3 .podium-block { height: 40px; background: linear-gradient(180deg, #cd9b6a, #a97748); }
.podium-col.is-me .podium-name { color: var(--brand-deep); }
.podium-col.is-me .podium-name::after { content: ' (우리)'; font-size: .74rem; }

/* ============================================================
   내 나라 HUD (학생 화면 상단)
   ============================================================ */

.my-bar {
  background: linear-gradient(120deg, var(--sea-700), var(--sea-600));
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius);
  padding: 15px 18px; margin-bottom: 16px; color: #fff;
  box-shadow: var(--shadow-pop);
  position: relative; overflow: hidden;
}
.my-bar::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='20' cy='20' r='1' fill='%23ffffff' fill-opacity='.1'/%3E%3C/svg%3E");
  pointer-events: none;
}
.my-bar > * { position: relative; }
.my-bar .name { font-size: 1.4rem; font-weight: 800; letter-spacing: -.03em; }
.my-bar .muted, .my-bar .small { color: #b9c6e4; }
.my-bar .stat-tile {
  background: rgba(255, 255, 255, .13);
  border-color: rgba(255, 255, 255, .2);
  flex: 0 1 auto; min-width: max-content;
}
.my-bar .stat-label, .my-bar .stat-sub { color: #b9c6e4; }
.my-bar .stat-value { color: #fff; }
.my-bar .stat-tile.tone-gold { background: rgba(240, 180, 41, .2); border-color: rgba(240, 180, 41, .5); }
.my-bar .stat-tile.tone-gold .stat-value { color: var(--gold); }
.my-bar .crest { border-color: rgba(255, 255, 255, .55); }

/* ============================================================
   제작소
   ============================================================ */

.recipe-card {
  border: 1.5px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 13px; background: #fff;
  transition: transform .13s, box-shadow .13s, border-color .13s;
}
.recipe-card.can {
  border-color: #9fd9c0;
  background: linear-gradient(160deg, #fff, var(--good-soft));
}
.recipe-card.can:hover { transform: translateY(-3px); box-shadow: var(--shadow-pop); }
.recipe-out { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.02rem; }
.recipe-arrow { color: var(--muted); font-weight: 900; margin: 0 2px; }
.ing {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: .8rem; padding: 3px 9px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line-soft);
  margin: 3px 4px 0 0; font-weight: 600;
}
.ing.lack { background: var(--bad-soft); border-color: #f6c4c1; color: var(--bad); font-weight: 800; }
.ing.ok { background: var(--good-soft); border-color: #b6e7d1; color: #0f7d54; }
.profit-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 800; font-size: .84rem;
  background: var(--gold-soft); color: var(--gold-deep);
  border: 1px solid #f0dca4; border-radius: 999px; padding: 2px 10px;
}

/* ============================================================
   회의실 채팅
   ============================================================ */

.chat-box {
  height: 280px; overflow-y: auto;
  background: var(--card-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 11px;
}
.chat-msg { margin-bottom: 10px; font-size: .91rem; }
.chat-msg .who { font-weight: 800; color: var(--brand-deep); }
.chat-msg.mine .who { color: var(--good); }
.chat-msg .bubble {
  display: inline-block; background: #fff; border: 1px solid var(--line-soft);
  border-radius: 4px 12px 12px 12px; padding: 6px 11px; margin-top: 3px;
  max-width: 100%; word-break: break-word;
}
.chat-msg.mine .bubble { background: var(--good-soft); border-color: #b6e7d1; }

/* ============================================================
   표
   ============================================================ */

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--line-soft); }
th {
  font-size: .76rem; color: var(--ink-2); font-weight: 800;
  background: var(--card-2); position: sticky; top: 0; z-index: 1;
  border-bottom: 1.5px solid var(--line);
}
tbody tr:hover { background: var(--card-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.is-me { background: var(--brand-soft) !important; font-weight: 700; }
.table-scroll {
  overflow-x: auto; max-height: 440px; overflow-y: auto;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}

/* ============================================================
   방 코드
   ============================================================ */

.room-code {
  font-size: clamp(2.2rem, 8vw, 4rem);
  font-weight: 900; letter-spacing: .14em;
  color: var(--sea-800);
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  background: linear-gradient(160deg, #fff, var(--gold-soft));
  border: 3px dashed var(--gold);
  border-radius: 20px;
  padding: 14px 22px 14px 34px;
  display: inline-block;
  box-shadow: var(--shadow-pop);
}

/* 학생 초대 영역: QR + 코드 나란히 */
.join-grid {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  flex-wrap: wrap; margin-top: 16px;
}
.join-or { color: var(--muted); font-weight: 800; font-size: .9rem; }
.qr-box {
  width: 240px; height: 240px; display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-card); padding: 10px; margin: 0 auto;
}
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; border-radius: 6px; }
.join-link {
  font-size: .82rem; word-break: break-all; color: var(--ink-2);
  background: var(--card-2); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 8px 10px; max-width: 320px; margin: 0 auto;
}
@media (max-width: 560px) { .join-or { display: none; } }

/* 학생 입장: QR/링크로 코드가 이미 채워진 경우 */
.joined-code { text-align: center; margin-bottom: 18px; }
.code-badge {
  display: inline-block; margin: 4px 0 8px;
  font-size: 1.7rem; font-weight: 900; letter-spacing: .12em;
  color: var(--good); background: var(--good-soft);
  border: 2px solid #b6e7d1; border-radius: 12px; padding: 8px 18px 8px 26px;
}
.code-badge .ok-check { font-size: 1.1rem; }
.linktext { display: block; margin: 0 auto; background: none; border: none; box-shadow: none;
  color: var(--muted); text-decoration: underline; cursor: pointer; padding: 4px; }
.linktext:hover { color: var(--ink-2); filter: none; }

/* 국가별 수요(원하는 물자) */
.need-card { border: 1.5px solid #f0dca4; background: linear-gradient(160deg, #fff, var(--gold-soft)); }
.want-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  margin-top: 8px; font-size: .82rem; font-weight: 700; color: var(--gold-deep);
  background: var(--gold-soft); border: 1px solid #f0dca4; border-radius: 8px; padding: 6px 10px;
}
.want-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: #fff; border: 1px solid #f0dca4; border-radius: 999px;
  padding: 2px 9px; font-weight: 700;
}

/* ============================================================
   빈 상태
   ============================================================ */

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty-art { font-size: 3rem; line-height: 1; margin-bottom: 10px; opacity: .55; }
.empty-art-img { width: 128px; height: auto; margin: 0 auto 10px; opacity: .85; }
.empty-title { font-weight: 800; color: var(--ink-2); margin-bottom: 3px; }
.empty-desc { font-size: .86rem; }

/* ============================================================
   토스트 알림
   ============================================================ */

.toast-host {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  background: var(--sea-800); color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 12px; padding: 11px 18px;
  font-weight: 700; font-size: .92rem; text-align: center;
  box-shadow: var(--shadow-pop);
  animation: toastIn .3s cubic-bezier(.2, .9, .3, 1.3);
}
.toast.tone-good { background: #0f8a5c; }
.toast.tone-bad { background: #c93f38; }
.toast.tone-gold { background: linear-gradient(120deg, #d99e0b, #b8860b); }
.toast.is-out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(.97); } }

/* ============================================================
   기타
   ============================================================ */

.loading { text-align: center; padding: 70px 20px; color: #a9b6d4; }
.loading::before {
  content: ''; display: block; width: 34px; height: 34px; margin: 0 auto 14px;
  border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.config-error {
  max-width: 660px; margin: 60px auto; padding: 32px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-pop); font-family: var(--font);
}
.config-error h1 { color: var(--brand-deep); }
.config-error li { margin-bottom: 8px; }

/* 화면 바탕이 어두우므로 카드 밖 글자는 밝게 */
.on-sea { color: #dce4f5; }
.on-sea .muted { color: #9fadc9; }

/* ============================================================
   교사 화면 전용
   ============================================================ */

/* 방 만들기 단계 표시 */
.step-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 22px; }
.dot {
  width: 38px; height: 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .22); transition: background .3s;
}
.dot.on { background: var(--gold); box-shadow: 0 0 10px -2px var(--gold); }

/* 나라 편집 */
.nation-edit { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.prod-row { display: flex; gap: 6px; align-items: center; margin-bottom: 7px; }
.prod-row select { flex: 2; }
.prod-row input { flex: 1; max-width: 92px; }

/* 나라 현황 카드 */
.nation-card {
  background: #fff; border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 14px;
}
.nation-card.empty { opacity: .55; }
.nation-card.alert { border-color: #f3b1b1; background: linear-gradient(160deg, #fff, var(--bad-soft)); }

/* 이벤트 카드 목록 */
.event-card {
  border: 1.5px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 12px; cursor: pointer; background: #fff; box-shadow: none;
  text-align: left; width: 100%; color: var(--ink); font-weight: 400;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.event-card:hover:not(:disabled) {
  border-color: var(--gold); background: var(--gold-soft);
  transform: translateY(-2px); box-shadow: var(--shadow-card); filter: none;
}
.event-card:disabled { opacity: .38; cursor: not-allowed; }
.event-card.rare {
  background: linear-gradient(100deg, #faf5ff, #fff0fa);
  border-color: #ddc7f7;
}
.event-card.rare:hover:not(:disabled) { border-color: #a855f7; background: linear-gradient(100deg, #f5ebfe, #ffe9f7); }
.event-list { max-height: 470px; overflow-y: auto; display: grid; gap: 9px; padding-right: 4px; }

/* ============================================================
   접근성 · 반응형
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 640px) {
  .wrap, .wrap-narrow { padding: 14px 12px 60px; }
  .card { padding: 15px; border-radius: 14px; }
  h1 { font-size: 1.5rem; }
  .my-bar { padding: 13px 14px; }
  .my-bar .name { font-size: 1.2rem; }
  .my-bar .row { gap: 10px; }
  .my-bar .stat-tile { flex: 1 1 42%; min-width: 0; }
  .my-bar .stat-tile.is-hero { flex-basis: 100%; }
  .my-bar .stat-value { white-space: normal; }
  .tabs button { padding: 8px 11px; font-size: .86rem; }
  .grid-4 { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .podium-col { max-width: 100px; }
}
