:root {
  /* Colors */
  --color-primary: #ff4d5a;
  --color-secondary: #23a8ff;
  --color-accent: #ffd23f;
  --color-success: #42c86b;
  --color-bg: #e0f7fa;
  --color-text: #26384a;
  --color-text-light: #FFFFFF;
  --color-slot: rgba(255, 255, 255, 0.34);
  --color-slot-border: rgba(38, 56, 74, 0.28);
  --theme-a: #34d8ff;
  --theme-b: #42f59b;
  --theme-c: #ffd23f;
  --theme-ink: #26384a;
  
  /* Fonts */
  --font-heading: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;

  /* Shadows & Radius */
  --shadow-sm: 0 4px 10px rgba(25, 55, 90, 0.16);
  --shadow-md: 0 12px 24px rgba(25, 55, 90, 0.18);
  --shadow-lg: 0 24px 50px rgba(25, 55, 90, 0.24);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --radius-round: 50%;
}

* {
  box-sizing: border-box;
  user-select: none; /* Prevent text selection during drag */
  -webkit-user-select: none;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--theme-a);
  overflow: hidden; /* Prevent pull-to-refresh on mobile */
  overscroll-behavior: none;
  touch-action: none; /* Let JS handle touch for dragging */
  position: fixed;
  inset: 0;
  width: 100%;
}

