/**
 * Toy Blast Studio Stylesheet
 * Tactile 3D Molded Plastic Toy Blocks, Embossed Colorblind Motifs,
 * Warm Toy-Box Bezels, and Directional Propellers.
 */

.toyblast-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Toy-Box HUD Header --- */
.toyblast-hud {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.92) 0%, rgba(17, 24, 39, 0.95) 100%);
  border: 2.5px solid var(--board-bezel-border, #fbbf24);
  border-radius: 18px;
  padding: 8px 12px;
  gap: 8px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.38), 0 10px 24px rgba(0, 0, 0, 0.32);
}

.toyblast-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toyblast-level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  border: 2px solid #fef3c7;
  border-radius: 12px;
  padding: 4px 10px;
  min-width: 54px;
  box-shadow: 0 3px 0 #92400e;
}

.toyblast-level-badge .level-lbl {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: #451a03;
  font-weight: 900;
}

.toyblast-level-badge .level-num {
  font-size: 1.2rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  line-height: 1.05;
}

/* Goals Bar */
.toyblast-goals {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.tb-goal-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  padding: 4px 9px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tb-goal-pill.done {
  background: rgba(16, 185, 129, 0.28);
  border-color: #34d399;
}

.tb-goal-cube {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  display: inline-block;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

.tb-cube-red { background: linear-gradient(180deg, #ff5e6c, #e11d48); }
.tb-cube-blue { background: linear-gradient(180deg, #38bdf8, #2563eb); }
.tb-cube-green { background: linear-gradient(180deg, #4ade80, #16a34a); }
.tb-cube-yellow { background: linear-gradient(180deg, #fde047, #eab308); }
.tb-cube-purple { background: linear-gradient(180deg, #c084fc, #9333ea); }

.tb-goal-count {
  font-size: 0.86rem;
  font-weight: 900;
  color: #ffffff;
  min-width: 16px;
  text-align: center;
}

.goal-check {
  color: #34d399;
}

/* Moves Left */
.toyblast-moves {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ec4899 0%, #be185d 100%);
  border: 2px solid #fbcfe8;
  border-radius: 12px;
  padding: 4px 10px;
  min-width: 56px;
  box-shadow: 0 3px 0 #831843;
  transition: background 0.3s ease, transform 0.2s ease;
}

.toyblast-moves.moves-low {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  border-color: #fecaca;
  animation: movesPulse 1.1s infinite alternate ease-in-out;
}

@keyframes movesPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.06); }
}

.toyblast-moves .moves-count {
  font-size: 1.25rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
}

.toyblast-moves .moves-lbl {
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #fce7f3;
}

/* Score Bar & Stars */
.toyblast-score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 10px;
  padding: 5px 10px;
}

.tb-score-info {
  display: flex;
  gap: 6px;
  align-items: baseline;
  min-width: 92px;
}

.tb-score-lbl {
  font-size: 0.65rem;
  font-weight: 800;
  color: #cbd5e1;
}

.tb-score-val {
  font-size: 0.95rem;
  font-weight: 900;
  color: #fde047;
}

.tb-star-meter {
  flex: 1;
}

.tb-star-track {
  position: relative;
  height: 9px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  overflow: visible;
}

.tb-star-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fde047);
  border-radius: 6px;
  transition: width 0.3s ease-out;
}

.tb-star-node {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.32);
  transition: color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tb-star-node.star-1 { left: 30%; }
.tb-star-node.star-2 { left: 65%; }
.tb-star-node.star-3 { left: 95%; }

.tb-star-node.lit {
  color: #fde047;
  transform: translate(-50%, -50%) scale(1.25);
  filter: drop-shadow(0 0 5px rgba(250, 204, 21, 0.85));
}

/* --- Main Toy-Box Board Grid --- */
.toyblast-board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
}

.toyblast-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 8), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 8), 1fr);
  gap: 5px;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
  background: var(--board-bezel-bg, linear-gradient(180deg, #1e293b 0%, #0f172a 100%));
  border: 4px solid var(--board-bezel-border, #fbbf24);
  border-radius: 22px;
  padding: 9px;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.55), 0 8px 0 rgba(0, 0, 0, 0.35), 0 14px 32px rgba(0, 0, 0, 0.45);
}

.toyblast-grid.board-shake {
  animation: boardShake 0.3s ease-in-out;
}

@keyframes boardShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 3px); }
  50% { transform: translate(4px, -3px); }
  75% { transform: translate(-3px, -2px); }
}

