/* =========================================================
   DISASTER TRIAGE — 골든타임을 사수하라
   고등학교 보건수업용 재난 트리아제 & 응급처치 시뮬레이터
   ========================================================= */

:root {
  --disaster-dark: #1a1410;
  --disaster-navy: #221b22;
  --warn-orange: #ff7a3d;
  --warn-red: #e63946;
  --er-bg: #eef4f8;
  --er-accent: #4a90d9;
  --er-accent-2: #2e6da4;
  --panel-bg: #ffffff;
  --panel-border: #d8dee4;
  --text-dark: #1f2530;
  --text-mute: #5a6472;
  --success: #3fae6a;
  --danger: #e05a4e;
  --ktas-1: #e63946;
  --ktas-2: #f4a261;
  --ktas-3: #f2c14e;
  --ktas-4: #4caf7d;
  --ktas-5: #4a90d9;
  --touch-min: 60px;
  font-size: clamp(14px, 1.15vw, 18px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: #000;
  color: var(--text-dark);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-width: 320px;
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}
.page.active {
  display: flex;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

/* =========================================================
   세로 화면 경고
   ========================================================= */
#orientation-warning {
  position: fixed;
  inset: 0;
  background: #10141c;
  color: #fff;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vw;
  gap: 1.2rem;
}
#orientation-warning svg {
  width: 20vw;
  max-width: 140px;
  animation: rotateHint 1.8s ease-in-out infinite;
}
#orientation-warning p {
  font-size: clamp(1rem, 3.2vw, 1.4rem);
  line-height: 1.6;
  margin: 0;
}
@keyframes rotateHint {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}
@media (orientation: portrait) and (max-aspect-ratio: 1/1) {
  #orientation-warning { display: flex; }
  #app { display: none; }
}

/* =========================================================
   PAGE 0 — 시작 화면
   ========================================================= */
#page-start {
  background: radial-gradient(circle at 50% 30%, #2a2035 0%, #100c14 70%);
  align-items: center;
  justify-content: center;
  position: relative;
}
.start-content {
  text-align: center;
  color: #fff;
  padding: 2rem;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}
.start-title {
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  margin: 0;
  background: linear-gradient(90deg, #ff7a3d, #ffb703);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(255, 122, 61, 0.35);
}
.start-subtitle {
  font-size: clamp(1.1rem, 2.4vw, 1.6rem);
  color: #ffd166;
  margin: 0 0 0.6rem;
  font-weight: 700;
}
.start-desc {
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  line-height: 1.8;
  color: #d8d3e0;
  margin: 0 0 1rem;
}
.start-btn {
  background: linear-gradient(135deg, #ff7a3d, #e63946);
  color: #fff;
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  font-weight: 800;
  padding: 1rem 3.2rem;
  border-radius: 999px;
  min-height: var(--touch-min);
  box-shadow: 0 8px 24px rgba(230, 57, 70, 0.4);
  letter-spacing: 0.08em;
  transition: transform 0.15s ease;
}
.start-btn:active {
  transform: scale(0.96);
}
.start-footer {
  margin-top: 1.4rem;
  font-size: clamp(0.7rem, 1.2vw, 0.85rem);
  color: #8b87a0;
}
.disclaimer {
  font-size: clamp(0.62rem, 1vw, 0.75rem);
  color: #6b6780;
  max-width: 640px;
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* =========================================================
   HUD (공통)
   ========================================================= */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem clamp(0.8rem, 2vw, 1.6rem);
  min-height: 56px;
  flex-shrink: 0;
  z-index: 20;
}
.hud-disaster {
  background: linear-gradient(180deg, rgba(20, 14, 10, 0.92), rgba(20, 14, 10, 0.7));
  color: #fff;
  border-bottom: 2px solid var(--warn-orange);
}
.hud-hospital {
  background: #fff;
  color: var(--text-dark);
  border-bottom: 2px solid var(--er-accent);
}
.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: clamp(0.75rem, 1.4vw, 1rem);
}
.hud-center {
  font-size: clamp(0.8rem, 1.5vw, 1.1rem);
  letter-spacing: 0.04em;
}
.hud-badge {
  background: rgba(255, 255, 255, 0.12);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
}
.hud-hospital .hud-badge {
  background: #eef4f8;
  color: var(--er-accent-2);
}
.hud-timer {
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   PAGE 1 — 재난 현장
   ========================================================= */
#page-triage {
  background: #100c0a;
}
.scene-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}
.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url("../assets/backgrounds/disaster.jpg");
  background-size: cover;
  background-position: center 40%;
}
.scene-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 14, 10, 0.15), rgba(20, 14, 10, 0.35));
}
.patient-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.patient-marker {
  position: absolute;
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: none;
  padding: 0;
  animation: markerPulse 2.4s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.patient-marker.done {
  animation: none;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.patient-marker .marker-figure {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #ffd166;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  background: #fff;
}
.patient-marker .marker-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.patient-marker .marker-id {
  margin-top: 3px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  background: rgba(230, 57, 70, 0.9);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.03em;
}
.patient-marker:active .marker-figure {
  transform: scale(0.9);
}
@keyframes markerPulse {
  0%, 100% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)) drop-shadow(0 0 0 rgba(255,122,61,0)); }
  50% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)) drop-shadow(0 0 10px rgba(255,122,61,0.7)); }
}

