/* Professional Logo Styles */
.logo-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px 0;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}

.logo-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="70" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="70" cy="10" r="1.5" fill="rgba(255,255,255,0.1)"/><circle cx="10" cy="60" r="1" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
  animation: sparkleMove 20s linear infinite;
}

@keyframes sparkleMove {
  0% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(100px) translateY(50px); }
}

.logo {
  position: relative;
  z-index: 2;
  max-width: 600px;
  margin: 0 auto;
}

.logo-icon {
  margin-bottom: 10px;
  position: relative;
}

.logo-icon .star,
.logo-icon .trophy {
  font-size: 2em;
  margin: 0 8px;
  display: inline-block;
  animation: logoFloat 3s ease-in-out infinite;
}

.logo-icon .trophy {
  animation-delay: 1.5s;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}

.logo-text {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 3.5em;
  line-height: 1;
  margin-bottom: 5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  letter-spacing: -1px;
}

.logo-main {
  color: #ffffff;
}

.logo-accent {
  color: #ffd700;
  background: linear-gradient(45deg, #ffd700, #ffed4e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
}

.logo-exclamation {
  color: #ff6b6b;
  animation: bounce 2s infinite;
  display: inline-block;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

.logo-tagline {
  font-family: 'Segoe UI', sans-serif;
  font-size: 1em;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 300;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 8px;
  opacity: 0.8;
}

/* General */
/* Global mobile optimizations */
* {
  /* Improve mobile scrolling performance */
  -webkit-overflow-scrolling: touch;
  /* Prevent text selection on mobile unless intended */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Allow text selection for inputs and content areas */
input, textarea, .modal-input, [contenteditable] {
  -webkit-user-select: text;
  -khtml-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Touch action optimizations */
.student-card-modern {
  touch-action: manipulation; /* Eliminate 300ms delay */
}

.action-btn, .header-btn, .timer-btn, .preset-btn {
  touch-action: manipulation;
}

.dropdown-content-modern a {
  touch-action: manipulation;
}

body {
  background: #fafaff;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  padding: 0 0 2em 0;
  /* Enable smooth scrolling on mobile */
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden; /* Prevent horizontal scroll */
  overflow-y: auto; /* Allow vertical scroll */
}
h1 {
  /* Legacy h1 styles - now using .logo-container */
  display: none;
}
#toolbar {
  text-align: center;
  margin: 1em 0;
}
button {
  margin: 4px 2px;
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  background: #e0e0ff;
  color: #333;
  font-size: 1em;
  cursor: pointer;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  transition: background 0.2s;
}
button:hover {
  background: #c0c0ff;
}

/* Dropdown Menus */
.dropdown {
  display: inline-block;
  position: relative;
  margin: 0 8px;
}
.dropbtn {
  background: #e0e0ff;
  color: #333;
  padding: 10px 18px;
  font-size: 1em;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}
.dropbtn:hover, .dropbtn:focus {
  background: #c0c0ff;
}
.dropdown-content {
  display: none;
  position: absolute;
  background: #fffbe9;
  min-width: 180px;
  box-shadow: 0 4px 16px #6646b055;
  border-radius: 12px;
  z-index: 1;
  margin-top: 4px;
}
.dropdown-content a {
  color: #6646b0;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  border-radius: 8px;
  font-size: 1em;
}
.dropdown-content a:hover {
  background: #ffd70033;
}
.dropdown:hover .dropdown-content, .dropdown:focus-within .dropdown-content {
  display: block;
}

/* Student Grid & Cards */
#student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin: 0 auto;
  max-width: 1200px;
  min-height: 200px;
  padding: 0 10px;
  justify-items: center;
  align-items: start;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  overscroll-behavior: auto; /* Allow normal scrolling */
}
.student-card {
  width: 100%;
  min-width: 0;
  max-width: 160px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px #0002;
  padding: 8px;
  margin: 0;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.2s, border 0.2s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.95em;
}
.student-card.selected {
  border: 2px solid #6646b0;
}
.student-card.multi-selected {
  border: 2px dashed #1bc;
}
.student-card.absent {
  opacity: 0.5;
  filter: grayscale(0.7);
}
.student-card.highlighted {
  box-shadow: 0 0 16px 4px #ffd700, 0 2px 8px #0002;
  border: 3px solid #ffd700;
}

/* Crown Icon */
.crown-icon {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.5em;
  z-index: 10;
  animation: crownGlow 2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.8));
}

