:root {
  --bg: #fef6e4;
  --card-bg: #ffffff;
  --primary: #ff8551;
  --primary-dark: #e8663a;
  --secondary: #6c9bcf;
  --secondary-dark: #4d7fb5;
  --accent: #8bd3a0;
  --text: #33313a;
  --text-light: #7a7686;
  --danger: #e05263;
  --radius: 20px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fef6e4 0%, #f3e8ff 100%);
  font-family: "Gowun Dodum", system-ui, -apple-system, sans-serif;
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 16px;
}

#app { width: 100%; max-width: 640px; }

h1, h2, h3 { font-family: "Jua", "Gowun Dodum", sans-serif; margin: 0 0 8px; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 24px;
}

.wide-card { max-width: 720px; margin-left: auto; margin-right: auto; }

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

.logo { font-size: 1.8rem; }
.subtitle { color: var(--text-light); margin-bottom: 24px; }

.role-buttons { display: flex; flex-direction: column; gap: 14px; }

.big-btn {
  border: none;
  border-radius: 16px;
  padding: 18px;
  font-size: 1.15rem;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s ease;
}
.big-btn:active { transform: scale(0.97); }

.student-btn { background: var(--secondary); }
.student-btn:hover { background: var(--secondary-dark); }
.teacher-btn { background: var(--primary); }
.teacher-btn:hover { background: var(--primary-dark); }
.submit-btn { background: var(--accent); color: #1c3d2b; width: 100%; margin-top: 12px; }

.small-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--secondary-dark);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 0;
  font-family: inherit;
}

.back-btn { display: block; margin-bottom: 12px; }

.hint { color: var(--text-light); margin: 0 0 16px; }

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}

.student-chip {
  background: #f4efff;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 1rem;
}
.student-chip:hover { border-color: var(--secondary); }
.student-chip .num { display: block; font-family: "Jua", sans-serif; font-size: 1.3rem; color: var(--primary-dark); }

.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.character { font-size: 3.5rem; line-height: 1; }
.profile-name { font-size: 1.3rem; font-weight: bold; }
.profile-stats { display: flex; gap: 8px; margin-top: 6px; }
.badge {
  background: #f4efff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.9rem;
}
.badge.points { background: #fff4d6; }

.levelup-banner {
  background: #fff4d6;
  border: 2px dashed var(--primary);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 16px;
  animation: pop 0.4s ease;
}
@keyframes pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.entry-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.entry-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; color: var(--text-light); }
.entry-form input, .entry-form textarea, .settings-form input {
  font-family: inherit;
  font-size: 1rem;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #ddd;
  resize: vertical;
}

.feedback { text-align: center; font-size: 0.95rem; padding: 8px; border-radius: 10px; }
.feedback.success { background: #e4f7ea; color: #1c7c4c; }
.feedback.error { background: #fde8ea; color: var(--danger); }

.section-title { margin-top: 8px; }

.record-list { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.record-item { background: #faf8ff; border-radius: 12px; padding: 12px 14px; }
.record-item .date { font-size: 0.8rem; color: var(--text-light); }
.record-item .book { font-weight: bold; margin: 2px 0; }
.record-item .content { font-size: 0.95rem; }
.empty { color: var(--text-light); text-align: center; padding: 20px 0; }

.pin-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.pin-form input {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 8px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #ddd;
}

.dash-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  border: none;
  background: #f4efff;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}
.tab-btn.active { background: var(--secondary); color: #fff; }

.roster-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.roster-table th, .roster-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; }
.roster-table tr:hover { background: #faf8ff; }
.row-link { color: var(--secondary-dark); cursor: pointer; text-decoration: underline; background: none; border: none; font-family: inherit; font-size: 0.9rem; }
.today-yes { color: #1c7c4c; }
.today-no { color: var(--text-light); }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; }

.inline-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form input { padding: 10px; border-radius: 10px; border: 1px solid #ddd; font-family: inherit; }
.inline-form input#new-student-id { width: 100px; }
.inline-form input#new-student-name { flex: 1; min-width: 120px; }

.settings-form { display: flex; flex-direction: column; gap: 14px; max-width: 360px; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; color: var(--text-light); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

@media (max-width: 480px) {
  .card { padding: 18px; border-radius: 16px; }
  .dash-header { flex-direction: column; gap: 8px; }
}
