* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f5f7;
  color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Arial, Helvetica, sans-serif;
}

.scoreboard-body {
  min-height: 100svh;
  overflow: hidden;
  background: linear-gradient(135deg, #f7f8fa 0%, #eef1f5 48%, #f8f8f9 100%);
}

button,
input {
  font: inherit;
}

.page {
  width: min(100% - 24px, 980px);
  margin: 0 auto;
  padding: 24px 0;
}

.page-narrow {
  max-width: 620px;
}

.page-wide {
  max-width: 1100px;
}

.scoreboard-page {
  position: relative;
  z-index: 1;
  width: min(100% - 56px, 1280px);
  min-height: 100svh;
  display: grid;
  align-items: center;
  margin: 0 auto;
  padding: 28px 0;
}

.page-wide .panel {
  box-shadow: none;
}

.vote-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 28px;
  padding-bottom: 28px;
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

.vote-header {
  align-items: flex-start;
  justify-content: center;
  text-align: center;
}

.vote-header .nav-link {
  position: absolute;
  top: 18px;
  right: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #6e6e73;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 9vw, 58px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.04;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.panel {
  margin-bottom: 16px;
  padding: 18px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

.vote-shell .panel {
  width: 100%;
}

.vote-shell > .panel {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  color: #424245;
}

.search-input {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 14px;
  background: #fbfbfd;
  color: #1d1d1f;
  outline: none;
}

.search-input:focus {
  border-color: #0071e3;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.16);
}

.suggestions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.button,
.suggestion-button {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  background: #fff;
  color: #1d1d1f;
  cursor: pointer;
  text-align: left;
}

.suggestion-button {
  background: #f5f5f7;
  border-left: 6px solid var(--teacher-color, #0071e3);
}

.suggestion-button:active {
  transform: scale(0.99);
}

.button {
  text-align: center;
  font-weight: 700;
}

.primary {
  background: #0071e3;
  border-color: #0071e3;
  color: #fff;
}

.danger {
  background: #991b1b;
  border-color: #991b1b;
  color: #fff;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.confirm-panel {
  text-align: center;
}

.confirm-panel h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

.confirm-actions {
  margin-top: 18px;
}

.nav-link {
  color: #0071e3;
  font-weight: 700;
  text-decoration: none;
}

.status-text,
.error,
.muted {
  margin-bottom: 0;
}

.muted {
  color: #6e6e73;
}

.error {
  margin-top: 10px;
  color: #991b1b;
  font-weight: 700;
}

.status-pill {
  margin: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e5e5e5;
  font-weight: 700;
}

.status-pill.is-open {
  background: #e8f7ee;
  color: #176b3a;
}

.status-pill.is-closed {
  background: #fee2e2;
  color: #991b1b;
}

.results-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.results-stage {
  min-height: calc(100svh - 48px);
}

.scoreboard-page .results-stage {
  min-height: auto;
  max-height: calc(100svh - 56px);
  overflow: hidden;
  padding: clamp(22px, 3vw, 44px);
  border: 0;
  background: transparent;
  box-shadow: none;
}

.results-stage .section-head {
  justify-content: flex-start;
  text-align: left;
}

.results-stage h1 {
  font-size: clamp(44px, 7vw, 86px);
}

.scoreboard-page .results-stage h1 {
  color: #14213d;
  text-shadow: none;
  font-size: clamp(48px, 6vw, 84px);
}

.presentation-page {
  min-height: 100svh;
  display: grid;
  padding: clamp(18px, 3vw, 42px);
}

.teacher-presentation {
  --preview-percent: 12%;
  min-height: calc(100svh - clamp(18px, 3vw, 42px) * 2);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(14px, 2vw, 26px);
}

.presentation-title-slide {
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(24px, 4vw, 48px);
  text-align: center;
}

.presentation-title-slide h1 {
  color: #152238;
  font-size: clamp(42px, 7vw, 96px);
  line-height: 0.95;
}

.teacher-slide {
  position: relative;
  min-height: 0;
  display: grid;
  align-content: center;
  gap: clamp(16px, 2.5vw, 32px);
}

.presentation-qr {
  padding: 3px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(16, 24, 39, 0.12);
}

.presentation-qr img {
  display: block;
  width: 100%;
  height: auto;
}

.presentation-qr-title {
  width: min(11vw, 15svh, 130px);
}

.presentation-qr-corner {
  position: absolute;
  top: clamp(8px, 1.2vw, 18px);
  right: clamp(8px, 1.2vw, 18px);
  z-index: 3;
  width: min(6vw, 8svh, 78px);
  opacity: 0.94;
}

.teacher-reveal-layout {
  min-height: 0;
  display: grid;
  align-items: center;
  gap: clamp(18px, 3vw, 44px);
}

.teacher-presentation.is-preview-slide .teacher-reveal-layout {
  grid-template-columns: minmax(320px, 0.7fr) minmax(420px, 1fr);
  grid-template-areas: "photo results";
}

.teacher-presentation.is-revealed .teacher-reveal-layout {
  grid-template-columns: 1fr;
  grid-template-areas: "photo";
}

.teacher-photo-frame {
  position: relative;
  grid-area: photo;
  width: min(100%, 980px);
  max-height: 62svh;
  aspect-ratio: 16 / 9;
  justify-self: center;
  overflow: hidden;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 20px 70px rgba(16, 24, 39, 0.18);
}

.teacher-presentation.is-preview-slide .teacher-photo-frame {
  width: min(100%, 460px);
  height: min(68svh, 720px);
  max-height: none;
  aspect-ratio: 190 / 281;
}

.teacher-presentation.is-revealed .teacher-photo-frame {
  width: auto;
  height: min(78svh, 860px);
  max-height: none;
  aspect-ratio: 190 / 281;
}

.teacher-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

.teacher-photo-preview {
  clip-path: inset(0 0 calc(100% - var(--preview-percent)) 0);
}

.teacher-photo-full {
  opacity: 1;
  transform: none;
}

.teacher-presentation.is-revealed .teacher-photo-full {
  opacity: 1;
  transform: none;
}

.teacher-reveal-name {
  min-height: 1.15em;
  color: #152238;
  font-size: clamp(38px, 6vw, 88px);
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  opacity: 0;
  transform: none;
  overflow-wrap: anywhere;
}

.teacher-presentation.is-revealed .teacher-reveal-name {
  opacity: 1;
  transform: none;
}

.presentation-results {
  grid-area: results;
  min-width: 0;
  align-self: stretch;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
}

.presentation-results h2 {
  margin-bottom: 18px;
  color: #152238;
  font-size: clamp(32px, 4vw, 64px);
  font-weight: 900;
  line-height: 1;
}

.presentation-results-list {
  display: grid;
  align-content: start;
  gap: 6px 10px;
  min-height: 0;
  overflow: hidden;
}

.presentation-results-list.election-chart {
  height: min(66vh, 640px);
  grid-auto-columns: minmax(96px, 1fr);
  gap: clamp(18px, 2.5vw, 44px);
  align-content: initial;
}

.presentation-results-list.election-chart .election-name {
  font-size: clamp(13px, 1vw, 17px);
}

.presentation-results-list.election-chart .election-value {
  font-size: clamp(24px, 2.7vw, 44px);
}

.presentation-election-chart .election-column {
  animation: presentationColumnIn 220ms ease-out both;
}

.presentation-election-chart .election-label {
  animation: presentationLabelIn 260ms ease-out both;
}

.presentation-election-chart .election-bar-track {
  transition: height 850ms linear;
}

.presentation-election-chart .election-value {
  transition: transform 180ms ease, color 180ms ease;
}

.presentation-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.presentation-controls .button {
  min-width: 130px;
  text-align: center;
}

.presentation-controls .button:disabled {
  cursor: default;
  opacity: 0.45;
}

.admin-page {
  padding-top: 22px;
}

.admin-login {
  display: grid;
  gap: 12px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
  align-items: start;
}

.admin-grid > .panel:last-child {
  grid-column: 1 / -1;
}

.admin-control-panel {
  display: grid;
  gap: 16px;
}

.admin-meta,
.admin-actions {
  display: grid;
  gap: 10px;
}

.admin-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-actions .danger {
  grid-column: 1 / -1;
}

.admin-timer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #f5f5f7;
}

.admin-timer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #424245;
  font-weight: 700;
}

.admin-progress {
  --progress: 0%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8dce3;
}

.admin-progress::before {
  content: "";
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: #0071e3;
}

.admin-preview-panel {
  min-width: 0;
  overflow: hidden;
}

.admin-presentation {
  min-height: 520px;
}

.admin-presentation .presentation-title-slide h1 {
  font-size: clamp(40px, 6vw, 82px);
}

.admin-presentation.teacher-presentation.is-preview-slide .teacher-reveal-layout {
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 1fr);
  gap: 18px;
}