/* Themes */
.theme-underwater {
  --theme-a: #19c7ff;
  --theme-b: #60f2cc;
  --theme-c: #ffdf5c;
  --theme-ink: #164d73;
  background:
    radial-gradient(circle at 16% 20%, rgba(255, 255, 255, 0.55) 0 10px, transparent 11px 100%),
    radial-gradient(circle at 82% 28%, rgba(255, 255, 255, 0.42) 0 15px, transparent 16px 100%),
    radial-gradient(circle at 72% 78%, rgba(255, 255, 255, 0.34) 0 9px, transparent 10px 100%),
    linear-gradient(135deg, #16b8ff 0%, #60f2cc 52%, #c8fff4 100%);
}
.theme-space {
  --theme-a: #3847ff;
  --theme-b: #9b5cff;
  --theme-c: #ffd84d;
  --theme-ink: #26225c;
  background:
    radial-gradient(circle at 14% 18%, #fff7a8 0 3px, transparent 4px),
    radial-gradient(circle at 72% 16%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 86% 62%, #fff7a8 0 4px, transparent 5px),
    radial-gradient(circle at 28% 76%, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    linear-gradient(135deg, #252b92 0%, #6b48df 55%, #ff79c6 100%);
}
.theme-jungle {
  --theme-a: #3bd65e;
  --theme-b: #a8f04d;
  --theme-c: #ffca3a;
  --theme-ink: #20522f;
  background:
    radial-gradient(ellipse at 16% 90%, rgba(22, 128, 48, 0.36) 0 90px, transparent 92px),
    radial-gradient(ellipse at 86% 86%, rgba(42, 170, 70, 0.34) 0 110px, transparent 112px),
    linear-gradient(135deg, #9af05b 0%, #46d661 48%, #1aa989 100%);
}

#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  max-width: 1000px;
  margin: 0 auto;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

#game-container::before,
#game-container::after {
  content: '';
  position: absolute;
  inset: auto;
  pointer-events: none;
  z-index: -1;
}

#game-container::before {
  width: 150%;
  height: 150%;
  left: -25%;
  top: -28%;
  background:
    radial-gradient(circle at 12% 46%, rgba(255, 255, 255, 0.42) 0 14px, transparent 15px),
    radial-gradient(circle at 72% 32%, rgba(255, 255, 255, 0.30) 0 18px, transparent 19px),
    radial-gradient(circle at 42% 70%, rgba(255, 255, 255, 0.25) 0 11px, transparent 12px),
    radial-gradient(circle at 86% 82%, rgba(255, 255, 255, 0.28) 0 13px, transparent 14px);
  animation: driftLayer 18s ease-in-out infinite alternate;
}

#game-container::after {
  width: 520px;
  height: 520px;
  right: -180px;
  bottom: -230px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.36), transparent 0 18%),
    radial-gradient(circle at 62% 62%, rgba(255, 210, 63, 0.36), transparent 0 20%),
    radial-gradient(circle, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
  filter: blur(1px);
  animation: slowSpin 28s linear infinite;
}

@keyframes driftLayer {
  0% { transform: translate3d(-18px, -8px, 0); }
  100% { transform: translate3d(26px, 18px, 0); }
}

@keyframes slowSpin {
  to { transform: rotate(360deg); }
}

/* Header */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(255,255,255,0.56);
  border-bottom: 2px solid rgba(255,255,255,0.64);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 28px rgba(35, 65, 90, 0.12);
}

.game-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin: 0;
  color: var(--theme-ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}

.icon-btn, .home-btn {
  background: linear-gradient(180deg, #fff, #f7fbff);
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-round);
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(27, 85, 128, 0.20), var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-btn:active, .home-btn:active {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 2px 0 rgba(27, 85, 128, 0.20), var(--shadow-sm);
}

/* Progress Strip */
.progress-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(255,255,255,0.36);
  font-weight: bold;
  color: var(--theme-ink);
  backdrop-filter: blur(12px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.sticker-book-btn {
  background: linear-gradient(180deg, #ffe878, var(--color-accent));
  border: 2px solid #fff;
  border-radius: var(--radius-md);
  padding: 5px 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #d99b00, var(--shadow-sm);
  transition: transform 160ms ease, filter 160ms ease;
}

.sticker-book-btn:hover {
  filter: saturate(1.12);
  transform: translateY(-1px) rotate(-1deg);
}

/* Main Area */
.main-play-area {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 10px;
  gap: 20px;
  position: relative;
}

/* Mascot */
.mascot-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
  position: relative;
}

.mascot {
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 14px 16px rgba(42, 72, 95, 0.22));
  animation: float 3s ease-in-out infinite;
  transform-origin: 50% 72%;
}

.mascot.celebrate {
  animation: mascotCelebrate 650ms cubic-bezier(0.22, 1.28, 0.36, 1);
}

.mascot.think {
  animation: mascotThink 520ms ease-in-out;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes mascotCelebrate {
  0% { transform: translateY(0) scale(1) rotate(0); }
  35% { transform: translateY(-18px) scale(1.12) rotate(-7deg); }
  70% { transform: translateY(3px) scale(0.98) rotate(5deg); }
  100% { transform: translateY(0) scale(1) rotate(0); }
}

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

.numbo-svg {
  overflow: visible;
}

.numbo-svg .eye-pupil {
  animation: blinkLook 4.5s ease-in-out infinite;
}

@keyframes blinkLook {
  0%, 88%, 100% { transform: translateX(0) scaleY(1); }
  90%, 93% { transform: translateX(1px) scaleY(0.18); }
  96% { transform: translateX(-1px) scaleY(1); }
}

.message-bubble {
  background: linear-gradient(180deg, #fff, #fff8d9);
  color: var(--color-text);
  padding: 10px;
  border-radius: var(--radius-md);
  box-shadow: 0 7px 0 rgba(214, 156, 15, 0.18), var(--shadow-md);
  font-family: var(--font-heading);
  font-size: 1rem;
  text-align: center;
  margin-top: 10px;
  position: absolute;
  top: 100%;
  width: 150px;
  z-index: 10;
  animation: bubblePop 260ms cubic-bezier(0.22, 1.28, 0.36, 1);
}
.message-bubble::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 10px 10px 10px;
  border-style: solid;
  border-color: transparent transparent #FFF transparent;
}

@keyframes bubblePop {
  0% { opacity: 0; transform: translateY(8px) scale(0.88); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.message-bubble.hint-bubble {
  position: fixed;
  top: auto;
  bottom: 18px;
  left: 50%;
  width: min(320px, calc(100vw - 32px));
  margin: 0;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 6px 16px rgba(31, 80, 116, 0.12);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 800;
  transform: translateX(-50%);
  animation: hintToastIn 180ms ease-out;
  pointer-events: none;
}

.message-bubble.hint-bubble::before {
  display: none;
}

@keyframes hintToastIn {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  100% { opacity: 1; transform: translate(-50%, 0); }
}

/* Board */
.board-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.puzzle-board {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  max-width: 600px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.58), rgba(255,255,255,0.26)),
    radial-gradient(circle at 12% 20%, rgba(255, 210, 63, 0.22), transparent 26%),
    radial-gradient(circle at 88% 78%, rgba(35, 168, 255, 0.20), transparent 30%);
  border-radius: var(--radius-lg);
  border: 3px solid rgba(255,255,255,0.48);
  box-shadow: inset 0 0 24px rgba(255,255,255,0.28), var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.puzzle-board::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius-lg) - 8px);
  border: 2px dashed rgba(255, 255, 255, 0.48);
  pointer-events: none;
}

.slot {
  width: 70px;
  height: 70px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.34), rgba(255,255,255,0.14)),
    var(--color-slot);
  border: 3px dashed var(--color-slot-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 2rem;
  color: rgba(38,56,74,0.24);
  position: relative;
  box-shadow: inset 0 4px 10px rgba(38, 56, 74, 0.14), 0 5px 0 rgba(255,255,255,0.28);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.slot::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.16);
  pointer-events: none;
}

