/* ====================================
   ROOT VARIABLES & RESET
==================================== */
:root {
  --primary: #6c63ff;
  --primary-dark: #4e45d1;
  --primary-light: #9b94ff;
  --secondary: #ff6584;
  --accent: #ffd93d;
  --accent2: #6bcb77;
  --bg-dark: #0f0e17;
  --bg-mid: #1a1a2e;
  --bg-card: #16213e;
  --bg-card2: #1e2a4a;
  --text-main: #fffffe;
  --text-sub: #a7a9be;
  --text-dim: #6b7280;
  --border: rgba(108,99,255,0.25);
  --shadow-glow: 0 0 20px rgba(108,99,255,0.4);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  --pixel-font: 'Press Start 2P', monospace;
  --body-font: 'Noto Sans KR', sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--body-font);
  background: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Pixel scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
  z-index: 1;
}

button { cursor: pointer; font-family: var(--body-font); border: none; outline: none; }
input, select, textarea { font-family: var(--body-font); outline: none; }

/* ====================================
   FLOATING PARTICLES
==================================== */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.15;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.15; }
  90% { opacity: 0.15; }
  100% { transform: translateY(-10vh) rotate(720deg); opacity: 0; }
}

/* ====================================
   HEADER
==================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,14,23,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon { font-size: 28px; }
.logo-text {
  font-family: var(--pixel-font);
  font-size: 11px;
  color: var(--primary-light);
  letter-spacing: 0.5px;
  text-shadow: 0 0 12px var(--primary);
  white-space: nowrap;
}
.header-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-btn {
  padding: 8px 16px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-btn:hover {
  color: var(--text-main);
  background: rgba(108,99,255,0.15);
  border-color: var(--border);
}
.nav-btn.active {
  color: var(--text-main);
  background: var(--primary);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

/* ====================================
   TAB CONTENT
==================================== */
.tab-content {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  position: relative;
  z-index: 2;
}
.tab-content.active { display: block; }

/* ====================================
   SECTION TITLE BAR
==================================== */
.section-title-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.section-title-bar h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}
.pixel-badge {
  font-family: var(--pixel-font);
  font-size: 9px;
  padding: 5px 10px;
  background: var(--primary);
  color: var(--text-main);
  border-radius: 4px;
  letter-spacing: 0.5px;
  box-shadow: 3px 3px 0 var(--primary-dark);
}

/* ====================================
   GRADE TABS
==================================== */
.grade-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.grade-tab {
  padding: 10px 22px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: all 0.2s;
}
.grade-tab:hover {
  color: var(--text-main);
  border-color: var(--primary-light);
}
.grade-tab.active {
  color: var(--text-main);
  background: var(--primary);
  border-color: var(--primary-light);
  box-shadow: var(--shadow-glow);
}

/* ====================================
   CLASS GRID
==================================== */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.class-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.class-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(108,99,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.class-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}
.class-card:hover::before { opacity: 1; }
.class-card.selected {
  border-color: var(--primary);
  background: rgba(108,99,255,0.2);
  box-shadow: var(--shadow-glow);
}
.class-card.selected::before { opacity: 1; }
.class-card-icon { font-size: 30px; margin-bottom: 8px; }
.class-card-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.class-card-count { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* 학급 카드 이미지 커스터마이징 */
.class-card-img-wrap {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 auto 8px;
  background: rgba(108,99,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 2px solid rgba(108,99,255,0.2);
  transition: border-color 0.2s;
}
.class-card:hover .class-card-img-wrap {
  border-color: rgba(108,99,255,0.5);
}
.class-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.class-card-img-wrap .img-emoji {
  font-size: 30px;
  line-height: 1;
}
.class-card-img-edit {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
  z-index: 3;
  font-size: 18px;
  color: #fff;
  border-radius: 10px;
}
.class-card:hover .class-card-img-edit {
  opacity: 1;
}

/* ====================================
   SETTINGS SECTION
==================================== */
.class-selector-section,
.settings-section,
.draw-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
}
.settings-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.settings-card-header {
  background: rgba(108,99,255,0.15);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.hint-text { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.settings-card-body { padding: 16px; }
.range-inputs {
  display: flex;
  align-items: center;
  gap: 10px;
}
.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-group label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.input-group input, .input-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  transition: border-color 0.2s;
}
.input-group input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(108,99,255,0.2);
}
.range-divider {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-light);
  margin-top: 18px;
}