/* Individual 3D Molded Plastic Toy Cube */
.tb-cell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 0 var(--cube-lip, rgba(0, 0, 0, 0.38)), inset 0 2px 1px rgba(255, 255, 255, 0.48);
}

.tb-cell:active {
  transform: translateY(2px) scale(0.95);
}

.tb-cell.shake {
  animation: shakeCell 0.3s ease-in-out;
}

@keyframes shakeCell {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.tb-cell.empty {
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
  cursor: default;
}

/* Toy Cube Colors with Chunky 3D Bottom Lips */
.tb-cell.color-red {
  --cube-lip: #9f1239;
  background: linear-gradient(180deg, #ff5e6c 0%, #e11d48 100%);
  border: 1.5px solid #fda4af;
}

.tb-cell.color-blue {
  --cube-lip: #1e40af;
  background: linear-gradient(180deg, #38bdf8 0%, #2563eb 100%);
  border: 1.5px solid #93c5fd;
}

.tb-cell.color-green {
  --cube-lip: #166534;
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  border: 1.5px solid #86efac;
}

.tb-cell.color-yellow {
  --cube-lip: #a16207;
  background: linear-gradient(180deg, #fde047 0%, #eab308 100%);
  border: 1.5px solid #fef9c3;
}

.tb-cell.color-purple {
  --cube-lip: #6b21a8;
  background: linear-gradient(180deg, #c084fc 0%, #9333ea 100%);
  border: 1.5px solid #e9d5ff;
}

/* Specular Top Gloss Pill */
.tb-cube-face {
  position: absolute;
  top: 3px;
  left: 4px;
  right: 4px;
  height: 32%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0%, rgba(255, 255, 255, 0.08) 100%);
  border-radius: 7px 7px 12px 12px;
  pointer-events: none;
}

/* Embossed Toy Motif Symbol (Heart, Waterdrop, Clover, Star, Diamond) */
.tb-cube-motif {
  width: 52%;
  height: 52%;
  color: rgba(255, 255, 255, 0.32);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.28));
  pointer-events: none;
  z-index: 2;
}

.tb-cell.color-yellow .tb-cube-motif {
  color: rgba(113, 63, 18, 0.28);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
}

/* Boosters */
.tb-booster {
  animation: boosterPulse 1.6s infinite alternate ease-in-out;
}

@keyframes boosterPulse {
  0% { transform: scale(1); filter: brightness(1); }
  100% { transform: scale(1.05); filter: brightness(1.15); }
}

.tb-rotor-h, .tb-rotor-v {
  --cube-lip: #9a3412;
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
  border: 2px solid #fed7aa;
}

.tb-bomb {
  --cube-lip: #0f172a;
  background: linear-gradient(180deg, #475569 0%, #1e293b 100%);
  border: 2px solid #f87171;
}

.tb-disco {
  --cube-lip: #4c1d95;
  background: linear-gradient(135deg, #ec4899, #8b5cf6, #06b6d4);
  border: 2px solid #ffffff;
}

/* Obstacles */
.tb-crate {
  --cube-lip: #451a03;
  background: linear-gradient(180deg, #d97706 0%, #92400e 100%);
  border: 2px solid #fde68a;
}

.tb-duck {
  --cube-lip: #a16207;
  background: linear-gradient(180deg, #fef9c3 0%, #facc15 100%);
  border: 2px solid #ffffff;
  animation: duckWobble 2s infinite ease-in-out;
}

@keyframes duckWobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-4deg); }
  75% { transform: rotate(4deg); }
}

.tb-bubble-overlay {
  position: absolute;
  inset: -3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7dd3fc;
  pointer-events: none;
  z-index: 4;
  animation: bubbleShimmer 2.2s infinite alternate ease-in-out;
}

@keyframes bubbleShimmer {
  0% { transform: scale(0.97); opacity: 0.85; }
  100% { transform: scale(1.03); opacity: 1; }
}

/* Particles Burst */
.tb-particle-burst {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
}

.tb-sparkle-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fde047;
  border-radius: 50%;
  transform: rotate(var(--angle)) translateY(0);
  animation: sparkleFly 0.5s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes sparkleFly {
  to {
    transform: rotate(var(--angle)) translateY(-42px);
    opacity: 0;
  }
}

/* --- Bottom Footer Controls --- */
.toyblast-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tb-ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.9) 0%, rgba(17, 24, 39, 0.95) 100%);
  border: 2px solid rgba(251, 191, 36, 0.45);
  border-radius: 14px;
  padding: 8px 14px;
  color: #fef3c7;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: all 0.15s ease;
}

