/* Cup Tower — reward mini-game overlay (Cup Hunt) */

.tw {
  position: fixed;
  inset: 0;
  z-index: 100;
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  color: #263238;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
.tw[hidden] {
  display: none;
}
.tw-canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: pointer;
}

.tw-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}
.tw-flash.is-on {
  animation: tw-flash 0.45s ease-out;
}
@keyframes tw-flash {
  0% { opacity: var(--flash, 0.6); }
  100% { opacity: 0; }
}

/* ── top bar ── */
.tw-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  width: max-content;
  max-width: calc(100% - 20px);
  background: #fff;
  border: 4px solid #263238;
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(38, 50, 56, 0.35);
  pointer-events: none;
}
.tw-top[hidden] {
  display: none;
}
.tw-title {
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
}
.tw-drops {
  display: flex;
  gap: 5px;
}
.tw-drops i {
  width: 16px;
  height: 20px;
  background: #cfd8dc;
  border: 3px solid #263238;
  clip-path: polygon(14% 0, 86% 0, 100% 100%, 0 100%);
  border-radius: 3px;
}
.tw-drops i.on {
  background: #ef5350;
}
.tw-height {
  font-weight: 600;
  white-space: nowrap;
  background: #fff3c4;
  border-radius: 999px;
  padding: 2px 10px;
}
.tw-height b {
  font-size: 1.2rem;
}
.tw-height.is-bump {
  animation: tw-bump 0.4s ease-out;
}
@keyframes tw-bump {
  40% { transform: scale(1.3); }
}

.tw-hint {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: #ffeb3b;
  border: 4px solid #263238;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.25rem;
  white-space: nowrap;
  pointer-events: none;
  animation: tw-hint 1s ease-in-out infinite;
}
.tw-hint[hidden] {
  display: none;
}
@keyframes tw-hint {
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ── panels ── */
.tw-panel {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 16px;
  background: rgba(38, 50, 56, 0.35);
  overflow-y: auto;
}
.tw-panel[hidden] {
  display: none;
}
.tw-card {
  width: min(420px, 100%);
  min-width: 0;
  box-sizing: border-box;
  background: #fff;
  border: 5px solid #263238;
  border-radius: 28px;
  box-shadow: 0 8px 0 rgba(38, 50, 56, 0.4);
  padding: 18px 18px 16px;
  text-align: center;
}
.tw-card--style {
  width: min(560px, 100%);
}
.tw-card.is-pop {
  animation: tw-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes tw-pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.tw-card__title {
  margin: 0 0 10px;
  font-size: 1.7rem;
  font-weight: 700;
}
.tw-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.tw-stat {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #e3f2fd;
  border: 3px solid #263238;
  border-radius: 18px;
  padding: 6px 4px;
}
.tw-stat__icon {
  font-size: 1.4rem;
}
.tw-stat b {
  font-size: 1.5rem;
  line-height: 1.1;
}
.tw-stat span:last-child {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.75;
}

.tw-unlock {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: linear-gradient(135deg, #fff59d, #ffcc80);
  border: 4px solid #263238;
  border-radius: 20px;
  padding: 8px;
  margin-bottom: 12px;
  animation: tw-glow 1.4s ease-in-out infinite;
}
@keyframes tw-glow {
  50% { box-shadow: 0 0 0 6px rgba(255, 235, 59, 0.55); }
}
.tw-unlock img {
  width: 96px;
  height: 60px;
  object-fit: cover;
  border: 3px solid #263238;
  border-radius: 12px;
  background: #fff;
}
.tw-unlock div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.tw-unlock__new {
  font-size: 0.75rem;
  font-weight: 700;
  color: #d84315;
  letter-spacing: 0.05em;
}
.tw-unlock b {
  font-size: 1.2rem;
}

.tw-next {
  margin: 0 0 14px;
  font-weight: 600;
  font-size: 0.95rem;
}
.tw-next__bar {
  margin-top: 6px;
  height: 16px;
  background: #eceff1;
  border: 3px solid #263238;
  border-radius: 999px;
  overflow: hidden;
}
.tw-next__bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #66bb6a, #aed581);
  border-radius: 999px;
}

.tw-card__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.tw-btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 10px 18px;
  min-height: 48px;
  color: #263238;
  border: 4px solid #263238;
  border-radius: 999px;
  box-shadow: 0 4px 0 #263238;
  cursor: pointer;
  transition: transform 0.08s;
}
.tw-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #263238;
}
.tw-btn--go {
  background: #66bb6a;
  color: #fff;
  text-shadow: 0 2px 0 #263238;
}
.tw-btn--style {
  background: #ce93d8;
}
.tw-btn--small {
  font-size: 0.9rem;
  min-height: 36px;
  padding: 4px 14px;
  background: #fff;
  margin-top: 4px;
}
.tw-btn:disabled {
  opacity: 0.8;
  cursor: default;
}

