@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

* { box-sizing: border-box; }
body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  margin: 0;
  padding: 12px;
  min-height: 100dvh;
}

.container {
  max-width: 100%;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 20px;
}

h1 { font-size: 24px; color: #1e40af; text-align: center; margin: 0 0 8px; }
h2 { font-size: 18px; color: #4b5563; text-align: center; margin-bottom: 25px; }

.centered { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; }

.form-group { margin-bottom: 18px; }
label { font-weight: 600; color: #1e40af; margin-bottom: 8px; font-size: 16px; display: block; }
input, select { width: 100%; padding: 14px; border: 2px solid #e0e0e0; border-radius: 10px; font-size: 18px; background: #f8fafc; }
input:focus, select:focus { outline: none; border-color: #2563eb; background: white; }

button { width: 100%; padding: 14px; border: none; border-radius: 10px; font-size: 18px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: all 0.2s; }
button:hover { transform: translateY(-2px); }
#get-data-button, #submit-button { background: #2563eb; color: white; }
#clear-button { background: #f97316; color: white; }
button:disabled { background: #94a3b8; opacity: 0.7; }

.info-note { background: #dbeafe; color: #1e40af; padding: 14px; border-radius: 10px; text-align: center; font-weight: 500; margin: 20px 0; font-size: 15px; }

/* TABLE LAYOUT */
#student-list { margin-top: 20px; }

.table-header {
  display: grid;
  grid-template-columns: 60px 1fr 100px 100px;
  background: #1e40af;
  color: white;
  font-weight: 600;
  padding: 12px 10px;
  border-radius: 12px 12px 0 0;
  text-align: center;
  font-size: 16px;
}

.table-row {
  display: grid;
  grid-template-columns: 60px 1fr 100px 100px;
  padding: 10px 8px;
  background: #f0f9ff;
  border-radius: 8px;
  margin-bottom: 12px;
  align-items: center;
  min-height: 52px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.table-row.row-focus {
  background: #e0f2fe !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.3);
}

.sn { text-align: center; font-weight: 700; color: #1e40af; font-size: 18px; }
.name {
  font-weight: 500;
  color: #1f2937;
  font-size: 14px !important;           /* smaller base size */
  line-height: 1.35;
  word-break: break-all;                /* force long names to wrap/break */
  hyphens: auto;                        /* better word breaking */
  overflow-wrap: break-word;
  white-space: normal !important;       /* allow wrapping to multiple lines */
  max-width: 100%;                      /* use all available space */
  padding-right: 6px;
}

.mark-cell { text-align: center; }
.mark {
  width: clamp(65px, 18vw, 80px);
  height: clamp(42px, 11vw, 50px);
  text-align: center;
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 600;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  background: white;
}

.mark:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.25);
  transform: scale(1.06);
}

.mark.invalid { border-color: #dc2626; background: #fee2e2; }
.error-text { grid-column: 1 / -1; color: #dc2626; font-size: 13px; text-align: center; margin-top: 6px; }

.button-group { display: flex; gap: 12px; margin-top: 20px; flex-direction: column; }
.wait-message { text-align: center; color: #2563eb; font-weight: 500; margin-top: 15px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #2563eb; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; margin-left: 6px; }

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
}

.loading-content {
  text-align: center;
  padding: 40px 30px;
  background: rgba(30, 64, 175, 0.92);
  border-radius: 20px;
  min-width: 280px;
}

.loading-content h2 { margin: 0 0 20px; font-size: 22px; }
.loading-content p { font-size: 17px; margin: 12px 0; }
#countdown { font-size: 52px; font-weight: bold; color: #fbbf24; }

.spinner-large {
  width: 70px;
  height: 70px;
  border: 8px solid rgba(255,255,255,0.3);
  border-top-color: #fbbf24;
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
  margin: 0 auto 20px;
}

/* Mobile adjustments */
@media (max-width: 500px) {
  .table-header, .table-row {
    grid-template-columns: 50px 1fr 80px 80px;
    font-size: 15px;
  }
  .mark { width: 70px; height: 48px; font-size: 18px; }
  .name { font-size: 14px; }
}

@media (min-width: 480px) {
  .button-group { flex-direction: row; }
}