@keyframes crownGlow {
  0% {
    transform: scale(1) rotate(-5deg);
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.8));
  }
  100% {
    transform: scale(1.1) rotate(5deg);
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 1));
  }
}
.avatar {
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: #f0f0ff;
  border: 2px solid #e0e0ff;
  object-fit: cover;
}
.absent-label {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #d22;
  color: #fff;
  font-size: 0.9em;
  padding: 2px 8px;
  border-radius: 8px;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

/* Modal styles */
.modal {
  position: fixed; left: 0; top: 0; width: 100vw; height: 100vh;
  background: rgba(80,60,180,0.15); display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-content {
  background: #fffbe9;
  border-radius: 18px;
  box-shadow: 0 4px 32px #6646b055;
  padding: 2em 2em 1.5em 2em;
  min-width: 320px;
  max-width: 90vw;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  text-align: center;
}
.modal-title {
  font-size: 1.4em;
  color: #6646b0;
  margin-bottom: 0.7em;
  font-weight: bold;
  letter-spacing: 1px;
}
.modal-message {
  margin-bottom: 1em;
  color: #444;
  font-size: 1.1em;
  white-space: pre-line;
}
#modal-input {
  width: 90%;
  border-radius: 10px;
  border: 2px solid #ffd700;
  font-size: 1.1em;
  padding: 0.5em;
  margin-bottom: 1em;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  resize: none;
  display: block;
}
.modal-buttons button {
  margin: 0 10px;
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  background: #ffd700;
  color: #6646b0;
  font-size: 1em;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s;
}
.modal-buttons button:hover {
  background: #ffec80;
}

/* Responsive */
@media (max-width: 600px) {
  .logo-text {
    font-size: 2.5em;
  }
  
  .logo-tagline {
    font-size: 0.8em;
    letter-spacing: 1px;
  }
  
  .logo-icon .star,
  .logo-icon .trophy {
    font-size: 1.5em;
    margin: 0 4px;
  }
  
  #student-grid {
    max-width: 98vw;
  }
  .student-card {
    width: 98vw;
    min-width: 0;
    margin: 8px 0;
  }
  .modal-content {
    min-width: 90vw;
    padding: 1em 0.5em 1em 0.5em;
  }
}

/* Professional Login Page Styles */
.login-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.2)" opacity="0.6"><animate attributeName="opacity" values="0.3;1;0.3" dur="3s" repeatCount="indefinite"/></circle><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.15)" opacity="0.4"><animate attributeName="opacity" values="0.2;0.8;0.2" dur="4s" repeatCount="indefinite"/></circle><circle cx="40" cy="70" r="1" fill="rgba(255,255,255,0.2)" opacity="0.5"><animate attributeName="opacity" values="0.3;0.9;0.3" dur="2s" repeatCount="indefinite"/></circle><circle cx="70" cy="10" r="1.5" fill="rgba(255,255,255,0.15)" opacity="0.3"><animate attributeName="opacity" values="0.2;0.7;0.2" dur="5s" repeatCount="indefinite"/></circle><circle cx="15" cy="85" r="1" fill="rgba(255,255,255,0.2)" opacity="0.4"><animate attributeName="opacity" values="0.2;0.8;0.2" dur="3.5s" repeatCount="indefinite"/></circle><circle cx="90" cy="75" r="1.5" fill="rgba(255,255,255,0.15)" opacity="0.5"><animate attributeName="opacity" values="0.3;0.9;0.3" dur="2.8s" repeatCount="indefinite"/></circle></svg>') repeat;
  animation: loginSparkleMove 25s linear infinite;
}

@keyframes loginSparkleMove {
  0% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(-120px) translateY(-60px); }
}

.login-form {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  max-width: 400px;
  width: 100%;
  position: relative;
  z-index: 2;
  transform: translateY(0);
  transition: all 0.3s ease;
}

.login-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 450px;
  width: 100%;
  position: relative;
  z-index: 2;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 100%;
  transform: translateY(0);
  transition: all 0.3s ease;
  margin-top: 20px;
}

.login-card:hover {
  transform: translateY(-5px);
  box-shadow: 
    0 25px 50px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

.login-logo-icon {
  margin-bottom: 15px;
  position: relative;
}

.login-logo-icon .star,
.login-logo-icon .trophy {
  font-size: 2.5em;
  margin: 0 12px;
  display: inline-block;
  animation: loginLogoFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 2px 8px rgba(255,255,255,0.3));
}

.login-logo-icon .trophy {
  animation-delay: 1.5s;
}

@keyframes loginLogoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  50% { transform: translateY(-12px) rotate(5deg) scale(1.05); }
}

