:root {
  --bg: #f6efe5;
  --bg-accent: #ffd9b8;
  --surface: rgba(255, 251, 247, 0.78);
  --surface-strong: #fff8f2;
  --text: #1f1b16;
  --muted: #66594b;
  --line: rgba(63, 39, 15, 0.12);
  --primary: #c94c28;
  --primary-dark: #992f15;
  --positive: #1d7c54;
  --negative: #a23b2c;
  --shadow: 0 22px 60px rgba(83, 47, 13, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(201, 76, 40, 0.18), transparent 18%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.45;
}

body::before {
  top: -8rem;
  right: -6rem;
  background: rgba(255, 179, 71, 0.65);
}

body::after {
  left: -8rem;
  bottom: -8rem;
  background: rgba(108, 176, 138, 0.4);
}

.page-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.avatar-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.hero {
  display: grid;
  gap: 1.5rem;
  align-items: end;
  grid-template-columns: 1.25fr 0.9fr;
  margin-bottom: 1.5rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.77rem;
  color: var(--primary-dark);
  font-weight: 700;
}

.hero h1,
.panel-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4.4rem);
  line-height: 0.94;
  max-width: 10ch;
}

.hero-text {
  margin: 1rem 0 0;
  max-width: 56ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.summary-panel,
.panel {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-panel {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: var(--radius-xl);
}

.summary-item {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 248, 242, 0.9);
}

.summary-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-item strong {
  font-size: 1.4rem;
}

.layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(280px, 340px) 1fr;
}

.panel {
  border-radius: var(--radius-xl);
  padding: 1.5rem;
}

.panel-heading {
  margin-bottom: 1.25rem;
}

.board-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.student-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
}

.field span {
  font-size: 0.95rem;
}

.field input {
  width: 100%;
  border: 1px solid rgba(70, 43, 17, 0.15);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.75);
  transition: border-color 160ms ease, transform 160ms ease;
}

.field input:focus {
  outline: none;
  border-color: rgba(201, 76, 40, 0.75);
  transform: translateY(-1px);
}

.field textarea {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid rgba(70, 43, 17, 0.15);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.75);
  transition: border-color 160ms ease, transform 160ms ease;
}

.field textarea:focus {
  outline: none;
  border-color: rgba(201, 76, 40, 0.75);
  transform: translateY(-1px);
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 0.7rem;
}

.avatar-option {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
  padding: 0.7rem 0.45rem;
  border: 1px solid rgba(70, 43, 17, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.avatar-option:hover,
.avatar-option:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(201, 76, 40, 0.45);
}

.avatar-option.is-selected {
  background: rgba(255, 237, 222, 0.95);
  border-color: rgba(201, 76, 40, 0.68);
  box-shadow: 0 12px 24px rgba(201, 76, 40, 0.12);
}

.avatar-option-preview {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
}

.avatar-option-label {
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: center;
  color: var(--muted);
}

.avatar-svg {
  width: 100%;
  height: 100%;
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
}

.primary-button,
.ghost-button,
.button-group button,
.delete-button {
  border-radius: 999px;
  padding: 0.78rem 1rem;
  font-weight: 700;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, var(--primary), #e97742);
  box-shadow: 0 14px 28px rgba(201, 76, 40, 0.26);
}

.ghost-button {
  background: rgba(201, 76, 40, 0.08);
  color: var(--primary-dark);
}

.primary-button:hover,
.ghost-button:hover,
.button-group button:hover,
.delete-button:hover {
  transform: translateY(-1px);
}

.student-list {
  display: grid;
  gap: 1rem;
}

.activity-panel {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 247, 239, 0.88);
  border: 1px solid rgba(70, 43, 17, 0.09);
}

.activity-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.activity-list {
  display: grid;
  gap: 0.75rem;
}

.activity-entry {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
}

.activity-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.8);
  padding: 0.15rem;
}

.activity-body {
  min-width: 0;
}

.activity-line,
.activity-time {
  margin: 0;
}

.activity-line {
  line-height: 1.35;
}

.activity-time {
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.student-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  border: 1px solid rgba(70, 43, 17, 0.1);
  animation: rise-in 260ms ease;
}

