:root {
  --gold-primary: #ffb74a;
  --gold-light: #fff4c2;
  --cyan-glow: #7ef8ff;
  --bg-dark: #0a0208;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Noto Sans SC", sans-serif;
  background: #000;
  color: #fff;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  filter: brightness(0.8);
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
  z-index: -1;
}

/* Block Container - Bottom Left Stack */
.block-container {
  position: absolute;
  left: 30px;
  bottom: 30px;
  width: 520px;
  max-width: 40vw;
  z-index: 20;
  
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 15px; /* Space between blocks */
  
  /* Allow growing upwards */
  max-height: 80vh;
}

/* Common Block Style */
.ui-block {
  background: rgba(10, 2, 8, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  
  animation: slideUp 0.5s var(--ease-out) forwards;
  transform-origin: bottom center;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Avatar Grid Block */
.avatar-block {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

/* Message Block */
.message-block {
  /* relative for inner positioning */
  position: relative;
  /* overflow: hidden; Removed to allow 3D effect if needed, but keeping for neatness */
  
  background: rgba(255, 183, 74, 0.15); /* Slight gold tint */
  border-color: rgba(255, 183, 74, 0.3);
  padding: 0; /* padding moved to inner wrapper for animation */
  
  perspective: 1000px; /* Enable 3D space */
}

/* Animation Class for 360 Flip */
.message-block.is-spinning {
  animation: spin360 0.8s ease-in-out forwards;
}

@keyframes spin360 {
  0% { transform: rotateX(0deg); }
  100% { transform: rotateX(360deg); }
}


.message-inner-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  width: 100%;
  height: 100%;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold-primary);
  flex-shrink: 0;
}

.message-content {
  display: flex;
  flex-direction: column;
}

.message-name {
  font-size: 12px;
  color: var(--gold-primary);
  font-weight: 700;
  margin-bottom: 2px;
}

.message-text {
  font-size: 14px;
  color: #fff;
  line-height: 1.4;
}

/* Grid Items (Avatars) */
.history-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  animation: fadeIn 0.3s ease-out forwards;
}

.history-item.is-placeholder {
  opacity: 0 !important;
  animation: none;
}

.history-item.is-visible {
  opacity: 1 !important;
  animation: none !important;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.history-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.history-name {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Animation Layer */
.anim-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  perspective: 1000px;
}

.fly-card {
  position: absolute;
  width: 400px;
  height: 140px;
  top: 0;
  left: 0;
  background: rgba(20, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--gold-primary);
  border-radius: 20px;
  box-shadow: 
    0 0 30px rgba(255, 183, 74, 0.2),
    0 20px 50px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  opacity: 0;
  transform: translate3d(-100vw, 0, 0);
}

.fly-card.state-enter {
  transition: transform 0.6s var(--ease-out), opacity 0.6s ease;
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

.fly-card.state-rotate {
  transition: transform 0.8s ease-in-out;
  transform: translate3d(0, 0, 0) rotateY(360deg);
}

.fly-card.state-fly {
  /* accelerate into the target */
  transition: transform 0.4s var(--ease-in-quad);
}

.fly-card-avatar-box {
  position: relative;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
}

.fly-card-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

.fly-card-ring {
  position: absolute;
  inset: -15px;
  width: 130px;
  height: 130px;
  animation: spin 10s linear infinite;
  filter: drop-shadow(0 0 10px var(--cyan-glow));
}

.fly-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.fly-card-label {
  font-size: 14px;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.fly-card-name {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

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