/* student-game.css — 학생창 게임 요소 (점수 대시보드 · 미션 · 반 비교)
   톤: 게임스럽지만 세련·전문적. 기존 styles.css CSS 변수 재사용. */

.game-panel {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-card {
  background: var(--panel, rgba(255, 255, 255, 0.94));
  border: 1px solid rgba(24, 40, 43, 0.07);
  border-radius: 16px;
  box-shadow: var(--shadow, 0 12px 30px rgba(24, 40, 43, 0.12));
  padding: 14px 15px;
}

.game-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted, #647376);
  margin: 0 0 10px;
  text-transform: none;
}

/* ── 점수 대시보드 ─────────────────────────────── */
.score-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.score-total-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.score-total {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--ink, #18282b);
  font-variant-numeric: tabular-nums;
}

.score-total small {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted, #647376);
  margin-left: 2px;
}

.score-total-label {
  font-size: 0.72rem;
  color: var(--muted, #647376);
  margin-top: 4px;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--grade-color, #2774c6);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(24, 40, 43, 0.18);
  transition: background 0.3s ease;
}

.grade-badge .grade-level {
  font-size: 0.68rem;
  opacity: 0.85;
  font-weight: 600;
}

@keyframes gradePulse {
  0% { transform: scale(1); box-shadow: 0 4px 12px rgba(24, 40, 43, 0.18); }
  40% { transform: scale(1.12); box-shadow: 0 8px 22px rgba(24, 40, 43, 0.28); }
  100% { transform: scale(1); box-shadow: 0 4px 12px rgba(24, 40, 43, 0.18); }
}

.grade-badge.grade-up {
  animation: gradePulse 0.7s ease;
}

.score-radar-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
}

.score-radar-wrap canvas {
  max-width: 100%;
}

/* ── 영역별 미니 바 ─────────────────────────────── */
.score-parts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.score-part-row {
  display: grid;
  grid-template-columns: 48px 1fr 52px;
  align-items: center;
  gap: 8px;
  cursor: help;
}

.score-part-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink, #18282b);
}

.score-part-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.score-part-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  width: 0%;
  transition: width 0.45s ease;
}

.score-part-value {
  font-size: 0.72rem;
  font-weight: 700;
  text-align: right;
  color: var(--muted, #647376);
  font-variant-numeric: tabular-nums;
}

/* ── 미션 체크리스트 ───────────────────────────── */
.mission-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink, #18282b);
}

.mission-progress .mission-count {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.mission-progress-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.mission-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--green, #2f9d68);
  transition: width 0.45s ease;
}

.mission-complete-ribbon {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0ad38, #d4a017);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
}

.mission-complete-ribbon.show {
  display: inline-flex;
}

.mission-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--blue, #2774c6);
  padding: 0;
}

/* 셰브론 토글 버튼 스타일 */
.mission-toggle.mission-toggle-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(245, 244, 238, 0.65);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.mission-toggle.mission-toggle-chevron:hover {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(245, 244, 238, 0.9);
  border-color: rgba(255, 255, 255, 0.22);
}

.mission-chevron-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s ease;
  display: block;
}

.mission-toggle.mission-toggle-chevron.collapsed .mission-chevron-icon {
  transform: rotate(-90deg);
}

.mission-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mission-list.collapsed {
  display: none;
}

.mission-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.mission-item.done {
  background: rgba(47, 157, 104, 0.18);
  border-color: rgba(47, 157, 104, 0.4);
}

.mission-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: transparent;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 1px;
}