.slot.empty-slot:hover,
.slot.count-slot:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.46);
}

.slot.hint-pulse {
  border-color: rgba(255, 210, 63, 0.95);
  box-shadow: inset 0 4px 10px rgba(38, 56, 74, 0.12), 0 0 0 7px rgba(255, 210, 63, 0.18);
  animation: slotHintPulse 1.2s ease-out;
}

@keyframes slotHintPulse {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.05); }
}

.slot.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(180deg, #fff, #fff6ca);
  color: var(--theme-ink);
  box-shadow: 0 6px 0 rgba(217, 155, 0, 0.28), var(--shadow-md);
  animation: tileLand 380ms cubic-bezier(0.22, 1.28, 0.36, 1);
}

.slot.success-burst::before {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: inherit;
  background:
    radial-gradient(circle at 15% 22%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 86% 20%, #ffe85f 0 5px, transparent 6px),
    radial-gradient(circle at 22% 85%, #5cf2ff 0 5px, transparent 6px),
    radial-gradient(circle at 80% 78%, #ff71a8 0 4px, transparent 5px);
  animation: burstFade 520ms ease-out forwards;
  pointer-events: none;
}

@keyframes tileLand {
  0% { transform: scale(0.72) rotate(-7deg); }
  65% { transform: scale(1.12) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes burstFade {
  0% { opacity: 0; transform: scale(0.62) rotate(0); }
  45% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.28) rotate(18deg); }
}

.count-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.count-objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 3.5rem;
  line-height: 1;
  max-width: 90%;
}

.count-objects span {
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
  transition: transform 0.2s;
}

.count-objects span:hover {
  transform: scale(1.2) rotate(10deg);
}

/* Tray */
.tray-area {
  padding: 15px;
  background: rgba(255,255,255,0.42);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border: 2px solid rgba(255,255,255,0.42);
  border-bottom: 0;
  box-shadow: 0 -10px 28px rgba(35, 65, 90, 0.12);
  backdrop-filter: blur(14px);
}

.number-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  min-height: 80px;
}

/* Tiles */
.tile {
  width: 70px;
  height: 70px;
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,0.92), transparent 0 18%),
    linear-gradient(180deg, #ffffff 0%, #fff2a8 100%);
  border: 3px solid rgba(255,255,255,0.86);
  border-radius: var(--radius-md);
  box-shadow: 0 7px 0 #d9a81a, var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 2.5rem;
  color: var(--theme-ink);
  cursor: grab;
  position: relative;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
  touch-action: none; /* Required for pointer events dragging */
  text-shadow: 0 2px 0 rgba(255,255,255,0.68);
  animation: tileEnter 420ms cubic-bezier(0.22, 1.28, 0.36, 1) both;
}