/* Number Grid for Exclude */
.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
}
.num-btn {
  aspect-ratio: 1;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-dark);
  color: var(--text-sub);
  border: 2px solid var(--border);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.num-btn:hover:not(:disabled) {
  border-color: var(--secondary);
  color: var(--secondary);
}
.num-btn.excluded {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
  box-shadow: 0 0 10px rgba(255,101,132,0.5);
}
.num-btn.out-of-range, .num-btn.inactive {
  opacity: 0.3;
}
.num-btn:disabled {
  cursor: not-allowed;
}

/* Candidate Info */
.candidate-info {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(107,203,119,0.1);
  border: 1px solid rgba(107,203,119,0.3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--accent2);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ====================================
   DRAW SECTION  –  새 캔버스 머신
==================================== */
.draw-arena {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

/* 캔버스 래퍼 */
.lottery-machine-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  flex: 1 1 460px;
  max-width: 560px;
}

/* 유리통 외곽 */
.lm-tank-outer {
  width: 100%;
  position: relative;
  background: linear-gradient(160deg, rgba(22,30,60,0.95), rgba(15,14,23,0.98));
  border: 2.5px solid rgba(108,99,255,0.55);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  overflow: visible;
  box-shadow:
    0 0 0 1px rgba(108,99,255,0.12),
    inset 0 2px 30px rgba(108,99,255,0.08),
    0 -4px 24px rgba(108,99,255,0.15);
}

/* 유리 광택 오버레이 */
.lm-tank-outer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.04) 0%,
    transparent 50%
  );
  border-radius: 22px 22px 0 0;
  pointer-events: none;
  z-index: 2;
}

.lottery-canvas {
  display: block;
  width: 100%;
  border-radius: 22px 22px 0 0;
}