.mission-item.done .mission-check {
  background: var(--green, #2f9d68);
  border-color: var(--green, #2f9d68);
  color: #fff;
}

.mission-body {
  flex: 1;
  min-width: 0;
}

.mission-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(245, 244, 238, 0.92);
}

.mission-item.done .mission-name {
  color: #ffffff;
}

.mission-desc {
  font-size: 0.72rem;
  color: rgba(245, 244, 238, 0.45);
  margin-top: 2px;
}

.mission-item.done .mission-desc {
  color: rgba(245, 244, 238, 0.6);
}

.mission-subject {
  flex: 0 0 auto;
  font-size: 0.64rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
}

.mission-subject.subject-social { background: #2774c6; }
.mission-subject.subject-math { background: #2f9d68; }
.mission-subject.subject-korean { background: #f0ad38; }

/* ── 반 비교 위젯 ──────────────────────────────── */
.class-compare-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.class-compare-wrap canvas {
  max-width: 100%;
}

.class-compare-summary {
  font-size: 0.76rem;
  color: var(--muted, #647376);
  text-align: center;
  line-height: 1.5;
}

.class-compare-summary strong {
  color: var(--ink, #18282b);
}

/* ── top 모드 최고기록 카드 ────────────────────────── */
.cc-top-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0 2px;
}

.cc-top-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d4a017;
  opacity: 0.9;
}

.cc-top-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cc-top-score {
  font-size: 2.6rem;
  font-weight: 800;
  color: #d4a017;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(212, 160, 23, 0.3);
}

.cc-top-unit {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(245, 244, 238, 0.6);
}

.cc-top-norecord {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(245, 244, 238, 0.45);
}

.cc-top-grade {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(212, 160, 23, 0.15);
  border: 1px solid rgba(212, 160, 23, 0.35);
  white-space: nowrap;
}

.cc-top-diff {
  font-size: 0.78rem;
  color: rgba(245, 244, 238, 0.7);
}

.cc-top-diff strong {
  color: #d4a017;
  font-weight: 700;
}

.cc-top-diff--crown {
  font-weight: 700;
  color: #d4a017;
}

.cc-top-count {
  font-size: 0.74rem;
  color: rgba(245, 244, 238, 0.5);
  margin-top: 2px;
}

.cc-top-count strong {
  color: rgba(245, 244, 238, 0.8);
}

.game-card.hidden,
.game-panel .hidden {
  display: none !important;
}

/* ── 경계 안내 토스트 ──────────────────────────── */
.student-toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%) translateY(12px);
  z-index: 2000;
  max-width: 90vw;
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(11, 31, 18, 0.95);
  border: 1px solid rgba(93, 247, 164, 0.4);
  color: #ecfff5;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.student-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── 배치한 시설 목록 ──────────────────────────── */
.placed-facilities {
  margin-top: 12px;
  background: var(--panel, rgba(10, 28, 20, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: var(--shadow, 0 12px 30px rgba(0, 0, 0, 0.3));
  padding: 12px 13px;
}

.placed-facilities-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(245, 244, 238, 0.7);
  margin-bottom: 9px;
}

.placed-facilities-head strong {
  color: var(--neon, #5df7a4);
  font-variant-numeric: tabular-nums;
}

.placed-facilities-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.placed-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.placed-row.selected {
  background: rgba(93, 247, 164, 0.14);
  border-color: rgba(93, 247, 164, 0.45);
}

.placed-row.outside {
  border-color: rgba(255, 86, 95, 0.55);
}

.placed-focus {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 6px 8px 10px;
  text-align: left;
  color: inherit;
}

.placed-icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.placed-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.placed-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(245, 244, 238, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.placed-flag {
  font-style: normal;
  font-size: 0.62rem;
  font-weight: 700;
  color: #ff565f;
  margin-left: 4px;
}

.placed-benefit {
  font-size: 0.72rem;
  color: rgba(245, 244, 238, 0.55);
  font-variant-numeric: tabular-nums;
}

.placed-delete {
  flex: 0 0 auto;
  align-self: stretch;
  margin: 4px 4px 4px 0;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 86, 95, 0.4);
  background: rgba(255, 86, 95, 0.12);
  color: #ff8a90;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.placed-delete:hover {
  background: rgba(255, 86, 95, 0.24);
  color: #fff;
}

/* ── 게임 컴팩트 헤더 (항상 표시) ─────────────────── */
.game-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 2px 0;
  flex-wrap: wrap;
}

.game-header-score {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink, #ecfff5);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.game-header-score small {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #92b6a3);
  margin-left: 1px;
}

.game-header-grade {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--neon, #5df7a4);
}

.game-header-grade::before {
  content: "·";
  margin-right: 6px;
  color: rgba(245, 244, 238, 0.3);
}

.game-header-mission {
  margin-left: auto;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--yellow, #ffcf5a);
  font-variant-numeric: tabular-nums;
}

/* ── 게임 탭 (다크 알약형) ────────────────────────── */
.game-tabs {
  display: flex;
  gap: 5px;
  margin-top: 10px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.game-tab {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: rgba(245, 244, 238, 0.6);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.game-tab:hover {
  color: rgba(245, 244, 238, 0.85);
}

.game-tab.active {
  background: rgba(93, 247, 164, 0.16);
  color: #ecfff5;
  box-shadow: inset 0 0 0 1px rgba(93, 247, 164, 0.35);
}

.game-tab-count {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.game-tab-dot {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow, #ffcf5a);
  box-shadow: 0 0 6px rgba(255, 207, 90, 0.8);
}

.game-tab-dot.show {
  display: inline-block;
}

.game-tab.hidden {
  display: none !important;
}

/* ── 탭 패널 전환 ────────────────────────────────── */
.game-panel .game-tabpanel {
  display: none;
  margin-top: 0;
}

.game-panel .game-tabpanel.active {
  display: block;
}

.score-mission-line {
  margin: 2px 0 0;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--yellow, #ffcf5a);
}

/* ── 폰 화면(≤640px): 점수/미션/반비교 패널을 압축하고 탭 영역을 40px 이상 확보 ──
   기존 styles.css의 640px 관례를 그대로 따른다. 데스크톱은 영향 없음. */
@media (max-width: 640px) {
  .game-panel {
    margin-top: 10px;
    gap: 10px;
  }

  .game-card {
    padding: 12px;
  }

  .game-tabs {
    margin-top: 8px;
  }

  .game-tab {
    min-height: 40px;
    padding: 8px;
  }

  .placed-facilities {
    margin-top: 10px;
    padding: 10px;
  }

  .placed-focus {
    min-height: 44px;
    padding: 8px 6px 8px 10px;
  }

  .placed-delete {
    min-height: 40px;
    min-width: 40px;
    padding: 0 12px;
  }

  /* 11px 미만 텍스트 전수 점검(스윕) 결과 발견된 3곳 — 폰에서만 11px로 올린다.
     데스크톱(이 미디어쿼리 밖)은 기존 0.6x rem 값 그대로 유지된다. */
  .grade-badge .grade-level {
    font-size: 11px;
  }

  .mission-subject {
    font-size: 11px;
  }

  .placed-flag {
    font-size: 11px;
  }
}