.student-info {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.student-identity {
  display: flex;
  gap: 1rem;
  align-items: start;
}

.student-avatar,
.history-modal-avatar {
  flex: 0 0 auto;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  padding: 0.2rem;
}

.student-avatar {
  width: 68px;
  height: 68px;
}

.student-meta {
  min-width: 0;
}

.student-name-button {
  display: inline-block;
  padding: 0;
  background: transparent;
  border-radius: 0;
  text-align: left;
}

.student-name-button:hover .student-name,
.student-name-button:focus-visible .student-name {
  color: var(--primary);
}

.student-name-button:focus-visible {
  outline: 2px solid rgba(201, 76, 40, 0.26);
  outline-offset: 4px;
}

.student-name {
  display: block;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.student-rank {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.student-note {
  margin: 0.55rem 0 0;
  max-width: 42ch;
  color: var(--primary-dark);
  font-size: 0.92rem;
  line-height: 1.45;
}

.points-badge {
  min-width: 110px;
  padding: 0.7rem 0.85rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 218, 184, 0.9), rgba(255, 242, 229, 0.95));
  text-align: right;
}

.points-badge span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.points-badge strong {
  font-size: 1.7rem;
  line-height: 1;
}

.student-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.button-group button {
  min-width: 68px;
  background: rgba(31, 27, 22, 0.06);
  color: var(--text);
}

.button-group button[data-delta^="-"] {
  background: rgba(162, 59, 44, 0.12);
  color: var(--negative);
}

.button-group button:not([data-delta^="-"]) {
  background: rgba(29, 124, 84, 0.12);
  color: var(--positive);
}

.delete-button {
  background: rgba(31, 27, 22, 0.08);
  color: var(--text);
}

.empty-state {
  padding: 2.4rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(70, 43, 17, 0.2);
  border-radius: var(--radius-lg);
}

.compact-empty-state {
  padding: 1rem;
}

.points-modal {
  width: min(100% - 1.5rem, 560px);
  padding: 0;
  border: 1px solid rgba(70, 43, 17, 0.12);
  border-radius: var(--radius-xl);
  background: rgba(255, 249, 243, 0.96);
  box-shadow: 0 28px 80px rgba(41, 24, 8, 0.24);
}

.points-modal::backdrop {
  background: rgba(31, 27, 22, 0.38);
  backdrop-filter: blur(5px);
}

.points-form {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-student-name {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.ghost-icon-button {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  background: rgba(31, 27, 22, 0.06);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

.ghost-icon-button:hover {
  transform: translateY(-1px);
}

.history-modal .points-form {
  gap: 1.2rem;
}

.history-modal-person {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.history-modal-avatar {
  width: 84px;
  height: 84px;
}

.preset-tasks-panel {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 244, 233, 0.8);
  border: 1px solid rgba(70, 43, 17, 0.1);
}

.preset-task-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.preset-task-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(70, 43, 17, 0.08);
}

.preset-task-button:hover {
  transform: translateY(-1px);
}

.preset-task-reason {
  color: var(--text);
  line-height: 1.2;
}

.history-list {
  display: grid;
  gap: 0.9rem;
  max-height: min(60vh, 560px);
  overflow-y: auto;
}

.history-entry {
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(70, 43, 17, 0.1);
}

.history-entry-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.history-delta {
  font-size: 1.05rem;
}

.history-delta.positive {
  color: var(--positive);
}

.history-delta.negative {
  color: var(--negative);
}

.history-timestamp {
  color: var(--muted);
  font-size: 0.88rem;
}

.history-reason {
  margin: 0.7rem 0 0;
  color: var(--text);
  line-height: 1.5;
}

.history-delete-button {
  margin-left: auto;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(162, 59, 44, 0.12);
  color: var(--negative);
  font-weight: 700;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 1rem, 100%);
    padding-top: 1rem;
  }

  .panel,
  .summary-panel {
    padding: 1rem;
  }

  .board-heading,
  .student-info,
  .student-actions,
  .student-identity,
  .history-modal-person,
  .activity-entry,
  .activity-panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .points-badge {
    text-align: left;
  }

  .button-group {
    width: 100%;
  }

  .button-group button,
  .delete-button,
  .ghost-button,
  .modal-actions .primary-button,
  .modal-actions .ghost-button,
  .preset-task-button {
    width: 100%;
  }

  .student-avatar,
  .history-modal-avatar {
    margin: 0 auto;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .history-entry-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
