.ball-daily-challenge {
  --ball-accent: #6d28d9;
  --ball-accent-dark: #5520ad;
  --ball-teal: #0f9f84;
  --ball-amber: #d98705;
  width: min(980px, calc(100% - 32px));
  margin: 0 auto 30px;
  overflow: hidden;
  border: 1px solid rgba(109, 40, 217, .18);
  border-radius: var(--radius-lg, 28px);
  background: #fff;
  box-shadow: var(--shadow);
}

.ball-daily-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #eef5ff, #f3efff);
}

.ball-daily-head h2,
.ball-daily-head h3 {
  margin: 0;
}

.ball-daily-head p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
}

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

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

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

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

.ball-daily-playfield,
.ball-daily-replay-stage {
  position: relative;
  margin: 14px 18px 0;
  overflow: hidden;
  border: 1px solid rgba(109, 40, 217, .16);
  border-radius: 16px;
  background: linear-gradient(180deg, #fcfbff, #f1eeff);
}

.ball-daily-rack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 18px 10px;
  min-height: 256px;
  padding: 25px 14px 40px;
  touch-action: manipulation;
}

.ball-daily-rack-base {
  position: absolute;
  z-index: 0;
  right: 3%;
  bottom: 20px;
  left: 3%;
  height: 13px;
  border-radius: 7px;
  background: linear-gradient(180deg, #d5b98e, #a98251);
  box-shadow: 0 8px 13px rgba(84, 54, 25, .17);
}

.ball-daily-tube-button,
.ball-daily-replay-tube {
  position: relative;
  display: grid;
  width: 68px;
  min-height: 204px;
  justify-items: center;
  align-content: end;
  gap: 7px;
}

button.ball-daily-tube-button {
  min-width: 0;
  min-height: 204px;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 7px 2px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

button.ball-daily-tube-button:hover {
  border-color: rgba(109, 40, 217, .2);
  background: rgba(255, 255, 255, .65);
}

button.ball-daily-tube-button:focus-visible {
  outline: 3px solid rgba(109, 40, 217, .34);
  outline-offset: 2px;
}

.ball-daily-tube-button.is-selected {
  transform: translateY(-7px);
  border-color: var(--ball-accent);
  background: #f4efff;
}

.ball-daily-tube-button.is-legal-target {
  border-color: var(--ball-teal);
  background: #ecfaf6;
}

.ball-daily-tube-button.is-hint-source {
  border-color: var(--ball-amber);
  background: #fff7e8;
}

.ball-daily-tube-button.is-hint-target {
  border-color: var(--ball-teal);
  background: #ecfaf6;
  box-shadow: 0 0 0 3px rgba(15, 159, 132, .12);
}

.ball-daily-tube-button.is-invalid {
  animation: ball-daily-shake .24s ease-in-out;
}

.ball-daily-tube {
  position: relative;
  width: 58px;
  height: 180px;
  border: 3px solid rgba(72, 64, 108, .72);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  padding: 10px 7px 8px;
  background: linear-gradient(90deg, rgba(255,255,255,.78), rgba(255,255,255,.22) 47%, rgba(109,40,217,.04));
  box-shadow: inset 7px 0 11px rgba(255,255,255,.75), 0 10px 18px rgba(50, 41, 89, .11);
}

.ball-daily-tube::before {
  content: "";
  position: absolute;
  right: -7px;
  top: -5px;
  left: -7px;
  height: 10px;
  border: 3px solid rgba(72, 64, 108, .72);
  border-radius: 50%;
  background: rgba(255,255,255,.8);
}

.is-selected .ball-daily-tube,
.is-hint-source .ball-daily-tube {
  border-color: var(--ball-accent);
}

.is-selected .ball-daily-tube::before,
.is-hint-source .ball-daily-tube::before {
  border-color: var(--ball-accent);
}

.is-legal-target .ball-daily-tube,
.is-hint-target .ball-daily-tube {
  border-color: var(--ball-teal);
}

.is-legal-target .ball-daily-tube::before,
.is-hint-target .ball-daily-tube::before {
  border-color: var(--ball-teal);
}

.ball-daily-slots {
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 3px;
}

.ball-daily-slot {
  min-height: 36px;
  display: grid;
  place-items: center;
}

.ball-daily-ball {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid rgba(35, 31, 55, .18);
  border-radius: 50%;
  background: radial-gradient(circle at 31% 23%, rgba(255,255,255,.95) 0 7%, rgba(255,255,255,.32) 8% 20%, transparent 21%), var(--ball-color);
  box-shadow: inset -6px -7px 9px rgba(38, 24, 68, .2), 0 3px 5px rgba(48, 32, 80, .2);
  color: #fff;
  font-size: .66rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .62);
}

.ball-daily-ball.is-arriving {
  animation: ball-daily-arrive .32s ease-out;
}

.ball-daily-tube-label {
  color: #594e70;
  font-size: .78rem;
  font-weight: 850;
  white-space: nowrap;
}

.ball-daily-instruction {
  margin: 0;
  padding: 13px 18px 7px;
  color: var(--muted);
  text-align: center;
}

.ball-daily-status {
  min-height: 42px;
  margin: 0 18px 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbff;
  color: var(--muted);
  font-weight: 750;
  text-align: center;
}

.ball-daily-status.is-error {
  border-color: #f0b6bb;
  background: #fff0f1;
  color: #a32632;
}

.ball-daily-status.is-hint {
  border-color: #efcf92;
  background: #fff7e8;
  color: #825003;
}

.ball-daily-status.is-success {
  border-color: #a9dfd1;
  background: #ecfaf6;
  color: #08745f;
}

.ball-daily-status.is-working {
  border-color: #d2c4ef;
  background: #f4efff;
  color: var(--ball-accent-dark);
}

.ball-daily-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  padding: 0 18px 18px;
}

