.stack-daily-challenge {
  --stack-tile: 54px;
  --stack-gap: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.stack-daily-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #eef7ff, #f5f1ff);
}

.stack-daily-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.stack-daily-head p:not(.daily-kicker) {
  margin: 5px 0 0;
  color: var(--muted);
}

.daily-kicker {
  margin: 0 0 4px;
  color: #6d28d9;
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.daily-status-pill {
  flex: 0 0 auto;
  border: 1px solid #d8d1f0;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, .82);
  color: #5b21b6;
  font-size: .76rem;
  font-weight: 850;
}

.stack-daily-meta {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 14px 18px 0;
}

.stack-daily-meta div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: #f8fbff;
}

.stack-daily-meta dt {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 750;
}

.stack-daily-meta dd {
  margin: 2px 0 0;
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  text-transform: capitalize;
  white-space: nowrap;
}

.stack-daily-playfield {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 0;
  margin: 14px 18px 0;
  overflow: hidden;
  contain: layout paint;
  border: 1px solid #ded8f2;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f3efff);
}

.stack-daily-hand-zone {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 18px 12px;
  border-right: 1px solid #ded8f2;
  background: rgba(255, 255, 255, .5);
}

.stack-daily-hand-zone > span {
  color: #493a69;
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stack-daily-hand-zone small {
  max-width: 105px;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
}

.stack-daily-hand {
  display: grid;
  width: calc(var(--stack-tile) + 15px);
  height: calc(var(--stack-tile) + 15px);
  place-items: center;
  border: 2px dashed #c9b9ef;
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
}

.stack-daily-board-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  contain: layout paint;
  padding: 22px 12px 20px;
}

.stack-daily-rack {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 382px;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  overflow: clip;
  contain: layout paint;
  touch-action: manipulation;
}


button.stack-daily-column {
  position: relative;
  display: grid;
  flex: 0 0 calc(var(--stack-tile) + 10px);
  width: calc(var(--stack-tile) + 10px);
  min-width: 0;
  min-height: 0;
  align-content: end;
  overflow: clip;
  border: 2px solid transparent;
  padding: 29px 3px 7px;
  background: transparent;
  box-shadow: none;
}

button.stack-daily-column:hover {
  border-color: rgba(109, 40, 217, .26);
  background: rgba(255, 255, 255, .62);
}

button.stack-daily-column:focus-visible {
  outline: 3px solid rgba(109, 40, 217, .34);
  outline-offset: 1px;
}

button.stack-daily-column.is-moving {
  border-color: #6d28d9;
  background: #f3efff;
}

button.stack-daily-column.is-locked {
  border-color: rgba(10, 143, 106, .3);
  background: #e9faf4;
  cursor: not-allowed;
}

button.stack-daily-column.is-invalid {
  animation: stack-daily-shake .25s ease-in-out;
}

.stack-daily-stack {
  display: grid;
  gap: var(--stack-gap);
  overflow: clip;
  border: 2px solid rgba(72, 64, 108, .58);
  border-radius: 7px;
  padding: 6px 4px;
  background: rgba(255, 255, 255, .58);
  box-shadow: inset 5px 0 9px rgba(255, 255, 255, .68), 0 8px 16px rgba(50, 41, 89, .09);
}

.stack-daily-column-check {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  display: none;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0a8f6a;
  color: #fff;
  font-size: .86rem;
  font-weight: 950;
  box-shadow: 0 4px 10px rgba(10, 143, 106, .24);
  transform: translateX(-50%);
}

.is-locked .stack-daily-column-check {
  display: grid;
}

.stack-daily-column-check.is-new {
  animation: stack-daily-check .34s ease-out;
}

.stack-daily-tile {
  --stack-color: #64748b;
  position: relative;
  display: grid;
  width: var(--stack-tile);
  height: var(--stack-tile);
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(30, 34, 54, .23);
  border-radius: 7px;
  background: var(--stack-color);
  color: #fff;
  box-shadow: inset 0 -7px 10px rgba(25, 28, 44, .2), inset 0 4px 7px rgba(255, 255, 255, .24), 0 3px 7px rgba(36, 39, 62, .14);
  font-size: .72rem;
  font-weight: 950;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .36);
  transform-style: preserve-3d;
}

.stack-daily-tile::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 7px;
  left: 7px;
  height: 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .28);
}

.stack-daily-tile > span {
  position: relative;
  z-index: 1;
}

