/* ============================================================
   Star Stack — game-only styles (linked from games/star-stack.html)
   Uses site tokens from styles.css
   ============================================================ */

.star-game {
  position: relative;
  overflow: visible;
  padding-bottom: 20px;
}

.star-help {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.35;
  text-align: center;
}

/* ---- HUD ---- */
.star-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin-bottom: 7px;
}

.star-stat {
  min-width: 88px;
  min-height: 48px;
  padding: 6px 12px;
  text-align: center;
  background: var(--bg-window);
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0 var(--shadow);
}

.star-stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
}

.star-stat-value {
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
}

.star-status {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
}

/* ---- board shell: overflow visible so last-row tiles/shadows aren't clipped ---- */
.star-board-shell {
  display: flex;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 13px;
  padding: 8px 8px 12px;
  overflow: visible;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.92) 0 2px, transparent 3px),
    radial-gradient(circle at 82% 78%, rgba(255, 255, 255, 0.75) 0 2px, transparent 3px),
    linear-gradient(145deg, rgba(255, 214, 234, 0.82), rgba(203, 182, 240, 0.74));
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.75), 3px 3px 0 var(--shadow);
}

.star-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0 0 2px;
  overflow: visible;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.star-cell {
  min-width: 0;
  aspect-ratio: 1 / 1;
  background: rgba(255, 250, 253, 0.55);
  border: 1px solid rgba(155, 77, 138, 0.28);
  border-radius: 10px;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.65);
}

.star-tile {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.85),
    2px 2px 0 rgba(155, 77, 138, 0.28);
  color: var(--text-dark);
  font-family: sans-serif;
  line-height: 1;
  pointer-events: none;
  transition:
    left 120ms ease-out,
    top 120ms ease-out,
    transform 140ms ease,
    box-shadow 140ms ease;
  will-change: left, top, transform;
}

.star-tile-icon {
  font-size: clamp(22px, 9vw, 36px);
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.7));
}

.star-tile-badge {
  position: absolute;
  right: 4px;
  bottom: 3px;
  color: rgba(74, 31, 92, 0.55);
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  line-height: 1;
}

/* Tier pastel fills */
.star-tile.tier-1  { background: linear-gradient(180deg, #fff 0%, #ffe9f4 100%); }
.star-tile.tier-2  { background: linear-gradient(180deg, #fff8fc 0%, var(--yellow-soft) 100%); }
.star-tile.tier-3  { background: linear-gradient(180deg, #fff 0%, var(--pink-soft) 100%); }
.star-tile.tier-4  { background: linear-gradient(180deg, #f4f0ff 0%, var(--lavender) 100%); }
.star-tile.tier-5  { background: linear-gradient(180deg, #ffe8f2 0%, var(--pink) 100%); }
.star-tile.tier-6  { background: linear-gradient(180deg, #fff6ef 0%, #ffd4b8 100%); }
.star-tile.tier-7  { background: linear-gradient(180deg, #fff0f8 0%, #f5b4d8 100%); }
.star-tile.tier-8  { background: linear-gradient(180deg, #f8f0ff 0%, var(--periwinkle) 100%); }
.star-tile.tier-9  { background: linear-gradient(180deg, #e8fff6 0%, var(--mint) 100%); }
.star-tile.tier-10 { background: linear-gradient(180deg, #fff8d8 0%, #ffe07a 100%); }
.star-tile.tier-11 { background: linear-gradient(180deg, #eef6ff 0%, var(--blue-soft) 100%); }

.star-tile.is-new {
  animation: star-spawn 180ms ease-out;
}

.star-tile.is-merged {
  animation: star-merge-pop 220ms ease-out;
  z-index: 3;
}

@keyframes star-spawn {
  from { transform: scale(0.35); opacity: 0.4; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes star-merge-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.star-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 2px;
}

.star-back-btn {
  display: inline-block;
  text-decoration: none;
  font-size: 8px !important;
}

/* ---- overlays (win soft / game over) ---- */
.star-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(243, 238, 252, 0.86);
}

.star-overlay[hidden] {
  display: none !important;
}

.star-overlay-inner {
  width: 100%;
  max-width: 330px;
  padding: 20px 16px;
  text-align: center;
  background: var(--bg-window);
  border: 2px solid var(--border);
  box-shadow: 4px 4px 0 var(--shadow);
}

.star-overlay-title {
  margin: 0 0 11px;
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
}

.star-overlay-msg {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.35;
}

@media (max-width: 560px) {
  .star-board-shell {
    max-width: min(360px, 100%);
    padding: 6px 6px 10px;
  }
  .star-board { gap: 6px; }
  .star-tile {
    border-width: 1px;
    border-radius: 10px;
  }
  .star-tile-icon { font-size: clamp(20px, 10vw, 30px); }
}

@media (max-width: 380px) {
  .star-game { padding-left: 7px; padding-right: 7px; }
  .star-help { font-size: 16px; }
  .star-board { gap: 5px; }
  .star-board-shell { padding: 5px 5px 8px; }
  .star-tile { border-radius: 8px; }
  .star-tile-icon { font-size: clamp(18px, 9vw, 26px); }
  .star-tile-badge { font-size: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .star-tile {
    transition: none;
    animation: none !important;
  }
  .star-tile.is-new,
  .star-tile.is-merged {
    animation: none !important;
  }
}

/* Site chrome otherwise clips the last tile row + shadows */
.os-body.star-game {
  overflow: visible;
  padding-bottom: 20px;
}

/* Soft-win: optional "end here & save" link-button under Keep stacking */
.star-end-btn {
  display: block;
  margin: 10px auto 0;
  padding: 2px 6px;
  font-family: 'VT323', monospace;
  font-size: 17px;
  color: var(--link);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: url("../assets/cursor-pink.png?v=3") 13 6, pointer;
}

.star-end-btn:hover {
  color: var(--link-hover);
}