.tile:nth-child(2n) {
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,0.9), transparent 0 18%),
    linear-gradient(180deg, #ffffff 0%, #bff4ff 100%);
  box-shadow: 0 7px 0 #148ecc, var(--shadow-md);
}

.tile:nth-child(3n) {
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,0.9), transparent 0 18%),
    linear-gradient(180deg, #ffffff 0%, #c9ffb8 100%);
  box-shadow: 0 7px 0 #36a54b, var(--shadow-md);
}

.tile:hover {
  filter: saturate(1.12);
  transform: translateY(-4px) rotate(-1deg);
}

.tile.selected {
  transform: translateY(-7px) scale(1.06);
  box-shadow: 0 10px 0 rgba(217, 168, 26, 0.72), 0 0 0 6px rgba(255, 255, 255, 0.58), 0 0 0 11px rgba(255, 210, 63, 0.46), var(--shadow-lg);
  animation: selectedPulse 1050ms ease-in-out infinite;
}

@keyframes selectedPulse {
  0%, 100% { filter: saturate(1.08) brightness(1); }
  50% { filter: saturate(1.22) brightness(1.08); }
}

@keyframes tileEnter {
  0% { opacity: 0; transform: translateY(18px) scale(0.82) rotate(-5deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

.tile:active, .tile.dragging {
  cursor: grabbing;
  transform: scale(1.1) translateY(-5px);
  box-shadow: 0 11px 0 rgba(35, 65, 90, 0.24), var(--shadow-lg);
  pointer-events: none;
  z-index: 100;
}

.tile-placeholder {
  border-radius: var(--radius-md);
  border: 3px dashed rgba(255,255,255,0.72);
  background: rgba(255,255,255,0.22);
  box-shadow: inset 0 4px 12px rgba(38, 56, 74, 0.14);
}

.tile.placed {
  box-shadow: 0 2px 0 #CCC;
  transform: translateY(4px);
  cursor: default;
}

.tile .face, .slot.filled .face {
  position: absolute;
  bottom: 9px;
  display: flex;
  gap: 5px;
  justify-content: center;
  width: 100%;
}
.tile .face::before, .tile .face::after, .slot.filled .face::before, .slot.filled .face::after {
  content: '';
  width: 5px;
  height: 5px;
  background: #333;
  border-radius: 50%;
}
.tile .face-smile, .slot.filled .face-smile {
  position: absolute;
  bottom: -7px;
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #333;
  border-radius: 50%;
  left: 50%;
  transform: translateX(-50%);
}

/* Controls */
.bottom-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 15px 20px 25px;
  background: transparent;
}

.control-btn, .primary-btn, .share-btn {
  background: linear-gradient(180deg, #57c8ff, var(--color-secondary));
  color: #FFF;
  border: none;
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 0 #1976D2;
  transition: transform 140ms ease, filter 140ms ease;
}
.control-btn:hover, .primary-btn:hover, .share-btn:hover {
  filter: saturate(1.12) brightness(1.03);
  transform: translateY(-2px);
}
.control-btn:active, .primary-btn:active, .share-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 #1976D2;
}

.primary-btn {
  background: var(--color-success);
  box-shadow: 0 4px 0 #388E3C;
  font-size: 1.5rem;
  padding: 15px 30px;
}

/* Modals */
.modal, .overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 34, 54, 0.62);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content, .celebration-content {
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 210, 63, 0.24), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(35, 168, 255, 0.20), transparent 30%),
    #fff;
  padding: 30px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 90%;
  width: 400px;
  border: 4px solid rgba(255,255,255,0.75);
  box-shadow: 0 10px 0 rgba(27, 85, 128, 0.16), var(--shadow-lg);
  animation: modalPop 320ms cubic-bezier(0.22, 1.28, 0.36, 1);
}