.admin-presentation.teacher-presentation.is-preview-slide .teacher-photo-frame,
.admin-presentation.teacher-presentation.is-revealed .teacher-photo-frame {
  height: min(50vh, 420px);
}

.admin-presentation .teacher-reveal-name {
  font-size: clamp(28px, 4vw, 48px);
}

.admin-presentation .presentation-results-list.election-chart {
  height: min(44vh, 380px);
  grid-auto-columns: minmax(64px, 1fr);
  gap: 14px;
}

.debug-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  width: min(320px, calc(100vw - 24px));
  max-height: 52vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(20, 33, 61, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: #14213d;
  box-shadow: 0 12px 40px rgba(16, 24, 39, 0.18);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.debug-title {
  margin-bottom: 6px;
  font-weight: 800;
}

.debug-recent {
  margin-top: 8px;
  color: #4b5563;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-actions {
    grid-template-columns: 1fr;
  }

  .admin-presentation.teacher-presentation.is-preview-slide .teacher-reveal-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "photo"
      "results";
  }
}

@media (max-width: 820px) {
  .teacher-presentation.is-preview-slide .teacher-reveal-layout,
  .teacher-presentation.is-revealed .teacher-reveal-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "photo"
      "results";
  }

  .teacher-presentation.is-preview-slide .teacher-photo-frame,
  .teacher-presentation.is-revealed .teacher-photo-frame {
    height: min(48svh, 560px);
  }

  .presentation-results-list.election-chart {
    height: min(42svh, 440px);
    grid-auto-columns: minmax(72px, 1fr);
  }
}