.scene-hint {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  color: #ffd166;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
  font-size: clamp(0.75rem, 1.4vw, 0.95rem);
  z-index: 15;
}

/* =========================================================
   환자 상세 팝업 (STEP1 / STEP2 공용)
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2vh 2vw;
}
.modal-overlay.active {
  display: flex;
}
.patient-modal {
  width: 92vw;
  height: 88vh;
  max-width: 1400px;
  background: var(--panel-bg);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: popIn 0.22s ease;
}
@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.2rem;
  background: var(--er-accent-2);
  color: #fff;
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.3rem);
}
.modal-close {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 40px;
  height: 40px;
  min-width: var(--touch-min);
  min-height: 44px;
  border-radius: 10px;
  font-size: 1.2rem;
  font-weight: 700;
}
.modal-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  min-height: 0;
}
@media (max-height: 620px), (max-width: 1050px) {
  .modal-body { grid-template-columns: 1.05fr 0.95fr; }
}

.modal-col {
  overflow-y: auto;
  padding: 1rem 1.2rem;
  min-height: 0;
}
.modal-col-left {
  border-right: 1px solid var(--panel-border);
}
.modal-col-right {
  display: flex;
  flex-direction: column;
  background: #fafcfe;
}

.info-block {
  margin-bottom: 0.9rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--panel-border);
}
.info-block:last-child { border-bottom: none; }
.info-block h3 {
  margin: 0 0 0.5rem;
  font-size: clamp(0.8rem, 1.3vw, 0.95rem);
  color: var(--er-accent-2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.basic-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 1rem;
  font-size: clamp(0.8rem, 1.3vw, 0.95rem);
}
.basic-info-grid .label { color: var(--text-mute); }
.basic-info-grid .value { font-weight: 700; }

.speech-bubble {
  position: relative;
  background: #fff5e6;
  border: 2px solid #ffd166;
  border-radius: 14px;
  padding: 0.7rem 1rem;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  font-weight: 600;
  color: #7a5a1e;
  margin-top: 0.3rem;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: 24px;
  top: -10px;
  border: 8px solid transparent;
  border-bottom-color: #ffd166;
}

.vital-row {
  display: flex;
  justify-content: space-between;
  padding: 0.28rem 0;
  font-size: clamp(0.8rem, 1.3vw, 0.95rem);
  border-bottom: 1px solid #f0f2f5;
}
.vital-label { color: var(--text-mute); }
.vital-value { font-weight: 700; }

.gcs-grid {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: clamp(0.78rem, 1.25vw, 0.9rem);
}
.gcs-item {
  display: flex;
  gap: 0.5rem;
  background: #f4f7fa;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.gcs-item b { color: var(--er-accent-2); min-width: 3.2em; }

/* 오른쪽: 아바타 시각화 */
.avatar-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 220px;
  padding: 0.6rem;
}
.avatar-stage .avatar-svg-wrap {
  width: min(85%, 360px);
  height: 90%;
  cursor: zoom-in;
  transition: transform 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-stage .avatar-svg-wrap:active {
  transform: scale(0.97);
}
.portrait-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(20, 20, 20, 0.18);
}
.magnify-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  pointer-events: none;
}
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
  border-radius: 0;
}
.zoom-overlay.active { display: flex; }
.zoom-overlay .zoom-svg-wrap {
  width: 70%;
  max-width: 420px;
  text-align: center;
}
.zoom-img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.zoom-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  color: #333;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
}

