/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(30, 30, 60, 0.7);
  --text-primary: #ffffff;
  --text-secondary: #a0a0c0;
  --accent-primary: #00ff88;
  --accent-secondary: #00ccff;
  --accent-warning: #ff6b6b;
  --accent-gold: #ffd700;
  --glass-border: rgba(255, 255, 255, 0.1);
  --shadow-glow: 0 0 30px rgba(0, 255, 136, 0.3);
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Typography ===== */
h1, h2, h3 {
  font-weight: 700;
}

/* ===== Glass Card ===== */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ===== Layout: Teacher Page ===== */
.teacher-container {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 20px;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.header h1 {
  font-size: 1.8rem;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Settings Panel ===== */
.settings-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: center;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-group label {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.setting-group input[type="number"] {
  width: 70px;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 1rem;
  text-align: center;
}

.setting-group input[type="number"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

/* ===== Buttons ===== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #00cc6a);
  color: #000;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-warning), #cc4444);
  color: #fff;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(255, 107, 107, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Timer Display ===== */
.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.timer-display {
  font-size: 8rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: var(--accent-primary);
  text-shadow: 
    0 0 20px rgba(0, 255, 136, 0.5),
    0 0 40px rgba(0, 255, 136, 0.3),
    0 0 60px rgba(0, 255, 136, 0.2);
  letter-spacing: 0.05em;
  animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.timer-status {
  margin-top: 20px;
  font-size: 1.2rem;
  color: var(--text-secondary);
}

.timer-status.active {
  color: var(--accent-primary);
}

.round-indicator {
  margin-top: 15px;
  font-size: 1.5rem;
  color: var(--accent-secondary);
}

/* ===== Student List ===== */
.student-list-section {
  grid-row: 2 / 4;
}

.student-list-section h2 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.student-count {
  background: var(--accent-secondary);
  color: #000;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.student-list {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.student-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.student-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-primary);
}

.student-status.waiting {
  background: var(--text-secondary);
  box-shadow: none;
}

.student-status.submitted {
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold);
}

/* ===== Score Table ===== */
.score-section {
  grid-column: 1 / 2;
  max-height: 350px;
  overflow: auto;
}

.score-section h2 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--accent-secondary);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  padding: 10px 0;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.score-table th,
.score-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--glass-border);
}

.score-table th {
  background: rgba(0, 204, 255, 0.1);
  color: var(--accent-secondary);
  font-weight: 600;
  position: sticky;
  top: 45px;
}

.score-table th:first-child,
.score-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--bg-card);
}

.score-table tr:hover td {
  background: rgba(255, 255, 255, 0.05);
}

.score-table .total-col {
  background: rgba(0, 255, 136, 0.1) !important;
  font-weight: 700;
  color: var(--accent-primary);
}

.score-table .rank-col {
  background: rgba(255, 215, 0, 0.1) !important;
  font-weight: 700;
  color: var(--accent-gold);
}

.rank-1 { color: #ffd700 !important; }
.rank-2 { color: #c0c0c0 !important; }
.rank-3 { color: #cd7f32 !important; }

/* ===== Student Page ===== */
.student-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  gap: 30px;
}

.join-section {
  text-align: center;
}

.join-section h1 {
  font-size: 2rem;
  margin-bottom: 30px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.join-section input[type="text"] {
  width: 280px;
  padding: 15px 20px;
  font-size: 1.2rem;
  border: 2px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 20px;
}

.join-section input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.game-section {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  width: 100%;
  max-width: 500px;
}

.game-section.active {
  display: flex;
}

.student-timer {
  font-size: 6rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: var(--accent-primary);
  text-shadow: 
    0 0 20px rgba(0, 255, 136, 0.5),
    0 0 40px rgba(0, 255, 136, 0.3);
}

.target-display {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.target-display span {
  color: var(--accent-gold);
  font-weight: 700;
}

.press-button {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), #00cc6a);
  border: none;
  font-size: 1.5rem;
  font-weight: 700;
  color: #000;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 
    0 10px 40px rgba(0, 255, 136, 0.4),
    inset 0 -5px 20px rgba(0, 0, 0, 0.2);
}

.press-button:hover {
  transform: scale(1.05);
}

.press-button:active {
  transform: scale(0.95);
  box-shadow: 
    0 5px 20px rgba(0, 255, 136, 0.3),
    inset 0 5px 20px rgba(0, 0, 0, 0.3);
}

.press-button:disabled {
  background: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.result-display {
  padding: 20px 40px;
  text-align: center;
}

.result-display .time {
  font-size: 2rem;
  color: var(--accent-secondary);
  margin-bottom: 10px;
}

.result-display .score {
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.result-display .score-label {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 5px;
}

.waiting-message {
  font-size: 1.5rem;
  color: var(--text-secondary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .teacher-container {
    grid-template-columns: 1fr;
  }
  
  .student-list-section {
    grid-row: auto;
  }
  
  .timer-display {
    font-size: 5rem;
  }
}

@media (max-width: 600px) {
  .timer-display {
    font-size: 3.5rem;
  }
  
  .student-timer {
    font-size: 4rem;
  }
  
  .press-button {
    width: 150px;
    height: 150px;
    font-size: 1.2rem;
  }
}
