/* 전자칠판 화면 — 어떤 화면에서도 스크롤이 생기지 않게 한다 */

body.board { overflow: hidden; }

#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.9) 0 22%, transparent 22.5%),
    radial-gradient(circle at 88% 76%, rgba(255,255,255,.75) 0 18%, transparent 18.5%),
    linear-gradient(160deg, var(--sky) 0%, var(--milk) 42%, var(--cream) 100%);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: clamp(10px, 1.6vh, 24px) clamp(14px, 2vw, 36px);
  gap: clamp(8px, 1.2vh, 18px);
  overflow: hidden;
}
.screen.active { display: flex; }

/* ── 상단 바 ───────────────────────────── */
.top {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.5vw, 28px);
  flex: none;
}
.brand { display: flex; align-items: center; gap: .5em; }
.brand-name {
  font-size: clamp(20px, 2.8vh, 40px);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.brand-ask {
  font-size: clamp(13px, 1.8vh, 24px);
  font-weight: 700;
  color: var(--ink-2);
  margin-left: .2em;
}
.now {
  display: flex; align-items: baseline; gap: .5em;
  margin-left: auto;
  font-size: clamp(15px, 1.9vh, 26px);
  color: var(--ink-2);
}
.now strong {
  font-size: clamp(22px, 3.2vh, 46px);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.now-points {
  display: flex;
  align-items: baseline;
  gap: .6em;
  background: var(--gold);
  color: #4A3608;
  font-size: clamp(14px, 1.8vh, 24px);
  font-weight: 800;
  padding: .45em 1.1em;
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--gold-d);
  white-space: nowrap;
}
.now-points em {
  font-style: normal;
  font-size: .82em;
  font-weight: 700;
  opacity: .72;
}
.now-points em:empty { display: none; }
.now-points.zero {
  background: var(--cream);
  color: var(--ink-2);
  box-shadow: 0 3px 0 var(--cream2);
}

/* 사진이 어디에 저장되는지 알리는 배지. 정상일 때는 뜨지 않는다. */
.dirwarn {
  background: #FBE9E7;
  color: #8A3B33;
  border: 1px solid #EBC9C5;
  font-size: clamp(12px, 1.5vh, 18px);
  font-weight: 800;
  padding: .5em 1em;
  border-radius: 999px;
  white-space: nowrap;
}
/* 폴더를 아직 안 정한 상태 — 문제는 아니지만 알아둬야 한다 */
.dirwarn.soft {
  background: #FDF3D8;
  color: #6B5417;
  border-color: #EEDCA6;
}

.gear {
  font-size: clamp(20px, 2.6vh, 34px);
  width: 2em; height: 2em;
  border-radius: 50%;
  background: rgba(255,255,255,.7);
  color: var(--ink-2);
  flex: none;
}
.gear.holding { background: var(--blue); color: #fff; }

/* ── 명단 그리드 ──────────────────────── */
.roster-wrap { flex: 1 1 auto; min-height: 0; position: relative; }

.roster {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  grid-template-rows: repeat(var(--rows, 5), 1fr);
  gap: clamp(6px, .9vh, 14px);
  width: 100%;
  height: 100%;
}

.stu {
  container-type: size;
  position: relative;
  display: grid;
  place-content: center;
  gap: 2cqh;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
  overflow: hidden;
}
.stu:active { transform: translateY(3px) scale(.98); }

/* --wch = 글자 폭 합(em). 길수록 글씨를 줄여 칸 안에 다 들어가게 한다 */
.stu .no {
  font-size: min(34cqh, calc(90cqw / var(--wch, 2)));
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}
.stu .nm {
  font-size: min(15cqh, calc(90cqw / var(--wch, 4)));
  font-weight: 700;
  color: var(--ink-2);
  line-height: 1.1;
  max-width: 92cqw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stu .badge {
  position: absolute;
  top: 6cqh; right: 6cqw;
  font-size: 18cqh;
  line-height: 1;
}
.stu .pt {
  position: absolute;
  bottom: 5cqh; left: 0; right: 0;
  font-size: 14cqh;
  font-weight: 800;
}

/* 상태별 */
.stu[data-state="done"] {
  background: #EFF8F0;
  border-color: var(--green);
}
.stu[data-state="done"] .no { color: var(--green-d); }
.stu[data-state="done"] .pt { color: var(--green-d); }

.stu[data-state="half"] {
  background: #FFF8E6;
  border-color: var(--gold);
  animation: pulse 1.6s ease-in-out infinite;
}
.stu[data-state="half"] .no { color: var(--gold-d); }

.stu[data-state="skip"],
.stu[data-state="nocheck"] {
  background: var(--cream);
  border-color: var(--cream2);
  opacity: .75;
}
.stu[data-state="skip"] .no,
.stu[data-state="nocheck"] .no { color: var(--ink-2); }

@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50%      { box-shadow: 0 2px 0 var(--cream2), 0 0 0 6px rgba(242,193,78,.35); }
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .6em;
  text-align: center;
  background: rgba(255,252,245,.92);
  border-radius: var(--r-lg);
}
.empty-hint h2 { font-size: clamp(20px, 3vh, 36px); }
.empty-hint p  { font-size: clamp(14px, 2vh, 22px); color: var(--ink-2); line-height: 1.6; }

/* ── 하단 집계 ────────────────────────── */
.bottom {
  flex: none;
  display: flex;
  gap: clamp(8px, 1.4vw, 22px);
  justify-content: center;
  font-size: clamp(13px, 1.8vh, 24px);
  color: var(--ink-2);
}
.tally b { font-size: 1.35em; font-weight: 900; margin-right: .15em; }
.tally.done b { color: var(--green-d); }
.tally.half b { color: var(--gold-d); }
.tally.skip b { color: var(--ink-2); }
.tally.left b { color: var(--blue-d); }

/* ── 학생 화면 / 사유 화면 ─────────────── */
.back {
  position: absolute;
  top: clamp(10px, 1.6vh, 24px);
  left: clamp(14px, 2vw, 36px);
  font-size: clamp(15px, 2vh, 26px);
  font-weight: 700;
  color: var(--ink-2);
  background: rgba(255,255,255,.75);
  border-radius: 999px;
  padding: .45em 1.1em;
  z-index: 3;
}

.student-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(6px, 1.2vh, 18px);
  text-align: center;
}
.who {
  font-size: clamp(28px, 5.5vh, 76px);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.step-hint {
  font-size: clamp(15px, 2.4vh, 30px);
  color: var(--ink-2);
  font-weight: 600;
}
.actions {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vh, 18px);
  margin-top: clamp(6px, 1.4vh, 20px);
  width: min(90vw, 720px);
}
.actions .big { width: 100%; }

/* 찍은 사진 미리보기 줄 */
.shots {
  flex: none;
  display: flex;
  gap: 12px;
  justify-content: center;
  height: clamp(0px, 12vh, 150px);
}
.shots:empty { display: none; }
.shots figure {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.shots img {
  height: calc(100% - 1.6em);
  border-radius: var(--r-sm);
  border: 3px solid #fff;
  box-shadow: var(--shadow);
  object-fit: cover;
}
.shots figcaption { font-size: clamp(11px, 1.5vh, 17px); color: var(--ink-2); font-weight: 700; }

/* ── 촬영 화면 ────────────────────────── */
.shoot-head {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .6em;
  font-size: clamp(16px, 2.2vh, 28px);
  color: var(--ink-2);
}
.shoot-head b {
  font-size: 1.25em;
  color: #fff;
  background: var(--blue);
  padding: .15em .8em;
  border-radius: 999px;
}

/* 16:9 화면에서 4:3 카메라를 놓으면 옆이 남는다. 그 자리에 예시 그림을 세운다. */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;          /* 카메라 높이를 남는 공간에 정확히 맞춘다 */
  justify-content: center;
  gap: clamp(10px, 2vw, 30px);
}

.shoot-side {
  flex: 0 1 clamp(200px, 27vw, 380px);
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;   /* 카메라 위쪽 선에 맞춘다 */
  gap: clamp(8px, 1.6vh, 20px);
  padding-top: clamp(4px, 1vh, 14px);
}

/* 촬영 화면에서는 예시를 세로로 쌓는다 (icons.css의 가로 배치를 덮는다).
   icons.css가 뒤에 오므로 셀렉터를 한 단계씩 더 깊게 잡아야 이긴다. */
.shoot-side .examples {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: clamp(6px, 1.2vh, 14px);
  min-height: 0;
  margin: 0;
}
.shoot-side .examples .ex {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: clamp(5px, .9vh, 10px) clamp(9px, 1vw, 15px);
}
.shoot-side .examples .ex .ex-img {
  width: clamp(52px, 9vh, 104px);
  flex: none;
}
.shoot-side .examples .ex figcaption {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-size: clamp(12px, 1.9vh, 22px);
  line-height: 1.3;
  word-break: keep-all;
}

/* 가이드 그림이 화면을 뒤덮으면 정작 학생 손이 안 보인다. 안내선답게 작게. */
.stage .cam-box .guide {
  background-size: 58%;
  opacity: .82;
}

/* 화면이 좁으면 예시를 접는다 — 카메라가 먼저다 */
@media (max-aspect-ratio: 5/4) {
  .stage { flex-direction: column; }
  .shoot-side { flex: none; align-self: auto; }
  .shoot-side .examples { flex-direction: row; justify-content: center; }
  .shoot-side .ex { flex-direction: column; }
}

.cam-box {
  position: relative;
  /* 높이는 stage가 정하고, 폭은 4:3 비율로 따라온다.
     이렇게 해야 아래 버튼과 위 헤더를 절대 밀어내지 않는다. */
  flex: 0 0 auto;
  min-height: 0;
  height: 100%;
  aspect-ratio: 4 / 3;
  width: auto;
  max-width: 68%;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #111;
  box-shadow: var(--shadow-up);
}
.cam-box video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);   /* 라이브 화면만 거울. 그래야 자세를 맞추기 쉽다 */
}