.login-logo-text {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
  font-weight: 700;
  font-size: 2.8em;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -1px;
  text-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.login-logo-text .logo-main {
  color: #ffffff;
}

.login-logo-text .logo-accent {
  color: #FFD700;
  text-shadow: 0 3px 6px rgba(255,215,0,0.4);
}

.login-logo-text .logo-exclamation {
  color: #FF6B6B;
  text-shadow: 0 3px 6px rgba(255,107,107,0.4);
}

.login-tagline {
  color: rgba(255,255,255,0.9);
  font-size: 0.95em;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  margin-top: 8px;
}

.form-group {
  margin-bottom: 25px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 500;
  font-size: 0.9em;
}

.form-group input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: #fafafa;
  box-sizing: border-box;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  transform: translateY(-1px);
}

.login-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.login-btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.login-btn.loading {
  color: transparent;
}

.login-btn.success {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  animation: successPulse 0.6s ease;
}

@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.btn-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: none;
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.auth-switch {
  text-align: center;
  margin-top: 25px;
  padding-top: 25px;
  border-top: 1px solid #e0e0e0;
}

.auth-switch p {
  color: #666;
  margin-bottom: 10px;
  font-size: 0.9em;
}

.switch-btn {
  background: none;
  border: none;
  color: #667eea;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.3s ease;
}

.switch-btn:hover {
  color: #764ba2;
}

.error-message {
  color: #e74c3c;
  font-size: 0.9em;
  margin-top: 15px;
  padding: 12px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: 8px;
  border-left: 4px solid #e74c3c;
  text-align: center;
  transition: all 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* App Container Styles for Main App */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px 20px; /* Add bottom padding to prevent cutoff */
  width: 100%;
}

#student-grid {
  width: 100%;
}

/* Professional Header Bar */
.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 15px;
  padding: 20px 25px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.header-left .class-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.class-label {
  font-size: 0.85em;
  color: #666;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.class-name {
  font-size: 1.4em;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  gap: 12px;
  align-items: center;
}

.header-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.header-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.header-btn.secondary {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border: 2px solid rgba(102, 126, 234, 0.2);
}

.header-btn.secondary:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 1.1em;
}

/* Professional Action Bar */
.action-bar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 500; /* Ensure action bar is above student cards */
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.dropdown-modern {
  position: relative;
  display: inline-block;
  z-index: 1000; /* Higher z-index for dropdown container */
}

.action-btn {
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 160px;
  justify-content: center;
}

.action-btn.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.action-btn.success {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
}

.action-btn.info {
  background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(33, 150, 243, 0.2);
}

.action-btn.warning {
  background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 152, 0, 0.2);
}

