:root {
  color-scheme: light;
  --bg: #f6f8f1;
  --ink: #172414;
  --muted: #63735d;
  --panel: #ffffff;
  --line: #dbe5d4;
  --line-strong: #bfd0b6;
  --accent: #4aa915;
  --accent-strong: #2f740b;
  --accent-soft: #edf7e8;
  --highlight: #eac41d;
  --highlight-strong: #b89608;
  --warning: #8a4b12;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.app-page {
  display: grid;
  gap: 12px;
}

.app-page.is-hidden {
  display: none;
}

.page-header {
  display: grid;
  padding: 0 2px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  text-align: center;
}

.summary dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.summary dd {
  margin: 2px 0 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.start-button,
.draw-button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--highlight);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 900;
}

.start-button:disabled,
.draw-button:disabled,
.draw-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.draw-button.is-complete {
  border: 1px solid var(--line-strong);
  background: #f9fbfc;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.7;
}

.draw-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.draw-nav-button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
}

.confirm-dialog {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

.confirm-dialog::backdrop {
  background: rgba(23, 33, 43, 0.42);
}

.confirm-dialog form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.confirm-dialog h2,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h2 {
  font-size: 1.1rem;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dialog-button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.dialog-button.is-danger {
  border-color: #be7b72;
  background: #fff1ef;
  color: #8f2f25;
}

.draw-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.back-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.summary-button {
  min-width: 112px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.summary-print {
  color: #000000;
  background: #ffffff;
  font-family: Arial, sans-serif;
  padding: 16px;
}

.summary-print section + section {
  margin-top: 18px;
}

.summary-print h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.summary-print ul,
.summary-print p {
  margin: 0 0 0 24px;
}

.summary-print ul {
  padding: 0;
  list-style: none;
}

.summary-print li {
  margin: 2px 0;
}

#summary-page > .back-button {
  justify-self: center;
}

.draw-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.draw-card h1 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
}

.winner-slots {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.winner-slots li {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.slot-number {
  display: grid;
  height: 100%;
  place-items: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.slot-name {
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.winner-slots li.is-filled {
  border-color: rgba(74, 169, 21, 0.38);
  background: var(--accent-soft);
}

.winner-slots li.is-filled .slot-name {
  color: var(--ink);
}

.winner-slots li.is-spinning {
  border-color: rgba(74, 169, 21, 0.3);
  background: linear-gradient(180deg, #f9fbfc 0%, var(--accent-soft) 50%, #f9fbfc 100%);
}

.winner-slots li.is-spinning .slot-number,
.winner-slots li.is-spinning .slot-name {
  animation: slot-scroll 140ms linear infinite;
  filter: blur(1px);
}

.winner-slots li.is-spinning .slot-name {
  color: var(--muted);
}

@keyframes slot-scroll {
  0% {
    opacity: 0.28;
    transform: translateY(-12px);
  }

  45% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0.28;
    transform: translateY(12px);
  }
}

.table-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.table-wrap {
  max-height: calc(100vh - 172px);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  padding-top: 14px;
  padding-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  width: 48px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

th:last-child,
td:last-child {
  width: 72px;
}

tbody tr {
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child {
  border-bottom: 0;
}

td {
  font-size: 0.94rem;
}

.student-cell {
  background: linear-gradient(
    90deg,
    rgba(74, 169, 21, 0.22) 0,
    rgba(74, 169, 21, 0.22) var(--chance-fill, 0%),
    transparent var(--chance-fill, 0%),
    transparent 100%
  );
  font-weight: 700;
  overflow-wrap: anywhere;
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

thead .number-cell,
thead .money-cell {
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  padding: 15px 4px 13px;
  text-align: center;
}

.money-cell {
  width: 72px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.empty-cell {
  padding: 28px 14px;
  color: var(--muted);
  text-align: center;
}

.empty-cell.is-error {
  color: var(--warning);
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 32px;
  }
}
