:root {
  color-scheme: light;
  --ink: #1e2623;
  --muted: #65736d;
  --line: #d9ded8;
  --paper: #fffdf6;
  --panel: #ffffff;
  --jade: #1f7a62;
  --jade-dark: #145441;
  --jade-soft: #e8f4ef;
  --gold: #bc8b2c;
  --gold-soft: #f5ead1;
  --rose: #9b4141;
  --sky: #dcebea;
  --shadow: 0 22px 60px rgba(31, 48, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7faf5 0%, #eef5ef 100%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--jade);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.35rem, 5.2vw, 4.7rem);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h1 span {
  display: block;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.8rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.lead {
  max-width: 34rem;
  color: #3f4c47;
  font-size: 1.08rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.draw-controls,
.lot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.button,
.icon-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

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

.button--primary {
  color: white;
  background: linear-gradient(180deg, #24916f 0%, var(--jade) 100%);
  box-shadow: 0 18px 36px rgba(31, 122, 98, 0.28);
}

.button--secondary {
  color: white;
  background: var(--gold);
}

.button--ghost {
  color: var(--jade-dark);
  background: #eef7f4;
  border-color: rgba(31, 122, 98, 0.18);
}

.button:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
}

.icon-button {
  width: 46px;
  padding: 0;
  color: var(--jade-dark);
  background: #f6f8f4;
  border-color: var(--line);
  font-size: 1.2rem;
}

.panel,
.lot-card {
  margin-top: 20px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 48px rgba(47, 59, 53, 0.10);
}

.checker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.status-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.status-panel summary::-webkit-details-marker {
  display: none;
}

.status-panel summary::after {
  content: "+";
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--jade-dark);
  background: #f7faf7;
  font-size: 1.4rem;
  line-height: 1;
}

.status-panel[open] summary::after {
  content: "-";
}

.status-panel summary strong {
  display: block;
  font-size: 1.35rem;
}

.status-content {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: white;
  font: inherit;
}

textarea {
  resize: vertical;
  min-height: 118px;
  line-height: 1.7;
}

.status-card {
  grid-column: 1 / -1;
  padding: 18px;
  border-radius: 8px;
  background: #f7faf7;
  border: 1px solid var(--line);
}

.status-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.15rem;
}

.status-card.ok {
  background: #edf8f3;
  border-color: rgba(31, 122, 98, 0.26);
}

.status-card.warn {
  background: #fff8ea;
  border-color: rgba(188, 139, 44, 0.32);
}

.status-card.stop {
  background: #fff1ef;
  border-color: rgba(155, 65, 65, 0.28);
}

.draw-grid {
  min-height: calc(100svh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 760px);
  gap: 16px;
  align-content: center;
  justify-content: center;
}

.draw-panel,
.lot-card {
  margin-top: 0;
}

.draw-panel {
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.draw-panel::before,
.draw-panel::after {
  content: "";
  position: absolute;
  left: 32px;
  right: 32px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(188, 139, 44, 0.5), transparent);
}

.draw-panel::before {
  top: 28px;
}

.draw-panel::after {
  bottom: 28px;
}

.draw-panel .section-kicker {
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--jade-soft);
  color: var(--jade-dark);
  font-size: 0.95rem;
}

.draw-intro {
  max-width: 38rem;
  margin: 0 auto 4px;
  color: #465650;
  font-size: 1.08rem;
  line-height: 1.75;
}

.lottery-tube {
  width: 160px;
  height: 240px;
  margin: 2px auto 8px;
  position: relative;
  display: grid;
  justify-items: center;
  align-items: end;
  filter: drop-shadow(0 18px 26px rgba(89, 23, 18, 0.18));
}

.tube-image {
  width: auto;
  height: 240px;
  display: block;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.lottery-tube.is-shaking {
  animation: tubeShake 0.16s ease-in-out 6;
}

.lottery-tube.is-shaking .tube-image {
  animation: imageBounce 0.32s ease-in-out 3;
}

@keyframes tubeShake {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  25% {
    transform: translateX(-5px) rotate(-4deg);
  }
  75% {
    transform: translateX(5px) rotate(4deg);
  }
}

@keyframes stickBounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  45% {
    transform: translateX(-50%) translateY(-15px);
  }
}

@keyframes imageBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(-12px);
  }
}

.draw-controls {
  width: min(430px, 100%);
  margin-top: 18px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  justify-content: center;
}