/* KTAS 선택 UI */
.ktas-section {
  padding: 0.8rem 1.2rem 1rem;
  border-top: 1px solid var(--panel-border);
  background: #fff;
  flex-shrink: 0;
}
.ktas-section h3 {
  margin: 0 0 0.5rem;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
}
.ktas-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}
.ktas-btn {
  min-height: 58px;
  border-radius: 12px;
  border: 2.5px solid var(--panel-border);
  background: #fff;
  font-weight: 800;
  font-size: clamp(0.8rem, 1.3vw, 1rem);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.12s ease;
}
.ktas-btn[data-ktas="1"] { border-color: var(--ktas-1); }
.ktas-btn[data-ktas="2"] { border-color: var(--ktas-2); }
.ktas-btn[data-ktas="3"] { border-color: var(--ktas-3); }
.ktas-btn[data-ktas="4"] { border-color: var(--ktas-4); }
.ktas-btn[data-ktas="5"] { border-color: var(--ktas-5); }
.ktas-btn.selected {
  transform: scale(1.06);
  color: #fff;
}
.ktas-btn.selected[data-ktas="1"] { background: var(--ktas-1); }
.ktas-btn.selected[data-ktas="2"] { background: var(--ktas-2); }
.ktas-btn.selected[data-ktas="3"] { background: var(--ktas-3); }
.ktas-btn.selected[data-ktas="4"] { background: var(--ktas-4); }
.ktas-btn.selected[data-ktas="5"] { background: var(--ktas-5); }
.ktas-btn .check { display: none; }
.ktas-btn.selected .check { display: inline; }

.submit-btn {
  width: 100%;
  min-height: var(--touch-min);
  background: linear-gradient(135deg, #2e6da4, #4a90d9);
  color: #fff;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  font-weight: 800;
  border-radius: 14px;
  letter-spacing: 0.03em;
}
.submit-btn:disabled {
  background: #c7cdd4;
  cursor: not-allowed;
}

.feedback-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(10px);
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 50;
  max-width: 90%;
  text-align: center;
}
.feedback-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.feedback-toast.correct { background: var(--success); color: #fff; }
.feedback-toast.wrong { background: var(--danger); color: #fff; }

/* =========================================================
   전환 화면 (TRIAGE COMPLETE)
   ========================================================= */
.transition-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a2a3a, #0d1620);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.8rem;
  z-index: 200;
  text-align: center;
  padding: 2rem;
}
.transition-screen.active { display: flex; }
.transition-screen h1 {
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  letter-spacing: 0.08em;
  margin: 0;
  color: #4caf7d;
  animation: fadeInUp 0.5s ease;
}
.transition-screen p {
  font-size: clamp(0.9rem, 1.8vw, 1.2rem);
  line-height: 1.7;
  color: #cfd8e3;
  max-width: 640px;
  margin: 0;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   PAGE 2 — 응급실
   ========================================================= */
#page-hospital {
  background: var(--er-bg);
}
.hospital-scene-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.hospital-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("../assets/backgrounds/hospital.jpg");
  background-size: cover;
  background-position: center;
}
.hospital-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(238, 244, 248, 0.55);
}
.card-grid-wrap {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: clamp(0.8rem, 2vw, 1.6rem);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.6rem, 1.5vw, 1.1rem);
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 1080px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-height: 620px) {
  .card-grid { grid-template-columns: repeat(6, 1fr); }
}