/* 출구 파이프 */
.lm-pipe {
  width: 60px;
  height: 36px;
  background: linear-gradient(to bottom, #1a1a3a, #12122a);
  border: 2.5px solid rgba(108,99,255,0.55);
  border-top: none;
  border-radius: 0 0 8px 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
.lm-pipe-inner {
  position: absolute;
  inset: 4px;
  background: linear-gradient(to bottom,
    rgba(108,99,255,0.3),
    rgba(108,99,255,0.05)
  );
  border-radius: 0 0 4px 4px;
}

/* 결과 트레이 */
.lm-tray {
  width: 100%;
  background: var(--bg-card2);
  border: 2.5px solid rgba(108,99,255,0.55);
  border-top: none;
  border-radius: 0 0 24px 24px;
  padding: 20px 28px 24px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.lm-tray::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 60px; height: 3px;
  background: linear-gradient(90deg, transparent, rgba(108,99,255,0.6), transparent);
}
.lm-tray-label {
  font-size: 10px;
  font-family: var(--pixel-font);
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.lm-tray-result { text-align: center; }
.lm-tray-prompt {
  font-size: 15px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* 결과 표시 – 공 이미지 + 텍스트 */
.lm-result-ball {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  box-shadow:
    inset -8px -8px 16px rgba(0,0,0,0.35),
    inset 8px 8px 16px rgba(255,255,255,0.18),
    0 0 40px rgba(255,217,61,0.55),
    0 0 80px rgba(255,217,61,0.2);
  animation: resultBallPop 0.5s cubic-bezier(0.175,0.885,0.32,1.275);
  position: relative;
}
.lm-result-ball::after {
  content: '';
  position: absolute;
  top: 14%; left: 18%;
  width: 30%; height: 20%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.5) 0%, transparent 100%);
  border-radius: 50%;
}
.lm-result-num {
  font-family: var(--pixel-font);
  font-size: 28px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 1;
}
.lm-result-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-main);
  animation: resultPop 0.4s 0.2s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
.lm-result-class {
  font-size: 12px;
  color: var(--primary-light);
  margin-top: 4px;
  letter-spacing: 0.5px;
}
@keyframes resultBallPop {
  0%   { transform: scale(0) translateY(30px); opacity: 0; }
  70%  { transform: scale(1.15) translateY(-5px); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes resultPop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Rolling animation (구 호환) */
.result-rolling {
  font-family: var(--pixel-font);
  font-size: 40px;
  color: var(--primary-light);
  text-shadow: 0 0 20px var(--primary);
  animation: rolling 0.1s infinite alternate;
}
@keyframes rolling {
  0% { transform: translateY(-3px) rotate(-5deg); color: var(--primary-light); }
  100% { transform: translateY(3px) rotate(5deg); color: var(--accent); }
}

/* Draw Controls */
.draw-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 0 0 auto;
  align-self: center;
}
.btn-draw {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--primary-light), var(--primary) 50%, var(--primary-dark));
  border: none;
  position: relative;
  box-shadow:
    0 8px 32px rgba(108,99,255,0.6),
    0 4px 0 var(--primary-dark),
    inset 0 -4px 10px rgba(0,0,0,0.3),
    inset 0 4px 10px rgba(255,255,255,0.2);
  transition: all 0.15s;
  color: #fff;
}
.btn-draw:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow:
    0 12px 40px rgba(108,99,255,0.7),
    0 6px 0 var(--primary-dark),
    inset 0 -4px 10px rgba(0,0,0,0.3),
    inset 0 4px 10px rgba(255,255,255,0.2);
}
.btn-draw:active {
  transform: scale(0.97) translateY(2px);
  box-shadow:
    0 4px 16px rgba(108,99,255,0.5),
    0 1px 0 var(--primary-dark),
    inset 0 -2px 6px rgba(0,0,0,0.3);
}
.btn-draw:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-draw-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.btn-draw-inner i { font-size: 32px; }
.btn-draw-inner span { font-family: var(--pixel-font); font-size: 14px; letter-spacing: 1px; }
.btn-redraw {
  padding: 10px 24px;
  border-radius: 40px;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-redraw:hover {
  border-color: var(--primary-light);
  color: var(--text-main);
  background: rgba(108,99,255,0.1);
}

/* ====================================
   SCORE PANEL
==================================== */
.score-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(15,14,23,0.96);
  backdrop-filter: blur(20px);
  border-top: 2px solid var(--primary);
  box-shadow: 0 -8px 32px rgba(108,99,255,0.4);
  padding: 20px;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.score-panel-inner {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}
.score-student-info {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}
.score-label {
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: 14px;
}
.score-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.star-btn {
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--bg-card2);
  border: 2px solid var(--border);
  font-size: 16px;
  color: var(--text-main);
  transition: all 0.15s;
}
.star-btn:hover, .star-btn.active {
  background: rgba(255,217,61,0.15);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(255,217,61,0.3);
  transform: scale(1.05);
}
.score-labels-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.memo-group {
  margin-bottom: 16px;
}
.memo-group input {
  width: 100%;
  max-width: 400px;
  padding: 10px 16px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 14px;
}
.memo-group input:focus {
  border-color: var(--primary-light);
}
.score-btns {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.btn-save-score {
  padding: 12px 28px;
  border-radius: 40px;
  background: var(--accent2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(107,203,119,0.4);
}
.btn-save-score:hover {
  background: #56b866;
  transform: translateY(-2px);
}
.btn-skip-score {
  padding: 12px 28px;
  border-radius: 40px;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
.btn-skip-score:hover {
  border-color: var(--text-sub);
  color: var(--text-main);
}

/* ====================================
   PAGE HEADER
==================================== */
.page-header {
  margin-bottom: 28px;
}
.page-header h2 {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.page-header h2 i { color: var(--primary-light); }
.page-desc {
  font-size: 13px;
  color: var(--text-sub);
}

/* ====================================
   STUDENTS TABLE
==================================== */
.students-toolbar {
  margin-bottom: 20px;
}
.class-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.class-tab {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.class-tab:hover { color: var(--text-main); border-color: var(--primary-light); }
.class-tab.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary-light);
}
.students-table-wrap, .ranking-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  background: rgba(108,99,255,0.15);
  padding: 14px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr {
  border-bottom: 1px solid rgba(108,99,255,0.1);
  transition: background 0.15s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(108,99,255,0.06); }
.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-main);
  vertical-align: middle;
}
.data-table td.num-cell {
  font-family: var(--pixel-font);
  font-size: 12px;
  color: var(--primary-light);
  width: 60px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.status-active {
  background: rgba(107,203,119,0.15);
  color: var(--accent2);
  border: 1px solid rgba(107,203,119,0.3);
}
.status-inactive {
  background: rgba(255,101,132,0.1);
  color: var(--secondary);
  border: 1px solid rgba(255,101,132,0.3);
}
.action-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.15s;
}
.btn-activate {
  background: rgba(107,203,119,0.15);
  color: var(--accent2);
  border: 1px solid rgba(107,203,119,0.3);
}
.btn-activate:hover { background: rgba(107,203,119,0.3); }
.btn-deactivate {
  background: rgba(255,101,132,0.1);
  color: var(--secondary);
  border: 1px solid rgba(255,101,132,0.3);
}
.btn-deactivate:hover { background: rgba(255,101,132,0.2); }

.name-input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  width: 100%;
  padding: 4px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.name-input:focus {
  border-bottom-color: var(--primary-light);
  outline: none;
}

/* ====================================
   HISTORY
==================================== */
.history-filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.filter-group input[type="date"],
.filter-group select {
  padding: 9px 14px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  min-width: 150px;
}
.filter-group input[type="date"]:focus,
.filter-group select:focus {
  border-color: var(--primary-light);
}
.filter-group select option { background: var(--bg-card2); }
.btn-clear-filter {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-clear-filter:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  transition: background 0.15s;
}
.history-item:hover { background: var(--bg-card2); }
.history-num {
  font-family: var(--pixel-font);
  font-size: 16px;
  color: var(--accent);
  min-width: 40px;
  text-align: center;
}
.history-info { flex: 1; min-width: 0; }
.history-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-class { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.history-date { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.history-score-wrap { text-align: right; min-width: 90px; }
.history-score { font-size: 16px; }
.history-memo { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* 삭제 버튼 */
.btn-history-delete {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  cursor: pointer;
}
.btn-history-delete:hover {
  background: rgba(255,101,132,0.12);
  border-color: rgba(255,101,132,0.35);
  color: var(--secondary);
}

/* ====================================
   RANKING TABLE
==================================== */
.ranking-row-rank {
  font-family: var(--pixel-font);
  font-size: 11px;
  min-width: 50px;
}
.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }
.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  transition: width 0.6s ease;
}
.score-num { font-size: 13px; font-weight: 700; color: var(--accent); min-width: 30px; text-align: right; }

/* ====================================
   EMPTY STATE
==================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; display: block; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ====================================
   LOADING
==================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,14,23,0.8);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.loading-spinner {
  display: flex;
  gap: 10px;
}
.spinner-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  animation: bounce 0.6s infinite alternate;
}
.spinner-dot:nth-child(2) { animation-delay: 0.2s; background: var(--accent); }
.spinner-dot:nth-child(3) { animation-delay: 0.4s; background: var(--secondary); }
@keyframes bounce {
  0% { transform: translateY(0); opacity: 0.5; }
  100% { transform: translateY(-16px); opacity: 1; }
}

/* ====================================
   TOAST
==================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  z-index: 9998;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ====================================
   CLASS LABEL
==================================== */
.class-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-light);
  background: rgba(108,99,255,0.15);
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: 4px;
}