.ball-daily-actions button {
  min-width: 126px;
  min-height: 44px;
}

.ball-daily-actions button:last-child,
.ball-daily-completion button {
  border-color: var(--ball-accent);
  background: var(--ball-accent);
  color: #fff;
}

.ball-daily-completion {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  align-items: center;
  margin: 0 18px 16px;
  border: 1px solid #a9dfd1;
  border-radius: 12px;
  padding: 12px;
  background: #ecfaf6;
  color: #08745f;
}

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

.ball-daily-completion span {
  color: #286a5c;
}

.ball-daily-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcff;
  color: var(--muted);
}

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

.ball-daily-solution-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 0;
  color: var(--text);
  box-shadow: 0 30px 80px rgba(23, 19, 45, .34);
}

.ball-daily-solution-dialog::backdrop {
  background: rgba(23, 25, 46, .72);
}

.ball-daily-dialog-head {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.ball-daily-dialog-head h3 {
  margin: 0;
}

.ball-daily-solution-dialog > p {
  margin: 13px 18px;
  color: var(--muted);
  text-align: center;
}

.ball-daily-replay-stage {
  margin-top: 0;
}

.ball-daily-replay-stage .ball-daily-rack {
  min-height: 228px;
  padding-top: 20px;
}

.ball-daily-replay-stage .ball-daily-replay-tube {
  width: 58px;
  min-height: 181px;
}

.ball-daily-replay-stage .ball-daily-tube {
  width: 50px;
  height: 158px;
}

.ball-daily-replay-stage .ball-daily-slot {
  min-height: 31px;
}

.ball-daily-replay-stage .ball-daily-ball {
  width: 31px;
  height: 31px;
}

.ball-daily-replay-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.ball-daily-replay-actions button {
  min-width: 106px;
}

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

.daily-archive-row {
  display: grid;
  grid-template-columns: minmax(130px, .55fr) minmax(0, 1fr) repeat(2, minmax(90px, .35fr)) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius, 18px);
  background: #fff;
}

.daily-archive-row strong {
  display: block;
}

.daily-archive-row span {
  color: var(--muted);
}

@keyframes ball-daily-arrive {
  from { transform: translateY(-23px) scale(.82); opacity: .35; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes ball-daily-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

@media (max-width: 760px) {
  .ball-daily-challenge {
    width: calc(100% - 20px);
    border-radius: 20px;
  }

  .ball-daily-head {
    grid-template-columns: 1fr;
    padding: 17px 16px;
  }

  .ball-daily-head .daily-status-pill {
    width: fit-content;
  }

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

  .ball-daily-rack {
    column-gap: 6px;
    padding-inline: 8px;
  }

  .ball-daily-tube-button {
    width: 64px;
  }

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

@media (max-width: 560px) {
  .ball-daily-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-inline: 10px;
  }

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

  .ball-daily-rack {
    gap: 13px 4px;
    min-height: 215px;
    padding: 18px 5px 36px;
  }

  .ball-daily-tube-button,
  .ball-daily-replay-tube {
    width: 59px;
    min-height: 164px;
  }

  button.ball-daily-tube-button {
    min-height: 164px;
  }

  .ball-daily-tube {
    width: 49px;
    height: 142px;
    padding: 8px 5px 7px;
  }

  .ball-daily-slot {
    min-height: 28px;
  }

  .ball-daily-ball {
    width: 28px;
    height: 28px;
    font-size: .56rem;
  }

  .ball-daily-instruction {
    padding-inline: 10px;
  }

  .ball-daily-status {
    margin-inline: 10px;
  }

  .ball-daily-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 10px 12px;
  }

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

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

  .ball-daily-foot {
    display: grid;
    padding: 11px;
    text-align: center;
  }

  .ball-daily-solution-dialog {
    width: calc(100% - 12px);
    max-height: calc(100dvh - 12px);
  }

  .ball-daily-replay-stage {
    margin-inline: 7px;
  }

  .ball-daily-replay-actions {
    padding-inline: 9px;
  }

  .ball-daily-replay-actions button {
    min-width: 0;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ball-daily-tube-button,
  .ball-daily-ball {
    transition: none;
    animation: none;
  }
}