/* 방금 찍은 사진. 카메라 영상 위에 겹쳐야 한다 —
   position을 빼면 영상 아래로 밀려나 상자 밖으로 나가버린다.
   거울 반전은 걸지 않는다. 실제로 저장되는 사진과 같아야 팩의 이름 글자를 확인할 수 있다. */
.cam-box .preview {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
}

.guide {
  position: absolute;
  inset: 8%;
  border: 6px dashed rgba(255,255,255,.75);
  border-radius: 50%;
  pointer-events: none;
}
.guide.rect { border-radius: var(--r-lg); inset: 10% 14%; }

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(80px, 28vh, 300px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 6px 30px rgba(0,0,0,.5);
  background: rgba(0,0,0,.25);
  animation: pop .6s ease;
}
@keyframes pop {
  from { transform: scale(1.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.shoot-tip {
  flex: none;
  font-size: clamp(14px, 2.2vh, 28px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.4;
}
.cam-error {
  flex: none;
  font-size: clamp(14px, 2vh, 24px);
  color: var(--red);
  font-weight: 700;
  text-align: center;
  max-width: 40em;
}

.shoot-btns {
  flex: none;
  display: flex;
  gap: clamp(8px, 1.4vw, 20px);
  justify-content: center;
}

/* ── 결과 화면 ────────────────────────── */
.result-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(4px, 1vh, 14px);
  text-align: center;
}
.result-title {
  font-size: clamp(30px, 6vh, 84px);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.result-score {
  font-size: clamp(40px, 9vh, 130px);
  font-weight: 900;
  color: var(--gold-d);
  line-height: 1;
  letter-spacing: -0.04em;
}
.result-score.zero { color: var(--ink-2); font-size: clamp(26px, 5vh, 68px); }
.result-sub {
  font-size: clamp(15px, 2.2vh, 28px);
  color: var(--ink-2);
  font-weight: 600;
}
.result-send {
  font-size: clamp(13px, 1.8vh, 22px);
  color: var(--ink-2);
  min-height: 1.4em;
}
.result-send.fail { color: var(--red); font-weight: 700; }
#btn-result-close { margin-top: clamp(8px, 2vh, 26px); }

/* ── 폴더 연결·사진 옮기기 모달 ─────────── */
/* 교사가 아침에 처리하는 화면이라 전자칠판에서도 읽히게 크게 */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(22, 28, 40, .55);
  display: grid; place-items: center;
  z-index: 60;
}
.modal-back[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vh, 48px) clamp(32px, 5vw, 56px);
  max-width: min(760px, 92vw);
  display: grid; gap: clamp(12px, 2vh, 20px);
  text-align: center;
}
.modal h3 {
  font-size: clamp(24px, 4vh, 38px);
  font-weight: 900;
  letter-spacing: -0.03em;
}
.modal p {
  font-size: clamp(16px, 2.6vh, 24px);
  color: var(--ink-2);
  font-weight: 600;
  line-height: 1.5;
}
.modal .modal-acts {
  display: flex; gap: 14px; justify-content: center;
  margin-top: clamp(4px, 1vh, 10px);
}