@keyframes modalPop {
  0% { opacity: 0; transform: translateY(16px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.share-options {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin: 25px 0;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 15px;
  margin: 20px 0;
  max-height: 60vh;
  overflow-y: auto;
}

.sticker-item {
  background: #e8f7ff;
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0.5; /* Locked state */
  filter: grayscale(100%);
}
.sticker-item.unlocked {
  opacity: 1;
  filter: none;
  background: #FFF9C4;
  box-shadow: 0 5px 0 rgba(217, 155, 0, 0.22), var(--shadow-sm);
  animation: stickerShine 700ms ease both;
}
.sticker-item span {
  font-size: 0.8rem;
  font-family: var(--font-body);
  margin-top: 5px;
  color: var(--color-text);
}

.large-sticker {
  font-size: 4rem;
  animation: rewardPop 900ms cubic-bezier(0.22, 1.28, 0.36, 1) infinite alternate;
}

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

@keyframes stickerShine {
  0% { transform: scale(0.84) rotate(-6deg); }
  60% { transform: scale(1.08) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes rewardPop {
  0% { transform: translateY(0) scale(1) rotate(-3deg); }
  100% { transform: translateY(-6px) scale(1.08) rotate(3deg); }
}

.close-modal-btn {
  background: #E0E0E0;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

.stars-earned {
  font-size: 3rem;
  margin: 20px 0;
  color: #CCC;
}
.stars-earned .earned {
  color: #FFD740;
  display: inline-block;
  animation: starEarned 620ms cubic-bezier(0.22, 1.28, 0.36, 1) both;
}

.stars-earned .earned:nth-child(2) {
  animation-delay: 120ms;
}

.stars-earned .earned:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes starEarned {
  0% { opacity: 0; transform: translateY(18px) scale(0) rotate(-28deg); }
  65% { opacity: 1; transform: translateY(-8px) scale(1.24) rotate(8deg); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

/* Animations */
.wiggle {
  animation: wiggle 0.4s ease-in-out;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

.sparkle {
  animation: burstFade 0.45s ease-out;
}

.confetti-piece,
.overlay-confetti {
  position: absolute;
  width: 10px;
  height: 14px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 900;
}

.confetti-piece {
  animation: confettiPop 820ms ease-out forwards;
}

.overlay-confetti {
  top: -24px;
  animation: confettiRain 1600ms ease-in forwards;
}

@keyframes confettiPop {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(0.8) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--tx), var(--ty), 0) scale(1) rotate(var(--rot));
  }
}

@keyframes confettiRain {
  0% {
    opacity: 0;
    transform: translate3d(0, -16px, 0) rotate(0deg);
  }
  15% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate3d(0, 105vh, 0) rotate(var(--rot));
  }
}

/* Responsive */
@media (max-width: 600px) {
  .main-play-area {
    flex-direction: column;
  }
  .mascot-area {
    flex-direction: row;
    width: 100%;
    justify-content: center;
    gap: 10px;
  }
  .mascot {
    width: 60px;
    height: 60px;
  }
  .message-bubble {
    position: relative;
    top: auto;
    width: auto;
    margin-top: 0;
  }
  .message-bubble.hint-bubble {
    position: fixed;
    top: auto;
    bottom: 12px;
    left: 50%;
    width: min(320px, calc(100vw - 28px));
    margin: 0;
    transform: translateX(-50%);
  }
  .message-bubble::before {
    top: 50%;
    left: -10px;
    transform: translateY(-50%);
    border-width: 10px 10px 10px 0;
    border-color: transparent #FFF transparent transparent;
  }
  .slot { width: 55px; height: 55px; font-size: 1.5rem; }
  .tile { width: 55px; height: 55px; font-size: 2rem; }
  .slot .item-visual { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
