/* ===== Drawers ===== */
.drawer-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(62, 39, 35, 0.45);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  z-index: 2000;
}

.drawer-overlay.open,
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 92vw);
  height: 100vh;
  background: var(--color-bg);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2001;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(93, 64, 55, 0.1);
  background: var(--color-mint);
}

.drawer-header h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--color-primary);
}

.drawer-close,
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(93, 64, 55, 0.08);
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-secondary);
  transition: transform var(--transition);
}

.drawer-close:hover,
.modal-close:hover {
  transform: scale(1.08);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(93, 64, 55, 0.1);
  background: #fff;
}

.drawer-total {
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--color-text);
}

.drawer-total strong {
  color: var(--color-accent);
  font-size: 20px;
}

.drawer-item {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
  align-items: center;
}

.drawer-item img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.drawer-item-info {
  flex: 1;
  min-width: 0;
}

.drawer-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.drawer-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-accent);
}

.drawer-item-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(229, 57, 53, 0.1);
  color: var(--color-accent);
  font-size: 18px;
  flex-shrink: 0;
}

.drawer-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.drawer-checkout {
  width: 100%;
}

/* ===== Fly animation ===== */
.fly-item {
  position: fixed;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3000;
  opacity: 0;
  object-fit: cover;
  box-shadow: var(--shadow-hover);
}

.fly-item.flying {
  opacity: 1;
  transition: top 0.65s cubic-bezier(0.4, 0, 0.2, 1),
              left 0.65s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.65s ease,
              opacity 0.2s ease 0.55s;
}

.fly-heart {
  position: fixed;
  font-size: 24px;
  pointer-events: none;
  z-index: 3000;
  opacity: 0;
}

.fly-heart.flying {
  opacity: 1;
  transition: top 0.6s ease, left 0.6s ease, opacity 0.15s ease 0.5s;
}

.fav-count {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.fav-count:not(:empty),
.cart-count:not(:empty) {
  display: flex;
}

.cart-count:empty,
.fav-count[data-zero="true"] {
  display: none;
}

.product-fav-btn {
  position: absolute;
  top: 28px;
  left: 28px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-accent);
  font-size: 16px;
  z-index: 2;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition);
}

.product-fav-btn:hover,
.product-fav-btn.active {
  transform: scale(1.1);
  color: var(--color-accent);
}

.product-fav-btn.active {
  background: var(--color-accent);
  color: #fff;
}

.product-card {
  position: relative;
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: rgba(255, 249, 230, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 48px rgba(93, 64, 55, 0.18);
  padding: 32px;
  max-width: min(480px, 92vw);
  width: 100%;
  z-index: 2002;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.modal.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.mission-modal {
  text-align: center;
  padding: 36px 28px;
}

.mission-avatar-wrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--color-yellow);
}

.mission-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mission-name {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.mission-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 16px;
}

.mission-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--color-text);
  text-align: left;
  padding: 16px;
  background: rgba(232, 245, 233, 0.6);
  border-radius: var(--radius-btn);
}

.mission-modal .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.team-card-clickable {
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.team-card-clickable:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.team-card-clickable:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* ===== Community Tabs & Posts ===== */
.community-container {
  position: relative;
}

.community-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.community-tab {
  padding: 10px 22px;
  border-radius: 24px;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: #fff;
  border: 1px solid rgba(93, 64, 55, 0.12);
  transition: all var(--transition);
}

.community-tab:hover,
.community-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  transform: scale(1.03);
}

.community-posts {
  display: none;
}

.community-posts.active {
  display: block;
}

.community-posts .masonry-grid {
  display: block;
  columns: 1;
}

.post-card {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
  break-inside: avoid;
}

.post-card-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--color-yellow);
  color: var(--color-primary);
  margin-bottom: 12px;
}

.post-card h4 {
  font-family: var(--font-heading);
  font-size: 17px;
  color: var(--color-primary);
  margin-bottom: 10px;
}