/* ====================================
   RANKING SUMMARY CARDS  (학년별)
==================================== */
#rankingSummary {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}
.summary-grade-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.summary-grade-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  background: rgba(108,99,255,0.10);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.grade-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.grade-dot.g1 { background: #6c63ff; box-shadow: 0 0 6px #6c63ff; }
.grade-dot.g2 { background: #ff6584; box-shadow: 0 0 6px #ff6584; }
.grade-dot.g3 { background: #ffd93d; box-shadow: 0 0 6px #ffd93d; }

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.summary-row .summary-card {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 14px 14px;
}
.summary-row .summary-card:last-child { border-right: none; }
.summary-row .summary-card::before { display: none; }
.summary-row .summary-card:hover {
  background: rgba(108,99,255,0.06);
  transform: none;
  box-shadow: none;
}
.summary-card-icon { font-size: 26px; margin-bottom: 6px; line-height: 1; }
.summary-card-label {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.summary-card-value {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.3;
}
.summary-card-sub {
  font-size: 11px;
  color: var(--primary-light);
  font-weight: 600;
}
.summary-loading {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 400;
}

/* ====================================
   EXCEL IMPORT BAR
==================================== */
.excel-import-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(29,111,66,0.08);
  border: 1px solid rgba(29,111,66,0.25);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.excel-import-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
  font-weight: 600;
  flex-wrap: wrap;
}
.excel-import-actions {
  display: flex;
  gap: 8px;
}
.btn-excel-sample {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid rgba(29,111,66,0.4);
  color: #4caf7d;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  cursor: pointer;
}
.btn-excel-sample:hover {
  background: rgba(29,111,66,0.15);
  border-color: #4caf7d;
}
.btn-excel-upload {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(29,111,66,0.2);
  border: 1px solid rgba(29,111,66,0.5);
  color: #6bcb77;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  cursor: pointer;
}
.btn-excel-upload:hover {
  background: rgba(29,111,66,0.35);
}

/* ====================================
   IMPORT PREVIEW MODAL
==================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: modalPop 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
}
@keyframes modalPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}
.modal-close:hover { background: rgba(255,101,132,0.15); color: var(--secondary); }
.modal-desc {
  padding: 12px 20px 4px;
  font-size: 13px;
  color: var(--text-sub);
}
.modal-table-wrap {
  overflow-y: auto;
  flex: 1;
  padding: 0 12px 12px;
}
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 전교생 import용 넓은 모달 */
.import-modal-wide {
  max-width: 780px;
  max-height: 85vh;
}
.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px 4px;
}
.import-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.35);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--primary-light);
}
.import-badge.ok { background: rgba(107,203,119,0.12); border-color: rgba(107,203,119,0.35); color: var(--accent2); }
.import-badge.warn { background: rgba(255,101,132,0.12); border-color: rgba(255,101,132,0.35); color: var(--secondary); }

