:root {
  --purple: #64258c;
  --purple-dark: #431661;
  --purple-soft: #f2eaf7;
  --blue: #327fbb;
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --background: #f5f6fa;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(31, 38, 55, 0.09);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(100, 37, 140, 0.08), transparent 28rem),
    var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

[hidden] { display: none !important; }

.site-header {
  color: white;
  background: linear-gradient(115deg, #431661 0%, #64258c 55%, #3e72a5 130%);
  border-top: 5px solid #8d55ad;
}

.header-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 152px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 26px;
}

.compact .header-inner { min-height: 118px; }
.sem-logo { width: 240px; max-height: 70px; object-fit: contain; background: transparent; padding: 0; }
.course-heading { flex: 1; }
.course-heading h1 { margin: 5px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4vw, 3.45rem); line-height: 1.05; letter-spacing: -0.03em; }
.compact .course-heading h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.course-heading p { margin: 8px 0 0; font-size: 1.04rem; color: rgba(255,255,255,.82); }
.eyebrow, .section-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
.eyebrow { color: rgba(255,255,255,.75); }
.section-kicker { color: var(--purple); }
.page-switch { display: inline-flex; gap: 3px; padding: 4px; background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.3); border-radius: 12px; }
.page-switch-link { color: rgba(255,255,255,.86); border-radius: 8px; padding: 8px 13px; font-size: .84rem; font-weight: 780; white-space: nowrap; text-decoration: none; transition: background-color .15s, color .15s; }
.page-switch-link:hover { color: white; background: rgba(255,255,255,.1); }
.page-switch-link.active { color: var(--purple-dark); background: white; box-shadow: 0 2px 8px rgba(31,38,55,.13); }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 38px auto; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr); gap: 26px; align-items: start; }
.panel { background: var(--surface); border: 1px solid rgba(100, 37, 140, .1); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(24px, 4vw, 38px); }
.panel h2 { margin: 6px 0 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.6rem, 3vw, 2.25rem); line-height: 1.15; }
.lead { margin: 0; color: #475467; font-size: 1.02rem; }
.muted { color: var(--muted); margin: 0 0 24px; }
.formula-card { display: flex; flex-direction: column; gap: 2px; margin: 25px 0; padding: 17px 20px; border-left: 4px solid var(--purple); background: var(--purple-soft); border-radius: 0 12px 12px 0; }
.formula-card span { color: var(--purple); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.formula-card strong { font-size: 1.05rem; }
.rules-table-wrap, .table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
.rules-table { font-size: .91rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #475467; background: #f2f4f7; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); }
.rules-table tbody tr:last-child td { border-bottom: 0; }
.bonus-note { margin: 24px 0 0; color: var(--danger); }

form { display: grid; gap: 9px; margin-top: 24px; }
label { margin-top: 7px; font-size: .83rem; font-weight: 750; color: #344054; }
input { width: 100%; border: 1px solid #cfd4dc; border-radius: 10px; padding: 12px 13px; font: inherit; color: var(--ink); background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(100,37,140,.12); }
.button { border: 0; border-radius: 10px; min-height: 44px; padding: 10px 17px; font: inherit; font-size: .9rem; font-weight: 800; cursor: pointer; transition: transform .12s, filter .12s; }
.button:hover:not(:disabled) { filter: brightness(.97); transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.primary { color: white; background: var(--purple); margin-top: 14px; }
.secondary { color: var(--purple-dark); background: var(--purple-soft); border: 1px solid #d9c5e6; }
.danger { color: white; background: var(--danger); }
.text-button { color: #475467; background: transparent; }
.message { padding: 10px 12px; border-radius: 9px; font-size: .88rem; }
.error { color: #912018; background: #fff1f0; border: 1px solid #fecdca; }
.success-message { color: #05603a; background: #ecfdf3; border: 1px solid #abefc6; }

.status-view { min-height: 470px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.status-view form { width: 100%; max-width: 360px; text-align: left; }
.status-icon { width: 58px; height: 58px; margin-bottom: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 900; }
.status-icon.success { color: #067647; background: #dcfae6; }
.status-icon.trophy { color: #9a6700; background: #fff3c6; }
.muted-icon { color: #667085 !important; background: #f2f4f7 !important; }
.decision-number { margin: 12px 0; color: var(--purple); font-family: Georgia, serif; font-size: 5rem; font-weight: 800; line-height: 1; }
.result-grid { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.result-grid div { display: flex; flex-direction: column; padding: 14px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 11px; }
.result-grid span, .final-score span, .summary-card span { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 750; }
.result-grid strong { font-size: 1.25rem; }
.final-score { width: 100%; display: flex; align-items: center; justify-content: space-between; color: white; padding: 17px 19px; background: var(--purple); border-radius: 12px; }
.final-score span { color: rgba(255,255,255,.75); }
.final-score strong { font-size: 1.7rem; }
.winner-message { color: #7a5100; font-weight: 800; }

.admin-shell { max-width: 1320px; }
.login-panel { max-width: 470px; margin: 80px auto; }
.admin-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.summary-card { display: flex; flex-direction: column; padding: 19px 22px; background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(31,38,55,.06); }
.summary-card strong { margin-top: 3px; font-family: Georgia, serif; font-size: 1.8rem; }
.toolbar-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-top: 24px; padding-bottom: 24px; margin-bottom: 20px; }
.toolbar-panel h2 { margin-bottom: 0; font-size: 1.55rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; justify-content: flex-end; }
.toolbar .button { margin: 0; }
.toolbar-panel .message { flex-basis: 100%; margin: 0; }
.records-panel { padding: 0; overflow: hidden; }
.records-heading { padding: 25px 28px 14px; }
.records-heading h2 { font-size: 1.6rem; }
.records-table { min-width: 950px; font-size: .88rem; }
.records-table tbody tr:hover { background: #faf8fc; }
.numeric { font-variant-numeric: tabular-nums; text-align: right; }
.strong { font-weight: 800; }
.winner-cell { color: #7a5100; font-weight: 850; }
.delete-button { color: var(--danger); border: 1px solid #fecdca; background: #fff7f6; border-radius: 7px; padding: 6px 10px; font-weight: 750; cursor: pointer; }
.empty-state { text-align: center; color: var(--muted); padding: 45px 20px; }
footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto 35px; color: #7b8190; font-size: .8rem; text-align: center; }

@media (max-width: 900px) {
  .two-column { grid-template-columns: 1fr; }
  .admin-summary { grid-template-columns: 1fr 1fr; }
  .toolbar-panel { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .header-inner, .page-shell, footer { width: min(100% - 24px, 1180px); }
  .header-inner { min-height: 130px; gap: 14px; flex-wrap: wrap; padding: 18px 0; }
  .sem-logo { width: 145px; }
  .course-heading { min-width: 180px; }
  .course-heading h1 { font-size: 1.8rem; }
  .course-heading .eyebrow { display: none; }
  .page-switch { width: 100%; }
  .page-switch-link { flex: 1; text-align: center; }
  .page-shell { margin-top: 20px; }
  .panel { padding: 23px 19px; border-radius: 14px; }
  .rules-table { font-size: .8rem; }
  th, td { padding: 10px 9px; }
  .admin-summary { gap: 10px; }
  .summary-card { padding: 14px; }
  .summary-card strong { font-size: 1.4rem; }
  .toolbar { width: 100%; }
  .toolbar .button { flex: 1 1 45%; }
}