.patient-card {
  background: #fff;
  border-radius: 16px;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  box-shadow: 0 4px 14px rgba(20, 40, 60, 0.12);
  border: 2px solid transparent;
  position: relative;
  min-height: var(--touch-min);
  transition: transform 0.12s ease;
}
.patient-card:active { transform: scale(0.96); }
.patient-card .card-face {
  width: clamp(56px, 9vw, 84px);
  height: clamp(56px, 9vw, 84px);
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #e2e8ee;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.patient-card .card-name {
  font-weight: 800;
  font-size: clamp(0.78rem, 1.2vw, 0.92rem);
}
.patient-card .card-sub {
  font-size: clamp(0.66rem, 1vw, 0.78rem);
  color: var(--text-mute);
}
.patient-card .card-ktas {
  font-size: clamp(0.68rem, 1.05vw, 0.8rem);
  font-weight: 800;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  color: #fff;
}
.patient-card.done {
  border-color: var(--success);
  opacity: 0.72;
}
.card-stamp {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--success);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  transform: rotate(-8deg);
  animation: stampIn 0.3s ease;
}
@keyframes stampIn {
  from { transform: rotate(-8deg) scale(1.8); opacity: 0; }
  to { transform: rotate(-8deg) scale(1); opacity: 1; }
}

/* 처치 물품 팔레트 */
.treatment-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.8rem 1.1rem;
  gap: 0.6rem;
  min-height: 0;
}
.treatment-panel h3 {
  margin: 0;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  color: var(--er-accent-2);
}
.item-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.item-btn {
  background: #fff;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.5rem 0.3rem;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: clamp(0.62rem, 1vw, 0.75rem);
  font-weight: 700;
  color: var(--text-dark);
}
.item-btn .item-icon { font-size: clamp(1.1rem, 2vw, 1.5rem); }
.item-btn.selected {
  border-color: var(--er-accent);
  background: #e7f1fb;
  transform: scale(1.05);
}

.treat-zone-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 140px;
  position: relative;
  background: #f4f7fa;
  border-radius: 14px;
  padding: 0.6rem;
}
.treat-zone-avatar {
  width: min(34%, 150px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.treat-zone-btns {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.zone-btn {
  background: #fff;
  border: 2px dashed var(--er-accent);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  font-weight: 700;
  font-size: clamp(0.72rem, 1.15vw, 0.88rem);
  color: var(--er-accent-2);
  min-height: 44px;
  text-align: left;
}
.zone-btn:active { background: #e7f1fb; }
.zone-hint {
  font-size: clamp(0.68rem, 1.1vw, 0.8rem);
  color: var(--text-mute);
  text-align: center;
}

.applied-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.4rem;
  background: #f4f7fa;
  border-radius: 10px;
}
.applied-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: #fff;
  border: 1.5px solid var(--er-accent);
  border-radius: 999px;
  padding: 0.25rem 0.55rem 0.25rem 0.7rem;
  font-size: clamp(0.7rem, 1.1vw, 0.85rem);
  font-weight: 700;
  animation: chipIn 0.18s ease;
}
@keyframes chipIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.applied-chip .chip-remove {
  background: #eee;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  line-height: 1;
  color: #888;
}

.complete-btn {
  width: 100%;
  min-height: var(--touch-min);
  background: linear-gradient(135deg, #3fae6a, #2e8b52);
  color: #fff;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  font-weight: 800;
  border-radius: 14px;
}

/* =========================================================
   PAGE 3 — 최종 결과
   ========================================================= */
#page-result {
  background: linear-gradient(160deg, #eef4f8, #dfeaf3);
  overflow-y: auto;
}
.result-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1.2rem, 3vw, 2.4rem);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.result-title {
  text-align: center;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  color: #2e6da4;
  margin: 0;
}
.result-total {
  text-align: center;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 900;
  color: #1f2530;
}
.result-total span { font-size: 0.4em; color: var(--text-mute); font-weight: 700; }

.score-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 800px) {
  .score-cards { grid-template-columns: 1fr; }
}
.score-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.1rem 1.3rem;
  box-shadow: 0 4px 14px rgba(20, 40, 60, 0.1);
}
.score-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: var(--er-accent-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.score-card .big-score {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text-dark);
}
.score-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.22rem 0;
  color: var(--text-mute);
  border-bottom: 1px dashed #eee;
}
.score-line b { color: var(--text-dark); }