/* 4열 preview table */
#importPreviewTable th:nth-child(1),
#importPreviewTable td:nth-child(1) { width:60px; text-align:center; }
#importPreviewTable th:nth-child(2),
#importPreviewTable td:nth-child(2) { width:50px; text-align:center; }
#importPreviewTable th:nth-child(3),
#importPreviewTable td:nth-child(3) { width:60px; text-align:center; }

/* ====================================
   RESPONSIVE
==================================== */
@media (max-width: 768px) {
  .header-inner { padding: 0 12px; }
  .logo-text { display: none; }
  .nav-btn { padding: 7px 12px; font-size: 12px; }
  .nav-btn i { font-size: 14px; }
  .tab-content { padding: 20px 12px 80px; }
  .class-selector-section, .settings-section, .draw-section { padding: 18px; }
  .draw-arena { flex-direction: column; align-items: center; gap: 20px; }
  .lottery-machine-wrap { max-width: 100%; }
  .btn-draw { width: 140px; height: 140px; }
  .btn-draw-inner i { font-size: 24px; }
  .btn-draw-inner span { font-size: 11px; }
  .lm-result-num { font-size: 22px; }
  .lm-result-ball { width: 70px; height: 70px; }
  .history-item { grid-template-columns: auto 1fr auto auto; gap: 10px; }
  .history-date { display: none; }
  .history-score-wrap { display: none; }
  .ranking-summary { gap: 12px; }
  .summary-row { grid-template-columns: 1fr; }
  .summary-row .summary-card { border-right: none; border-bottom: 1px solid var(--border); }
  .summary-row .summary-card:last-child { border-bottom: none; }
}

@media (max-width: 480px) {
  .grade-tabs { flex-wrap: wrap; }
  .grade-tab { padding: 8px 14px; font-size: 13px; }
  .score-labels-row { gap: 10px; font-size: 10px; }
  .summary-row { grid-template-columns: 1fr 1fr; }
  .summary-row .summary-card:nth-child(3) { grid-column: 1 / -1; border-bottom: none; border-right: none; }
  .summary-row .summary-card:nth-child(1) { border-bottom: 1px solid var(--border); }
  .summary-row .summary-card:nth-child(2) { border-bottom: 1px solid var(--border); border-right: none; }
}