/* ── style picker ── */
.tw-style__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tw-style__head .tw-card__title {
  margin: 0;
}
.tw-style__tower {
  font-weight: 700;
  background: #fff3c4;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}
.tw-style__sub {
  margin: 12px 0 6px;
  text-align: left;
  font-size: 1rem;
  font-weight: 700;
}
.tw-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  min-width: 0;
  gap: 8px;
}
.tw-pick {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 5px;
  min-width: 0;
  background: #fff;
  border: 3px solid #263238;
  border-radius: 16px;
  cursor: pointer;
  color: #263238;
}
.tw-pick img {
  width: 100%;
  aspect-ratio: 8 / 5;
  object-fit: cover;
  border-radius: 10px;
  background: #eceff1;
}
.tw-pick span {
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.1;
}
.tw-pick.is-on {
  background: #c8e6c9;
  box-shadow: 0 0 0 4px #66bb6a;
}
.tw-pick.is-locked {
  cursor: default;
  background: #eceff1;
}
.tw-pick.is-locked img {
  filter: grayscale(1) brightness(0.7);
}
.tw-style__tip {
  margin: 12px 0;
  font-weight: 600;
  opacity: 0.75;
}

/* ── phones ── */
@media (max-width: 430px) {
  .tw-top {
    gap: 8px;
    padding: 6px 12px;
  }
  .tw-title {
    font-size: 1rem;
  }
  .tw-card__title {
    font-size: 1.45rem;
  }
  .tw-picks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── short landscape (phone on its side) ── */
@media (max-height: 500px) and (orientation: landscape) {
  .tw-panel {
    place-items: start center;
    padding: 10px;
  }
  .tw-card {
    width: min(620px, 100%);
    padding: 10px 14px;
  }
  .tw-card--style {
    width: min(720px, 100%);
  }
  .tw-card__title {
    font-size: 1.3rem;
    margin-bottom: 6px;
  }
  .tw-stats {
    margin-bottom: 8px;
  }
  .tw-stat {
    flex-direction: row;
    gap: 6px;
    max-width: 170px;
    padding: 2px 8px;
  }
  .tw-stat__icon {
    font-size: 1.1rem;
  }
  .tw-stat b {
    font-size: 1.2rem;
  }
  .tw-unlock {
    margin-bottom: 8px;
    padding: 5px;
  }
  .tw-unlock img {
    width: 72px;
    height: 45px;
  }
  .tw-next {
    margin-bottom: 8px;
  }
  .tw-picks {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .tw-style__sub {
    margin: 6px 0 4px;
  }
  .tw-style__tip {
    margin: 6px 0;
  }
  .tw-btn {
    min-height: 42px;
    padding: 6px 16px;
  }
  .tw-hint {
    font-size: 1rem;
    padding: 6px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tw-hint,
  .tw-unlock,
  .tw-card.is-pop,
  .tw-height.is-bump {
    animation: none;
  }
}