.result-table-wrap {
  background: #fff;
  border-radius: 16px;
  padding: 1.1rem 1.3rem;
  box-shadow: 0 4px 14px rgba(20, 40, 60, 0.1);
  overflow-x: auto;
}
.result-table-wrap h3 { margin: 0 0 0.7rem; color: var(--er-accent-2); }
table.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.72rem, 1.15vw, 0.9rem);
  min-width: 640px;
}
table.result-table th, table.result-table td {
  padding: 0.5rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid #eef1f4;
}
table.result-table th { color: var(--text-mute); font-weight: 700; background: #f7fafc; }
.tag-ok { color: var(--success); font-weight: 800; }
.tag-fail { color: var(--danger); font-weight: 800; }
.tag-pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 0.78em;
}

.feedback-list-wrap {
  background: #fff;
  border-radius: 16px;
  padding: 1.1rem 1.3rem;
  box-shadow: 0 4px 14px rgba(20, 40, 60, 0.1);
}
.feedback-list-wrap h3 { margin: 0 0 0.7rem; color: var(--er-accent-2); }
.feedback-item {
  display: flex;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #f1f4f7;
  font-size: clamp(0.78rem, 1.2vw, 0.92rem);
}
.feedback-item:last-child { border-bottom: none; }
.feedback-item .fb-id {
  font-weight: 800;
  color: var(--er-accent-2);
  flex-shrink: 0;
}

.result-actions {
  display: flex;
  justify-content: center;
  padding-bottom: 1rem;
}
.restart-btn {
  background: linear-gradient(135deg, #ff7a3d, #e63946);
  color: #fff;
  font-weight: 800;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  padding: 1rem 2.6rem;
  border-radius: 999px;
  min-height: var(--touch-min);
}

/* =========================================================
   확인 모달 (다시 시작)
   ========================================================= */
.confirm-modal {
  background: #fff;
  border-radius: 18px;
  padding: 1.6rem;
  width: min(92vw, 420px);
  text-align: center;
  animation: popIn 0.2s ease;
}
.confirm-modal p {
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  line-height: 1.6;
  margin: 0 0 1.2rem;
}
.confirm-actions {
  display: flex;
  gap: 0.7rem;
}
.confirm-actions button {
  flex: 1;
  min-height: var(--touch-min);
  border-radius: 12px;
  font-weight: 800;
  font-size: 1rem;
}
.btn-cancel {
  background: #eef1f4;
  color: var(--text-dark);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}

.count-up {
  animation: countUp 0.6s ease;
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 스크롤바 미세 스타일 */
.modal-col::-webkit-scrollbar, .card-grid-wrap::-webkit-scrollbar, #page-result::-webkit-scrollbar {
  width: 8px;
}
.modal-col::-webkit-scrollbar-thumb, .card-grid-wrap::-webkit-scrollbar-thumb, #page-result::-webkit-scrollbar-thumb {
  background: #c7d0d9;
  border-radius: 8px;
}