.draw-controls .button--primary {
  min-width: 320px;
  min-height: 76px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  font-size: 1.95rem;
}

.draw-controls .icon-button {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.draw-controls .icon-button:hover {
  transform: translateY(-52%);
}

.note,
footer p {
  color: var(--muted);
  line-height: 1.75;
}

.draw-status {
  min-height: 1.6em;
  margin: 10px auto 0;
  color: var(--jade-dark);
  font-weight: 700;
}

.note {
  max-width: 34rem;
  margin: 6px auto 0;
}

.lot-card {
  min-height: 330px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  background:
    linear-gradient(90deg, rgba(188, 139, 44, 0.18) 0 8px, transparent 8px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 248, 0.96));
}

.lot-card__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.lot-badge {
  width: fit-content;
  margin: 18px auto 0;
  padding: 8px 16px;
  border: 1px solid rgba(31, 122, 98, 0.18);
  border-radius: 999px;
  color: var(--jade-dark);
  background: var(--jade-soft);
  font-weight: 800;
}

.lot-card.empty .lot-badge {
  color: var(--muted);
  background: #f7faf7;
}

.lot-card.confirmed .lot-badge {
  color: #704f12;
  background: var(--gold-soft);
  border-color: rgba(188, 139, 44, 0.28);
}

.lot-stick {
  width: min(230px, 76vw);
  min-height: 330px;
  margin: 24px auto 18px;
  padding: 28px 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(188, 139, 44, 0.34);
  border-top: 8px solid rgba(188, 139, 44, 0.58);
  border-bottom: 8px solid rgba(188, 139, 44, 0.58);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8 0%, #fbf8ed 100%);
  box-shadow: 0 18px 42px rgba(58, 68, 63, 0.08);
}

#lotStem {
  color: var(--jade-dark);
  font-size: clamp(3.8rem, 8vw, 5.8rem);
  line-height: 1;
  text-align: center;
  letter-spacing: 0;
}

.lot-title {
  display: grid;
  gap: 18px;
  justify-items: center;
}

#lotPoem {
  color: #35443e;
  font-size: 1.13rem;
  line-height: 2;
  white-space: pre-line;
  text-align: center;
}

.lot-actions {
  justify-content: center;
}

.is-hidden {
  display: none;
}

.lot-card.empty .lot-actions {
  opacity: 0.72;
}

.lot-card.empty .lot-stick {
  min-height: 250px;
}

.lot-card.empty #lotStem {
  font-size: clamp(2.7rem, 7vw, 4rem);
}

.lot-card.confirmed {
  border-color: rgba(188, 139, 44, 0.48);
  box-shadow: 0 16px 44px rgba(188, 139, 44, 0.14);
}

.lot-card.confirmed .lot-stick {
  border-color: rgba(31, 122, 98, 0.36);
  border-top-color: rgba(31, 122, 98, 0.54);
  border-bottom-color: rgba(31, 122, 98, 0.54);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.steps div {
  min-height: 126px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.steps strong {
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--jade);
}

.steps span {
  display: block;
  color: #42514b;
  line-height: 1.75;
}

.about h2 {
  margin-bottom: 10px;
}

.about p:last-child {
  max-width: 52rem;
  color: #42514b;
  line-height: 1.9;
}

footer {
  padding: 20px 2px 0;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 640px);
    padding-top: 10px;
  }

  .draw-grid,
  .steps {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
    line-height: 1.16;
  }

  h2 {
    font-size: 1.45rem;
  }

  .panel,
  .lot-card {
    padding: 22px;
  }

  .draw-grid {
    min-height: auto;
  }

  .draw-panel,
  .lot-card {
    min-height: auto;
  }

  .draw-controls .button--primary {
    min-width: 0;
    min-height: 60px;
    font-size: 1.35rem;
  }

  .lottery-tube {
    height: 210px;
    margin-bottom: 6px;
  }

  .tube-image {
    height: 210px;
  }

  .draw-controls .icon-button {
    position: static;
    transform: none;
  }

  #lotStem {
    font-size: clamp(3.1rem, 15vw, 4.6rem);
  }

  .lot-stick {
    min-height: 290px;
  }

  .checker {
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .draw-controls .button {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  .draw-controls {
    width: 100%;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .draw-controls .icon-button {
    flex: 0 0 48px;
  }
}