.post-card p {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.post-card-meta {
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.community-post-fab {
  position: absolute;
  bottom: -20px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-hover);
  z-index: 10;
  transition: transform var(--transition);
}

.community-post-fab:hover {
  transform: scale(1.08);
}

.masonry-item-link {
  display: block;
  color: inherit;
  cursor: pointer;
}

.masonry-item-link:hover .masonry-thumb img {
  transform: scale(1.04);
}

.masonry-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.masonry-item-link .masonry-play {
  opacity: 0;
  transition: opacity var(--transition);
}

.masonry-item-link:hover .masonry-play {
  opacity: 1;
}

/* ===== Post Modal ===== */
.post-modal {
  max-width: min(520px, 92vw);
  padding: 0;
  overflow: hidden;
}

.post-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: var(--color-mint);
}

.post-modal .modal-header h3 {
  font-family: var(--font-heading);
  color: var(--color-primary);
}

.post-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-form textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(93, 64, 55, 0.15);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 14px;
  resize: vertical;
  outline: none;
}

.post-form textarea:focus {
  border-color: var(--color-accent);
}

.post-upload {
  display: block;
  padding: 14px;
  border: 2px dashed rgba(93, 64, 55, 0.2);
  border-radius: var(--radius-btn);
  text-align: center;
  font-size: 14px;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color var(--transition);
}

.post-upload:hover {
  border-color: var(--color-accent);
}

.post-loading {
  padding: 40px 24px;
  text-align: center;
}

.post-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-mint);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Game Section ===== */
.game-section {
  background: linear-gradient(180deg, var(--color-mint) 0%, var(--color-bg) 100%);
}

.game-subtitle {
  text-align: center;
  color: var(--color-text-secondary);
  margin: -32px auto 32px;
  max-width: 520px;
  font-size: 15px;
}

.game-wrap {
  display: flex;
  gap: 32px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 64px);
  grid-template-rows: repeat(4, 64px);
  gap: 6px;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.game-cell {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: background 0.2s ease;
}

.game-cell.wall {
  background: var(--color-primary);
}

.game-cell.path {
  background: var(--color-mint);
}

.game-cell.trap {
  background: #FFCDD2;
}

.game-cell.goal {
  background: var(--color-yellow);
}

.game-cell.cat {
  background: var(--color-mint);
  animation: ledFlash 0.3s ease;
}

.game-cell.led-flash {
  box-shadow: inset 0 0 12px var(--color-accent);
}

@keyframes ledFlash {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: inset 0 0 16px var(--color-accent); }
}

.game-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.game-dir-row {
  display: flex;
  gap: 8px;
}

.game-dir {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-btn);
  background: #fff;
  font-size: 20px;
  color: var(--color-primary);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), background var(--transition);
}

.game-dir:hover {
  transform: scale(1.08);
  background: var(--color-yellow);
}

.game-win-modal {
  text-align: center;
}