.action-btn.secondary {
  background: rgba(108, 117, 125, 0.1);
  color: #6c757d;
  border: 2px solid rgba(108, 117, 125, 0.2);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dropdown-arrow {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.dropdown-modern:hover .dropdown-arrow,
.dropdown-modern.dropdown-open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-content-modern {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  min-width: 250px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  z-index: 9999; /* Much higher z-index to ensure it's always on top */
  border: 1px solid rgba(0, 0, 0, 0.05);
  overflow: hidden;
  margin-top: 8px;
}

.dropdown-modern:hover .dropdown-content-modern,
.dropdown-modern.dropdown-open .dropdown-content-modern {
  display: block;
  animation: dropdownFadeIn 0.3s ease;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-content-modern a {
  color: #333;
  padding: 15px 20px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dropdown-content-modern a:last-child {
  border-bottom: none;
}

.dropdown-content-modern a:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateX(5px);
}

.dropdown-content-modern a.danger:hover {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.menu-icon {
  font-size: 1.1em;
  min-width: 20px;
  text-align: center;
}

.menu-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
  margin: 8px 0;
}

/* Responsive Design for Action Bar */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 15px;
    padding: 20px;
  }
  
  .header-right {
    width: 100%;
    justify-content: center;
  }
  
  .header-btn {
    padding: 12px 18px;
    font-size: 0.9em;
    min-height: 44px; /* iOS minimum touch target */
  }
  
  .action-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-btn {
    padding: 12px 18px;
    font-size: 0.9em;
    min-height: 44px;
  }
  
  .dropdown-content-modern a {
    padding: 16px 20px; /* Larger touch targets */
    font-size: 0.95em;
  }
  
  .action-btn {
    min-width: 100%;
    justify-content: center;
  }
  
  .dropdown-content-modern {
    position: fixed;
    left: 10px;
    right: 10px;
    width: auto;
    min-width: auto;
  }
}

/* Professional Student Grid - Auto-sizing based on student count */
.students-grid {
  display: grid;
  gap: 12px; /* Reduced gap for better screen utilization */
  padding: 40px 0 20px 0; /* Added top padding for crown visibility */
  width: 100%;
  min-height: 60vh; /* Reduced from 70vh */
  max-height: none; /* Remove height restriction */
  overflow: visible; /* Allow content to be visible */
}

/* Large cards for very small classes (1-4 students) */
.students-grid.grid-large {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.students-grid.grid-large .student-card-modern {
  padding: 22px;
}

.students-grid.grid-large .avatar-modern {
  width: 75px;
  height: 75px;
}

.students-grid.grid-large .student-name {
  font-size: 1.3em;
}

.students-grid.grid-large .points-value {
  font-size: 2em;
}

/* Medium cards for small classes (5-8 students) */
.students-grid.grid-medium {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.students-grid.grid-medium .student-card-modern {
  padding: 18px;
}

.students-grid.grid-medium .avatar-modern {
  width: 60px;
  height: 60px;
}

.students-grid.grid-medium .student-name {
  font-size: 1.1em;
}

.students-grid.grid-medium .points-value {
  font-size: 1.6em;
}

/* Small cards for medium classes (9-15 students) */
.students-grid.grid-small {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.students-grid.grid-small .student-card-modern {
  padding: 14px;
}

.students-grid.grid-small .avatar-modern {
  width: 45px;
  height: 45px;
}

.students-grid.grid-small .student-name {
  font-size: 0.95em;
  margin-bottom: 8px;
}

.students-grid.grid-small .points-value {
  font-size: 1.4em;
}

.students-grid.grid-small .points-display {
  padding: 8px;
  margin-bottom: 10px;
}

.students-grid.grid-small .card-header {
  margin-bottom: 10px;
}

/* Tiny cards for large classes (16-25 students) */
.students-grid.grid-tiny {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.students-grid.grid-tiny .student-card-modern {
  padding: 10px;
}

.students-grid.grid-tiny .avatar-modern {
  width: 35px;
  height: 35px;
}

.students-grid.grid-tiny .student-name {
  font-size: 0.85em;
  margin-bottom: 6px;
}

.students-grid.grid-tiny .points-value {
  font-size: 1.2em;
}

.students-grid.grid-tiny .points-display {
  padding: 6px;
  margin-bottom: 8px;
}

.students-grid.grid-tiny .card-header {
  margin-bottom: 8px;
}

.students-grid.grid-tiny .slider {
  width: 70px;
  height: 28px;
}

.students-grid.grid-tiny .slider:before {
  height: 18px;
  width: 18px;
  left: 5px;
  top: 5px;
}

.students-grid.grid-tiny .toggle-switch input:checked + .slider:before {
  transform: translateX(42px);
}

/* Micro cards for very large classes (26+ students) */
.students-grid.grid-micro {
  grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
  gap: 8px;
}

.students-grid.grid-micro .student-card-modern {
  padding: 8px;
}

.students-grid.grid-micro .avatar-modern {
  width: 28px;
  height: 28px;
}

.students-grid.grid-micro .student-name {
  font-size: 0.75em;
  margin-bottom: 5px;
}

.students-grid.grid-micro .points-value {
  font-size: 1em;
}

.students-grid.grid-micro .points-display {
  padding: 5px;
  margin-bottom: 6px;
}

.students-grid.grid-micro .card-header {
  margin-bottom: 6px;
}

.students-grid.grid-micro .slider {
  width: 55px;
  height: 22px;
}

.students-grid.grid-micro .slider:before {
  height: 12px;
  width: 12px;
  left: 5px;
  top: 5px;
}

.students-grid.grid-micro .toggle-switch input:checked + .slider:before {
  transform: translateX(33px);
}

.students-grid.grid-micro .slider-label {
  font-size: 0.65em;
}

/* Remove old static responsive rules that conflict */

.student-card-modern {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 25px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(255, 255, 255, 0.2);
  overflow: hidden;
  z-index: 1; /* Lower z-index than dropdowns */
}

.student-card-modern:hover {
  transform: translateY(-5px);
  box-shadow: 
    0 15px 40px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.3);
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .student-card-modern:hover {
    transform: none;
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.1),
      0 0 0 1px rgba(255, 255, 255, 0.2);
  }
  
  .student-card-modern:active {
    transform: translateY(-2px) scale(0.98);
    box-shadow: 
      0 10px 25px rgba(0, 0, 0, 0.2),
      0 0 0 1px rgba(255, 255, 255, 0.3);
    transition: all 0.1s ease;
  }
  
  /* Disable hover animations for better mobile performance */
  .action-btn:hover {
    transform: none;
  }
  
  .header-btn:hover {
    transform: none;
  }
  
  .empty-action-btn:hover {
    transform: none;
  }
}

.student-card-modern.selected {
  border: 3px solid #2196F3;
  box-shadow: 
    0 15px 40px rgba(33, 150, 243, 0.4),
    0 0 0 4px rgba(33, 150, 243, 0.3),
    0 0 20px rgba(33, 150, 243, 0.2);
  transform: translateY(-8px) scale(1.05);
  animation: selectedWiggle 0.6s ease-in-out;
  z-index: 5;
}

@keyframes selectedWiggle {
  0% { transform: translateY(-8px) scale(1.05) rotate(0deg); }
  25% { transform: translateY(-8px) scale(1.05) rotate(1deg); }
  50% { transform: translateY(-8px) scale(1.05) rotate(0deg); }
  75% { transform: translateY(-8px) scale(1.05) rotate(-1deg); }
  100% { transform: translateY(-8px) scale(1.05) rotate(0deg); }
}

.student-card-modern.multi-selected {
  border: 3px solid #4CAF50;
  box-shadow: 
    0 15px 40px rgba(76, 175, 80, 0.4),
    0 0 0 4px rgba(76, 175, 80, 0.3),
    0 0 20px rgba(76, 175, 80, 0.2);
  transform: translateY(-6px) scale(1.03);
  animation: multiSelectedPulse 1.5s ease-in-out infinite;
}

@keyframes multiSelectedPulse {
  0%, 100% { 
    box-shadow: 
      0 15px 40px rgba(76, 175, 80, 0.4),
      0 0 0 4px rgba(76, 175, 80, 0.3),
      0 0 20px rgba(76, 175, 80, 0.2);
  }
  50% { 
    box-shadow: 
      0 15px 40px rgba(76, 175, 80, 0.6),
      0 0 0 6px rgba(76, 175, 80, 0.4),
      0 0 25px rgba(76, 175, 80, 0.3);
  }
}

.student-card-modern.absent {
  opacity: 0.6;
  filter: grayscale(30%);
}

.student-card-modern.negative-points {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  border: 2px solid #f44336;
  box-shadow: 0 4px 8px rgba(244, 67, 54, 0.2);
}

.student-card-modern.negative-points:hover {
  background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
  box-shadow: 0 6px 12px rgba(244, 67, 54, 0.3);
}

.student-card-modern.negative-points .points {
  color: #d32f2f;
  font-weight: bold;
}

.student-card-modern.negative-points .student-name {
  color: #b71c1c;
}

/* Selection mode styling */
.student-card-modern.selection-mode {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border: 2px solid #4CAF50;
  cursor: pointer;
  animation: selectionPulse 2s ease-in-out infinite;
  position: relative;
}

.student-card-modern.selection-mode::before {
  content: "👆";
  position: absolute;
  top: -10px;
  right: -5px;
  background: #4CAF50;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  animation: bounce 1s ease-in-out infinite;
}

.student-card-modern.selection-mode:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(76, 175, 80, 0.4);
}

@keyframes selectionPulse {
  0%, 100% { 
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
  }
  50% { 
    box-shadow: 0 8px 16px rgba(76, 175, 80, 0.5);
  }
}

@keyframes bounce {
  0%, 100% { 
    transform: translateY(0);
  }
  50% { 
    transform: translateY(-3px);
  }
}

/* Green styling for positive points */
.student-card-modern.positive-points {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border: 2px solid #4caf50;
  box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
}

.student-card-modern.positive-points:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
}

.student-card-modern.positive-points .points {
  color: #2e7d32;
  font-weight: bold;
}

.student-card-modern.positive-points .student-name {
  color: #1b5e20;
}

.student-card-modern.highlighted {
  animation: cardPulse 1s ease-in-out;
}

@keyframes cardPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.crown-container {
  position: absolute;
  top: -10px;
  right: -5px;
  z-index: 10;
}

/* Crown positioned above the card */
.crown-above-card {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 20;
  pointer-events: none;
}

.crown-icon {
  font-size: 2.5em;
  animation: crownShine 2s ease-in-out infinite;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8));
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Responsive crown sizing for different grid sizes */
.students-grid.grid-large .crown-icon {
  font-size: 2.5em; /* Large crown for small classes */
}