.stack-color-1 { --stack-color: #e8494f; }
.stack-color-2 { --stack-color: #2874d0; }
.stack-color-3 { --stack-color: #15966d; }
.stack-color-4 {
  --stack-color: #e2a70c;
  color: #302600;
  text-shadow: none;
}
.stack-color-5 { --stack-color: #7b4acb; }
.stack-color-6 { --stack-color: #e56d24; }
.stack-color-7 { --stack-color: #d74494; }

.stack-daily-tile.is-hidden {
  border-color: #20283a;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .12) 0 7px, transparent 7px 14px),
    #39465c;
  box-shadow: inset 0 -7px 10px rgba(12, 17, 28, .36), inset 0 4px 7px rgba(255, 255, 255, .2), 0 0 0 2px #f8fafc, 0 0 0 4px #39465c;
}

.stack-daily-tile.is-hidden > span {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: rgba(17, 24, 39, .34);
  font-size: 1.42rem;
}

.stack-daily-tile.is-wild {
  border-color: #fff;
  background: conic-gradient(from 225deg, #e8494f, #e2a70c, #15966d, #2874d0, #7b4acb, #d74494, #e8494f);
  box-shadow: inset 0 -7px 10px rgba(25, 28, 44, .22), inset 0 4px 7px rgba(255, 255, 255, .3), 0 0 0 3px #f5b82e, 0 4px 12px rgba(109, 40, 217, .28);
}

.stack-daily-tile.is-wild > span {
  font-size: 1.42rem;
  text-shadow: 0 0 3px #fff, 0 2px 4px rgba(28, 18, 53, .55);
}

.stack-daily-hand .stack-daily-tile.is-revealing {
  animation: stack-daily-reveal .42s ease-out;
}

.stack-daily-motion-ghost {
  position: fixed;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  will-change: transform;
}

.stack-daily-status {
  min-height: 24px;
  margin: 12px 18px 0;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.stack-daily-status[data-tone="success"] {
  color: #087456;
}

.stack-daily-status[data-tone="error"] {
  color: #b4232f;
}

.stack-daily-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 2px 18px 16px;
}

.stack-daily-actions button {
  min-width: 118px;
  min-height: 44px;
}

.stack-daily-completion[hidden] {
  display: none;
}

.stack-daily-completion {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: center;
  margin: 0 18px 16px;
  border: 1px solid #a9e0cd;
  border-radius: 8px;
  padding: 12px;
  background: #e9faf4;
  color: #075f47;
}

.stack-daily-completion button {
  min-height: 44px;
}

.stack-daily-foot {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #f8fbff;
  color: var(--muted);
  font-size: .84rem;
}

.stack-daily-foot a {
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.daily-archive-list {
  display: grid;
  gap: 9px;
}

.daily-archive-row {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(220px, 1.5fr) minmax(85px, .5fr) minmax(120px, .7fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #fff;
}

.daily-archive-row div {
  display: grid;
}

.daily-archive-row span {
  color: var(--muted);
  font-size: .82rem;
  text-transform: capitalize;
}

@keyframes stack-daily-shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@keyframes stack-daily-reveal {
  0% { opacity: .25; transform: rotateY(90deg) scale(.92); }
  65% { transform: rotateY(-8deg) scale(1.04); }
  100% { opacity: 1; transform: rotateY(0) scale(1); }
}

@keyframes stack-daily-check {
  0% { opacity: 0; transform: translateX(-50%) scale(.4); }
  70% { transform: translateX(-50%) scale(1.15); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}

@media (max-width: 820px) {
  .stack-daily-challenge {
    --stack-tile: 50px;
  }

  .stack-daily-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stack-daily-playfield {
    grid-template-columns: 1fr;
  }

  .stack-daily-hand-zone {
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    border-right: 0;
    border-bottom: 1px solid #ded8f2;
    padding: 12px 16px;
  }

  .stack-daily-hand-zone small {
    max-width: none;
    text-align: left;
  }

  .stack-daily-rack {
    min-height: 355px;
    gap: 5px;
  }

  .daily-archive-row {
    grid-template-columns: 1fr 1fr;
  }

  .daily-archive-row .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .stack-daily-challenge {
    --stack-tile: 39px;
    --stack-gap: 4px;
  }

  .stack-daily-head {
    align-items: flex-start;
    padding: 16px 14px;
  }

  .daily-status-pill {
    border: 0;
    padding: 2px 0;
    background: transparent;
  }

  .stack-daily-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px 9px 0;
  }

  .stack-daily-playfield {
    margin: 10px 8px 0;
  }

  .stack-daily-hand-zone {
    grid-template-columns: auto auto;
    gap: 7px 11px;
    padding: 10px 12px;
  }

  .stack-daily-hand-zone small {
    grid-column: 1 / -1;
  }

  .stack-daily-hand {
    width: calc(var(--stack-tile) + 13px);
    height: calc(var(--stack-tile) + 13px);
  }

  .stack-daily-board-wrap {
    padding-right: 4px;
    padding-left: 4px;
  }

  .stack-daily-rack {
    min-height: 306px;
    gap: 0;
  }

  button.stack-daily-column {
    flex-basis: calc(var(--stack-tile) + 5px);
    width: calc(var(--stack-tile) + 5px);
    padding-right: 1px;
    padding-left: 1px;
  }

  .stack-daily-stack {
    padding-right: 2px;
    padding-left: 2px;
  }

  .stack-daily-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-right: 10px;
    padding-left: 10px;
  }

  .stack-daily-actions button {
    min-width: 0;
  }

  .stack-daily-actions button:last-child {
    grid-column: 1 / -1;
  }

  .stack-daily-foot {
    align-items: flex-start;
  }

  .daily-archive-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stack-daily-challenge *,
  .stack-daily-motion-ghost {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Keep the Daily game name primary and present generated level names as stable IDs. */
.stack-daily-head-details {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  align-items: center;
  margin-top: 8px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}
.stack-daily-level-label {
  border: 1px solid #cbc3e8;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, .86);
  color: #5324a6;
  font-weight: 900;
}
@media (max-width: 520px) {
  .stack-daily-head {
    display: block;
  }
  .stack-daily-head-details {
    gap: 6px 9px;
  }
  .stack-daily-head-details span:last-child {
    flex-basis: 100%;
  }
  .stack-daily-head .daily-status-pill {
    display: inline-flex;
    margin-top: 10px;
    border: 1px solid #d8d1f0;
    padding: 5px 8px;
    background: rgba(255, 255, 255, .82);
  }
}