.game-win-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.game-win-modal h3 {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.game-win-modal p {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.coupon-card {
  background: linear-gradient(135deg, var(--color-accent), #FF7043);
  color: #fff;
  padding: 16px 24px;
  border-radius: var(--radius-btn);
  font-weight: 700;
  margin-bottom: 20px;
}

/* ===== Virtual Cat ===== */
.virtual-cat {
  position: fixed;
  bottom: 100px;
  left: 24px;
  z-index: 1400;
}

.vcat-body {
  width: 72px;
  height: 64px;
  background: #FFCC80;
  border-radius: 50% 50% 45% 45%;
  position: relative;
  cursor: pointer;
  box-shadow: var(--shadow-hover);
  transition: box-shadow var(--transition);
}

.vcat-body:not(.pounce):not(.vcat-idle-pause) {
  animation: vcatIdleHop 2.6s ease-in-out infinite;
  transform-origin: center bottom;
}

.vcat-body:hover:not(.pounce):not(.vcat-idle-pause) {
  animation-duration: 1.8s;
  box-shadow: 0 8px 24px rgba(229, 57, 53, 0.22);
}

@keyframes vcatIdleHop {
  0%, 100% {
    transform: translate(0, 0) scale(1, 1);
  }
  15% {
    transform: translate(5px, -11px) scale(1.05, 0.94);
  }
  30% {
    transform: translate(9px, -1px) scale(0.96, 1.04);
  }
  45% {
    transform: translate(-4px, -13px) scale(1.06, 0.93);
  }
  60% {
    transform: translate(-7px, -2px) scale(0.95, 1.05);
  }
  75% {
    transform: translate(3px, -10px) scale(1.04, 0.95);
  }
  90% {
    transform: translate(1px, -3px) scale(1, 1);
  }
}

.vcat-ear {
  position: absolute;
  top: -8px;
  width: 18px;
  height: 22px;
  background: #FFCC80;
  border-radius: 50% 50% 0 0;
}

.vcat-ear-l { left: 8px; transform: rotate(-15deg); }
.vcat-ear-r { right: 8px; transform: rotate(15deg); }

.vcat-face {
  position: absolute;
  inset: 12px 8px 8px;
}

.vcat-eyes {
  display: flex;
  justify-content: space-around;
  padding: 0 8px;
}

.vcat-eye {
  width: 10px;
  height: 10px;
  background: var(--color-text);
  border-radius: 50%;
  transition: transform 0.1s ease;
}

.vcat-body.blink .vcat-eye {
  transform: scaleY(0.1);
}

.vcat-nose {
  width: 8px;
  height: 6px;
  background: #FFAB91;
  border-radius: 50%;
  margin: 4px auto;
}

.vcat-mouth {
  width: 16px;
  height: 8px;
  border-bottom: 2px solid var(--color-text);
  border-radius: 0 0 50% 50%;
  margin: 0 auto;
}

.vcat-body.pounce {
  animation: pounce 0.4s ease;
}

@keyframes pounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-20px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

.vcat-panel {
  position: absolute;
  bottom: 80px;
  left: 0;
  width: 280px;
  background: rgba(255, 249, 230, 0.95);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transition: all 0.35s ease;
}

.vcat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.vcat-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--color-mint);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: var(--color-primary);
}

.vcat-panel-close,
.vcat-back {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.vcat-stats,
.vcat-health-view {
  padding: 16px;
}

.vcat-stat {
  margin-bottom: 12px;
  font-size: 13px;
}

.vcat-bar {
  height: 8px;
  background: rgba(93, 64, 55, 0.1);
  border-radius: 4px;
  margin: 6px 0;
  overflow: hidden;
}

.vcat-bar span {
  display: block;
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.vcat-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.vcat-btn {
  padding: 10px 14px;
  border-radius: var(--radius-btn);
  background: #fff;
  border: 1px solid rgba(93, 64, 55, 0.12);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  text-align: left;
  transition: all var(--transition);
}

.vcat-btn:hover {
  background: var(--color-yellow);
  transform: scale(1.02);
}

.vcat-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  margin-bottom: 8px;
}

.vcat-chart span {
  flex: 1;
  background: var(--color-accent);
  border-radius: 3px 3px 0 0;
  opacity: 0.7;
  animation: barPulse 1.5s ease infinite;
}

.vcat-chart span:nth-child(odd) { animation-delay: 0.2s; }

@keyframes barPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.vcat-heartbeat {
  font-size: 14px;
  color: var(--color-accent);
  margin-bottom: 16px;
  animation: heartbeat 1s ease infinite;
}

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

.vcat-chart-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 6px;
}

body.wand-mode {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%23E53935' d='M4 20l4-8 3 3 8-12 1 1-12 8 3 3z'/%3E%3C/svg%3E") 4 20, pointer;
}

/* ===== Photo Modal ===== */
.photo-modal {
  padding: 24px;
  text-align: center;
}

.photo-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 3000;
  transition: opacity 0.15s ease;
}

.photo-flash.active {
  opacity: 0.85;
}

.photo-card {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: 16px;
}

.photo-result {
  width: 100%;
  border-radius: var(--radius-card);
}

.photo-watermark {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(93, 64, 55, 0.75);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
}

.photo-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

@media (max-width: 768px) {
  .virtual-cat {
    bottom: 90px;
    left: 16px;
  }

  .vcat-panel {
    width: calc(100vw - 32px);
    max-width: 300px;
  }

  .game-grid {
    grid-template-columns: repeat(4, 56px);
    grid-template-rows: repeat(4, 56px);
  }

  .game-cell {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .community-post-fab {
    right: 16px;
    bottom: -16px;
  }
}
