:root {
  --game-bg: radial-gradient(circle at 50% 25%, #fff8e1 0%, #ffecb3 45%, #ffe082 100%);
}

.top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 16px;
  box-sizing: border-box;
  gap: 12px;
  z-index: 30;
}

.top-controls .instruction-banner {
  flex: 1;
  margin: 0;
}

.push-btn {
  background: linear-gradient(135deg, #ff5722 0%, #e64a19 100%);
  color: #ffffff;
  border: 2px solid #ffab91;
  font-size: 16px;
  font-weight: 800;
  padding: 6px 18px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(230, 74, 25, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, opacity 0.2s;
  outline: none;
}

.push-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(230, 74, 25, 0.5);
}

.push-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.push-btn:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.push-btn.ready-topple {
  animation: push-pulse 1s infinite alternate;
}

@keyframes push-pulse {
  0% { transform: scale(1); box-shadow: 0 4px 14px rgba(230, 74, 25, 0.4); }
  100% { transform: scale(1.08); box-shadow: 0 6px 20px rgba(230, 74, 25, 0.7); }
}

.push-btn:focus-visible {
  outline: 3px solid #ffb300;
  outline-offset: 2px;
}

.topple-field {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 20px;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.topple-field:focus-visible {
  outline: 4px solid #ffb300;
  outline-offset: -4px;
}

/* Warm Nursery Room Lighting */
.room-lighting {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 10%, rgba(255, 255, 255, 0.45) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
}

/* Tower Construction Stage */
.tower-stage {
  position: relative;
  width: min(85vw, 360px);
  height: min(72vh, 480px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  z-index: 5;
}

.blocks-container {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  padding-bottom: 2px;
  z-index: 10;
}

/* Wooden Toy Block */
.toy-block {
  width: 125px;
  height: 56px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 4px 6px rgba(255, 255, 255, 0.4), inset 0 -4px 6px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 3px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  animation: block-drop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.45s ease;
  cursor: pointer;
}

.block-color-0 { background: #e53935; }
.block-color-1 { background: #1e88e5; }
.block-color-2 { background: #43a047; }
.block-color-3 { background: #8e24aa; }
.block-color-4 { background: #fb8c00; }

.toy-block.roof-block {
  width: 135px;
  height: 56px;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  border-radius: 6px;
  background: linear-gradient(135deg, #ffd54f 0%, #ffb300 50%, #ff8f00 100%) !important;
  color: #5d4037;
  padding-top: 14px;
}

@keyframes block-drop {
  0% { transform: translateY(-120px) scale(0.7); opacity: 0; }
  70% { transform: translateY(6px) scale(1.05); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* Wobbly Tower leaning states */
.wobble-1 { transform: rotate(1.5deg); }
.wobble-2 { transform: rotate(-2.5deg); }
.wobble-3 { transform: rotate(4deg); }
.wobble-4 { transform: rotate(-5.5deg); }
.wobble-5 { transform: rotate(7deg); }
.wobble-6 { transform: rotate(-8deg); }

/* Toppled Blocks scattered trajectories */
.block-toppled-0 { transform: translate(-140px, 90px) rotate(-65deg) !important; opacity: 0.9; }
.block-toppled-1 { transform: translate(-75px, 75px) rotate(-35deg) !important; opacity: 0.9; }
.block-toppled-2 { transform: translate(50px, 105px) rotate(45deg) !important; opacity: 0.9; }
.block-toppled-3 { transform: translate(130px, 85px) rotate(60deg) !important; opacity: 0.9; }
.block-toppled-4 { transform: translate(-10px, 120px) rotate(-15deg) !important; opacity: 0.9; }
.block-toppled-5 { transform: translate(90px, 115px) rotate(80deg) !important; opacity: 0.9; }

/* Smooth fade out when topple round completes */
.block-topple-fade {
  opacity: 0 !important;
  transform: scale(0.85);
  transition: opacity 0.45s ease-out, transform 0.45s ease-out !important;
}

/* Wooden Play Table */
.floor-table {
  position: relative;
  width: 100%;
  height: 38px;
  background: linear-gradient(180deg, #a1887f 0%, #8d6e63 40%, #5d4037 100%);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25), inset 0 3px 4px rgba(255, 255, 255, 0.3);
  border-top: 3px solid #bcaaa4;
  z-index: 8;
}

.table-grain {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 30px, rgba(0, 0, 0, 0.04) 30px, rgba(0, 0, 0, 0.04) 60px);
  pointer-events: none;
}

/* Cheering Mascot Friend */
.cheer-mascot {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 25;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.mascot-icon {
  font-size: 54px;
  line-height: 1;
  display: inline-block;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.2));
  animation: mascot-idle 3.5s ease-in-out infinite alternate;
}

@keyframes mascot-idle {
  0% { transform: translateY(0) rotate(-3deg); }
  100% { transform: translateY(-6px) rotate(3deg); }
}

.cheer-mascot:hover,
.cheer-mascot:active {
  transform: scale(1.2) rotate(8deg);
}

.cheer-mascot.mascot-cheering .mascot-icon {
  animation: mascot-jump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) infinite alternate;
}

@keyframes mascot-jump {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(1.2) translateY(-20px) rotate(10deg); }
}

.cheer-mascot:focus-visible {
  outline: 3px solid #ffb300;
  border-radius: 50%;
}

.mascot-spark {
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 26px;
  animation: spark-pop 0.6s ease-out infinite alternate;
}

@keyframes spark-pop {
  0% { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* Confetti & Star Bursts */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 35;
}

.confetti-piece {
  position: absolute;
  font-size: 24px;
  line-height: 1;
  pointer-events: none;
  animation: confetti-scatter 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes confetti-scatter {
  0% { transform: translate(0, 0) scale(0.3) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, 100px)) scale(1.2) rotate(var(--rot, 360deg)); opacity: 0; }
}

@media (max-height: 600px) {
  .topple-field { padding-bottom: 10px; }
  .tower-stage { height: min(68vh, 320px); }
  .floor-table { height: 28px; }
  .toy-block { width: 105px; height: 42px; font-size: 22px; margin-bottom: 2px; }
  .toy-block.roof-block { width: 115px; height: 42px; padding-top: 10px; }
  .mascot-icon { font-size: 42px; }
  .cheer-mascot { bottom: 10px; left: 10px; }
  .push-btn { font-size: 14px; padding: 5px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .toy-block,
  .block-drop,
  .block-topple-fade,
  .mascot-icon,
  .mascot-spark,
  .confetti-piece,
  .push-btn {
    animation: none !important;
    transition: none !important;
  }
}
