.ld-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  margin-bottom: 20px;
}
@media (min-width: 860px) {
  .ld-grid {
    grid-template-columns: 320px 1fr;
    grid-template-areas: "entries stage" "history stage";
    align-items: start;
  }
  .ld-entries { grid-area: entries; }
  .ld-stage { grid-area: stage; }
  .ld-history { grid-area: history; }
}
.ld-check {
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
}
.ld-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--sg-blue);
}
.ld-center {
  text-align: center;
}

/* ------------------------------------------------------------------ stage */
.ld-stage {
  position: relative;
  display: grid;
  gap: 14px;
  justify-items: center;
}
.ld-top {
  width: 100%;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}
.ld-seg {
  display: inline-flex;
  border: 3px solid var(--sg-ink);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}
.ld-seg button {
  font: 500 15px var(--sg-font-th);
  border: 0;
  background: transparent;
  color: var(--sg-ink);
  padding: 6px 14px;
  cursor: pointer;
}
.ld-seg button + button {
  border-left: 2px solid var(--sg-ink);
}
.ld-seg button.active {
  background: var(--sg-yellow);
}

.ld-wheel-box {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1;
}
.ld-wheel {
  display: block;
  cursor: pointer;
  filter: drop-shadow(0 6px 0 rgba(35, 31, 32, 0.25));
}
.ld-pointer {
  position: absolute;
  left: 50%;
  top: -10px;
  width: 0;
  height: 0;
  margin-left: -18px;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 34px solid var(--sg-red, #e8202a);
  filter: drop-shadow(0 2px 0 var(--sg-ink));
  z-index: 2;
  transform-origin: 50% 0;
}
.ld-pointer.flap {
  animation: ld-flap 0.12s ease-out;
}
@keyframes ld-flap {
  40% { transform: rotate(-14deg); }
}
.ld-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid var(--sg-ink);
  background: #fff;
  padding: 6px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--sg-ink);
  display: grid;
  place-items: center;
}
.ld-hub img {
  width: 100%;
  height: auto;
  display: block;
}

.ld-flicker {
  width: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 3px dashed var(--sg-ink);
  border-radius: 18px;
  background: #fff9ed;
  padding: 20px;
  overflow: hidden;
}
.ld-flicker-text {
  font-family: "Kanit", var(--sg-font-th);
  font-weight: 700;
  font-size: clamp(32px, 7vw, 64px);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}
.ld-flicker-text.spinning {
  opacity: 0.8;
}
.ld-flicker-text.flick {
  animation: ld-flick 0.12s ease-out;
}
@keyframes ld-flick {
  from { transform: translateY(-40%) scale(0.92); opacity: 0.2; }
}
.ld-spin {
  max-width: 360px;
  font-size: 22px;
}

/* result card sits over the stage */
.ld-result {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(255, 249, 237, 0.7);
  border-radius: inherit;
}
.ld-result[hidden] {
  display: none;
}
.ld-result-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: #fff;
  border: 3px solid var(--sg-ink);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--sg-ink);
  padding: 18px;
  display: grid;
  gap: 12px;
  text-align: center;
  animation: ld-pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
@keyframes ld-pop {
  from { transform: scale(0.4); opacity: 0; }
}
.ld-result-label {
  color: var(--sk-muted);
}
.ld-result-name {
  font-family: "Kanit", var(--sg-font-th);
  font-weight: 800;
  font-size: clamp(34px, 8vw, 60px);
  line-height: 1.15;
  word-break: break-word;
}
.ld-confetti {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 2;
}
.ld-confetti i {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: ld-burst 1.3s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
@keyframes ld-burst {
  0% { transform: translate(0, 0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--x), calc(var(--y) + 120px)) rotate(var(--r)); opacity: 0; }
}

/* ------------------------------------------------------------------ history */
.ld-history-head {
  justify-content: space-between;
}
.ld-history h2 {
  font-size: 20px;
  margin: 0;
}
.ld-history-list {
  margin: 10px 0 0;
  padding-left: 28px;
  max-height: 260px;
  overflow: auto;
  line-height: 1.7;
}

/* ------------------------------------------------------------------ full screen (projector) */
.ld-stage:fullscreen,
.ld-stage.ld-big {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
  background: #fff9ed;
  align-content: center;
  padding: 16px;
}
.ld-stage:fullscreen .ld-wheel-box,
.ld-stage.ld-big .ld-wheel-box {
  width: min(78vh, 92vw);
}
.ld-stage:fullscreen .ld-flicker,
.ld-stage.ld-big .ld-flicker {
  width: min(1000px, 92vw);
  min-height: 50vh;
}
.ld-stage:fullscreen .ld-flicker-text,
.ld-stage.ld-big .ld-flicker-text {
  font-size: clamp(48px, 10vw, 120px);
}
.ld-stage:fullscreen .ld-top,
.ld-stage.ld-big .ld-top {
  width: min(1000px, 92vw);
}

@media (prefers-reduced-motion: reduce) {
  .ld-pointer.flap,
  .ld-flicker-text.flick,
  .ld-result-card {
    animation: none;
  }
}
