:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --paper: #ffffff;
  --text: #142033;
  --muted: #5a6b7d;
  --line: #d9e3ee;
  --accent: #0b7ea5;
  --accent-soft: #e8f6fc;
  --green: #14805d;
  --danger: #c0392b;
  --shadow: 0 14px 36px rgba(20, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(11, 126, 165, 0.08), transparent 34%), var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang HK", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card,
.panel,
.stats > article,
.week-stats > article {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.gate-card {
  width: min(460px, 100%);
  padding: 28px;
}

.gate-card h1,
.header h1,
.panel h2 {
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}

.gate-card p,
.subtitle,
.meta,
.rules-note {
  color: var(--muted);
  line-height: 1.6;
}

.rules-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #21465b;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gate-card input,
.entry-form input,
.entry-form select,
.filters select,
.cell-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.gate-card input,
.gate-card button {
  margin-top: 10px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f2c7c2;
}

.error {
  margin-top: 10px;
  color: var(--danger);
}

.app {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.header,
.panel-head,
.entry-form {
  display: grid;
  gap: 16px;
}

.header {
  grid-template-columns: 1fr auto;
  align-items: start;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.stats,
.week-stats {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.week-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats > article,
.week-stats > article {
  padding: 16px;
}

.stats span,
.week-stats span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stats strong,
.week-stats strong {
  font-size: 24px;
  color: var(--accent);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 14px;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.entry-form .wide {
  grid-column: span 2;
}

.entry-form .checkbox {
  align-content: end;
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  gap: 8px;
}

.entry-form .checkbox input {
  width: auto;
}

.entry-form button {
  align-self: end;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eef5fb;
  color: #2a3d52;
  font-size: 12px;
}

.center {
  text-align: center;
}

.actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.cell-check {
  width: 18px;
  height: 18px;
}

.draw-panel {
  background: linear-gradient(135deg, #ffffff, #eefaf4);
}

.draw-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.draw-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.draw-actions input {
  width: 120px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.winner-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.winner-card {
  border: 1px solid #b9e7d2;
  border-radius: 14px;
  padding: 14px;
  background: #f4fff8;
}

.winner-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--green);
}

.winner-card span {
  display: block;
  font-size: 18px;
  color: var(--text);
}

.winner-card p,
.winner-list .meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.winner-row {
  background: #f4fff8;
}

.winner-row td:first-child {
  box-shadow: inset 4px 0 0 var(--green);
}


@media (max-width: 900px) {
  .header,
  .panel-head,
  .stats,
  .week-stats,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .entry-form .wide {
    grid-column: span 1;
  }
}