.students-grid.grid-medium .crown-icon {
  font-size: 2em; /* Medium crown for medium classes */
}

.students-grid.grid-small .crown-icon {
  font-size: 1.6em; /* Smaller crown for larger classes */
}

.students-grid.grid-tiny .crown-icon {
  font-size: 1.3em; /* Tiny crown for large classes */
}

.students-grid.grid-micro .crown-icon {
  font-size: 1em; /* Micro crown for very large classes */
}

@keyframes crownShine {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.1); }
}

.card-header {
  text-align: center;
  margin-bottom: 20px;
}

.avatar-container {
  position: relative;
  display: inline-block;
}

.avatar-modern {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid transparent;
  transition: all 0.3s ease;
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.avatar-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 3px solid;
  transition: all 0.3s ease;
}

.avatar-ring.present {
  border-color: #4CAF50;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.avatar-ring.absent {
  border-color: #f44336;
  box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
}

.card-content {
  text-align: center;
}

.student-name {
  font-size: 1.4em;
  font-weight: 700;
  color: #333;
  margin-bottom: 15px;
  letter-spacing: 0.5px;
}

.points-display {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.points-label {
  font-size: 0.85em;
  color: #666;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.points-value {
  font-size: 2em;
  font-weight: 700;
  transition: all 0.3s ease;
}

.points-value.positive {
  color: #4CAF50;
  text-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.points-value.negative {
  color: #f44336;
  text-shadow: 0 0 10px rgba(244, 67, 54, 0.3);
}

.points-value.neutral {
  color: #666;
}

.presence-control {
  margin-top: 20px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: relative;
  display: inline-block;
  width: 140px;
  height: 45px;
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  border-radius: 25px;
  transition: all 0.3s ease;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 4px 15px rgba(244, 67, 54, 0.3);
}

.slider:before {
  position: absolute;
  content: "";
  height: 35px;
  width: 35px;
  left: 5px;
  top: 5px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .slider {
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 4px 15px rgba(76, 175, 80, 0.3);
}

.toggle-switch input:checked + .slider:before {
  transform: translateX(95px);
}

.slider-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.absent-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.absent-text {
  color: white;
  font-weight: 700;
  font-size: 1.2em;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  border: 2px dashed rgba(102, 126, 234, 0.3);
  margin: 40px auto;
  max-width: 500px;
}

.empty-icon {
  font-size: 4em;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-title {
  font-size: 1.8em;
  font-weight: 700;
  color: #333;
  margin-bottom: 10px;
}

.empty-message {
  color: #666;
  margin-bottom: 30px;
  font-size: 1.1em;
}

.empty-action-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 30px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.empty-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* Mobile responsiveness for all grid sizes */
@media (max-width: 600px) {
  .students-grid.grid-large,
  .students-grid.grid-medium,
  .students-grid.grid-small,
  .students-grid.grid-tiny,
  .students-grid.grid-micro {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    max-height: none; /* Remove height restriction on mobile */
    padding-bottom: 30px; /* Extra bottom padding for mobile */
  }
  
  .students-grid.grid-large .student-card-modern,
  .students-grid.grid-medium .student-card-modern {
    padding: 12px;
  }
  
  .students-grid.grid-small .student-card-modern,
  .students-grid.grid-tiny .student-card-modern,
  .students-grid.grid-micro .student-card-modern {
    padding: 8px;
  }
  
  .students-grid.grid-large .avatar-modern {
    width: 40px;
    height: 40px;
  }
  
  .students-grid.grid-medium .avatar-modern {
    width: 35px;
    height: 35px;
  }
  
  .students-grid.grid-small .avatar-modern,
  .students-grid.grid-tiny .avatar-modern,
  .students-grid.grid-micro .avatar-modern {
    width: 30px;
    height: 30px;
  }
  
  .students-grid.grid-large .student-name {
    font-size: 1em;
  }
  
  .students-grid.grid-medium .student-name {
    font-size: 0.9em;
  }
  
  .students-grid.grid-small .student-name,
  .students-grid.grid-tiny .student-name,
  .students-grid.grid-micro .student-name {
    font-size: 0.8em;
  }
  
  .students-grid.grid-large .points-value {
    font-size: 1.5em;
  }
  
  .students-grid.grid-medium .points-value {
    font-size: 1.3em;
  }
  
  .students-grid.grid-small .points-value,
  .students-grid.grid-tiny .points-value,
  .students-grid.grid-micro .points-value {
    font-size: 1.1em;
  }
}

/* Tablet adjustments */
@media (min-width: 601px) and (max-width: 899px) {
  .students-grid.grid-large {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  
  .students-grid.grid-medium {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  
  .students-grid.grid-small {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
  
  .students-grid.grid-tiny {
    grid-template-columns: repeat(auto-fit, minmax(95px, 1fr));
  }
  
  .students-grid.grid-micro {
    grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  }
}

/* Responsive Design for Login */
@media (max-width: 480px) {
  .login-form {
    padding: 30px 25px;
    margin: 10px;
  }
  
  .login-logo {
    font-size: 2em;
  }
  
  .form-group input {
    padding: 12px 15px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .login-btn {
    padding: 14px;
    font-size: 15px;
  }
}

/* Point Celebration Animations */
.point-celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: celebrationFadeIn 0.3s ease-out;
}

@keyframes celebrationFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.celebration-content {
  text-align: center;
  color: white;
  animation: celebrationBounce 0.6s ease-out;
}

@keyframes celebrationBounce {
  0% { transform: scale(0.3) translateY(50px); opacity: 0; }
  50% { transform: scale(1.1) translateY(-10px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}

.celebration-emoji {
  font-size: 4em;
  margin-bottom: 20px;
  animation: emojiFloat 1s ease-in-out infinite alternate;
}

@keyframes emojiFloat {
  from { transform: translateY(0px); }
  to { transform: translateY(-10px); }
}

.celebration-message {
  font-size: 2.5em;
  font-weight: bold;
  margin-bottom: 10px;
  color: #4CAF50;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.celebration-points {
  font-size: 1.8em;
  color: #FFC107;
  margin-bottom: 20px;
}

.celebration-reason {
  font-size: 1.2em;
  color: #E3F2FD;
  font-style: italic;
}

/* Student Card Point Animation */
.student-card.getting-points {
  animation: pointWiggle 0.8s ease-in-out, pointGlow 1s ease-in-out;
  transform-origin: center;
}

@keyframes pointWiggle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.05) rotate(1deg); }
  50% { transform: scale(1.1) rotate(-1deg); }
  75% { transform: scale(1.05) rotate(1deg); }
}

@keyframes pointGlow {
  0% { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
  50% { box-shadow: 0 0 25px rgba(76, 175, 80, 0.6), 0 0 50px rgba(76, 175, 80, 0.3); }
  100% { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
}

/* Confetti Animation */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #4CAF50;
  animation: confettiFall 3s linear infinite;
  pointer-events: none;
}

.confetti:nth-child(2n) { background: #2196F3; animation-delay: 0.5s; }
.confetti:nth-child(3n) { background: #FF9800; animation-delay: 1s; }
.confetti:nth-child(4n) { background: #E91E63; animation-delay: 1.5s; }
.confetti:nth-child(5n) { background: #9C27B0; animation-delay: 2s; }

@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Rain drop animation for negative points */
@keyframes rainFall {
  0% {
    transform: translateY(-100vh);
    opacity: 0.8;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

/* Quick Feedback Menu (ClassDojo-style) */
.quick-feedback-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.quick-feedback-overlay.show {
  opacity: 1;
  visibility: visible;
}

.quick-feedback-menu {
  background: white;
  border-radius: 20px;
  width: 95%;
  max-width: 600px; /* Increased from 400px for grid layout */
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.8) translateY(50px);
  transition: all 0.3s ease;
}

.quick-feedback-overlay.show .quick-feedback-menu {
  transform: scale(1) translateY(0);
}

.quick-feedback-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  position: relative;
}

.student-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.student-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.student-info h3 {
  margin: 0;
  font-size: 1.3em;
  font-weight: 600;
}

.student-info p {
  margin: 5px 0 0 0;
  opacity: 0.9;
  font-size: 0.9em;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.feedback-tabs {
  display: flex;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.tab-btn {
  flex: 1;
  padding: 15px;
  background: none;
  border: none;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  color: #6c757d;
  transition: all 0.2s ease;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #495057;
  border-bottom-color: #667eea;
  background: white;
}

.feedback-content {
  max-height: 400px;
  overflow-y: auto;
  padding: 15px;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  overscroll-behavior: contain; /* Prevent scroll chaining */
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  justify-items: stretch;
}

/* Mobile optimization - force 2 columns on smaller screens */
@media (max-width: 480px) {
  .tab-content.active {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

/* Larger screens - allow more columns */
@media (min-width: 500px) {
  .tab-content.active {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
  }
}

.feedback-option {
  width: 100%;
  padding: 12px 8px;
  margin: 0; /* Remove margin since grid handles spacing */
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.85em;
  font-weight: 600;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 70px; /* Consistent height for grid items */
  gap: 4px;
}

.feedback-option .points-display {
  font-size: 0.9em;
  font-weight: bold;
  opacity: 0.8;
}

.feedback-option.positive {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  border: 2px solid #4caf50;
  color: #2e7d32;
}

.feedback-option.positive:hover {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.feedback-option.negative {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  border: 2px solid #f44336;
  color: #c62828;
}

.feedback-option.negative:hover {
  background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

/* Touch device optimizations for grid */
@media (hover: none) and (pointer: coarse) {
  .feedback-option:hover {
    transform: none;
  }
  
  .feedback-option:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
  }
}

.feedback-option.negative:hover {
  background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.option-text {
  font-weight: 500;
}

.option-points {
  font-weight: bold;
  font-size: 1.1em;
  padding: 5px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  min-width: 40px;
  text-align: center;
}

/* Summary section in quick feedback menu */
.summary-section {
  padding: 15px;
  border-top: 1px solid #e9ecef;
  border-bottom: 1px solid #e9ecef;
  background: #f8f9fa;
}

.view-summary-btn {
  width: 100%;
  padding: 12px 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.view-summary-btn:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.summary-icon {
  font-size: 1.2em;
}

/* Remove section in quick feedback menu */
.remove-section {
  padding: 15px;
  border-top: 1px solid #e9ecef;
  background: #fff5f5;
}

.remove-student-btn {
  width: 100%;
  padding: 12px 15px;
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.remove-student-btn:hover {
  background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.remove-icon {
  font-size: 1.2em;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .quick-feedback-menu {
    width: 98%;
    margin: 5px;
    max-width: none; /* Remove max-width constraint on mobile */
  }
  
  .quick-feedback-header {
    padding: 15px;
  }
  
  .student-avatar {
    width: 50px;
    height: 50px;
  }
  
  .student-info h3 {
    font-size: 1.1em;
  }
  
  .feedback-option {
    padding: 10px 6px;
    font-size: 0.8em;
    min-height: 65px;
  }
  
  .feedback-content {
    padding: 10px;
  }
}

/* Medium screens optimization */
@media (min-width: 481px) and (max-width: 768px) {
  .quick-feedback-menu {
    width: 90%;
    max-width: 550px;
  }
  
  .tab-content.active {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

/* Classroom Timer Styles */
.timer-display {
  font-size: 4em;
  font-weight: bold;
  color: #333;
  margin: 30px 0;
  padding: 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 20px;
  border: 3px solid #e0e0e0;
  text-align: center;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  transition: all 0.3s ease;
}

.timer-display.timer-warning {
  color: #ff9800;
  border-color: #ff9800;
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  animation: timerPulse 1s ease-in-out infinite;
}

.timer-display.timer-countdown {
  color: #f44336;
  border-color: #f44336;
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-display.timer-complete {
  color: #4caf50;
  border-color: #4caf50;
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
  animation: timerComplete 1s ease-in-out;
}

@keyframes timerPulse {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  }
}

@keyframes timerComplete {
  0% { transform: scale(1); }
  25% { transform: scale(1.1); }
  50% { transform: scale(1.2); }
  75% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.timer-controls {
  padding: 20px 0;
}

.time-input-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.time-input-group input {
  width: 80px;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1em;
  font-weight: 600;
}

.time-input-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-label {
  font-weight: 600;
  color: #666;
  font-size: 0.9em;
}

.timer-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.timer-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-btn.start {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.timer-btn.start:hover:not(:disabled) {
  background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

.timer-btn.pause {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.timer-btn.pause:hover:not(:disabled) {
  background: linear-gradient(135deg, #f57c00 0%, #ef6c00 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

.timer-btn.reset {
  background: linear-gradient(135deg, #666 0%, #555 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 102, 102, 0.3);
}

.timer-btn.reset:hover {
  background: linear-gradient(135deg, #555 0%, #444 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 102, 102, 0.4);
}

.timer-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.timer-presets {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-btn {
  padding: 8px 16px;
  border: 2px solid #667eea;
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.9em;
}

.preset-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Mobile responsive timer */
@media (max-width: 600px) {
  .timer-display {
    font-size: 2.5em;
    margin: 20px 0;
    padding: 15px;
  }
  
  .time-input-group {
    flex-direction: column;
    gap: 15px;
  }
  
  .time-input-group input {
    width: 120px;
  }
  
  .timer-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .timer-btn {
    width: 200px;
    justify-content: center;
  }
  
  .timer-presets {
    justify-content: center;
    gap: 8px;
  }
  
  .preset-btn {
    padding: 10px 15px;
    font-size: 0.85em;
  }
}

/* Mobile input optimizations */
input, textarea, select {
  font-size: 16px !important; /* Prevent zoom on iOS */
  -webkit-appearance: none;
  appearance: none;
  border-radius: 8px;
  touch-action: manipulation;
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  input, textarea, select {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: text;
    user-select: text;
  }
}

/* Prevent accidental zooming on mobile */
@media screen and (max-width: 768px) {
  input[type="text"], 
  input[type="email"], 
  input[type="password"], 
  input[type="number"], 
  textarea {
    font-size: 16px !important;
    transform: scale(1) !important;
  }
}

/* Timer Alarm Flash Animation */
@keyframes timerAlarmFlash {
  0%, 100% { 
    background: linear-gradient(135deg, #ff1744 0%, #d50000 100%);
    color: white;
    border-color: #ff1744;
    box-shadow: 0 0 30px rgba(255, 23, 68, 0.8);
    transform: scale(1);
  }
  50% { 
    background: linear-gradient(135deg, #ffffff 0%, #ff8a80 100%);
    color: #d50000;
    border-color: #d50000;
    box-shadow: 0 0 50px rgba(255, 23, 68, 1);
    transform: scale(1.02);
  }
}