.thanks {
  margin-bottom: 22px;
  text-align: center;
}

.thanks h2 {
  margin-bottom: 6px;
  color: #003c96;
  font-size: 30px;
}

.thanks p {
  margin-bottom: 0;
  color: #6e6e73;
}

.checkmark {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 16px;
  background: #003c96;
  color: #fff;
  font-size: 32px;
  font-weight: 800;
}

.result-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-left: 8px solid var(--teacher-color, #0071e3);
  border-radius: 14px;
  background: color-mix(in srgb, var(--teacher-color, #0071e3) 10%, white);
}

.results-large .result-row {
  grid-template-columns: 72px minmax(0, 1fr) 120px;
  padding: 18px 20px;
  font-size: 24px;
}

.scoreboard-list {
  gap: 14px;
  max-height: calc(100svh - 210px);
  overflow: hidden;
}

.scoreboard-list .result-row {
  min-height: 76px;
  border-left: 8px solid var(--teacher-color, #0071e3);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(18, 32, 58, 0.08);
}

.scoreboard-list .result-row.is-podium {
  background: #ffffff;
}

.scoreboard-list .result-row.is-first {
  min-height: 96px;
  color: #14213d;
  background: #f8fbff;
  box-shadow: 0 14px 36px rgba(18, 32, 58, 0.12);
}

.rank {
  font-weight: 700;
}

.scoreboard-list .rank {
  font-size: 42px;
  font-weight: 900;
  text-align: center;
}

.result-main {
  min-width: 0;
}

.result-name {
  margin-bottom: 5px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.scoreboard-list .result-name {
  margin-bottom: 0;
  font-size: clamp(28px, 3.2vw, 48px);
  line-height: 1.05;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e5e5;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #0071e3;
}

.scoreboard-list .bar-track {
  display: block;
  height: 16px;
  margin-top: 10px;
  background: #e7ebf2;
}

.vote-count {
  text-align: right;
  font-weight: 700;
}

.scoreboard-list .vote-count {
  color: #14213d;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1;
}

.scoreboard-list .is-first .vote-count {
  font-size: clamp(32px, 3.6vw, 54px);
  font-weight: 900;
}

.election-chart {
  height: min(72vh, 680px);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(130px, 1fr);
  align-items: end;
  gap: clamp(28px, 4vw, 70px);
  margin-top: 0;
}

.election-column {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: center;
}

.election-label {
  margin-bottom: 12px;
}

.election-name {
  min-height: 2.24em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #243044;
  font-size: clamp(14px, 1.15vw, 19px);
  font-weight: 800;
  line-height: 1.12;
  overflow-wrap: normal;
}

.election-value {
  margin-top: 8px;
  color: #14213d;
  font-size: clamp(24px, 2.8vw, 46px);
  font-weight: 900;
  line-height: 1;
}

.election-bar-track {
  height: var(--bar-height, 8%);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
}

.election-bar {
  width: 100%;
  height: 100%;
  min-height: 18px;
  border-radius: 8px 8px 2px 2px;
  background: var(--teacher-color, #0071e3);
  box-shadow:
    0 18px 34px color-mix(in srgb, var(--teacher-color, #0071e3) 26%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

@keyframes presentationColumnIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

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

@keyframes presentationLabelIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

[hidden] {
  display: none !important;
}