.tb-ctrl-btn:active {
  transform: translateY(2px);
}

/* --- Modals --- */
.tb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 36, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.tb-modal-card {
  background: linear-gradient(165deg, #1e3a8a 0%, #0f172a 100%);
  border: 2.5px solid #fbbf24;
  border-radius: 24px;
  width: 100%;
  max-width: 380px;
  padding: 24px 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
  text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.tb-victory-trophy {
  color: #fde047;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 16px rgba(250, 204, 21, 0.6));
}

.tb-modal-header h2 {
  font-size: 1.4rem;
  font-weight: 900;
  color: #fef3c7;
  margin: 0 0 4px;
}

.tb-modal-header p {
  font-size: 0.9rem;
  color: #bae6fd;
  margin: 0;
}

.tb-stars-earned {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
}

.tb-stars-earned .star-pill {
  color: rgba(255, 255, 255, 0.22);
  transition: transform 0.4s ease;
}

.tb-stars-earned .star-pill.earned {
  color: #fde047;
  transform: scale(1.15);
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.75));
}

.tb-victory-stats {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tb-victory-stats .v-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.tb-victory-stats .stat-l { color: #cbd5e1; font-weight: 700; }
.tb-victory-stats .stat-v {
  color: #fde047;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tb-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tb-modal-btn {
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  border: none;
  min-height: 48px;
  transition: transform 0.15s ease, filter 0.2s ease;
}

.tb-modal-btn.primary {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 0 #065f46;
}

.tb-modal-btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
}

/* Guide scroll */
.tb-guide-scroll {
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
  margin: 14px 0;
  padding-right: 4px;
}

.guide-section {
  margin-bottom: 14px;
}

.guide-section h3 {
  font-size: 0.95rem;
  color: #fde047;
  margin: 0 0 8px;
}

.guide-section p, .guide-section ul {
  font-size: 0.84rem;
  color: #e2e8f0;
  line-height: 1.4;
  margin: 0 0 8px;
}

.guide-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 9px 12px;
  border-radius: 12px;
}

.guide-item .g-icon {
  color: #fde047;
  flex-shrink: 0;
}

.guide-item .g-text strong {
  display: block;
  font-size: 0.85rem;
  color: #ffffff;
}

.guide-item .g-text p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #cbd5e1;
}

/* Levels Grid Modal */
.tb-levels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
  max-height: 45vh;
  overflow-y: auto;
}

.tb-lvl-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  cursor: pointer;
  color: #ffffff;
  min-height: 74px;
  transition: all 0.15s ease;
}

.tb-lvl-card.active {
  border-color: #fde047;
  background: rgba(245, 158, 11, 0.25);
}

.tb-lvl-card .lvl-num {
  font-size: 1.2rem;
  font-weight: 900;
  color: #fde047;
}

.tb-lvl-card .lvl-name {
  font-size: 0.75rem;
  color: #e2e8f0;
  margin: 2px 0 4px;
  font-weight: 700;
}

.lvl-stars {
  display: flex;
  gap: 3px;
  color: rgba(255, 255, 255, 0.25);
}

.lvl-stars .lit {
  color: #fde047;
}
